Skip to content

Harden setup script temporary files and credential logging - #78464

Merged
pelikhan merged 4 commits into
mainfrom
copilot/uk-ai-resilience-triage-ai-scan-alerts
Nov 17, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/uk-ai-resilience-triage-ai-scan-alerts

Conversation

@gh-aw-bot

@gh-aw-bot gh-aw-bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

AI-scan alerts flagged setup-script risks involving temporary files, symlinks, command injection, and log leakage. This change addresses the locally confirmed predictable diagnostic paths and API-key-prefix logging.

  • Temporary files: Store Git diagnostics in a private mktemp -d directory and remove it on exit.
  • Credential logging: Stop logging API-key prefixes in both MCP server startup scripts; the key remains available through GITHUB_OUTPUT.
  • Alert review: The code-scanning API denied access, so individual alert status and ownership could not be updated. Any CWE-78 confirmation still requires human review.

@gh-aw-bot gh-aw-bot changed the title [WIP] Triage AI-scan alerts in setup scripts Harden setup script temporary files and credential logging Nov 16, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 17, 2026 01:09
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 01:09
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #78464 · copilot · gpt56 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~6 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by Ponytail Reviewer for #78464 · codex · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions github-actions Bot 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.

Reviewed the changed setup scripts and regression tests. The diagnostic files now use a private mktemp directory with cleanup, and API-key prefix logging is removed. No merge-blocking correctness or security issues found in the changed lines. Static review only; tests were not run per review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-c89812ee-4807-4841-bd21-296da73930d5","parents":[],"payload":{"id":"ldg-8104556c-efc4-4b1a-bff7-dd63ac5020bb","operation":"append","value":{"finding_count":0,"head_sha":"1b3af88a1ce9b1864801def64aee4b2af42f45d5","outcome":"aligned"}},"sha":"sha256:ba627e976196c96ecd94b733d5819d4f5c9d735668dd07eae4f4cbf3dd9c9f78","timestamp":"2026-11-17T01:17:08.634Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-b139c451-3d97-480a-9552-0829415e5371","parents":[],"payload":{"id":"ldg-1fe66cd8-c2ca-47d8-92c5-572da006a460","operation":"append","value":{"finding_count":0,"head_sha":"1b3af88a1ce9b1864801def64aee4b2af42f45d5","outcome":"no_findings"}},"sha":"sha256:7a5814a5a33ada2ef08136dcb5d6a0c4d632124d8cfe6ab72c567cd7108e08c4","timestamp":"2026-11-17T01:18:10.200Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. The core fix is sound: the predictable /tmp/gh-aw-* diagnostic paths are replaced by a private mktemp -d directory with a trap cleanup, and the API_KEY:0:8 prefix logging is removed from both server scripts. The existing shell suite passes (73/0). Two test-strength gaps remain, and both are posted inline.

📋 Key Themes & Highlights

Key Themes

  • Regression guards are weak: the JS guard matches only the literal API Key:, and the shell Test 0 greps source text instead of checking behavior.

Positive Highlights

  • ✅ Private temp directory plus trap ... EXIT removes the predictable-path risk and cleans up on every exit path.
  • ✅ Key values still reach GITHUB_OUTPUT, which the PR describes; only the stdout prefix is dropped.
  • ✅ Tests were added in the same PR as the fix.

Pre-existing issue (not changed here)

  • checkout_exit=$? at setup_cache_memory_git.sh:244 runs after if ! git checkout, so it always captures 0. A genuine checkout failure therefore exits 0 at line 255. This is outside the diff, so it is noted here rather than blocking. A follow-up that captures the status before the negation would fix it.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~6 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again


# ── Test 0: Git diagnostics use private, unpredictable temporary paths ────────
echo "Test 0: Git diagnostics use private temporary paths"
assert "diagnostic directory is created with mktemp" \

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.

[/tdd] Test 0 greps the script source. It passes even if the trap never removes the directory, or if the script writes diagnostics to another fixed path. Test 13 already drives the fsck branch, so this check can assert behavior instead.

💡 Suggested behavioral check

Run the script against a corrupted repo, as Test 13 does, then assert that no /tmp/gh-aw-git-fsck-* files exist and that the /tmp/gh-aw-cache-memory.* count matches its pre-run value. Keep the grep checks as a secondary guard.

@copilot please address this.

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.

Addressed in 4afb049: corruption recovery now checks that no predictable fsck diagnostic files remain and that the private diagnostic-path set is unchanged after execution. The source guards remain, and all 75 shell assertions pass.


