Repository navigation
Closed
Labels
priority/p3-lowPriority P3: a small improvementscope/cliCore CLI framework, Typer subcommands, options, and tablestype/bugType bug: the code does not do what it must
Milestone
Description
Problem
The devsecops review session 20261001-224227 (2026-10-02, a path review of the whole repository with local models) raised 563 findings. A triage of every finding against release/v0.2.25 (c279c18) judged 489 false. Each of the 2 defects below was confirmed with code evidence and then upheld by a second agent that tried to refute it. The severities are re-rated; the review's own ratings were inflated.
Insecure Regex Substitution in Docker Push Command (src/devops_cli/commands/docker.py:164, LOW, security)
- Defect: The control-character strip works, but status text from the registry is then passed to
print_info(clean_status, prefix=False)andprint_error(clean_err, prefix=False)(lines 165 and 168), and the buildstreamlines (line 132) go through the same path, all withoutsafe=True. console.py prints that text unescaped (formatted_message = escape_text(raw_message) if safe else raw_message), so Rich markup in remote content is interpreted. Checked with the repo's Rich: a status ofdenied: [/v2/repo] accessraisesMarkupError: closing tag '[/v2/repo]' ... doesn't match any open tag, sodocker pushcrashes with a traceback instead of a cleanExit(1).[link=http://x]Pushed[/link]renders an attacker-chosen hyperlink, and[internal]text silently vanishes. The project already hasprint_safefor untrusted content, and a similar MarkupError was fixed in the TUI … - Skeptic's ruling: Upheld at LOW, re-scoped. The control-character strip in
pushandbuildworks, and stripping shell metacharacters (the finding's fix) does nothing useful because nothing here reaches a shell. The real defect: registry push status/error text and buildstreamlines go toprint_info(..., prefix=False)andprint_error(..., prefix=False)withoutsafe=True. In output/console.py,formatted_message = escape_text(raw_message) if safe else raw_message, and the result goes toConsole.print… - Fix: Keep the control-character strip, and pass
safe=Truetoprint_infofor build stream lines and push status, and toprint_errorfor the push error.print_safeis the alternative; the project already uses it for untrusted content. - Regression test: In tests/test_docker.py, with the existing
docker_enginefixture, setmock_client.images.push.return_value = [{"error": "denied: [/v2/repo] access"}]and invokepush registry/app:1. Assertexit_code == 1,isinstance(result.exception, SystemExit)and that '[/v2/repo]' appears literally in the output. Todayresult.exceptionis arich.errors.MarkupError. Add a build case whereimages.buildreturns(img, [{"stream": "Step [/x] done\n"}])and assert exit 0 with the literal text in …
Potential SSRF Vulnerability in Prometheus Scraping (src/devops_cli/commands/sandbox.py:535, LOW, security)
- Defect: Metric names are already restricted by _METRIC_LINE_REGEX
[a-zA-Z_:][a-zA-Z0-9_:]*(metrics.py:29-31), so the proposed name check does nothing. The claim that scraped content is unsafe in later rendering is correct for label values and TYPE text. _LABEL_REGEX accepts arbitrary values, and _record_type (metrics.py:328-332) stores free text from# TYPElines. _render_prom_table (commands/sandbox.py:534-538) buildslbl_str = ", ".join(f"{k}={v}" ...)and m.metric_type.upper(), then calls print_table, which goes to render_table with safe=False (output/formatters/tables.py:62,103), so Rich parses the cells as markup. The scraped endpoint is remote content: the sandboxed workload's port, or a user-given URL. Reproduced against c279c18:up{job="[/]"} 1(or# TYPE up [/]) makes the table render raise MarkupError "closing tag '[/]' at position 0 has nothing to close", which aborts … - Skeptic's ruling: I could not refute this. The original title (SSRF) and its fix (a metric-name regex) are wrong: METRIC_LINE_REGEX already limits names to [a-zA-Z:][a-zA-Z0-9_:]*, and _validate_scrape_url / validate_url_egress handle SSRF. The triage's narrower claim holds in the current code. _LABEL_REGEX accepts any label value, and _record_type (sandbox/metrics.py) stores the free text after '# TYPE ' as metric_type. _render_prom_table (commands/sandbox.py) joins those values into raw strings and …
- Fix: 1. In _render_prom_table, escape every value that comes from the scrape: escape_text(m.name), escape_text(m.metric_type.upper()), and escape_text on the label string. Truncate the label string to 40 characters before escaping, so the cut cannot land inside an escape sequence. Alternatively, give print_table a
safe: bool = Falseparameter that it passes to print(..., safe=safe), and have _render_prom_table call it with safe=True. That would also let other callers that show remote data (the trace waterfall, probe tables) opt in.
- In _record_type, keep a TYPE only when parts[2] matches the metric-name regex and parts[3].lower() is one of {counter, gauge, histogram, summary, untyped}. Otherwise ignore the line, so the type falls back to _infer_metric_type.
- Optionally, have print_warning(..., safe=True) handle snapshot.scrape_error, which can carry text from exceptions.
- Regression test: tests/unit/commands/test_sandbox_metrics_render.py:
(a) Build snapshot metrics with parse_prometheus_exposition('# TYPE up [/]\nup{job="[/]",x="[bold red]FAKE[/]"} 1'). Call _render_prom_table('t', metrics) with the module console patched to a Rich Console(record=True, width=200). Assert that no MarkupError is raised and that console.export_text() contains the literal strings 'job=[/]' and '[bold red]FAKE'. Today this raises MarkupError.
(b) A unit test that parse_prometheus_exposition('# TYPE …
Acceptance criteria
- Each defect above is fixed as its Fix line describes, or the PR says why another fix is better.
- Each has its Regression test: offline, failing on the base revision and passing after the fix.
- Removed code goes without shims (pre-1.0), and docs that described it are corrected.
uv run devops cipasses.
Key questions
- One PR for all of these? Yes (proposed). They share a module area and none needs a design decision; each fix is small.
Metadata
Metadata
Assignees
Labels
priority/p3-lowPriority P3: a small improvementscope/cliCore CLI framework, Typer subcommands, options, and tablestype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(cli): docker and sandbox output print remote text as written, nev…
dan-petty commentedon Oct 3, 2026
Closed by #1073, merged into
release/v0.2.25.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.feat(release): v0.2.25 (#1089)