-
Notifications
You must be signed in to change notification settings - Fork 368
Error on unknown single-word ecosystem identifiers in network.allowed #27475
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
Changes from all commits
88c65f2
d7fc6e8
b589959
8860a74
0e03284
5ae8ba0
092bbde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ package workflow | |||||
| import ( | ||||||
| "fmt" | ||||||
| "regexp" | ||||||
| "sort" | ||||||
| "strings" | ||||||
|
|
||||||
| "github.com/github/gh-aw/pkg/constants" | ||||||
|
|
@@ -71,9 +72,24 @@ func (c *Compiler) validateNetworkAllowedDomains(network *NetworkPermissions) er | |||||
| continue | ||||||
| } | ||||||
|
|
||||||
| // Skip ecosystem identifiers - they don't need domain pattern validation | ||||||
| // Check if this looks like an ecosystem identifier (single lowercase word with optional hyphens) | ||||||
| if isEcosystemIdentifier(domain) { | ||||||
| networkFirewallValidationLog.Printf("Skipping ecosystem identifier: %s", domain) | ||||||
| // Validate it's a known ecosystem identifier using a direct map lookup to avoid allocations | ||||||
| if isKnownEcosystemIdentifier(domain) { | ||||||
| networkFirewallValidationLog.Printf("Skipping known ecosystem identifier: %s", domain) | ||||||
| continue | ||||||
| } | ||||||
| // Unknown ecosystem identifier - error | ||||||
| networkFirewallValidationLog.Printf("Validation error: unknown ecosystem identifier: %s", domain) | ||||||
| wrappedErr := fmt.Errorf("network.allowed[%d]: %w", i, NewValidationError( | ||||||
| "network.allowed", | ||||||
| domain, | ||||||
| fmt.Sprintf("'%s' is not a valid ecosystem identifier", domain), | ||||||
| "Use a valid ecosystem identifier or a domain name containing a dot (e.g., 'example.com').\n\nValid ecosystem identifiers: "+strings.Join(getValidEcosystemIdentifiers(), ", "), | ||||||
|
||||||
| "Use a valid ecosystem identifier or a domain name containing a dot (e.g., 'example.com').\n\nValid ecosystem identifiers: "+strings.Join(getValidEcosystemIdentifiers(), ", "), | |
| "Unknown single-word entries are rejected unless they match a valid ecosystem identifier. Use a valid ecosystem identifier or specify a domain name containing a dot (for example, 'example.com').\n\nValid ecosystem identifiers: "+strings.Join(getValidEcosystemIdentifiers(), ", "), |
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.
getEcosystemDomains(domain)is being called here only to check whether an identifier is known. That helper allocates/copies and sorts the full domain list (see pkg/workflow/domains.go:288+), which is unnecessary work during validation. Prefer checking membership directly (e.g.,_, ok := ecosystemDomains[domain]orcompoundEcosystems[domain]) or introducing a lightweightisKnownEcosystemIdentifierhelper that avoids sorting/allocations.This issue also appears in the following locations of the same file: