From f971ededd0b8b11393b92fc94363b3a603931cf1 Mon Sep 17 00:00:00 2001 From: mrjoelkamp Date: Mon, 8 Jul 2024 12:44:28 -0500 Subject: [PATCH] feat: add att style and referrers repo opts --- main.go | 20 ++++++++++++++------ pkg/handler/validate.go | 12 +++++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index d35f7cb..50cafaa 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,9 @@ var ( policyDir string policyCacheDir string + + attestationStyle string + referrersRepo string ) const ( @@ -73,6 +76,9 @@ func init() { flag.StringVar(&policyDir, "local-policy-dir", "", "path to local policy directory (overrides TUF policy)") flag.StringVar(&policyCacheDir, "policy-cache-dir", defaultPolicyCacheDir, "path to store policy downloaded from TUF") + flag.StringVar(&attestationStyle, "attestation-style", "referrers", "attestation style [referrers, attached]") + flag.StringVar(&referrersRepo, "referrers-source", "", "repo from which to fetch Referrers for attestation lookup") + flag.Parse() } @@ -80,12 +86,14 @@ func main() { mux := http.NewServeMux() validateHandler, err := handler.NewValidateHandler(&handler.ValidateHandlerOptions{ - TUFRoot: tufRoot, - TUFOutputPath: tufoutputPath, - TUFMetadataURL: metadataURL, - TUFTargetsURL: targetsURL, - PolicyDir: policyDir, - PolicyCacheDir: policyCacheDir, + TUFRoot: tufRoot, + TUFOutputPath: tufoutputPath, + TUFMetadataURL: metadataURL, + TUFTargetsURL: targetsURL, + PolicyDir: policyDir, + PolicyCacheDir: policyCacheDir, + AttestationStyle: attestationStyle, + ReferrersRepo: referrersRepo, }) if err != nil { klog.ErrorS(err, "unable to create validate handler") diff --git a/pkg/handler/validate.go b/pkg/handler/validate.go index 2f653d9..ac886e9 100644 --- a/pkg/handler/validate.go +++ b/pkg/handler/validate.go @@ -10,6 +10,7 @@ import ( "github.com/docker/attest-provider/internal/embed" "github.com/docker/attest-provider/pkg/utils" "github.com/docker/attest/pkg/attest" + "github.com/docker/attest/pkg/config" "github.com/docker/attest/pkg/oci" "github.com/docker/attest/pkg/policy" "github.com/docker/attest/pkg/tuf" @@ -33,6 +34,9 @@ type ValidateHandlerOptions struct { PolicyDir string PolicyCacheDir string + + AttestationStyle string + ReferrersRepo string } type validateHandler struct { @@ -104,9 +108,11 @@ func (h *validateHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } policyOpts := &policy.PolicyOptions{ - TufClient: tufClient, - LocalTargetsDir: h.opts.PolicyCacheDir, - LocalPolicyDir: h.opts.PolicyDir, + TufClient: tufClient, + LocalTargetsDir: h.opts.PolicyCacheDir, + LocalPolicyDir: h.opts.PolicyDir, + AttestationStyle: config.AttestationStyle(h.opts.AttestationStyle), + ReferrersRepo: h.opts.ReferrersRepo, } results := make([]externaldata.Item, 0)