Skip to content

Safely collect redacted AWF resolved configuration artifacts - #69109

Merged
lpcox merged 7 commits into
mainfrom
copilot/safely-redact-awf-config-artifact
Oct 15, 2026
Merged

lpcox merged 7 commits into
mainfrom
copilot/safely-redact-awf-config-artifact

Conversation

Copilot AI commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

AWF publishes early resolved configuration under a protected host path so diagnostics remain available when privileged cleanup fails. gh-aw now validates, redacts, stages, and collects that evidence without exposing raw configuration or weakening host/guest isolation.

  • Secure collection

    • Accept only the expected /run/awf-config-audit/run-<id>/awf-resolved-config.json layout.
    • Validate ownership, permissions, link count, file type, and inode stability.
    • Read through a no-follow descriptor to prevent path races.
  • Redaction and failure handling

    • Recursively redact sensitive fields and credential values before staging.
    • Fail closed on malformed, unsafe, or redaction-failure inputs.
    • Remove stale staged output and emit actionable diagnostics without revealing contents.
    • Preserve compatibility when older AWF versions omit AWF_RESOLVED_CONFIG.
  • Artifact integration

    • Stage sanitized evidence at /tmp/gh-aw/awf-resolved-config.json.
    • Include it in normal, fallback, ARC, and DinD artifact collection paths.
    • Ensure collection remains available on cleanup-failure paths.
AWF_RESOLVED_CONFIG
  -> validate protected source
  -> redact sensitive values
  -> atomically stage sanitized JSON
  -> collect as a diagnostic artifact

Copilot AI and others added 2 commits October 15, 2026 21:18
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix redaction and collection of AWF's resolved config artifact Safely collect redacted AWF resolved configuration artifacts Oct 15, 2026
Copilot AI requested a review from lpcox October 15, 2026 21:24
@lpcox
lpcox marked this pull request as ready for review October 15, 2026 21:28
Copilot AI max review requested due to automatic review settings October 15, 2026 21:28
Comment thread actions/setup/js/redact_secrets.cjs
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox

lpcox commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

@copilot fix all failing ci checks

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

Secret-redaction and runtime-packaging defects remain unresolved.

6 open findings
What changed in this PR

Extends gh-aw’s artifact pipeline to collect AWF’s early resolved configuration for cleanup-failure diagnostics.

Changes:

  • Adds source validation, redaction, and sanitized staging.
  • Extends normal, fallback, and ARC/DinD artifact collection.
  • Adds regression tests and documents compatibility.
File Description
pkg/​workflow/​compiler_yaml_post_agent.go Adds configuration evidence to unified uploads.
pkg/​workflow/​compiler_yaml_artifacts.go Includes evidence in fallback uploads.
pkg/​workflow/​compiler_artifacts_test.go Checks expected artifact paths.
pkg/​constants/​constants.go Defines sanitized staging paths.
docs/​src/​content/​docs/​reference/​artifacts.md Documents publication and compatibility requirements.
actions/​setup/​js/​redact_secrets.test.cjs Adds path, compatibility, and staging tests.
actions/​setup/​js/​redact_secrets.cjs Validates, sanitizes, and stages resolved configuration.

🧠 Review effort: Max


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

const { collectAddMaskedValues, redactArtifactMaskedValues } = require("./add_mask_redaction.cjs");
const { redactPiSessionHTML } = require("./pi_session_redaction.cjs");
const { getOTLPSecretValues } = require("./otlp_header_helpers.cjs");
const { redactSensitiveConfig } = require("./safe_outputs_config_redact.cjs");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added safe_outputs_config_redact.cjs to the session parser embed list; it was already present in MCP_SCRIPTS_FILES in setup.sh. The runtime packaging test passes. Fixed in 18a682d.

