Repository navigation
fix(accounting): limit user text in reports - #516
Conversation
Container runtimes pull an image reference with a digest by that digest and ignore its tag, so a task with an image such as `quay.io/biocontainers/samtools:john.doe@sha256:<real digest>` completes, and its tag (any text, e.g. the name of a user) went into the execution reports as `tool_version`. References with a digest now give no version or package version. The docs also say that the tags `biotools_id` and `rrid` are checked against their patterns only, as the user who creates a task chooses them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
- Records and reports of images given with a digest have no version: say so in the configuration, API and upgrade docs, and test it on the usage record too. - The upgrade note on accounting (#459, #490) was in "To version 0.6.0", but accounting is new in 0.7.0: moved to "To version 0.7.0", whose note on execution reports now says "Nothing else changes" without accounting (the collection `usage` and its indexes are created anyway). - The docstring of the reports no longer claims more than the code guarantees: tags `biotools_id` and `rrid` are chosen by the user and only checked against their patterns. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Reviewer's GuideData structuresDefine the recognized task-tag identifier types and distinguish their IRIs from the image repository identifier.
Expose the report tag allow list in the execution-report configuration, defaulting to the two recognized tag names.
APIUpdate the public OpenAPI description to clarify that task-tag identifiers are included only when their tag names are configured.
ImplementationOmit image tags and package versions for digest references so unchecked text cannot enter reports, and construct the image identifier through the shared constant.
Filter recorded tool identifiers to the image identifier and configured task-tag identifiers, and skip reports that would lack a required identifier.
ConfigurationAdd the configurable report tag allow list to the example configuration and explain its defaults, validation, and effect on reported identifiers.
DocumentationClarify report field behavior for digest images and configured tag identifiers, including that user-supplied tag values are only pattern-checked.
Move the accounting upgrade note to the version where accounting is introduced and update execution-report guidance for digest versions and configured tags.
TestsVerify that usage records never retain versions from image references supplied with a digest.
Cover configured tag filtering, rejection of unknown identifiers, empty-identifier reports, and configuration validation.
Test digest-reference version suppression and classification of known identifier IRIs by task tag.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #516 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 38 38
Lines 3635 3655 +20
=========================================
+ Hits 3635 3655 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Execution reports drop unchecked tags of images given with a digest and report identifiers from tags of tasks only for the tags listed in custom.accounting.reports.tags (D-434; #520, #516). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Execution reports give identifiers of the tool from tags of the task only for the tags listed in custom.accounting.reports.tags (D-434): by default biotools_id and rrid, the only known ones; other names are invalid, and [] reports only the image repository. The list applies when reports are requested, also to tasks recorded before (identifiers are told apart by the start of their IRIs). Docs: configuration, API (also the OpenAPI description), upgrade note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Reports keep only the identifier of the image and those of listed tags; other recorded identifiers (other tags or IRI forms, no strings) are dropped instead of passed through. Docs: the API page says that tag identifiers are reported only if listed. Direct tests of identifier_tag. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
A record whose tool has no reported identifier (only possible for records not written by proTES) gives no reports, as the report format requires one. The API page says that tag identifiers are reported as IRIs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Linked issuesChecked at commit c98d560 #520 fix: drop unchecked image tags from reports · 3 of 3 met
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pro_tes/accounting/reports.py" line_range="184" />
<code_context>
+ return False
+ if identifier.startswith(IMAGE_IRI.format("")):
+ return True
+ return identifier_tag(identifier) in config.tags
+
+
</code_context>
<issue_to_address>
**User-chosen text reaches reports**
When a task creator sets `biotools_id` to personal or otherwise user-chosen text that matches the pattern and runs a trusted image, `_tag_identifiers` accepts a `biotools_id` that matches its broad character pattern, and the default `reports.tags` lets `_reported_identifier` pass it into `tool_identifier`. A task creator can therefore put a personal handle or other chosen text in a task tag and have it appear in reports returned to admins, despite the reports’ no-personal-data promise.
Verify tag values against a trusted identifier source before reporting them, or omit user-supplied tag values from reports that promise not to expose user text.
Also at `pro_tes/accounting/config.py:201`.
</issue_to_address>
### Comment 2
<location path="pro_tes/accounting/reports.py" line_range="182" />
<code_context>
+ """
+ if not isinstance(identifier, str):
+ return False
+ if identifier.startswith(IMAGE_IRI.format("")):
+ return True
+ return identifier_tag(identifier) in config.tags
</code_context>
<issue_to_address>
**Untrusted identifiers appear in reports**
When a usage record contains a prefixed identifier that is malformed or does not match the trusted tool repository, `_reported_identifier` accepts the identifier without validating it against the trusted tool data, and `_reports` emits it as `tool_identifier`, so users see the untrusted text in reports.
Validate the complete identifier against the trusted tool data, including requiring Docker identifiers to match the recorded tool repository.
Also at `pro_tes/accounting/tool.py:61`, `pro_tes/accounting/reports.py:183-184`.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: pro_tes/accounting/reports.py:184, pro_tes/accounting/reports.py:182
# Conflicts: # docs/upgrading.md
Closes #520
Summary
Found by the pre-release review of 0.7.0 (security): execution reports could carry text chosen by the user, against the promise that they hold no user identifiers.
quay.io/biocontainers/samtools:john.doe@sha256:<real digest>therefore completes, in a trusted namespace, and its tag went intoGET /usage/reportsastool_version. Now a reference with a digest gives no version and no package version (pro_tes/accounting/tool.py).custom.accounting.reports.tags(default[biotools_id, rrid], the only known tag names; others are invalid at startup;[]reports only the image repository). It applies when reports are requested, also to tasks recorded before. Reports keep only the identifier of the image (docker://…) and identifiers of listed tags; any other recorded identifier (other IRI forms, no strings) is dropped, and a record left without any reported identifier gives no reports (the format requires one).docs/configuration.md(example and key),docs/api.md(tool_version,tool_package_version,tool_identifier, the note on tags),docs/upgrading.md, the OpenAPI description oftool_identifier, and the docstring ofpro_tes/accounting/reports.py, which no longer claims more than the code guarantees (tag values are user-chosen and only checked against their patterns).usageand its indexes are created with accounting off).devmerged in (ci: add a dry-run mode to the release workflow #513).Execution reports are unreleased (0.7.0), so no released data is affected.
How it was verified
test_tool.pyfor digests; the allow-list cases andtest_config_tagsintest_reports.py;test_reports_unknown_identifiersbefore the fail-closed filter), and pass after; plustest_record_for_reports_digestand direct tests ofidentifier_tag.coverage run -m pytest -W ignore::DeprecationWarning(chart dependency built with Helm 3.22.1): 2238 passed, 11 skipped; coverage 100%.pre-commit runon the changed files (ruff, mypy, semgrep, ast-grep, secrets): passed.mkdocs build --strict: passed.tool_package_version, upgrade and configuration notes, record-level test, the API sentence on tags, fail-closed filter, no reports without identifiers, direct tests); round 2 found nothing above low.Scan image(see below).Unrelated failures
Scan imagefails on libzstd1 1.5.7+dfsg-1 of the base imageelixircloud/foca:0.22.0-py3.13(Debian 13.7), CVE-2026-124851, HIGH, fixed in 1.5.7+dfsg-1+deb13u1, published after the last green scan ofdev. Not fixed here: per the maintainer's decision (D-435), FOCA 0.23.0 is released and proTES migrates to it before 0.7.0. This PR stays a draft until then.Declined review findings
tagsare accepted (quality, low): harmless, the filter tests membership.config.pynow imports the tag names fromtool.py(quality, low): a one-way dependency, fine at this size.devbuilds before the digest fix keep their stored version (adversarial, low): unreleased feature, no deployment exports reports fromdev.biotools_idvalues reach reports (medium): the tag allow list is a maintainer decision (defaultbiotools_id,rrid); documented as pattern-checked only,tags: []turns it off.Open questions
None (the draft state is only for the base-image scan above).
🤖 Generated with Claude Code
https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Summary by Sourcery
Harden execution reports against user-controlled text while making reported task-tag identifiers explicitly configurable.
Bug Fixes:
Enhancements:
biotools_idandrridenabled by default, while retaining the image repository identifier.Documentation:
Tests: