Skip to content

Commit 1d2d066

Browse files
authored
fix: pass allowed hostnames during group verification (#2336)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 862c2c3 commit 1d2d066

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/attestation/crafter/crafter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ func (c *Crafter) addMaterial(ctx context.Context, m *schemaapi.CraftingSchema_M
616616
})
617617

618618
// Validate policy groups
619-
pgv := policies.NewPolicyGroupVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger)
619+
pgv := policies.NewPolicyGroupVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger, policies.WithAllowedHostnames(c.CraftingState.Attestation.PoliciesAllowedHostnames...))
620620
policyGroupResults, err := pgv.VerifyMaterial(ctx, mt, value)
621621
if err != nil {
622622
return nil, fmt.Errorf("error applying policy groups to material: %w", err)
@@ -657,13 +657,13 @@ func (c *Crafter) addMaterial(ctx context.Context, m *schemaapi.CraftingSchema_M
657657
// EvaluateAttestationPolicies evaluates the attestation-level policies and stores them in the attestation state
658658
func (c *Crafter) EvaluateAttestationPolicies(ctx context.Context, attestationID string, statement *intoto.Statement) error {
659659
// evaluate attestation-level policies
660-
pv := policies.NewPolicyVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger)
660+
pv := policies.NewPolicyVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger, policies.WithAllowedHostnames(c.CraftingState.Attestation.PoliciesAllowedHostnames...))
661661
policyEvaluations, err := pv.VerifyStatement(ctx, statement)
662662
if err != nil {
663663
return fmt.Errorf("evaluating policies in statement: %w", err)
664664
}
665665

666-
pgv := policies.NewPolicyGroupVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger)
666+
pgv := policies.NewPolicyGroupVerifier(c.CraftingState.InputSchema, c.attClient, c.Logger, policies.WithAllowedHostnames(c.CraftingState.Attestation.PoliciesAllowedHostnames...))
667667
policyGroupResults, err := pgv.VerifyStatement(ctx, statement)
668668
if err != nil {
669669
return fmt.Errorf("evaluating policy groups in statement: %w", err)

pkg/policies/policy_groups.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ type PolicyGroupVerifier struct {
4040

4141
var _ Verifier = (*PolicyGroupVerifier)(nil)
4242

43-
func NewPolicyGroupVerifier(schema *v1.CraftingSchema, client v13.AttestationServiceClient, logger *zerolog.Logger) *PolicyGroupVerifier {
43+
func NewPolicyGroupVerifier(schema *v1.CraftingSchema, client v13.AttestationServiceClient, logger *zerolog.Logger, opts ...PolicyVerifierOption) *PolicyGroupVerifier {
4444
return &PolicyGroupVerifier{schema: schema, client: client, logger: logger,
45-
PolicyVerifier: NewPolicyVerifier(schema, client, logger)}
45+
PolicyVerifier: NewPolicyVerifier(schema, client, logger, opts...)}
4646
}
4747

4848
// VerifyMaterial evaluates a material against groups of policies defined in the schema

0 commit comments

Comments
 (0)