Repository navigation
fix: mask sensitive input values in printed commands and report stage build failures - #8
Merged
Merged
Conversation
… build failures Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgoUpTaqPJBUQ7p2oFznr2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
A. A sensitive input's value was printed in plain text.
Input.sensitiveonly affected--schema. A value read from a marked input and interpolated throughcmd $"...", the stringrun, orCmd.ofListwas an ordinary argument, so the run log's command line,--explain(text and JSON) and a failed command's message all showed it. OnlyCmd.secretOption/runSensitivemasked it.B. A keyless publish failed with a bare NullReferenceException. A
stagebody is built eagerly, soapiKey.Valuein theelsebranch of awhen' (dryPublish || apiKey.IsSome)stage ran while the command read its pipelines, before any condition. Reproduced before the fix: the exception escapedpipeline.Readin the command action and reached System.CommandLine's default handler. It printedUnhandled exception: System.NullReferenceException ...with a stack trace to the error writer and exited 1. This happened identically for a plain run,--explainand--json.--jsonwrote no result, and nothing named the command or stage.Changes
Cmd.Redaction(inPartas.Build.Cmd, netstandard2.0-safe) is a process-wide set of values to mask.Cmd.toLogStringmasks every registered value as a whole argument and inside one (--api-key=***), longest value first. A null, empty or whitespace value is never registered.ActionInput.GetValueregisters each value it reads from a symbol markedInput.sensitive: a string, each string in an option, voption or collection, and the invariant text of any other non-bool value. The process still receives the value unmasked.--explainalso redacts its step labels.Constructionmodule: eachStageBuilder.Delayruns the body underConstruction.inStage, which records the stage name on the exception'sDataand rethrows it unchanged (same type, message and stack). Input reads record the input name the same way.Command (x) failed while building its pipelines in stage (publish/push). NullReferenceException: ...) and exits 1 (Failed). It records a pipeline run whose report is addressed by the stages being built and carries the exception as araisedcause, soRunResult.Failures,--jsonand--reportcarry it. Under--explainit prints the same message and exits 1 without a run result.when',failIfIgnoredandwhenSome(sharedbuiltRegardlessxmldoc fragment) now say the body is built whatever the condition says, and point atwhenSome. The guides cover the same points and the newInput.sensitivebehaviour.Stage bodies stay eager. Making them lazy would change when every stage is built, and when its inputs are read, across the builders. Reporting the failure gives the user the stage name and the fix (
whenSome) without that change.Tests
New Expecto tests: Cmd redaction (netstandard suite), sensitive input registration for string, option, list and int values (plus blank and unmarked values),
--explaintext and JSON masking acrosscmd, the stringrunandCmd.ofList, a real run whose log masks the key while the child process receives it, the stage-path record on a raised exception, and the keyless publish under a plain run,--jsonand--explain, plus its dry branch.dotnet run --project Build.fsproj -- testis green: 431 passed in Partas.Build.Tests (1 ignored), 65 in ExternalAnnotations.Tests (6 ignored), 73 in Partas.ExternalAnnotations.Tests (2 ignored), 6 in Cmd.NetStandard.Tests, and 11 + 11 compiler probe (Debug and Release).dotnet build src/Partas.Build -c Releaseis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01DgoUpTaqPJBUQ7p2oFznr2