Skip to content

Report dependency findings and malware in the scan summary - #213

Open
juangaitanv wants to merge 3 commits into
mainfrom
fix/scan-summary-sca-findings
Open

juangaitanv wants to merge 3 commits into
mainfrom
fix/scan-summary-sca-findings

Conversation

@juangaitanv

@juangaitanv juangaitanv commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The summary that corgea scan and corgea wait print at the end now includes the scan's dependency findings, and it calls out malicious packages:

1 finding in this scan: 0 open, 0 in other states, 1 in dependencies.
Malware: 1 malicious package in this scan's dependencies.

Open issues                   Critical  High  Medium  Low  Total
...
Dependencies, any status      Critical  High  Medium  Low  Total
----------------------------------------------------------------
Malicious packages                   1     0       0    0      1
Vulnerable packages                  0     0       0    0      0
----------------------------------------------------------------
Total dependencies                   1     0       0    0      1

Code findings by status       Critical  High  Medium  Low  Total
...

--format agent gains dependency rows for malicious and vulnerable packages. --format json gains a dependencies object. The table that was titled "All findings by status" is now "Code findings by status", because it still counts code findings only.

Why

The summary read only code issues. A project whose lockfiles pin known malware printed 0 findings and looked clean, while the scan page listed the malicious packages. We hit this with four test projects whose lockfiles pin OSV MAL- packages (for example flatmap-stream 0.1.1 and rustdecimal 1.23.1). The server flagged all 9 pins as malicious, and every CLI summary said 0 findings.

Invariants

  • The CLI reads dependency findings once per run. The summary, the --fail-on malicious gate and the --out-format json report all use that read. Before, the gate and the report each fetched separately.
  • A failed dependency read never shows as zero. The summary prints dependencies not fetched and the error, the agent format writes a dependency_error record, and the JSON sets dependencies.error with null counts. The code issues still print.
  • --fail-on and --block-on exit codes don't change. The gate and the report still exit on a failed dependency read, as before.

What can go wrong

  • Extra requests. Every scan and wait now pages through all dependency findings, 30 per page. A scan with thousands of dependency findings adds that many requests divided by 30. Not measured.
  • Counts differ from the scan page. The dependency endpoint doesn't return a finding's status, so the CLI counts dependency findings in every status, and the table title says "any status". The scan page counts open ones only, so the numbers differ once a dependency finding is triaged.
  • Severity. A dependency finding with a missing or unknown severity counts as unrated. It appears in the totals but in no severity column, so a malicious package with no severity still shows up.

Compatibility

  • total_findings in --format json now includes dependency findings, and schema_version stays 1. A consumer that expects code findings only will see a larger number.
  • The human output renames "All findings by status" to "Code findings by status". A script that matches that string has to change.
  • No server change is needed: the CLI already used the dependency endpoint for --fail-on malicious.

Validation

  • The new e2e test in tests/cloud_commands_e2e/scan_list.rs (malware shows with no gate) failed on main with remaining: ["read SCA issues"] and passes on this branch.

  • Another e2e test fails if the run fetches dependency findings more than once (unexpected extra request).

  • corgea wait for the malware-demo-node-shop scan, run in a terminal against a local stub API. The stub serves the scan's dependency findings: 3 malicious npm packages and 3 vulnerable ones. Same command and data, main (e8cf18c) vs this branch (cbd78b0):

    Before:

    summary before

    After:

    summary after

  • Not run against a real instance. The stub's dependency response shape comes from doghouse's _map_package_issue.

The scan and wait summary read only code issues, so a scan whose
lockfiles pin malicious packages printed "0 findings in this scan" and
an all-zero table. Only --fail-on malicious and the --out-format json
report read the scan's dependency findings.

ScanIssues::fetch now reads the dependency findings next to the code
issues, once per run. The summary, the --fail-on malicious gate and the
JSON report share that read. Before, the gate and the report each read
them again when both flags were set.

The summary counts dependency findings in every status, because the
dependency endpoint does not report a status:

- human: the findings line adds "N in dependencies", a "Malware:" line
  counts malicious packages, and a "Dependencies, any status" table
  splits malicious and vulnerable packages by severity. The by-status
  table is now titled "Code findings by status".
- agent: dependency rows for malicious and vulnerable packages.
- json: a dependencies object; total_findings includes them.

A failed dependency read prints "dependencies not fetched" and the
error, a dependency_error record, or dependencies.error with null
counts. It never reads as zero. Findings with no severity count in the
total as unrated, so a malicious package without a score still shows.
Comment thread src/scanners/summary.rs Resolved
Comment thread src/scanners/blast.rs Resolved
Comment thread src/scanners/summary.rs Resolved
Comment thread src/scanners/summary.rs Resolved
@corgea-security corgea-security added the dennis-reviewed Dennis completed an automated review label Nov 27, 2026

@corgea-security corgea-security 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.

Automated review risk: 2/5.

Dependency findings are fetched once and shared across the summary, --fail-on malicious gate, and JSON report. Failed reads stay distinct from zero in the dependency section, and the new unit and e2e coverage matches that behavior. No critical or high defect is visible in the diff. Two non-blocking contract and copy issues are worth cleaning up.

No critical or high-priority changes were found.

@corgea-security corgea-security 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.

Approved by Dennis: high policy risk and automated risk 2/5.

Comment thread src/scanners/summary.rs Resolved
Comment thread src/scanners/summary.rs Resolved
A failed dependency read made total_findings count code findings only, so
a malware-only scan could read as clean. Bump the JSON schema_version to 2
for the changed total_findings meaning, and fix the unrated note's grammar.
@juangaitanv

Copy link
Copy Markdown
Contributor Author

Addressed the review in d0d5e62. When the dependency read fails, total_findings is now null. JSON schema_version is now 2. The unrated note has singular and plural forms. Two threads needed no change: the classification rule (Doghouse leaves classification null for ordinary vulnerabilities) and gate error handling (a failed read is already reported in every format). Each thread has the details.

Comment thread src/scanners/summary.rs Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dennis-reviewed Dennis completed an automated review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants