fix: use detected version for CVE lookup filtering - #29
Merged
Conversation
- Improve AffectedProduct.matches_version() to support version ranges (versionStartIncluding/versionEndExcluding) using packaging.version - Pass detected version to CVE aggregator in _lookup_cves() - Add _cve_affects_version() to filter CVEs by detected version - Add deduplication of CVE entries across technologies - Add packaging dependency for semantic version comparison Previously, fingerprinting detected 'jQuery 3.6.0' but CVE lookup searched for 'jQuery' generically, returning all CVEs regardless of version. Now CVEs are filtered to only those affecting the detected version.
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.
Description
Fix CVE lookup to use the detected technology version instead of searching generically by product name only.
Problem
Previously, when fingerprinting detected a technology like
jQuery 3.6.0, the CVE lookup would search forjQuerywithout the version, returning all CVEs for that product regardless of whether they affected the detected version. This caused noise and false positives.Changes
1.
AffectedProduct.matches_version()— Version range supportsrc/ciberwebscan/core/analyzers/cve/models.pypackaging.version.Versionfor semantic version comparisonversionStartIncludingandversionEndExcludingfrom CPE configurations2.
_lookup_cves()— Version-aware filteringsrc/ciberwebscan/services/analyze_service.pytech.versionto the CVE aggregator_cve_affects_version()to post-filter CVEs by detected version3. Dependency
pyproject.tomlpackaging>=21.0for semantic version parsingFlow
BEFORE: 'jQuery 3.6.0' → searches 'jQuery' → returns ALL CVEs (noise)
AFTER: 'jQuery 3.6.0' → searches 'jQuery' + '3.6.0' → filters → only relevant CVEs
API Compatibility
All three CVE sources are supported:
_cve_affects_version()Testing
Breaking Changes
None. This is a backward-compatible improvement.