Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/config/guard_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (p *GuardPolicy) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
logGuardPolicy.Printf("UnmarshalJSON: parsing guard policy, keys=%d", len(raw))

var allowOnlyRaw json.RawMessage
var writeSinkRaw json.RawMessage
Expand Down Expand Up @@ -106,6 +107,11 @@ func (p *GuardPolicy) UnmarshalJSON(data []byte) error {
p.WriteSink = &writeSink
}

if len(allowOnlyRaw) > 0 {
logGuardPolicy.Print("UnmarshalJSON: guard policy type is allow-only")
} else {
logGuardPolicy.Print("UnmarshalJSON: guard policy type is write-sink")
}
return nil
}

Expand All @@ -123,6 +129,7 @@ func (p *AllowOnlyPolicy) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
logGuardPolicy.Printf("UnmarshalJSON: parsing allow-only policy, fields=%d", len(raw))

for key, value := range raw {
switch strings.ToLower(key) {
Expand Down Expand Up @@ -174,6 +181,7 @@ func (p *AllowOnlyPolicy) UnmarshalJSON(data []byte) error {
return fmt.Errorf("allow-only must include min-integrity")
}

logGuardPolicy.Printf("UnmarshalJSON: allow-only policy parsed, repos=%T, minIntegrity=%s", p.Repos, p.MinIntegrity)
return nil
}

Expand Down Expand Up @@ -477,6 +485,7 @@ func normalizeAndValidateScopeArray(scopes []interface{}) ([]string, error) {
if len(scopes) == 0 {
return nil, fmt.Errorf("allow-only.repos array must contain at least one scope")
}
logGuardPolicy.Printf("normalizeAndValidateScopeArray: validating %d repo scope entries", len(scopes))

seen := make(map[string]struct{}, len(scopes))
normalized := make([]string, 0, len(scopes))
Expand Down
Loading