fix(references): ignore scoped npm package specs in plain relative paths - #532
rksharma-owg wants to merge 1 commit into
Conversation
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Reviewed current head e3a0827b75edae76e35600571fac46108afb251f. The scoped-package prose boundary is useful, but the unconditional @ rejection also removes explicit Markdown references to real inventoried local paths. That turns a false-positive fix into a fail-open completeness regression for otherwise out-of-scope artifacts. Preserve the prose exclusion while still resolving explicit, known @ paths and add the regression.
All required checks pass, but this correctness/security issue and mergeStateStatus=BEHIND block merging.
| raw = unquote(raw.strip().strip("<>")) | ||
| split = urlsplit(raw) | ||
| if split.scheme or split.netloc or raw.startswith(("/", "\\", "#")): | ||
| if split.scheme or split.netloc or raw.startswith(("/", "\\", "#", "@")): |
There was a problem hiding this comment.
[P1] Preserve explicit references to real @-prefixed paths
This unconditional return also rejects an explicit Markdown reference such as [payload](@scope/payload.bin) even when that exact path is present in known_paths. Those references previously resolved, and resolution is security-significant because a referenced nested/binary artifact may otherwise fall outside normal analysis scope and completeness accounting. Keep the scoped-npm plain-prose boundary, but allow explicit reference syntax to resolve a real inventoried @ path; add a regression for that case.
e3a0827 to
2b1d60b
Compare
|
Thanks for the review, @rng1995! Updated in commit
All 311 unit tests and formatting/lint checks pass locally. |
|
The intent works, In Measured against the previous pattern, these stop matching entirely: That is the same false-negative direction this PR is trying to remove, just on a different input. Putting |
2b1d60b to
68daad7
Compare
|
Good catch, @MohammedAlkindi — thanks! Updated in commit
All 312 tests pass locally. |
68daad7 to
d3237f6
Compare
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Re-reviewed current head d3237f6693679a6b53cf355fd1226c12d5d4907d against the prior requested change and subsequent feedback. The original fail-open regression is resolved: scoped npm packages are excluded only at the plain-prose regex boundary, while explicit Markdown references to inventoried @-prefixed paths still reach normalization and resolve as analyzed artifacts. The corrected character class keeps - literal, and the new punctuation regressions protect ordinary references followed by ;, ?, or > and HTML-attribute forms. I found no remaining required code, test, documentation, security, or compatibility changes.
All required checks are green. Merging is currently blocked by conflicts (mergeable=CONFLICTING, mergeStateStatus=DIRTY), and the outdated prior thread remains unresolved in GitHub even though the code concern is addressed. Rebase/conflict resolution will change the reviewed head and require another review.
Scoped npm package specs like `@xerg/cli@0.34.0` or `@types/node` in plain text or code spans were previously matched by `_PLAIN_RELATIVE_PATH` because `@` was not excluded by the negative lookbehind/lookahead. This caused unresolved reference ledger exceptions, rendering clean scans partial and raising recommendations to CAUTION. - Add `@` to `_PLAIN_RELATIVE_PATH` negative lookbehind and lookahead, placed after the hyphen to avoid creating an unintended character range (.-@). - Ensure explicit Markdown references to real inventoried local paths (including `@` prefixed paths) continue to normalize and resolve. - Add regression tests covering scoped npm package prose exclusion, explicit known `@` path resolution, and paths followed by common punctuation. Fixes NVIDIA#528 Signed-off-by: RKS <rajesh.sharma@owasp.org>
d3237f6 to
7919dec
Compare
|
Rebased onto latest |
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Re-reviewed current head 7919dec63adfa15a46ca6f67757a2c0b9f0dec4b against the prior requested change, the rebased one-commit diff, surrounding reference-resolution behavior, the unresolved outdated thread, and exact-head checks.
The original fail-open regression remains resolved: the scoped-package exclusion is confined to plain-prose matching, while explicit Markdown references to inventoried @-prefixed paths still reach normalization and resolve. The punctuation boundary remains correct, and focused regressions cover both behaviors. I found no remaining required code, test, documentation, security, or compatibility changes.
All six exact-head checks pass. GitHub still reports BLOCKED, and the outdated prior thread remains unresolved even though its code concern is addressed; those are merge-gate concerns rather than code-review blockers.
Priority: P1 — reference completeness affects nested-artifact inspection, but this is a narrow false-positive correction.
Problem
Scoped npm package specifications (such as
@xerg/cli@0.34.0,@types/node,@modelcontextprotocol/server-filesystem) in skill documentation or commands are misclassified as unresolved local relative paths. This produces areference_unresolvedledger exception and marks an otherwise clean scan as partial (analysis_completeness.is_complete = false), which downgrades the risk recommendation fromSAFEtoCAUTION.Root Cause
_PLAIN_RELATIVE_PATHinsrc/skillspector/references.pyused lookaround assertions(?<![\w:/.-])and(?![\w/.-]). Because@is neither a word character nor part of the character set, the pattern matched the inner path segment of scoped npm packages (for example,xerg/clifrom@xerg/cli@0.34.0)._normalize_candidatethen treated it as a relative local path, creating an unresolvable reference in the bundle.Solution
_PLAIN_RELATIVE_PATHnegative lookbehind and lookahead to include@((?<![\w:/.-@])and(?![\w/.-@])), preventing@-scoped packages and version-tagged tokens from being extracted as plain relative paths._normalize_candidateto reject candidates starting with@as unsupported references.tests/nodes/test_security_remediation.pytesting scoped npm package commands and specs, while confirming legitimate local relative file references continue to resolve correctly.Verification
uv run pytest tests/nodes/test_security_remediation.py -k "npm or reference" -v(11 passed)uv run pytest tests/nodes/test_security_remediation.py -q(310 passed)uv run ruff check src/ tests/(passed)uv run ruff format --check src/ tests/(passed)Signed-off-by)Fixes #528