Skip to content

fix(desktop-test): do not redact short secret-named environment values - #4401

Open
Jason Morse (JasonVMo) wants to merge 1 commit into
mainfrom
user/jasonvmo/tester-win32-legal-alert
Open

Jason Morse (JasonVMo) wants to merge 1 commit into
mainfrom
user/jasonvmo/tester-win32-legal-alert

Conversation

@JasonVMo

Copy link
Copy Markdown
Contributor

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

No platform runtime code changes. This fixes @fluentui-react-native/desktop-test, the development-time desktop test harness.

Description of changes

NodeDesktopCommandRunner registers the value of every environment variable whose name contains nonce, token, password, secret, or authorization as a secret and redacts it from all command output. When such a variable holds a flag-like value such as true, every true in the output is rewritten. A nested CLI's machine output {"runId":"...","delegated":true,"exitCode":0} becomes "delegated":[REDACTED] and no longer parses, which fails the delegated-cli contract test added in #4389. The test passes locally and on GitHub-hosted checks but fails in the Office main pipeline, whose environment evidently has such a variable. The rewrite also reaches the real events.jsonl journal and commands/*.log files, so this is a product bug and not only a test problem.

Why it matters now. Of the 12 main builds since #4389 landed on 2026-10-23, 4 failed on this test and 8 failed earlier at yarn install (the Office feed returned 404 for storybook@10.6.3). Installs have succeeded since 2026-10-27, and each of those builds then failed on this test. A failed main build skips the stages after the tests, including Component Governance scanning, so alerts that earlier PRs already fixed cannot clear. That includes the legal-information alert for @fluentui-react-native/tester-win32@0.1.0, which #4399 addressed (version 0.0.0 and "license": "MIT") and which only a successful scan of main can close.

Changes:

  • packages/agentic/desktop-test/src/commands.ts: register an environment value as a secret only when it is at least 8 characters long (MIN_ENVIRONMENT_SECRET_LENGTH). Real credentials, passwords, and nonces are long; flags and counters such as true or 0 are not. Explicit addSecret calls are unchanged and still apply to values of any length.
  • packages/agentic/desktop-test/src/contracts.contract.cjs and contracts.test.ts: new command-secrets contract. It runs a real child through NodeDesktopCommandRunner with secret-named variables set to true, a 7-character value, and an 8-character value, and asserts that the JSON output stays parseable, the 7-character value is untouched, and the 8-character value is redacted.
  • packages/agentic/desktop-test/references/reporting.md: documents the rule.
  • .changeset/desktop-test-env-secret-length.md: patch changeset for @fluentui-react-native/desktop-test.

Trade-off: a real secret shorter than 8 characters that reaches a child only through a secret-named environment variable is no longer registered automatically. Pattern-based redaction of key=value assignments for password, authorization, access-token, and the nonce keys still applies, and callers can register any value explicitly with addSecret.

Merge note: this is expected to turn the main pipeline green, which will run the stages after the tests (pack, publish, Component Governance) for the first time since 2026-10-22. Other issues behind this one are possible, and any pending changesets will be published by that run.

Verification

Run on Windows against the final tree:

Command Result
yarn format, yarn lint, yarn build in packages/agentic/desktop-test Passed.
yarn test in packages/agentic/desktop-test 2 suites and 26 tests passed, including the new command-secrets contract and delegated-cli.
yarn change:check Passed.
yarn clean-lage-cache, then yarn lage buildci --continue --concurrency 4 175 tasks passed, 1 failed. check-package-contents reports spawnSync yarn ENOENT on Windows because scripts/src/tasks/checkPackageContentsTask.ts calls execFileSync('yarn') without a shell. That predates this PR; with a session-only preload that launches yarn.cmd, node ./scripts/src/cli.ts check-package-contents verified all 8 guided packages.

Manual check, run in packages/agentic/desktop-test after yarn build:

  • With the threshold temporarily set to 0 (the previous behavior), node src/contracts.contract.cjs command-secrets fails, and so does node src/contracts.contract.cjs delegated-cli with ZZ_ACCESS_TOKEN_ENABLED=true set. Both report SyntaxError: Unexpected token 'R', ..."legated":[REDACTED],"... is not valid JSON, the same error as the main pipeline. With the fix, both pass.
Before After
With a secret-named variable set to true, the output {"delegated":true} is rewritten to {"delegated":[REDACTED]} and fails to parse. The JSON is unchanged. Only secret-named values of 8 or more characters are redacted.

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

NodeDesktopCommandRunner registered the value of every environment variable
named like a token, secret, password, nonce, or authorization header as a
secret. A value such as `true` then rewrote machine-readable output
(`"delegated":true` became `"delegated":[REDACTED]`). That fails the
delegated-cli contract in the Office main pipeline, where the environment
carries such a variable, and stops the stages after the tests, including
Component Governance scanning.

Register only values of at least 8 characters. Explicit addSecret calls are
unchanged. The new command-secrets contract covers a flag, a 7-character
value, and an 8-character value, and fails without the change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b6f34858-06bf-4230-8be7-1f65402b208a
@github-actions

Copy link
Copy Markdown
Contributor

Bundle size report

Tree-shaken, minified production esbuild bundles with React and React Native runtimes externalized.

Scenario Modules-Mac (Δ) Modules-Win (Δ) Size-Mac (Δ) Size-Win (Δ)
components-button 64 (+0) 65 (+0) 50.63k (+0b) 50.55k (+0b)
components-catalog 214 (+0) 215 (+0) 205.49k (+0b) 205.41k (+0b)
design-theme-state 34 (+0) 35 (+0) 30.15k (+0b) 30.08k (+0b)
design-themed-root 38 (+0) 39 (+0) 32.12k (+0b) 32.04k (+0b)
design-color-lib 6 (+0) 6 (+0) 6.33k (+0b) 6.33k (+0b)
design-theme-state-legacy-source 35 (+0) 36 (+0) 31.81k (+0b) 31.73k (+0b)
design-legacy-theme-from-flex 58 (+0) 59 (+0) 97.77k (+0b) 97.63k (+0b)

The job is advisory: size changes are reported but do not fail the pull request. Bundle or analysis errors still fail.


View bundle-size workflow run

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.

1 participant