Skip to content

test(report): harden #464's report tests, and record the #457 slowdown - #465

Merged
sromoam merged 4 commits into
awslabs:fix/report-hardening-from-452from
digalaviz:test/464-extras
Oct 30, 2026
Merged

sromoam merged 4 commits into
awslabs:fix/report-hardening-from-452from
digalaviz:test/464-extras

Conversation

@digalaviz

Copy link
Copy Markdown
Contributor

@sromoam, this has the parts of the #452 recut that #464 doesn't cover yet. I've opened it as a PR
against your branch rather than pushing onto it, so you can take or drop each commit. It's tests
and one CHANGELOG entry; nothing under src/ changes.
test_html_reporter.py is untouched, and the
only existing test it edits is the truncation test in test_section_generator.py, which predates #464. The
recut's code and #464's do the same thing: the recut's tests pass unchanged against #464's
getDocument call and doc_id loader.

  • 6af633f test(report): pin the PDF viewer's only loader call, its reachability and its
    pdf.js.
    Adds test_pdf_viewer.py with three tests, which sit next to
    test_the_pdf_viewer_disables_eval:
    • The page has exactly one pdfjsLib.getDocument(...) call, and that call disables eval.
    • The viewer isn't embedded without individual_results_jsonl_path.
    • The pdf.js <script> tag still loads 3.11.174 and has no integrity hash. When the upgrade
      lands, the failure messages say to invert the integrity assertion, not delete it.
  • 0b694bd test(report): cover the doc_id conversion's edge cases. Nine tests on
    _load_individual_results:
    • Zero, float and NaN ids become strings.
    • A string id, None and a missing key are left as they are.
    • A line that isn't an object doesn't drop the records after it.
    • Ids that differ only by type now map to the same string.
    • Every id generate_report embeds is a string, including one above 2**53.
  • c24055c test(report): let the truncation test catch escape-then-truncate on the
    prediction.
    The fixture gave prediction_value the value 'short', so only one column could
    tell the two orders apart. Now both can.
  • 9fd99e2 docs(changelog): record the report-generation slowdown tracked in perf(report): _json_for_script is ~10x slower than json.dumps since 1.0.1 #457. This is the
    line you asked for on release(v1.0.1): escape document values and field names, mitigate CVE-2024-4367 #452, which fix(report): carry the #452 report hardening onto dev, and mitigate CVE-2024-4367 #464's CHANGELOG doesn't have yet. It's under
    [Unreleased] → ### Performance, following the [1.0.0] precedent, and is scoped to
    individual_results_jsonl_path using perf(report): _json_for_script is ~10x slower than json.dumps since 1.0.1 #457's figures.

What the tests add. None of these is a bug in #464; your code passes all of them. They're
mistakes a future edit could make that the existing tests would let through. I applied each one to
#464's head in a scratch copy and ran tests/reporting/html twice: once with #464's tests only, and
once with these added.

Possible future change to #464's code #464's tests With this PR
A second loader, pdfjsLib.getDocument(u) pass fail
A second loader, pdfjsLib.getDocument( url ) pass fail
doc_id: the dict guard dropped pass fail
doc_id: None converted too pass fail
doc_id: tested for truthiness, so 0 stays a number pass fail
doc_id: only int converted pass fail
Non-matches prediction escaped before truncating pass fail

A comment that mentions pdfjsLib.getDocument() doesn't trip the count.

Full suite on this branch after a plain uv sync --frozen, with stickler imported from it:
3986 passed, 13 skipped, 1 xfailed. #464 reports 3974 passed; the 12 extra are the tests added
here. ruff check src tests, docs/check_links.py and uv lock --check are clean.

None of these tests runs a browser. The browser-level result is still vawsgit's headless-Chrome
measurement from #452.

… and its pdf.js

Three tests in a new test_pdf_viewer.py, alongside the existing
test_the_pdf_viewer_disables_eval:

- the page has exactly one pdfjsLib.getDocument(...) call and it carries
  isEvalSupported: false. A check for the safe form alone still passes when a
  second loader is added without the option, e.g. getDocument(u);
- the viewer is not embedded without individual_results_jsonl_path;
- the pdf.js <script> tag still loads 3.11.174 and has no integrity hash, so
  the upgrade is a deliberate change. Its failure messages say to invert the
  integrity assertion then, not delete it.
Nine tests on _load_individual_results: zero, float and NaN ids become
strings; a string id, None and a missing key are left alone; a line that is
not an object does not drop the records after it; ids that differ only by type
now map to the same string; and every id embedded by generate_report is a
string, including one above 2**53. Several guard against a mis-fix rather
than the fix: dropping the dict guard, converting None, testing the id for
truthiness, or converting only int each pass the existing tests.
…he prediction

The fixture gave prediction_value the value 'short', so only the ground-truth
column could tell truncate-then-escape from escape-then-truncate. Both columns
now carry 97 characters and an ampersand, and both are asserted.
…labs#457

