Repository navigation
test: cover svg-active-content's encoding and unnamed-PI scanner branches - #1042
Merged
Merged
Conversation
…ches scripts/lib/svg-active-content.mjs held the only uncovered regions in the whole source tree (2431/2435 source regions) at lines 457, 465, 475 and 637. All four are reachable branches on attacker-facing detection paths: - L457: XML_DECLARATION_ENCODING's second capture group, which fires only for a single-quoted encoding= declaration. Every prior test used double quotes, so the spoofed-encoding detector had an untested input spelling. - L465: the 'empty' label used when encoding="" names no encoding at all. - L475/L637: the '(unnamed)' label for a target-less processing instruction. PROCESSING_INSTRUCTION stops its target capture at whitespace, so '<??>' and '<? ... ?>' both match with an empty target -- the shape that slips past a filter keyed on known PI names -- in both findActiveContent and stripOnce. Source-region coverage goes from 99.84% to 100.00% (2435/2435). Closes #1041 Signed-off-by: quality <quality@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This was referenced Oct 4, 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.
Test Improvement
scripts/lib/svg-active-content.mjs— the SVG active-content security scanner —held the only uncovered regions left in the whole source tree at
main900592b:
src files | 2431/2435 regions | 99.84%, with all four missingregions in this one file (lines
457 465 475 637).All four are reachable branches on attacker-facing detection paths, not dead
code. This PR adds three tests to
tests/svg-active-content.test.mjscoveringthem:
reads the declared encoding from a single-quoted declaration— L457,declaredEncoding[1] ?? declaredEncoding[2].XML_DECLARATION_ENCODINGcaptures
"..."in group 1 and'...'in group 2; every prior test spelledthe declaration with double quotes, so group 2 had never fired and the
spoofed-encoding detector had an entirely untested legal input spelling.
The test asserts
encoding='utf-16'produces the same finding and the samefail-closed
stripActiveContentthrow as the double-quoted form, and that asingle-quoted
UTF-8still passes — so the new spelling is no morepermissive than the old one.
names an empty declared encoding rather than printing a blank— L465,encoding || 'empty'.encoding=""is in neitherSAFE_ENCODINGSnorSINGLE_BYTE_ASCII_ENCODING, so the finding fires with theemptylabel.reports and removes a processing instruction with no target— L475 andL637,
target || '(unnamed)'infindActiveContentandstripOnce.PROCESSING_INSTRUCTIONis/<\?([^\s?>]*)[\s\S]*?\?>/g, and because thetarget class excludes whitespace both
<??>and<? type="text/xsl" ?>match with an empty target — precisely the shape that slips past a
filter keyed on known PI names. The test drives both inputs through
detection and strip, asserts the
<?(unnamed)?>label on each side, andasserts the stripped source is clean.
No production code is changed — tests only.
Verification
TZ=UTC node --test tests/svg-active-content.test.mjs→ 77 pass, 0 fail(node v26.10.0).
npm run test:unit:coverage:check→ exit 0, andscripts/lib/svg-active-content.mjsgoes from100.00 | 97.67to100.00 | 100.00.npx prettier --check tests/svg-active-content.test.mjs→ clean.Scope
Touches exactly one file,
tests/svg-active-content.test.mjs. Disjoint fromevery open hold-gated PR: #1039 is
scripts/lib/mdx-active-content.mjs+tests/mdx-active-content.test.mjs(a different module), #1034 is the e2edata-variant fixtures, and #1040 is the e2e coverage reporter/runner tooling.
No overlap in files, functions, or tracker cluster.
Related Issue
Closes #1041
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88