Conversation
…w_call inputs
- Schema: `safe-outputs.threat-detection` now accepts a GHA expression string
(e.g. `${{ inputs.enable-threat-detection }}`) in addition to boolean/object forms.
Object-form `enabled` and `continue-on-error` also accept `templatable_boolean`.
- Model: Added `EnabledExpr *string` and `ContinueOnErrorExpr *string` to
`ThreatDetectionConfig`. Added `IsConditional()` method on config and
`IsConditionalDetection(*SafeOutputsConfig)` top-level helper.
- Parsing: `parseThreatDetectionConfig` handles expression strings for both
top-level and object-form `enabled` field. Refactored shared object parsing
into `parseThreatDetectionObjectConfig`.
- Compilation: when `EnabledExpr != nil`, the detection job `if:` condition
includes the raw caller expression. Downstream jobs (safe_outputs, safe_jobs,
upload_assets) use `always() + buildDetectionPassedCondition()` to handle the
case where detection is skipped at runtime (expression evaluated to false).
- `continue-on-error` expression: emitted as an unquoted GHA expression in both
the step `continue-on-error:` field and `GH_AW_DETECTION_CONTINUE_ON_ERROR` env var.
- Tests: parser, model, compiler, and integration tests for all new expression paths.
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7b7ef13f-1bcd-4ffa-ab50-2a58a6ecd4d7
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ntinue-on-error logic Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7b7ef13f-1bcd-4ffa-ab50-2a58a6ecd4d7 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds runtime (workflow_call input) control over safe-outputs.threat-detection by allowing GitHub Actions expressions in the schema and compiler, and adjusts downstream job conditions to behave correctly when detection is skipped at runtime.
Changes:
- Extend workflow schema to accept expression strings for
safe-outputs.threat-detectionand templatable booleans forenabled/continue-on-error. - Update threat detection parsing/model (
ThreatDetectionConfig) to capture expression forms and compile them into the detection job’sif:condition. - Update safe job conditions (and add tests) to handle conditional detection where the detection job can be skipped at runtime.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/threat_detection.go | Parses expression-based configs, tracks conditional detection, and injects the caller expression into the detection job if:. |
| pkg/workflow/safe_jobs_threat_detection_test.go | Adds test coverage for expression parsing and conditional detection job/condition behavior. |
| pkg/workflow/safe_jobs.go | Wraps safe-jobs if: with always() + detection-passed gating when detection is conditional. |
| pkg/workflow/publish_assets.go | Updates upload_assets job condition for conditional detection (but currently misses a required needs dependency). |
| pkg/workflow/compiler_safe_outputs_job.go | Adjusts safe_outputs job condition to run when detection is skipped due to runtime expression. |
| pkg/parser/schemas/main_workflow_schema.json | Schema updates to allow expression strings/templatable booleans for threat-detection configuration. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
pkg/workflow/publish_assets.go:196
buildUploadAssetsJobbuildsjobConditionwithbuildDetectionPassedCondition()when detection is conditional, but the job'sneedsdoes not include thedetectionjob. SincebuildDetectionPassedCondition()referencesneeds.detection.result, this will evaluate incorrectly (or error) at runtime. Addconstants.DetectionJobNametoneedswhenever the condition can reference detection (e.g. whenIsConditionalDetection(data.SafeOutputs)or more generally whenthreatDetectionEnabledis true).
jobCondition := BuildSafeOutputType("upload_asset")
if IsConditionalDetection(data.SafeOutputs) {
jobCondition = BuildAnd(
BuildAnd(BuildFunctionCall("always"), BuildSafeOutputType("upload_asset")),
buildDetectionPassedCondition(),
)
}
// Build job dependencies — always include activation job for OTLP trace ID correlation
needs := []string{mainJobName, string(constants.ActivationJobName)}
- Files reviewed: 6/6 changed files
- Comments generated: 0
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification DetailsView All 7 Tests
HighlightsAll 7 new tests are design tests that verify behavioral contracts:
Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §25170616401
|
…tion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Commit pushed:
|
|
@copilot review all jobs that are gated by detection: push_repo_memory, upload_cache_memory as well |
…nal detection correctly Agent-Logs-Url: https://github.com/github/gh-aw/sessions/44e1142d-22c4-49d8-be40-f9ab61c046bb Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Both jobs already handle conditional detection correctly without changes needed:
Both already used Added |
|
@copilot ensure integration tests workflows in pkg/cli/workflows for every job type and combination of threat detection enablement or not |
… threat detection combinations Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c3a083ab-d654-4a59-86b1-97009f7715b2 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added in commit 6 workflow fixtures in
|
Reusable
workflow_callworkflows couldn't parameterize threat detection at runtime —threat-detectiononly accepted compile-time boolean/object values, forcing separate workflow files for detection-on vs detection-off configurations.Changes
Schema
safe-outputs.threat-detectionnow accepts a GHA expression string (top-level)enabledandcontinue-on-errornow usetemplatable_boolean(bool literal or expression)Model & parsing (
ThreatDetectionConfig)EnabledExpr *stringandContinueOnErrorExpr *stringfor expression formsIsConditional()/IsConditionalDetection()helpersparseThreatDetectionConfighandles expression strings at both the top level and inside the object form; object parsing extracted toparseThreatDetectionObjectConfigCompilation
EnabledExpr != nil, the detection job'sif:includes the raw caller expression — GitHub Actions evaluates it at runtime and skips the job when falsesafe_outputs,safe_jobs, andupload_assetsjobs switch toalways() && buildDetectionPassedCondition()(success || skipped) when detection is conditional, preventing them from being silently skipped when detection is skipped at runtimecontinue-on-errorexpression is emitted unquoted in both the step field andGH_AW_DETECTION_CONTINUE_ON_ERRORenv varpush_repo_memoryandupdate_cache_memoryalready usedbuildDetectionPassedCondition()so they correctly handle conditional detection without code changesTests
push_repo_memoryandupdate_cache_memoryjob conditions with conditional detectionthreat_detection_job_combinations_integration_test.gocovers all job types × detection modes (disabled / boolean-enabled / expression):TestThreatDetectionCombinations— 13 subtests acrosssafe_outputs,detection,push_repo_memory,update_cache_memory, and custom safe-jobsTestWorkflowFilesCompile— compiles all fixture.mdfiles and verifies correct job generationTestRepoMemoryWithThreatDetectionNeedsAndConditions— parametric tests forpush_repo_memoryacross all 3 detection modesTestCacheMemoryWithThreatDetectionNeedsAndConditions— parametric tests forupdate_cache_memoryacross all 3 detection modespkg/cli/workflows/documenting every combinationExample
Literal boolean and object forms remain fully backward compatible.