Reports generated with individual_results_jsonl_path take longer to write
since the script-block escaping: 467 ms against 42 ms at 1.0.0 for 1,000
documents, per awslabs#457. Evaluation results are unaffected.
@digalaviz
digalaviz requested a review from sromoam as a code owner October 29, 2026 21:28
@digalaviz digalaviz changed the title test(report): harden #464's report tests, and record the #457 slowdown test(report): harden #464's report tests, and record the #457 slowdown Oct 29, 2026
@github-actions

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-10-29T21:47:45+00:00
  • Time since scan: 3 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-10-29T21:44:05+00:00
  • ASH version: 3.1.2

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

  • Severity levels:
    • Suppressed (S): Findings that have been explicitly suppressed and don't affect scanner status
    • Critical (C): Highest severity findings that require immediate attention
    • High (H): Serious findings that should be addressed soon
    • Medium (M): Moderate risk findings
    • Low (L): Lower risk findings
    • Info (I): Informational findings with minimal risk
  • Duration (Time): Time taken by the scanner to complete its execution
  • Actionable: Number of findings at or above the threshold severity level that require attention
  • Result:
    • PASSED = No findings at or above threshold
    • FAILED = Findings at or above threshold
    • MISSING = Required dependencies not available
    • SKIPPED = Scanner explicitly disabled
    • ERROR = Scanner execution error
  • Threshold: The minimum severity level that will cause a scanner to fail
    • Thresholds: ALL, LOW, MEDIUM, HIGH, CRITICAL
    • Source: Values in parentheses indicate where the threshold is set:
      • global (global_settings section in the ASH_CONFIG used)
      • config (scanner config section in the ASH_CONFIG used)
      • scanner (default configuration in the plugin, if explicitly set)
  • Statistics calculation:
    • All statistics are calculated from the final aggregated SARIF report
    • Suppressed findings are counted separately and do not contribute to actionable findings
    • Scanner status is determined by comparing actionable findings to the threshold
Scanner Suppressed Critical High Medium Low Info Actionable Result Threshold
bandit 0 4 0 0 6475 0 4 FAILED MEDIUM (global)
cdk-nag 0 0 0 0 0 0 0 PASSED MEDIUM (global)
cfn-nag 0 0 0 0 0 0 0 MISSING MEDIUM (global)
checkov 0 0 0 0 0 0 0 PASSED MEDIUM (global)
detect-secrets 0 1 0 0 0 0 1 SKIPPED MEDIUM (global)
grype 0 0 0 0 0 0 0 MISSING MEDIUM (global)
npm-audit 0 0 0 0 0 0 0 PASSED MEDIUM (global)
opengrep 0 0 0 0 0 0 0 MISSING MEDIUM (global)
semgrep 3 0 0 0 0 0 0 PASSED MEDIUM (global)
syft 0 0 0 0 0 0 0 MISSING MEDIUM (global)

Top 3 Hotspots

Files with the highest number of security findings:

Finding Count File Location
2 tests/comparators/test_anls_leaf_semantics.py
2 tests/structured_object_evaluator/test_rollup_node_semantics.py
1 tests/test_readme_examples.py

Detailed Findings

Show 5 actionable findings

Finding 1: SECRET-HEX-HIGH-ENTROPY-STRING

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-HEX-HIGH-ENTROPY-STRING
  • Location: tests/comparators/test_anls_leaf_semantics.py:89

Description:
Secret of type 'Hex High Entropy String' detected in file 'tests/comparators/test_anls_leaf_semantics.py' at line 89

Code Snippet:

Secret of type Hex High Entropy String detected

Finding 2: B108

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B108
  • Location: tests/comparators/test_anls_leaf_semantics.py:210-212

Description:
Probable insecure usage of temp file/directory.

Code Snippet:

uuid.UUID(int=1),
            pathlib.Path("/tmp/x"),
            b"bytes",

Finding 3: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1363-1369

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

def published_label(node: dict, section: str, object_lists: set) -> str:
            counts_objects = eval(  # noqa: S307
                cond.group(1),
                {},
                {"data": node, "section": section, "OBJECT_LISTS": object_lists},
            )
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Finding 4: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1368-1370

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

)
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Finding 5: B102

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B102
  • Location: tests/test_readme_examples.py:55-57

Description:
Use of exec detected.

Code Snippet:

with contextlib.redirect_stdout(out):
        exec(code, namespace)
    prints = [line for line in code.splitlines() if line.startswith("print(")]

Report generated by Automated Security Helper (ASH) at 2026-10-29T21:47:47+00:00

@sromoam
sromoam merged commit 01f6fff into awslabs:fix/report-hardening-from-452 Oct 30, 2026
9 checks passed
@digalaviz
digalaviz deleted the test/464-extras branch November 8, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants