-
Notifications
You must be signed in to change notification settings - Fork 367
fix: skip detection job when engine disabled; include patches in agent artifact #22924
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 4 commits
01692ce
81aeca4
b0e1a6d
3fb9918
3930974
1f5ff74
b904c01
1debe70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,7 +348,8 @@ func (c *Compiler) buildQmdIndexingJobWrapper(data *WorkflowData) error { | |
| // buildMemoryManagementJobs builds memory management jobs (push_repo_memory and update_cache_memory). | ||
| // These jobs handle artifact-based memory persistence to git branches and GitHub Actions cache. | ||
|
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. Same pattern as |
||
| func (c *Compiler) buildMemoryManagementJobs(data *WorkflowData) error { | ||
| threatDetectionEnabledForSafeJobs := data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil | ||
| threatDetectionEnabledForSafeJobs := data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil && | ||
| !(data.SafeOutputs.ThreatDetection.EngineDisabled && len(data.SafeOutputs.ThreatDetection.Steps) == 0) | ||
|
|
||
| // Build push_repo_memory job if repo-memory is configured | ||
| pushRepoMemoryJobName, err := c.buildPushRepoMemoryJobWrapper(data, threatDetectionEnabledForSafeJobs) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,12 @@ func (c *Compiler) buildSafeOutputsJobs(data *WorkflowData, jobName, markdownPat | |
| compilerSafeOutputJobsLog.Print("Building safe outputs jobs") | ||
|
|
||
| // Detection is always enabled for safe-outputs workflows unless threat-detection is explicitly | ||
| // disabled (threat-detection: false). ThreatDetection is nil only when explicitly disabled. | ||
| threatDetectionEnabled := data.SafeOutputs.ThreatDetection != nil | ||
| // disabled (threat-detection: false) or the engine is disabled with no custom steps | ||
| // (threat-detection: { engine: false } with no steps). ThreatDetection is nil only when | ||
| // explicitly disabled. When engine is false with no custom steps, the detection job has | ||
| // nothing to run so it is skipped entirely. | ||
| threatDetectionEnabled := data.SafeOutputs.ThreatDetection != nil && | ||
| !(data.SafeOutputs.ThreatDetection.EngineDisabled && len(data.SafeOutputs.ThreatDetection.Steps) == 0) | ||
|
|
||
| // Build the separate detection job. Detection runs by default for all safe-outputs workflows | ||
| // and is only skipped when ThreatDetection is nil (i.e. threat-detection: false was set). | ||
|
davidslater marked this conversation as resolved.
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. The predicate |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -521,7 +521,13 @@ func (c *Compiler) generateMainJobSteps(yaml *strings.Builder, data *WorkflowDat | |
| // NOTE: Git patch generation has been moved to the safe-outputs MCP server | ||
| // The patch is now generated when create_pull_request or push_to_pull_request_branch | ||
| // tools are called, providing immediate error feedback if no changes are present. | ||
| if usesPatchesAndCheckouts(data.SafeOutputs) { | ||
| // Include patches in the artifact when: | ||
| // 1. Safe outputs needs them for checkout (non-staged create_pull_request/push_to_pull_request_branch) | ||
| // 2. Threat detection is enabled (detection job needs patches for security analysis, even when the | ||
| // safe-output handler is staged and doesn't need checkout itself) | ||
| threatDetectionNeedsPatches := data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil && | ||
| !(data.SafeOutputs.ThreatDetection.EngineDisabled && len(data.SafeOutputs.ThreatDetection.Steps) == 0) | ||
|
||
| if usesPatchesAndCheckouts(data.SafeOutputs) || threatDetectionNeedsPatches { | ||
| artifactPaths = append(artifactPaths, "/tmp/gh-aw/aw-*.patch") | ||
| } | ||
|
|
||
|
|
||
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.
The multi-line condition for
threatDetectionEnabledlooks correct. Consider extractingEngineDisabled && len(Steps) == 0into a helper method likeThreatDetection.IsEffectivelyDisabled()for readability across the multiple call sites in this file.