feat: guard DIFC proxy emission with difc-proxy feature flag#23471
feat: guard DIFC proxy emission with difc-proxy feature flag#23471
difc-proxy feature flag#23471Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e8427951-8f03-48f4-ac96-ebb39730f6d9 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot recompile and make sure the difc proxy is not emitted unless the feature flag is enabled |
…without difc-proxy feature flag Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7e2bf4e5-6e4e-452a-b256-adad884e6e2e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Recompiled in 62cb48c. All 22 lock files that previously had DIFC proxy steps (from workflows with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR makes DIFC proxy step injection opt-in by gating all DIFC proxy emission behind a new difc-proxy feature flag, preventing existing workflows that only set min-integrity from changing behavior.
Changes:
- Added
constants.DIFCProxyFeatureFlagand included it in feature-flag constant tests. - Updated DIFC proxy compilation gating to require both
min-integrityanddifc-proxybeing enabled. - Updated/added tests and regenerated workflow lock files to remove DIFC proxy steps/paths unless the flag is present.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/compiler_difc_proxy.go | Adds feature-flag gate to the core DIFC proxy injection predicate. |
| pkg/workflow/compiler_difc_proxy_test.go | Updates existing tests to opt into difc-proxy and adds coverage for “guards set but flag absent”. |
| pkg/constants/constants.go | Introduces DIFCProxyFeatureFlag constant with documentation. |
| pkg/constants/constants_test.go | Extends feature-flag constant table test to include difc-proxy. |
| .github/workflows/workflow-generator.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/weekly-safe-outputs-spec-review.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/weekly-issue-summary.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/weekly-blog-post-writer.lock.yml | Removes DIFC proxy start/stop steps and log paths (flag not enabled). |
| .github/workflows/stale-repo-identifier.lock.yml | Removes DIFC proxy start/stop steps and log paths (flag not enabled). |
| .github/workflows/smoke-agent-scoped-approved.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/smoke-agent-public-none.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/smoke-agent-public-approved.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/smoke-agent-all-none.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/smoke-agent-all-merged.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/scout.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/refiner.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/pr-triage-agent.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/plan.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/org-health-report.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/issue-triage-agent.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/issue-monster.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/issue-arborist.lock.yml | Removes DIFC proxy start/stop steps and log paths (flag not enabled). |
| .github/workflows/grumpy-reviewer.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/discussion-task-miner.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
| .github/workflows/daily-issues-report.lock.yml | Removes DIFC proxy start/stop steps and log paths (flag not enabled). |
| .github/workflows/contribution-check.lock.yml | Removes DIFC proxy log paths now that proxy isn’t emitted by default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func TestDIFCProxyNotInjectedWithoutFeatureFlag(t *testing.T) { | ||
| workflow := `--- | ||
| on: issues | ||
| engine: copilot | ||
| tools: | ||
| github: | ||
| mode: local | ||
| toolsets: [default] | ||
| min-integrity: approved | ||
| steps: | ||
| - name: Fetch repo data | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: gh issue list | ||
| --- | ||
|
|
||
| # Test Workflow | ||
|
|
||
| Test that DIFC proxy is NOT injected when min-integrity is set but difc-proxy feature flag is absent. | ||
| ` | ||
| compiler := NewCompiler() | ||
| data, err := compiler.ParseWorkflowString(workflow, "test-workflow.md") | ||
| require.NoError(t, err, "parsing should succeed") | ||
|
|
||
| result, err := compiler.CompileToYAML(data, "test-workflow.md") | ||
| require.NoError(t, err, "compilation should succeed") | ||
|
|
There was a problem hiding this comment.
This test assumes the difc-proxy feature flag is disabled, but isFeatureEnabled also considers the GH_AW_FEATURES environment variable. To avoid flakiness when running tests with GH_AW_FEATURES set, explicitly clear it (e.g., via t.Setenv) within the test.
| // hasDIFCGuardsConfigured returns true if the GitHub tool has explicit guard policies configured | ||
| // (min-integrity is set). This is the base condition for DIFC proxy injection. | ||
| // (min-integrity is set) AND the "difc-proxy" feature flag is enabled. | ||
| // This is the base condition for DIFC proxy injection. | ||
| func hasDIFCGuardsConfigured(data *WorkflowData) bool { | ||
| if data == nil { | ||
| return false | ||
| } | ||
| if !isFeatureEnabled(constants.DIFCProxyFeatureFlag, data) { | ||
| difcProxyLog.Print("difc-proxy feature flag not enabled, skipping DIFC proxy injection") | ||
| return false | ||
| } |
There was a problem hiding this comment.
hasDIFCGuardsConfigured now returns false when guard policies are present but the difc-proxy feature flag is disabled. The updated doc comment explains this, but the function name is now misleading (it no longer answers whether guards are configured). Consider renaming to reflect the combined condition (e.g., guards configured and DIFC proxy feature enabled) or splitting the checks into two functions.
DIFC proxy steps were unconditionally emitted whenever
min-integritywas configured. They should be opt-in via a feature flag so existing workflows aren't affected.Changes
pkg/constants— AddedDIFCProxyFeatureFlag = "difc-proxy"constant.pkg/workflow/compiler_difc_proxy.go— Added feature flag check as the first gate inhasDIFCGuardsConfigured. This single function controls all DIFC emission paths (main job start/stop, qmd indexing wrapping, artifact log paths), so no other call sites needed changing.Features: map[string]any{"difc-proxy": true}to all test cases expecting proxy injection; addedTestDIFCProxyNotInjectedWithoutFeatureFlagto assert proxy steps are absent when onlymin-integrityis set without the flag.min-integrityconfigured; DIFC proxy steps have been removed from all of them since none include thedifc-proxyfeature flag.Usage
To enable DIFC proxy injection, opt in via frontmatter:
Or via environment variable:
GH_AW_FEATURES=difc-proxy.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.