Repository navigation
fix(telemetry): the command span holds no argument value, so a secret given to devops config set never reaches the trace backend - #2028
Merged
Conversation
… given to devops config set never reaches the trace backend The command span of `_delegate` put every argument in `cli.args`, with no mask. The tracer resource put `sys.argv` in `process.command_line`, through a secret pattern that keeps a credential for 5 of the 13 secret keys. Both went to the trace backend. The command span now keeps `cli.command` and `cli.args_count`, and has no `cli.args`. The resource has no `process.command_line`. The OpenTelemetry semantic conventions give `process.command_args` and `process.command_line` as Opt-In for this reason. The span of the command that runs holds Click's command path (`cli.command_path`, such as `devops config set`), which holds no argument. Task file: `docs/agent/tasks/task-1996-command-span-holds-no-argument-value.md`
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.
Summary
A command span recorded each argument of the command, so a credential given to
devops config set <key> <value>went to the trace backend. Two places sent it:_delegateinsrc/devops_cli/main.pyput" ".join(effective_args)in the span attributecli.args, with no mask.OTelTelemetryClientinsrc/devops_cli/telemetry/tracer.pyputmask_secrets(" ".join(sys.argv))in the resource attributeprocess.command_lineof every trace payload.mask_secretsfinds secrets by pattern. Fordevops config set <key> correct-horse-battery-staple, it keeps the value for 5 of the 13 secret keys:cloudflare.api_token,cloudflare.tunnel_token,runs.index_password,service.webhook_secretsandtelemetry.logfire_token.Evidence: the Tempo data source lists
cli.argsas a span attribute andprocess.command_lineas a resource attribute. The OpenTelemetry semantic conventions giveprocess.command_argsandprocess.command_lineas Opt-In, and say that a producer "SHOULD NOT" collect them by default "unless there is sanitization that excludes sensitive data". A secret pattern does not exclude all sensitive data.The change:
_delegatehas nocli.args. It keepscli.commandandcli.args_count.process.command_line._execute_traced_cli_commandinsrc/devops_cli/core/cli.py) holds Click's command path incli.command_path, such asdevops config set. The command path holds the command names and no argument, as in the config write record of fix(tests): a test that writes a real config.yaml fails at the write and names itself, and every config write keeps a backup and a change record #1921. Thus the trace still names the command that ran.docs/TELEMETRY.md(fromsrc/devops_cli/docs/generator.py) andARCHITECTURE.mdsay which attributes describe the command line, and that they hold no argument value.No dashboard, alert or query under
k8s/monitoring/readscli.argsorprocess.command_line, so no manifest changes.Tests:
tests/test_otel_command_coverage.pyrunsset cloudflare.tunnel_token <credential>through_delegatewith telemetry export captured.test_no_exported_attribute_holds_an_argument_valuefinds the credential in no exported payload. It fails onorigin/main, and it also fails with only thecli.argschange, because the resource held the credential.test_the_command_spans_keep_the_command_path_and_the_argument_countshows that the spans keepcli.command,cli.args_countandcli.command_path.Two related paths stay as they are; #2024 and #2025 cover them:
error.message. Also,except click.ClickExceptionin_delegatedoes not catch the errors that Typer 0.27 raises, because Typer has its own copy of Click.subprocess.cmdandprocess.command_line, through a secret pattern). A command that passes the arguments of a person to a program, such asdevops uv runordevops gh api, puts them there.Item
Closes #1996
Task file:
docs/agent/tasks/task-1996-command-span-holds-no-argument-value.md