Skip to content

Propagate context to external threat detection - #50853

Merged
pelikhan merged 4 commits into
mainfrom
copilot/threat-detection-fix-env-vars
Aug 6, 2026
Merged

Propagate context to external threat detection#50853
pelikhan merged 4 commits into
mainfrom
copilot/threat-detection-fix-env-vars

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

External threat-detect execution did not receive workflow context, custom prompts, or detection validation inputs, causing unnamed-workflow prompts and inconsistent strict-mode behavior.

  • External detector environment

    • Adds WORKFLOW_NAME, WORKFLOW_DESCRIPTION, HAS_PATCH, and GH_AW_DETECTION_CONTINUE_ON_ERROR to the AWF execution step.
    • Adds CUSTOM_PROMPT only when configured.
  • Safe prompt propagation

    • Uses step environment variables forwarded by AWF rather than embedding user-controlled prompt text in the command line.
  • Shared rendering

    • Centralizes threat-detection context env generation so setup, external execution, and conclusion paths use consistent continue-on-error formatting.
env:
  WORKFLOW_NAME: "Example workflow"
  WORKFLOW_DESCRIPTION: "Reviews repository changes"
  HAS_PATCH: ${{ needs.agent.outputs.has_patch }}
  GH_AW_DETECTION_CONTINUE_ON_ERROR: "false"
  CUSTOM_PROMPT: "Prioritize credential exposure."
  • Coverage and generated workflows
    • Adds compiler assertions for configured and omitted custom prompts.
    • Regenerates affected workflow lock files.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix environment variables for external detector execution Propagate context to external threat detection Aug 6, 2026
Copilot AI requested a review from pelikhan August 6, 2026 12:58
@pelikhan
pelikhan marked this pull request as ready for review August 6, 2026 13:03
Copilot AI balanced review requested due to automatic review settings August 6, 2026 13:03
@pelikhan

pelikhan commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Propagates workflow context and strict-mode inputs into external threat detection.

Changes:

  • Adds shared threat-detection environment rendering.
  • Adds compiler coverage for custom prompt propagation.
  • Regenerates affected workflow lock files.
Show a summary per file
File Description
pkg/workflow/threat_detection_test.go Tests external detector context propagation.
pkg/workflow/threat_detection_steps.go Centralizes detection environment rendering.
pkg/workflow/threat_detection_external.go Adds context to the AWF execution environment.
.github/workflows/typist.lock.yml Regenerates detector environment.
.github/workflows/prompt-clustering-analysis.lock.yml Regenerates detector environment.
.github/workflows/github-mcp-structural-analysis.lock.yml Regenerates detector environment.
.github/workflows/example-workflow-analyzer.lock.yml Regenerates detector environment.
.github/workflows/duplicate-code-detector.lock.yml Regenerates detector environment.
.github/workflows/detection-analysis-report.lock.yml Regenerates detector environment.
.github/workflows/design-decision-gate.lock.yml Regenerates detector environment.
.github/workflows/daily-token-consumption-report.lock.yml Regenerates detector environment.
.github/workflows/daily-rendering-scripts-verifier.lock.yml Regenerates detector environment.
.github/workflows/daily-reliability-review.lock.yml Regenerates detector environment.
.github/workflows/daily-observability-report.lock.yml Regenerates detector environment.
.github/workflows/daily-fact.lock.yml Regenerates detector environment.
.github/workflows/daily-evals-report.lock.yml Regenerates detector environment.
.github/workflows/daily-elixir-credo-snippet-audit.lock.yml Regenerates detector environment.
.github/workflows/daily-doc-healer.lock.yml Regenerates detector environment.
.github/workflows/daily-code-metrics.lock.yml Regenerates detector environment.
.github/workflows/daily-choice-test.lock.yml Regenerates detector environment.
.github/workflows/daily-caveman-optimizer.lock.yml Regenerates detector environment.
.github/workflows/daily-cache-strategy-analyzer.lock.yml Regenerates detector environment.
.github/workflows/daily-aw-cross-repo-compile-check.lock.yml Regenerates detector environment.
.github/workflows/daily-astrostylelite-markdown-spellcheck.lock.yml Regenerates detector environment.
.github/workflows/daily-agentrx-trace-optimizer.lock.yml Regenerates detector environment.
.github/workflows/craft.lock.yml Regenerates detector environment and step ordering.
.github/workflows/copilot-session-insights.lock.yml Regenerates detector environment.
.github/workflows/copilot-agent-analysis.lock.yml Regenerates detector environment.
.github/workflows/contribution-check.lock.yml Regenerates detector environment and step ordering.
.github/workflows/cloclo.lock.yml Regenerates detector environment.
.github/workflows/cli-version-checker.lock.yml Regenerates detector environment.
.github/workflows/claude-code-user-docs-review.lock.yml Regenerates detector environment.
.github/workflows/ci-doctor.lock.yml Regenerates detector environment.
.github/workflows/ci-coach.lock.yml Regenerates detector environment and step ordering.
.github/workflows/changeset.lock.yml Regenerates detector environment.
.github/workflows/blog-auditor.lock.yml Regenerates detector environment.
.github/workflows/aw-failure-investigator.lock.yml Regenerates detector environment.
.github/workflows/avenger.lock.yml Regenerates detector environment.
.github/workflows/audit-workflows.lock.yml Regenerates detector environment.
.github/workflows/artifacts-summary.lock.yml Regenerates detector environment and step ordering.
.github/workflows/archivx-agentic-workflows-analyzer.lock.yml Regenerates detector environment.
.github/workflows/archie.lock.yml Regenerates detector environment and step ordering.
.github/workflows/approach-validator.lock.yml Regenerates detector environment.
.github/workflows/api-consumption-report.lock.yml Regenerates detector environment.
.github/skills/agentic-workflows/SKILL.md Adds the designer-mappings workflow reference.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 79/101 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +408 to +410
// Pass context as environment variables: AWF's --env-all forwards them to
// threat-detect without interpolating user-controlled prompt text into a command.
steps = append(steps, c.buildThreatDetectionContextEnvVars(data, continueOnError, continueOnErrorExpr)...)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Resolved in b67f4e7.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot This PR is currently blocked by merge conflicts. Please run make merge-main on this branch to resolve conflicts, then continue with the pr-finisher skill and address the latest review thread: #50853 (comment)

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.5 AIC · ⊞ 8.3K ·
Comment /souschef to run again

@pelikhan
pelikhan merged commit 0a90c95 into main Aug 6, 2026
4 of 6 checks passed
@pelikhan
pelikhan deleted the copilot/threat-detection-fix-env-vars branch August 6, 2026 13:23
Copilot stopped work on behalf of gh-aw-bot due to an error August 6, 2026 13:23
Copilot AI requested a review from gh-aw-bot August 6, 2026 13:23
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

threat-detection: workflow context and detection env vars never reach the external detector execution step

4 participants