Skip to content

fix(accounting): limit user text in reports - #516

Merged
uniqueg merged 8 commits into
devfrom
fix/ter-digest-tag
Nov 26, 2026
Merged

uniqueg merged 8 commits into
devfrom
fix/ter-digest-tag

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

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.

  • Unchecked tags of digests: container runtimes pull an image reference with a digest by that digest and ignore its tag. A task with, e.g., quay.io/biocontainers/samtools:john.doe@sha256:<real digest> therefore completes, in a trusted namespace, and its tag went into GET /usage/reports as tool_version. Now a reference with a digest gives no version and no package version (pro_tes/accounting/tool.py).
  • Identifiers from task tags only for listed tags (decision D-434: "execution reports export identifiers from task tags only for tag names on a configured allow list; the default list holds biotools_id and rrid"): new setting 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: 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 of tool_identifier, and the docstring of pro_tes/accounting/reports.py, which no longer claims more than the code guarantees (tag values are user-chosen and only checked against their patterns).
  • Docs: the upgrade note on accounting (feat: account resource usage per user #459, feat: account resource usage per user #490) was in "To version 0.6.0", but accounting is new in 0.7.0: moved to "To version 0.7.0" (it also says that the collection usage and its indexes are created with accounting off).
  • dev merged 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-driven: the new tests failed before each change (3 in test_tool.py for digests; the allow-list cases and test_config_tags in test_reports.py; test_reports_unknown_identifiers before the fail-closed filter), and pass after; plus test_record_for_reports_digest and direct tests of identifier_tag.
  • coverage run -m pytest -W ignore::DeprecationWarning (chart dependency built with Helm 3.22.1): 2238 passed, 11 skipped; coverage 100%.
  • pre-commit run on the changed files (ruff, mypy, semgrep, ast-grep, secrets): passed. mkdocs build --strict: passed.
  • Reviews: adversarial and quality, two rounds per change; findings fixed (docs of 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.
  • CI: all jobs pass except Scan image (see below).

Unrelated failures

  • Scan image fails on libzstd1 1.5.7+dfsg-1 of the base image elixircloud/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 of dev. 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

  • Duplicate tag names in tags are accepted (quality, low): harmless, the filter tests membership.
  • config.py now imports the tag names from tool.py (quality, low): a one-way dependency, fine at this size.
  • Records written by dev builds before the digest fix keep their stored version (adversarial, low): unreleased feature, no deployment exports reports from dev.
  • Ragged line wrapping in two reflowed doc paragraphs (quality, low): formatting only.
  • Sourcery: user-chosen biotools_id values reach reports (medium): the tag allow list is a maintainer decision (default biotools_id, rrid); documented as pattern-checked only, tags: [] turns it off.
  • Sourcery: identifiers in records are not re-validated when reports are read (medium): records are written by proTES only, with the checks at write time.

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:

  • Prevent execution reports from exposing user-controlled image tags by omitting versions and package versions for digest-based image references.
  • Restrict task-tag identifiers in execution reports to the configured allow list and omit reports that have no valid reportable identifier.

Enhancements:

  • Add configurable execution-report tag filtering with biotools_id and rrid enabled by default, while retaining the image repository identifier.
  • Update accounting, API, configuration, upgrade, and OpenAPI documentation to describe the tightened report contents and digest handling.

Documentation:

  • Document the execution-report tag allow list, digest behavior, identifier validation limits, and corrected accounting upgrade placement.

Tests:

  • Add coverage for digest-based image records, configurable tag identifiers, unknown identifiers, missing report identifiers, and identifier classification.

uniqueg and others added 2 commits November 25, 2026 10:24
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
@uniqueg uniqueg added the type: bug Something isn't working label Nov 25, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Define the recognized task-tag identifier types and distinguish their IRIs from the image repository identifier.

  • pro_tes/accounting/tool.py L38-63

Expose the report tag allow list in the execution-report configuration, defaulting to the two recognized tag names.

  • pro_tes/accounting/config.py L178-181 (+3 small edits)
  • pro_tes/config.yaml L434

API

Update the public OpenAPI description to clarify that task-tag identifiers are included only when their tag names are configured.

  • pro_tes/api/additions.openapi.yaml L287-288

Implementation

Omit image tags and package versions for digest references so unchecked text cannot enter reports, and construct the image identifier through the shared constant.

  • pro_tes/accounting/tool.py L6-9, L81-84 (+2 small edits)

Filter recorded tool identifiers to the image identifier and configured task-tag identifiers, and skip reports that would lack a required identifier.

  • pro_tes/accounting/reports.py L16-20, L166-186, L200-211 (+2 small edits)

Configuration

Add the configurable report tag allow list to the example configuration and explain its defaults, validation, and effect on reported identifiers.

  • docs/configuration.md L816-818, L871-874, L905-913

Documentation

Clarify report field behavior for digest images and configured tag identifiers, including that user-supplied tag values are only pattern-checked.

  • docs/api.md L255-257, L281-283

Move the accounting upgrade note to the version where accounting is introduced and update execution-report guidance for digest versions and configured tags.

  • docs/upgrading.md L119-131, L155-160, L333 (removed lines)

Tests

Verify that usage records never retain versions from image references supplied with a digest.

  • tests/accounting/test_record.py L160-183

Cover configured tag filtering, rejection of unknown identifiers, empty-identifier reports, and configuration validation.

  • tests/accounting/test_reports.py L172-176, L504-594 (+2 small edits)

Test digest-reference version suppression and classification of known identifier IRIs by task tag.

  • tests/accounting/test_tool.py L37-46, L157-171 (+2 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ceb0caa) to head (c98d560).
⚠️ Report is 1 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg uniqueg added this to the v0.7.0 milestone Nov 25, 2026
uniqueg added a commit that referenced this pull request Nov 25, 2026
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
uniqueg and others added 4 commits November 25, 2026 14:17
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
@uniqueg uniqueg changed the title fix(accounting): drop unchecked tags of digests fix(accounting): limit user text in reports Nov 25, 2026
@uniqueg
uniqueg marked this pull request as ready for review November 26, 2026 02:10
@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit c98d560

#520 fix: drop unchecked image tags from reports · 3 of 3 met

# Requirement Status Notes
1 Drop versions from image references that include a digest. ✅ Met Digest-qualified references set the tag to null before deriving either version field, so neither version nor package_version is recorded.
2 Document that biotools_id and rrid values are user-chosen and checked only against their patterns. ✅ Met The report docstring and documentation explain that the task creator chooses these values and that they are pattern-checked, not looked up.
3 Move the accounting upgrade note to version 0.7.0. ✅ Met The accounting note appears under “To version 0.7.0” and was removed from its prior location.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pro_tes/accounting/reports.py Resolved
Comment thread pro_tes/accounting/reports.py Resolved
@uniqueg
uniqueg merged commit 32c6ae2 into dev Nov 26, 2026
36 checks passed
@uniqueg
uniqueg deleted the fix/ter-digest-tag branch November 26, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: drop unchecked image tags from reports

1 participant