fix: render lockfile poisoning findings for non-http(s) resolved URLs#746
Merged
Conversation
The console and markdown reporters re-parse the analyzer's free-text lockfile poisoning messages via regex to aggregate findings by URL. The URL-extraction regex (lfpURLRe) only matched http(s) URLs, so any finding whose package resolved to a git+ssh, git+https, git, or ssh URL was silently dropped during aggregation. Because the "Lockfile Poisoning Detected" header gates on the raw (unaggregated) event count while the body iterates over the aggregated groups, a lockfile whose poisoning findings were all on non-http(s) URLs (common for git dependencies) rendered the header with an empty body. Relax lfpURLRe to match any URL scheme. The package name is the first backtick group and never contains "://", so the URL group is still matched unambiguously. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #746 +/- ##
==========================================
+ Coverage 12.41% 12.46% +0.04%
==========================================
Files 372 372
Lines 49231 49231
==========================================
+ Hits 6111 6135 +24
+ Misses 42634 42609 -25
- Partials 486 487 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
abhisek
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Users on v1.17.3 reported a
** Lockfile Poisoning Detectedsection with no findings under it — the header prints but the body is empty.Root cause
The console (
summary.go) and markdown (markdown_summary.go) reporters aggregate lockfile poisoning findings by re-parsing the analyzer's free-text messages with regex (aggregateLFPMessages). The URL-extraction regex only matched http(s):The npm analyzer legitimately flags packages resolving to any untrusted scheme — including
git+ssh://,git+https://,git://,ssh://(common for git dependencies). Those messages failed the regex and were silently dropped during aggregation (thecontinuein the loop).The section header gates on the raw event count (
len(r.lockfilePoisoning) > 0), while the body iterates over the aggregated groups. So a lockfile whose poisoning findings were all on non-http(s) URLs rendered the header with an empty body.This was introduced in v1.17.3 by
add61ab("consolidate lockfile poisoning output by URL"), which added the reporter-side string re-parsing. Before that, the reporter printed each raw message directly, so all schemes always showed.Fix
Relax
lfpURLReto match any URL scheme ([a-zA-Z][a-zA-Z0-9+.-]*://). The package name is the first backtick group and never contains://, so the URL group is still matched unambiguously.Testing
Added
pkg/reporter/lfp_aggregation_test.gowith regression coverage forgit+ssh,git+https,git, andsshschemes, plus existing http(s) and path-convention cases.Verified end-to-end on a lockfile mixing all schemes:
Before: only
http://andhttps://packages shown; the three git-based deps dropped.After: all five untrusted URLs render; trusted
registry.npmjs.orgcorrectly not flagged.🤖 Generated with Claude Code