it.each(["start_safe_outputs_server.sh", "start_mcp_scripts_server.sh"])("%s does not log the API key", script => {
const content = fs.readFileSync(path.join(__dirname, "../sh", script), "utf8");
assert.doesNotMatch(content, /API Key:/);

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.

[/tdd] This guard only matches the literal text API Key:. The leak was the ${GH_AW_..._API_KEY:0:8} expansion, so a reworded log line such as echo "Key: ${GH_AW_SAFE_OUTPUTS_API_KEY:0:8}" would still pass.

💡 Suggested assertion
assert.doesNotMatch(content, /API_KEY:\d/);

Matching the expansion catches a re-added key prefix regardless of its label.

@copilot please address this.

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.

Addressed in 4afb049: added the /API_KEY:\d/ guard for both startup scripts so a renamed log label cannot conceal reintroduced key-prefix slicing. All 7 startup tests pass.

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.

🟡 Changes recommended

The test-scripts target omits the new setup-cache regression script, leaving regressions that reintroduce predictable diagnostic paths unchecked by automated validation.

1 open issue
What changed in this PR

Hardens gh-aw setup scripts by isolating Git diagnostics and removing API-key prefixes from MCP server startup logs.

Changes:

  • Stores Git diagnostics in a private temporary directory with exit cleanup.
  • Removes API-key prefix logging while preserving credential forwarding through GITHUB_OUTPUT.
  • Adds regression checks for diagnostic paths and credential logging.
File Description
actions/​setup/​sh/​start_safe_outputs_server.sh Removes API-key prefix logging.
actions/​setup/​sh/​start_mcp_scripts_server.sh Removes API-key prefix logging.
actions/​setup/​sh/​setup_cache_memory_git.sh Moves Git diagnostics into a private, automatically cleaned temporary directory.
actions/​setup/​sh/​setup_cache_memory_git_test.sh Adds checks against predictable diagnostic paths.
actions/​setup/​js/​start_safe_outputs_server.test.cjs Adds checks against API-key log labels in both startup scripts.

Review effort: Max (adaptive)

Comment on lines +79 to +82
assert "diagnostic directory is created with mktemp" \
"grep -q 'mktemp -d /tmp/gh-aw-cache-memory.XXXXXX' '${SCRIPT}'"
assert "fixed diagnostic paths are not used" \
"! grep -Eq '/tmp/gh-aw-(git-fsck|checkout|merge)-' '${SCRIPT}'"

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.

Addressed in 4afb049: added the cache-memory setup regression suite to test-scripts. The suite passes all 75 assertions.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator Author

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/sh/setup_cache_memory_git_test.sh:79): address unresolved feedback - Review comment
  3. Review (actions/setup/js/start_safe_outputs_server.test.cjs:47): address unresolved feedback - Review comment
  4. Review (actions/setup/sh/setup_cache_memory_git_test.sh:82): address unresolved feedback - Review comment
  5. Fix failing check impacted-js-tests (FAILURE): Check run.
  6. Fix failing check impacted-js-tests (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "1b3af88a1ce9b1864801def64aee4b2af42f45d5",
  "kind": "requested",
  "schema_version": "1",
  "state": "46bbe423a87ad9a530ce48682779e694f38cad62322eb2c6692c4a2923f5a069",
  "work": [
    "26583d185129738525bf55540b975ca315061f8be302859fc976dc1f3dc0dc54",
    "7fdcb480e7a98cc7e0f466a49ad1c7f7e8c5cfc22f8fbcc711724ed335220761",
    "87d010a05869c90dac5f7f07759c0fff448b0f8ae40361fe15b7bc140407ac0f",
    "abfdc2fdb839cef195b2bd3ddd2ad824e1ab572836d1e6fd92ca80f111f86698"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 17, 2026 01:55
…nce-triage-ai-scan-alerts

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Updated from main via make merge-main in fb30503; no conflicts. Addressed all three linked review comments in 4afb049. Main already fixes the shared Dependabot harness failure behind both CI jobs; all 41 workflow contract tests now pass locally. Also passed 75 shell assertions, 7 startup tests, the final repository gate, secret scanning, and compilation of all 368 workflows. CodeQL timed out and instructed against retrying, so that scan remains incomplete. No PR merge or CI dispatch was performed.

@pelikhan
pelikhan merged commit 6a47c85 into main Nov 17, 2026
90 checks passed
@pelikhan
pelikhan deleted the copilot/uk-ai-resilience-triage-ai-scan-alerts branch November 17, 2026 03:04
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[uk-ai-resilience] [uk-ai-governance] Tier B: triage AI-scan alerts in setup scripts (CWE-59/78/1327/377)

4 participants