fix: improve CDN URL normalization and version extraction - #31
Merged
Conversation
- Add @ separator to regex character class for npm-style CDN URLs
(jsDelivr, unpkg) like jquery@3.6.0
- Expand CDN detection from 2 to 9 providers (jsDelivr, unpkg,
BootstrapCDN, Fastly, jQuery CDN, Microsoft CDN, bootcdn, staticfile)
- Add _parse_cdn_url() for structured CDN URL parsing by hostname
and path patterns (/ajax/libs/{lib}/{ver}/, /npm/{lib}@{ver}/)
- Replace if/if CDN detection with dict-based CDN_HOSTNAMES lookup
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 CDN-hosted library version extraction that was failing for npm-style URLs and expand CDN provider coverage from 2 to 9.
Problem
The fingerprinter detected CDN-hosted libraries using regex patterns like
jquery[.-]([\d\.]+)?, but:@separator not handled: URLs likecdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.jsused@as version separator, but the regex only matched/and-. Version was silently dropped.cdnjs.cloudflare.comandajax.googleapis.comwere recognized. Popular CDNs like jsDelivr, unpkg, BootstrapCDN were ignored./ajax/libs/{lib}/{ver}/,/npm/{lib}@{ver}/) to extract library name + version reliably.Changes
1. Regex
@separatorsrc/ciberwebscan/core/analyzers/fingerprint/html_analyzer.py[\/-]?to[/@-]?in both script (line 234) and CSS (line 287) analysis loops2. CDN provider detection (2 → 9)
src/ciberwebscan/core/analyzers/fingerprint/html_analyzer.pyCDN_HOSTNAMESlookup3. Structured CDN URL parser
src/ciberwebscan/core/analyzers/fingerprint/html_analyzer.py_parse_cdn_url()function that extracts library + version from CDN URL patterns by hostname/ajax/libs/{lib}/{ver}/), jsDelivr (/npm/{lib}@{ver}/), unpkg (/{lib}@{ver}/)Examples