Skip to content

Commit fe0c626

Browse files
Readme updates (#17)
* Log duration from OCI registry. * Added more details to the readme file * spelling errors * added more clarifications
1 parent 9ad4290 commit fe0c626

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,51 @@ $ helm install artifact-attestations-opa-provider charts/artifact-attestations-o
114114

115115
## Verification
116116

117+
### Architecture
118+
119+
GitHub Artifact Attestations OPA provider is a regular [OPA Gatekeeper
120+
external data
121+
provider](https://open-policy-agent.github.io/gatekeeper/website/docs/externaldata).
122+
123+
It works by interacting with OCI registries to fetch [Sigstore
124+
bundles](https://github.com/sigstore/architecture-docs/blob/main/client-spec.md#5-serialization-and-wire-format)
125+
containing attestations for the container to be deployed. The Artifact
126+
Attestations OPA provider will fetch the bundles, verify the
127+
cryptographic integrity, and if valid, return them to OPA Gatekeeper,
128+
where the data can be used during policy evaluation. This means only
129+
the cryptographic properties are verified within the Artifact
130+
Attestations OPA provider, the rego policy is evaluated by OPA
131+
Gatekeeper with normal [constraint
132+
objects](https://open-policy-agent.github.io/gatekeeper/website/docs/constrainttemplates). In
133+
the constraint configuration is where affected resources and
134+
namespaces are configured.
135+
136+
> [!NOTE]
137+
> OPA Gatekeeper has a hard timeout on 3 seconds, which include the
138+
> time for the external data provider. Be sure that you don't have
139+
> unnecessary attestations stored in the OCI registry as it may impact
140+
> the duration so that a timeout can occur.
141+
142+
```mermaid
143+
sequenceDiagram
144+
participant k8s as K8s
145+
participant opag as OPA Gatekeeper
146+
participant opadp as Artifact Attestations OPA Provider
147+
participant ocir as OCI Registry
148+
149+
k8s->>opag: Admit OCI image ref?
150+
opag->>opadp: Validate OCI image ref
151+
opadp->>ocir: Fetch attestations for image ref
152+
ocir->>opadp: Zero or more attestations
153+
opadp->>opadp: Verify integrity and authenticity of attestations
154+
opadp->>opag: Verified attestations
155+
opag->>opag: Perform rego policy evaluation on attestations
156+
opag->>k8s: Policy decision
157+
158+
```
159+
160+
### Rego policies
161+
117162
Three examples are provided that can be used as references when
118163
building out the policy.
119164

charts/artifact-attestations-opa-provider/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ serviceAccount: opa-provider-sa
33
port: 8090
44
imagePullSecrets: aa-login-secret
55
provider:
6-
timeout: 10
6+
timeout: 5
77
tls:
88
caBundle: ""

pkg/provider/provider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"log"
7+
"time"
78

89
"github.com/google/go-containerregistry/pkg/authn"
910
"github.com/google/go-containerregistry/pkg/name"
@@ -82,7 +83,10 @@ func (p *Provider) Validate(ctx context.Context, r *externaldata.ProviderRequest
8283
return ErrorResponse(fmt.Sprintf("ERROR: ParseReference(%q): %v", key, err))
8384
}
8485

86+
start := time.Now()
8587
b, h, err := fetcher.BundleFromName(ref, ro)
88+
dur := time.Since(start)
89+
log.Printf("validate: fetched OCI bundles in %s", dur)
8690
if err != nil {
8791
log.Printf("validate: error fetching bundles: %s", err)
8892
return ErrorResponse(fmt.Sprintf("ERROR: FromBundle(%q): %v", key, err))

0 commit comments

Comments
 (0)