Comment thread actions/setup/js/redact_secrets.cjs Outdated
function stageAWFResolvedConfig(sourcePath, secretValues, maskedValues) {
const existing = fs.lstatSync(AWF_RESOLVED_CONFIG_STAGING_PATH, { throwIfNoEntry: false });
if (existing) {
if (!existing.isFile()) throw new Error(`${ERR_VALIDATION}: AWF resolved configuration staging path is not a file`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Staging now recursively removes stale files/directories/symlinks without following links, and both unified and fallback uploads require successful redaction whenever the AWF artifact path is included. Cleanup failures therefore block uploads. Added regressions; fixed in 18a682d.

Comment thread actions/setup/js/redact_secrets.cjs Outdated
}
const safeConfig = redactSensitiveConfig(parsed);
const serialized = JSON.stringify(safeConfig, null, 2);
const redacted = redactSecrets(redactBuiltInPatterns(redactArtifactMaskedValues(serialized, maskedValues)).content, secretValues).content;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The JSON-aware staging redactor now receives eligible secretValues as well as runtime masks; added a quote/backslash/newline secret regression. Fixed in 18a682d.

Comment on lines +618 to +630
let stagedResolvedConfig = false;
try {
stagedResolvedConfig = stageAWFResolvedConfig(process.env.AWF_RESOLVED_CONFIG, secretValues, maskedValues);
} catch (error) {
core.setFailed(`${ERR_VALIDATION}: AWF resolved configuration was not collected safely`);
core.warning(`AWF resolved configuration collection failed: ${getErrorMessage(error)}`);
return;
}
if (stagedResolvedConfig) {
core.info("Collected sanitized AWF resolved configuration");
} else {
core.info("AWF did not publish an early resolved configuration artifact");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Collection errors now remain visible, skip the misleading absent-publication message, and do not stop redaction of other artifacts. Uploads containing the AWF path are gated on redaction success. Added a main-path regression; fixed in 18a682d.

paths = append(paths, constants.AWFReflectFilePathExpr)
} else {
paths = append(paths, constants.AWFConfigFilePath.String())
paths = append(paths, constants.AWFResolvedConfigFilePath.String())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Regenerated the native and wasm golden fixtures with make update-wasm-golden; the wasm golden tests now pass. Fixed in 18a682d.

expect(fs.existsSync(AWF_RESOLVED_CONFIG_STAGING_PATH)).toBe(false);
});

it("stages only sanitized configuration after validating the protected source", () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added regressions for invalid ownership/modes, symlink/non-regular sources, hard links, inode/device changes, malformed JSON, stale-output cleanup, cleanup failure, and continued redaction of other artifacts. Fixed in 18a682d.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix all failing ci checks

Fixed the failing checks in 8f10371: added the MCP runtime dependency, regenerated the affected wasm goldens and compiled workflow locks. Focused tests and the final pre-commit gate passed.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/redact_secrets.cjs:16): This top-level import adds a required dependency wherever redact_secrets.cjs is deployed, but both MCP_SCRIPTS_FILES in actions/setup/setup.sh and the embed list in actions/setup/session_parsers.go omit safe_outputs_config_redact.cjs. The MCP scripts server loads this through diagnostic_sanitization → safe_output_manifest; the CLI session parser loads it through session_artifact → safe_output_manifest. Both startup paths now fail with Cannot find module './safe_outputs_config_redact.cjs'. Add the module to both deployment lists. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  3. Review (actions/setup/js/redact_secrets.cjs:357): If the staging path already exists as a directory, this throws without removing it, even when AWF_RESOLVED_CONFIG is unset. The ordinary unified and fallback uploads still run on failure and now include this path, so they can recursively upload its unvalidated children. Files such as .pem are not scanned by the normal redactor, so continuing that redactor alone will not fix this. Remove or quarantine rejected staging entries without following links, and ensure neither upload consumes this path unless sanitized staging succeeded, including when cleanup fails. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  4. Review (actions/setup/js/redact_secrets.cjs:370): Known secrets containing quotes, backslashes, or newlines survive staging in non-sensitive fields such as command: JSON.stringify escapes them, but redactSecrets searches for the original values. Parsing the staged JSON recovers the credential. The JSON-aware redactor currently receives only runtime masks; include eligible secretValues in that pass too, and add an escaped-secret regression. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  5. Review (actions/setup/js/redact_secrets.cjs:630): An invalid, unreadable, or malformed AWF publication returns before the processFile loop, skipping redaction of every other discovered artifact. Ordinary unified uploads and the fallback upload still run with if: always() (compiler_yaml_artifacts.go:48,121), so credential-bearing logs remain uploadable. This can also happen with older AWF when a directory occupies the staging path. Record the collection failure but continue sanitizing the remaining files, and do not report a failed collection as an absent publication. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  6. Review (pkg/workflow/compiler_yaml_post_agent.go:149): This changes compiled artifact paths, but the golden fixtures still omit awf-resolved-config.json. For example, testdata/TestWasmGolden_AllEngines/copilot.golden:813-814 goes directly from awf-config.json to the firewall logs directory. normalizeOutput does not remove the new path, so the exact golden comparisons no longer match. Regenerate and commit the affected native and WebAssembly golden fixtures with make update-wasm-golden. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  7. Review (actions/setup/js/redact_secrets.test.cjs:1240): The added tests reject path syntax or supply entirely valid mocked metadata. None exercise rejection of wrong ownership/modes, symlinks or other non-regular sources, extra hard links, or an inode/device change after opening. Malformed JSON, stale-output cleanup, and redaction/staging failures also lack AWF regressions. Add negative cases asserting that rejected evidence leaves no uploadable output and preserves the protected source, plus a main() case simulating early publication followed by failed cleanup. Check that other artifacts still get redacted. These are the fail-closed guarantees required by Safely redact and collect AWF's early AWF_RESOLVED_CONFIG artifact after failed cleanup #69107. - Safely collect redacted AWF resolved configuration artifacts #69109 (comment)
  8. Fix failing check build-wasm (FAILURE): https://github.com/github/gh-aw/actions/runs/38814614277/job/116706301530.
  9. Fix failing check impacted-go-tests (FAILURE): https://github.com/github/gh-aw/actions/runs/38814614277/job/116706301429.

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 8f10371
Sous-chef work: 3cde85983c9784a94a0ed51fe6c114b5e0f5c3cd60bfbdb857e70c5417dcc824 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac 449ba1cfb54aa800feb17c41eda57d8a7fe5ca50cab7e0afd7105d94e242899e 4ca2b5fe4b20832845acd562cd96999767f9ce8b5d1c53b2d4ee3dcdf30acca1 88fabae4a8a800399a1d891a15ae058fb7222848516ef3984b38d3a0ed81dae0 8acb61a077717e3a460018aacdfde96fd489f77606cd36169e2328d9079b75bb c3664f67d7b22fa1185ece5895a0b513e9e43c1934598a1779b5dcba434c74ea c90d5825544e59423bd90178a6fdff4b0b07c6a5006047dd7a6075c7de20750d
Sous-chef state: 2663dd9e7026172ca6a5af19f27414142db3b620ba0ffd0cda0a42b9a19b252a

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 6.63 AIC · ⌖ 6.84 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

@lpcox

lpcox commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

@copilot fix failing CGO ci checks

Copilot AI and others added 2 commits October 15, 2026 22:54
…-awf-config-artifact

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix failing CGO ci checks

The CGO failures were on the earlier 8f10371 head: wasm golden expectations were stale after the artifact path change. Regenerated fixtures in 18a682d; make build-wasm, make test-impacted-go, and the final make agent-report-progress now pass. No CGO run is recorded for the current head; CI needs a maintainer-triggered rerun.

@lpcox
lpcox merged commit 2687cab into main Oct 15, 2026
48 of 49 checks passed
@lpcox
lpcox deleted the copilot/safely-redact-awf-config-artifact branch October 15, 2026 23:35
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.92.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.

Safely redact and collect AWF's early AWF_RESOLVED_CONFIG artifact after failed cleanup

5 participants