Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60140,7 +60140,7 @@ const XML_PATTERNS = [
{
id: 'xml-comment-close',
description: '--> closes an enclosing XML comment',
pattern: /-->/,
pattern: /--!?>/,
},
{
id: 'xml-pi-close',
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91195,7 +91195,7 @@ const XML_PATTERNS = [
{
id: 'xml-comment-close',
description: '--> closes an enclosing XML comment',
pattern: /-->/,
pattern: /--!?>/,
},
{
id: 'xml-pi-close',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=24.0.0"
},
"scripts": {
"build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
"build": "node scripts/patch-is-unsafe.mjs && ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
"format": "prettier --no-error-on-unmatched-pattern --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint \"**/*.ts\"",
Expand Down
20 changes: 20 additions & 0 deletions scripts/patch-is-unsafe.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {readFile, writeFile} from 'node:fs/promises';

const sourcePath = new URL('../node_modules/is-unsafe/src/contexts/xml.js', import.meta.url);
const vulnerablePattern = 'pattern: /-->/,';
const safePattern = 'pattern: /--!?>/,';
const source = await readFile(sourcePath, 'utf8');

// CodeQL treats this XML detector as an incomplete HTML comment-end filter.
if (source.includes(safePattern)) {
process.exit(0);
}

const occurrences = source.split(vulnerablePattern).length - 1;
if (occurrences !== 1) {
throw new Error(
`Expected one ${JSON.stringify(vulnerablePattern)} in ${sourcePath.pathname}, found ${occurrences}`
);
}

await writeFile(sourcePath, source.replace(vulnerablePattern, safePattern));
Comment on lines +8 to +20
Loading