Skip to content

fix(report): escape the executive summary's document count - #466

Merged
sromoam merged 1 commit into
awslabs:devfrom
digalaviz:fix/document-count-escape
Oct 30, 2026
Merged

sromoam merged 1 commit into
awslabs:devfrom
digalaviz:fix/document-count-escape

Conversation

@digalaviz

Copy link
Copy Markdown
Contributor

Issue Reference

Related: #453

Description of Changes

The Executive Summary's Documents card interpolated document_count into the page without
escaping. ProcessEvaluation validates the field as an int at construction, but not on
assignment or through model_construct, so a caller that sets it either way could put markup into
the report. Document data does not reach it: the bulk evaluator sets an int, and a results dict
falls back to 1.

It has the same in-process-caller reachability as #453. #456 covers the :.3f / :.1f cells in
visualization_engine.py; this card is in section_generator.py and is not among them.

Changes Made

  • section_generator.py: the card renders html.escape(str(doc_count)). None, int and
    float values render as before.
  • test_section_generator.py: a real ProcessEvaluation with markup assigned after construction;
    the test asserts the escaped cell and the absence of the raw markup.

Testing

  • Unit tests added/updated. The new test fails against dev and passes with the change.
  • All existing tests pass: 4002 passed, 13 skipped, 1 xfailed.

Checklist

  • CHANGELOG.md entry added under [Unreleased] ### Fixed. It is not under ### Security:
    document data does not reach this value.
  • Tests added/updated for new functionality

This does not touch the card's count behaviour raised as Q1 on #452.

The Documents card interpolated document_count into the page unescaped.
ProcessEvaluation validates the field as an int at construction, but not on
assignment or through model_construct, so a caller that assigns it, or builds
the model with model_construct, could put markup into the report. Document
data does not reach it: the bulk evaluator sets an int, and a results dict
falls back to 1.

The value now goes through html.escape like the other cells, and a test
assigns markup after construction and asserts it is escaped. It has the same
in-process-caller reachability as awslabs#453; awslabs#456 escapes the visualization_engine.py
cells, not this one.
@digalaviz
digalaviz requested a review from sromoam as a code owner October 30, 2026 03:20
@github-actions

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-10-30T03:24:24+00:00
  • Time since scan: 3 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-10-30T03:20:52+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 6486 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-30T03:24:26+00:00

@sromoam sromoam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @digalaviz, approving: the escape is right and the test fails without it. Two older bugs in the same function are filed as #467: the colour branch checks for viz_engine._get_performance_color, which doesn't exist, so every float card renders blue and color_thresholds is ignored; and the document count reads 1 for a results dict and "None" for a default ProcessEvaluation (Q1 on #452). Nit: the CHANGELOG entry could link #466.

@sromoam
sromoam merged commit 1619dd2 into awslabs:dev Oct 30, 2026
10 checks passed
@digalaviz
digalaviz deleted the fix/document-count-escape 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