Repository navigation
Centralize engine default domain sets #55461
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 1 commit
03724be
7dc9cba
3cd8e22
a099902
03a3bcb
d671c0c
5e44cf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ func getLoadedEcosystemDomains() map[string][]string { | |
| return getLoadedDomainSets().Ecosystems | ||
| } | ||
|
|
||
| // Engine default domain lists intentionally exclude package registries (npm, PyPI, ...). | ||
| // Runtime engine default domain lists intentionally exclude package registries (npm, PyPI, ...). | ||
| // | ||
| // Engine CLIs and SDKs are installed by dedicated GitHub Actions steps that run on the | ||
| // runner *before* the AWF-wrapped agent step, so package registries are not needed inside | ||
|
|
@@ -73,21 +73,25 @@ func getLoadedEcosystemDomains() map[string][]string { | |
| // documented behavior that package ecosystems require explicit opt-in | ||
| // (`network: { allowed: [node] }`, `[python]`, or a matching `runtimes:` entry). | ||
| // | ||
| // This invariant is enforced by TestEngineDefaultDomainsDoNotOverlapEcosystems in | ||
| // domains_package_registry_test.go, which fails if any engine default domain list below | ||
| // overlaps with the full "node" or "python" ecosystem domain sets in data/ecosystem_domains.json | ||
| // — not just the registries known when this comment was written. If you need to add a domain | ||
| // to an engine default and that test starts failing, the domain belongs behind an explicit | ||
| // ecosystem/runtime opt-in instead, not in the unconditional default list. | ||
| // This invariant is enforced for runtime engine defaults by | ||
| // TestEngineDefaultDomainsDoNotOverlapEcosystems in domains_package_registry_test.go, which | ||
| // fails if those default domain lists overlap with the full "node" or "python" ecosystem | ||
| // domain sets in data/ecosystem_domains.json — not just the registries known when this comment | ||
| // was written. If you need to add a package-registry domain to a runtime engine default and | ||
| // that test starts failing, the domain belongs behind an explicit ecosystem/runtime opt-in | ||
| // instead, not in the unconditional default list. Copilot threat detection is the exception: | ||
| // its dedicated detection allow-list includes registry.npmjs.org for read-only lockfile | ||
| // validation, and that list is not part of normal agent engine defaults. | ||
|
|
||
| // engineDefaultDomainSets centralizes every unconditional engine allow-list. These | ||
| // sets are intentionally distinct from user-selectable ecosystem domain lists: the | ||
| // compiler includes them automatically for the matching engine, rather than allowing | ||
| // users to select them through network.allowed. | ||
| // | ||
| // Engine default domain lists intentionally exclude package registries (npm, PyPI, | ||
| // and similar). The threat-detection set is the exception because the Copilot | ||
| // threat detector uses the npm registry. See the package-registry invariant above. | ||
| // Runtime engine default domain lists intentionally exclude package registries | ||
| // (npm, PyPI, and similar). The threat-detection set is the exception because | ||
| // Copilot threat detection uses the npm registry. See the package-registry | ||
| // invariant above. | ||
| var engineDefaultDomainSets = getLoadedDomainSets().EngineDefaults | ||
|
|
||
| // GetEngineDefaultDomainSets returns copies of the named engine domain sets for | ||
|
|
@@ -707,7 +711,7 @@ func GetAllowedDomainsForEngine(engine constants.EngineName, network *NetworkPer | |
| // Any additional user-specified network.allowed entries are merged in (typically empty for detection). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/codebase-design] Direct map access hands the internal slice to 💡 Suggested fixUse the same defensive copy pattern used everywhere else in this PR: detectionDomains := copyEngineDefaultDomainSet(engineDefaultDomainSets["threat-detection"])This is a one-liner and keeps the access pattern consistent with @copilot please address this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in |
||
| // Returns a deduplicated, sorted, comma-separated string suitable for AWF's --allow-domains flag. | ||
| func GetThreatDetectionAllowedDomains(network *NetworkPermissions) string { | ||
| detectionDomains := engineDefaultDomainSets["threat-detection"] | ||
| detectionDomains := copyEngineDefaultDomainSet(engineDefaultDomainSets["threat-detection"]) | ||
| // Pass nil tools and runtimes: detection runs with no npm/runtime ecosystem, so | ||
| // ecosystem domain expansion is intentionally skipped. | ||
| return mergeDomainsWithNetworkToolsAndRuntimes(detectionDomains, network, nil, 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.
[/grill-with-docs] The
pi-baseset exists inengineDefaultDomainSetsand is exported viaGetEngineDefaultDomainSets()/PiBaseDefaultDomains, but it is absent from both doc tables — leaving a gap between the code and the reference docs.💡 Suggested addition
Add a row after the
pirow in bothdocs/src/content/docs/reference/network.mdand.github/aw/network.md:@copilot please address this.
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.
Addressed in
03a3bcb: added the missingpi-baserow to both network reference tables.