Skip to content
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 GetApplicableTrustPolicy function #51

Merged
merged 7 commits into from
Jun 17, 2022

Conversation

Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
@rgnote rgnote requested a review from a team June 8, 2022 05:06
verification/policy.go Outdated Show resolved Hide resolved
verification/policy.go Outdated Show resolved Hide resolved
Copy link

@gokarnm gokarnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment, we should use terminology matching the spec, otherwise it gets confusing sometimes.

  • trustPolicy instead of policyStatement
  • (signature) verificationLevel vs verificationPreset

verification/policy.go Show resolved Hide resolved
verification/policy.go Outdated Show resolved Hide resolved
verification/policy.go Outdated Show resolved Hide resolved
Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
verification/policy.go Outdated Show resolved Hide resolved
Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
} else if wildcardPolicy != nil {
return wildcardPolicy, nil
} else {
return nil, fmt.Errorf("registry scope %q has no applicable trust policy", artifactPath)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("registry scope %q has no applicable trust policy", artifactPath)
return nil, fmt.Errorf("artifact %q has no applicable trust policy", artifactUri)

// TODO support more types of URI like "domain.com/repository", "domain.com/repository:tag", "domain.com/repository@sha256:digest"
i := strings.LastIndex(artifactUri, ":")
if i < 0 {
return "", fmt.Errorf("registry URI %q could not be parsed, make sure it is the fully qualified registry URI without the scheme/protocol. e.g domain.com:80/my/repository:digest", artifactUri)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", fmt.Errorf("registry URI %q could not be parsed, make sure it is the fully qualified registry URI without the scheme/protocol. e.g domain.com:80/my/repository:digest", artifactUri)
return "", fmt.Errorf("artifact URI %q could not be parsed, make sure it is the fully qualified OCI artifact URI without the scheme/protocol. e.g domain.com:80/my/repository:digest", artifactUri)

Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
} else if wildcardPolicy != nil {
return wildcardPolicy, nil
} else {
return nil, fmt.Errorf("artifact %q has no applicable trust policy", artifactPath)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, I'd prefer artifactUri in the error message which is the user provided input, artifactPath is calculated in our internal logic.

Suggested change
return nil, fmt.Errorf("artifact %q has no applicable trust policy", artifactPath)
return nil, fmt.Errorf("artifact %q has no applicable trust policy", artifactUri)

Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
// Constants
supportedPolicyVersions := []string{"1.0"}
supportedVerificationPresets := []string{"strict", "permissive", "audit", "skip"}
supportedVerificationLevels := []string{"strict", "permissive", "audit", "skip"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to replaces this with levels define in #55 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I have a TODO to do that.

Comment on lines +222 to +224
} else if isPresent(artifactPath, policyStatement.RegistryScopes) {
applicablePolicy = policyStatement.deepCopy()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: Where are we validating that there is only one applicable trust policy fir a given repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gokarnm
Copy link

gokarnm commented Jun 17, 2022

@shizhMSFT merging this PR with two approvals.

@gokarnm gokarnm merged commit a4fdff4 into notaryproject:main Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants