-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add platform filtering support to mapping.yml #167
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
==========================================
+ Coverage 69.46% 69.58% +0.11%
==========================================
Files 44 44
Lines 2505 2528 +23
==========================================
+ Hits 1740 1759 +19
- Misses 475 477 +2
- Partials 290 292 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions
@@ -1,4 +1,4 @@ | |||
package config | |||
package mapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That feels right
- path: doi/policy.rego | ||
rules: | ||
- pattern: "^docker[.]io/library/(.*)$" | ||
platforms: ["linux/amd64"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a test with two values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, it's an array, so I think the same paths will be exercised...happy to add one if you like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
@@ -55,7 +55,12 @@ func (verifier *tufVerifier) Verify(ctx context.Context, src *oci.ImageSpec) (re | |||
return nil, fmt.Errorf("failed to resolve image name: %w", err) | |||
} | |||
policyResolver := policy.NewResolver(verifier.tufClient, verifier.opts) | |||
resolvedPolicy, err := policyResolver.ResolvePolicy(ctx, imageName) | |||
|
|||
platform, err := detailsResolver.ImagePlatform(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is platform
used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how the input image platform makes it down to the policy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whalelines For better or worse, it would actually be a compiler error if it wasn't!
case rule.PolicyID == "" && rule.Replacement == "": | ||
return nil, fmt.Errorf("rule %s has neither policy-id nor rewrite", rule.Pattern) | ||
case rule.PolicyID != "" && rule.Replacement != "": | ||
return nil, fmt.Errorf("rule %s has both policy-id and rewrite", rule.Pattern) | ||
case rule.PolicyID != "": | ||
policy := mappings.Policies[rule.PolicyID] | ||
if policy != nil { | ||
return &PolicyMatch{ | ||
MatchType: MatchTypePolicy, | ||
Policy: policy, | ||
Rule: rule, | ||
MatchedName: imageName, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code seems very familiar. Does it exist somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a move from the policy package.
@@ -55,7 +55,12 @@ func (verifier *tufVerifier) Verify(ctx context.Context, src *oci.ImageSpec) (re | |||
return nil, fmt.Errorf("failed to resolve image name: %w", err) | |||
} | |||
policyResolver := policy.NewResolver(verifier.tufClient, verifier.opts) | |||
resolvedPolicy, err := policyResolver.ResolvePolicy(ctx, imageName) | |||
|
|||
platform, err := detailsResolver.ImagePlatform(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whalelines For better or worse, it would actually be a compiler error if it wasn't!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This will help us roll out policy platform by platform, and control the amount of historical image signing we will need
e.g. only
linux/amd64
images will be matched by the rule below:config
package tomapping
, and move matching code over there frompolicy
package