@stll/oxlint-plugin 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun-test-hygiene.cjs +401 -0
- package/dist/bun-test-hygiene.cjs.map +1 -0
- package/dist/bun-test-hygiene.d.cts +4 -0
- package/dist/bun-test-hygiene.d.mts +5 -0
- package/dist/bun-test-hygiene.mjs +397 -0
- package/dist/bun-test-hygiene.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/dist/no-unsafe-inner-html.cjs +181 -44
- package/dist/no-unsafe-inner-html.cjs.map +1 -1
- package/dist/no-unsafe-inner-html.d.cts +18 -1
- package/dist/no-unsafe-inner-html.d.mts +18 -1
- package/dist/no-unsafe-inner-html.mjs +180 -46
- package/dist/no-unsafe-inner-html.mjs.map +1 -1
- package/dist/require-loader-prefetch.mjs +1 -1
- package/dist/utils.cjs +76 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +71 -4
- package/dist/utils.mjs.map +1 -1
- package/package.json +12 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isAstNode, c as memberPropertyName, d as
|
|
1
|
+
import { a as isAstNode, c as memberPropertyName, d as staticStringValue, f as unwrapExpression, i as invokedCallee, o as isIdentifier, r as getPropertyName, s as isStringLiteral, u as resolveLiteralArraySpreads } from "./utils.mjs";
|
|
2
2
|
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
3
3
|
//#region src/no-unsafe-inner-html.ts
|
|
4
4
|
const DOM_ELEMENT_PRODUCERS = [
|
|
@@ -87,6 +87,11 @@ const DOM_ELEMENT_PRODUCERS = [
|
|
|
87
87
|
kind: "collection",
|
|
88
88
|
receiver: "either"
|
|
89
89
|
},
|
|
90
|
+
{
|
|
91
|
+
name: "children",
|
|
92
|
+
kind: "collection-property",
|
|
93
|
+
receiver: "element"
|
|
94
|
+
},
|
|
90
95
|
{
|
|
91
96
|
name: "parentElement",
|
|
92
97
|
kind: "property",
|
|
@@ -148,11 +153,28 @@ const HTML_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
148
153
|
]);
|
|
149
154
|
const HTML_FIRST_ARGUMENT_METHODS = /* @__PURE__ */ new Set(["createContextualFragment", "setHTMLUnsafe"]);
|
|
150
155
|
const DOCUMENT_WRITE_METHODS = /* @__PURE__ */ new Set(["write", "writeln"]);
|
|
156
|
+
const HTML_ATTRIBUTE_SINKS = [{
|
|
157
|
+
name: "setAttribute",
|
|
158
|
+
namespaceIndex: null,
|
|
159
|
+
nameIndex: 0,
|
|
160
|
+
valueIndex: 1
|
|
161
|
+
}, {
|
|
162
|
+
name: "setAttributeNS",
|
|
163
|
+
namespaceIndex: 0,
|
|
164
|
+
nameIndex: 1,
|
|
165
|
+
valueIndex: 2
|
|
166
|
+
}];
|
|
151
167
|
const DOCUMENT_MEMBERS = /* @__PURE__ */ new Set([
|
|
152
168
|
"contentDocument",
|
|
153
169
|
"document",
|
|
154
170
|
"ownerDocument"
|
|
155
171
|
]);
|
|
172
|
+
const FILE_SYSTEM_MODULES = /* @__PURE__ */ new Set([
|
|
173
|
+
"fs",
|
|
174
|
+
"fs/promises",
|
|
175
|
+
"node:fs",
|
|
176
|
+
"node:fs/promises"
|
|
177
|
+
]);
|
|
156
178
|
const HTML_SANITIZER_LEAF_RE = /^(?:escape(?:html|xml)|sanitize(?:html|dom)|purify(?:html|dom)|dompurify)$/iu;
|
|
157
179
|
const SANITIZER_RESULT_MEMBERS = /* @__PURE__ */ new Set([
|
|
158
180
|
"value",
|
|
@@ -219,7 +241,15 @@ const isOpaqueProperty = (property) => property.type === "SpreadElement" || prop
|
|
|
219
241
|
const objectProperties = (node) => {
|
|
220
242
|
const expression = unwrapExpression(node);
|
|
221
243
|
if (expression?.type !== "ObjectExpression" || !Array.isArray(expression.properties)) return [];
|
|
222
|
-
|
|
244
|
+
const properties = [];
|
|
245
|
+
for (const property of expression.properties.filter(isAstNode)) {
|
|
246
|
+
if (property.type === "SpreadElement" && unwrapExpression(property.argument)?.type === "ObjectExpression") {
|
|
247
|
+
properties.push(...objectProperties(property.argument));
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
properties.push(property);
|
|
251
|
+
}
|
|
252
|
+
return properties;
|
|
223
253
|
};
|
|
224
254
|
const appliedArgumentsFor = (args) => {
|
|
225
255
|
const applied = unwrapExpression(args.at(1));
|
|
@@ -260,13 +290,6 @@ const invokedArguments = (call) => {
|
|
|
260
290
|
}
|
|
261
291
|
return appliedArgumentsFor(resolved.args);
|
|
262
292
|
};
|
|
263
|
-
const isDocumentReceiver = (node) => {
|
|
264
|
-
const receiver = unwrapExpression(node);
|
|
265
|
-
if (isIdentifier(receiver, "document")) return true;
|
|
266
|
-
if (receiver?.type !== "MemberExpression") return false;
|
|
267
|
-
const name = memberPropertyName(receiver);
|
|
268
|
-
return name !== null && DOCUMENT_MEMBERS.has(name);
|
|
269
|
-
};
|
|
270
293
|
var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
271
294
|
meta: { name: "no-unsafe-inner-html" },
|
|
272
295
|
rules: { "no-unsafe-inner-html": {
|
|
@@ -282,35 +305,133 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
282
305
|
}],
|
|
283
306
|
messages: {
|
|
284
307
|
unsafeInnerHtml: "Dynamic HTML injected into the DOM must be static, proven by the configured sanitizer policy, or have an adjacent `// safe-html: <provenance>` comment naming the trusted source. Function names outside the allowlist are not proof because a local identity function can shadow them.",
|
|
285
|
-
unsafeInnerHtmlSpread: "Do not spread an object
|
|
308
|
+
unsafeInnerHtmlSpread: "Do not spread an object in dangerouslySetInnerHTML. Keep `__html` inline so this rule can prove the HTML value is sanitized or escaped.",
|
|
309
|
+
unsafeInnerHtmlComputedKey: "Do not use an unresolved computed key in dangerouslySetInnerHTML. Write an explicit `__html` property so this rule can prove the HTML value is sanitized or escaped."
|
|
286
310
|
}
|
|
287
311
|
},
|
|
288
312
|
createOnce(context) {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
313
|
+
const resolveStableBinding = ({ node, scope, seen }) => {
|
|
314
|
+
let target = unwrapExpression(node);
|
|
315
|
+
while (isIdentifier(target)) {
|
|
292
316
|
let current = scope;
|
|
317
|
+
let variable;
|
|
293
318
|
while (current !== null) {
|
|
294
|
-
|
|
295
|
-
if (variable
|
|
296
|
-
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
if (variable.defs.length === 0) return kind === "element" && isDocumentReceiver(target);
|
|
300
|
-
if (seen.has(variable)) return false;
|
|
301
|
-
seen.add(variable);
|
|
302
|
-
const definition = variable.defs.at(0);
|
|
303
|
-
if (variable.defs.length !== 1 || definition?.type !== "Variable" || definition.node.type !== "VariableDeclarator" || definition.node.id.type !== "Identifier" || definition.node.init === null || variable.references.some((reference) => reference.isWrite() && !reference.init)) return false;
|
|
304
|
-
return isKnownDomTarget({
|
|
305
|
-
node: definition.node.init,
|
|
306
|
-
scope: context.sourceCode.getScope(definition.node),
|
|
307
|
-
seen,
|
|
308
|
-
kind
|
|
309
|
-
});
|
|
319
|
+
variable = current.set.get(target.name);
|
|
320
|
+
if (variable !== void 0) break;
|
|
321
|
+
current = current.upper;
|
|
310
322
|
}
|
|
323
|
+
if (variable === void 0 || variable.defs.length === 0) return {
|
|
324
|
+
kind: "expression",
|
|
325
|
+
node: target,
|
|
326
|
+
scope
|
|
327
|
+
};
|
|
328
|
+
if (seen.has(variable)) return null;
|
|
329
|
+
seen.add(variable);
|
|
330
|
+
const definition = variable.defs.at(0);
|
|
331
|
+
if (variable.defs.length !== 1 || definition?.type !== "Variable" || definition.node.type !== "VariableDeclarator" || definition.node.id.type !== "Identifier" || variable.references.some((reference) => reference.isWrite() && !reference.init)) return null;
|
|
332
|
+
const declarator = definition.node;
|
|
333
|
+
if (declarator.init !== null) {
|
|
334
|
+
target = unwrapExpression(declarator.init);
|
|
335
|
+
scope = context.sourceCode.getScope(declarator);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const declaration = declarator.parent;
|
|
339
|
+
if (declaration.type !== "VariableDeclaration") return null;
|
|
340
|
+
const loop = declaration.parent;
|
|
341
|
+
if (loop.type !== "ForOfStatement" || loop.left !== declaration) return null;
|
|
342
|
+
return {
|
|
343
|
+
kind: "iteration",
|
|
344
|
+
node: unwrapExpression(loop.right),
|
|
345
|
+
scope: context.sourceCode.getScope(loop.right)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
kind: "expression",
|
|
350
|
+
node: target,
|
|
351
|
+
scope
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
const isKnownNonEmptyNamespace = (namespace, scope) => {
|
|
355
|
+
const source = resolveStableBinding({
|
|
356
|
+
node: namespace,
|
|
357
|
+
scope,
|
|
358
|
+
seen: /* @__PURE__ */ new Set()
|
|
359
|
+
});
|
|
360
|
+
if (source?.kind !== "expression") return false;
|
|
361
|
+
const text = staticStringValue(source.node);
|
|
362
|
+
if (text !== null) return text !== "";
|
|
363
|
+
if (source.node?.type !== "Literal") return false;
|
|
364
|
+
const { value } = source.node;
|
|
365
|
+
return typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
|
|
366
|
+
};
|
|
367
|
+
const variableFor = (identifier, initialScope) => {
|
|
368
|
+
let current = initialScope;
|
|
369
|
+
while (current !== null) {
|
|
370
|
+
const variable = current.set.get(identifier.name);
|
|
371
|
+
if (variable !== void 0) return variable;
|
|
372
|
+
current = current.upper;
|
|
311
373
|
}
|
|
374
|
+
};
|
|
375
|
+
const isKnownNonDocumentReceiver = (node, scope) => {
|
|
376
|
+
const isUnshadowedGlobal = (identifier, name) => isIdentifier(identifier, name) && variableFor(identifier, scope) === void 0;
|
|
377
|
+
const isFileSystemImport = (identifier) => {
|
|
378
|
+
if (!isIdentifier(identifier)) return false;
|
|
379
|
+
const variable = variableFor(identifier, scope);
|
|
380
|
+
if (variable?.defs.length !== 1) return false;
|
|
381
|
+
const definition = variable.defs.at(0);
|
|
382
|
+
return definition?.type === "ImportBinding" && definition.parent?.type === "ImportDeclaration" && FILE_SYSTEM_MODULES.has(definition.parent.source.value);
|
|
383
|
+
};
|
|
384
|
+
const root = unwrapExpression(node);
|
|
385
|
+
if (isUnshadowedGlobal(root, "Bun") || isFileSystemImport(root)) return true;
|
|
386
|
+
return root?.type === "MemberExpression" && (memberPropertyName(root) === "stdout" || memberPropertyName(root) === "stderr") && isUnshadowedGlobal(unwrapExpression(root.object), "process");
|
|
387
|
+
};
|
|
388
|
+
const isDocumentReceiver = (node, scope) => {
|
|
389
|
+
if (isKnownNonDocumentReceiver(node, scope)) return false;
|
|
390
|
+
const source = resolveStableBinding({
|
|
391
|
+
node,
|
|
392
|
+
scope,
|
|
393
|
+
seen: /* @__PURE__ */ new Set()
|
|
394
|
+
});
|
|
395
|
+
if (source === null || source.kind !== "expression") return true;
|
|
396
|
+
const receiver = source.node;
|
|
397
|
+
if (isIdentifier(receiver, "document")) return true;
|
|
398
|
+
if (receiver?.type !== "MemberExpression") return false;
|
|
399
|
+
const name = memberPropertyName(receiver);
|
|
400
|
+
return name !== null && DOCUMENT_MEMBERS.has(name);
|
|
401
|
+
};
|
|
402
|
+
const isDocumentSinkReceiver = (node, scope) => {
|
|
403
|
+
if (isKnownNonDocumentReceiver(node, scope)) return false;
|
|
404
|
+
const receiver = unwrapExpression(node);
|
|
405
|
+
if (!isIdentifier(receiver)) return true;
|
|
406
|
+
let current = scope;
|
|
407
|
+
let variable;
|
|
408
|
+
while (current !== null) {
|
|
409
|
+
variable = current.set.get(receiver.name);
|
|
410
|
+
if (variable !== void 0) break;
|
|
411
|
+
current = current.upper;
|
|
412
|
+
}
|
|
413
|
+
if (variable === void 0 || variable.defs.length !== 1) return true;
|
|
414
|
+
const definition = variable.defs.at(0);
|
|
415
|
+
if (definition?.type !== "Variable" || definition.node.type !== "VariableDeclarator" || definition.node.id.type !== "Identifier" || definition.node.init === null || unwrapExpression(definition.node.init)?.type !== "ObjectExpression" || definition.node.parent.type !== "VariableDeclaration" || definition.node.parent.kind !== "const" || variable.scope.variableScope !== scope.variableScope || variable.references.some((reference) => reference.isWrite() && !reference.init)) return true;
|
|
416
|
+
return false;
|
|
417
|
+
};
|
|
418
|
+
const isKnownDomTarget = ({ node, scope, seen = /* @__PURE__ */ new Set(), kind = "element" }) => {
|
|
419
|
+
const source = resolveStableBinding({
|
|
420
|
+
node,
|
|
421
|
+
scope,
|
|
422
|
+
seen
|
|
423
|
+
});
|
|
424
|
+
if (source === null) return true;
|
|
425
|
+
if (source.kind === "iteration") return kind === "element" && isKnownDomTarget({
|
|
426
|
+
node: source.node,
|
|
427
|
+
scope: source.scope,
|
|
428
|
+
seen,
|
|
429
|
+
kind: "collection"
|
|
430
|
+
});
|
|
431
|
+
const target = source.node;
|
|
432
|
+
scope = source.scope;
|
|
312
433
|
const hasProducerReceiver = (receiver, producer) => {
|
|
313
|
-
if (producer.receiver !== "element" && isDocumentReceiver(receiver)) return true;
|
|
434
|
+
if (producer.receiver !== "element" && isDocumentReceiver(receiver, scope)) return true;
|
|
314
435
|
return producer.receiver !== "document" && isKnownDomTarget({
|
|
315
436
|
node: receiver,
|
|
316
437
|
scope,
|
|
@@ -323,12 +444,12 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
323
444
|
seen,
|
|
324
445
|
kind: "collection"
|
|
325
446
|
});
|
|
326
|
-
if (
|
|
447
|
+
if (target?.type === "MemberExpression") {
|
|
327
448
|
const property = memberPropertyName(target);
|
|
328
|
-
const producer = DOM_ELEMENT_PRODUCERS.find((entry) => entry.kind === "property" && entry.name === property);
|
|
449
|
+
const producer = DOM_ELEMENT_PRODUCERS.find((entry) => entry.kind === (kind === "collection" ? "collection-property" : "property") && entry.name === property);
|
|
329
450
|
if (producer !== void 0) return hasProducerReceiver(target.object, producer);
|
|
330
451
|
const index = unwrapExpression(target.property);
|
|
331
|
-
if (target.computed === true && index?.type === "Literal" && typeof index.value === "number" && Number.isInteger(index.value) && index.value >= 0) return isElementCollection(target.object);
|
|
452
|
+
if (kind === "element" && target.computed === true && index?.type === "Literal" && typeof index.value === "number" && Number.isInteger(index.value) && index.value >= 0) return isElementCollection(target.object);
|
|
332
453
|
}
|
|
333
454
|
if (target?.type === "CallExpression") {
|
|
334
455
|
const callee = invokedCallee(target);
|
|
@@ -338,7 +459,7 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
338
459
|
const producer = DOM_ELEMENT_PRODUCERS.find((entry) => entry.kind === (kind === "collection" ? "collection" : "method") && entry.name === method);
|
|
339
460
|
return producer !== void 0 && hasProducerReceiver(callee.object, producer);
|
|
340
461
|
}
|
|
341
|
-
return kind === "element" && isDocumentReceiver(target);
|
|
462
|
+
return kind === "element" && isDocumentReceiver(target, scope);
|
|
342
463
|
};
|
|
343
464
|
let sanitizerPolicy = SANITIZER_POLICY.allowlist;
|
|
344
465
|
const waiverLines = /* @__PURE__ */ new Set();
|
|
@@ -349,6 +470,11 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
349
470
|
kind
|
|
350
471
|
});
|
|
351
472
|
};
|
|
473
|
+
const messageIdFor = (kind) => {
|
|
474
|
+
if (kind === "opaque-payload-spread") return "unsafeInnerHtmlSpread";
|
|
475
|
+
if (kind === "opaque-payload-computed-key") return "unsafeInnerHtmlComputedKey";
|
|
476
|
+
return "unsafeInnerHtml";
|
|
477
|
+
};
|
|
352
478
|
const consumeWaiver = (node) => {
|
|
353
479
|
const line = startLine(node) - 1;
|
|
354
480
|
if (!waiverLines.has(line)) return false;
|
|
@@ -366,7 +492,7 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
366
492
|
}
|
|
367
493
|
for (const property of objectProperties(expression)) {
|
|
368
494
|
if (isOpaqueProperty(property)) {
|
|
369
|
-
observeSink(property, "opaque-payload");
|
|
495
|
+
observeSink(property, property.type === "SpreadElement" ? "opaque-payload-spread" : "opaque-payload-computed-key");
|
|
370
496
|
continue;
|
|
371
497
|
}
|
|
372
498
|
if (property.type === "Property" && objectPropertyKey(property) === htmlKey) reportIfUnsafe(property.value);
|
|
@@ -383,6 +509,14 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
383
509
|
default: throw new Error(`Unknown React HTML prop: ${String(prop)}`);
|
|
384
510
|
}
|
|
385
511
|
};
|
|
512
|
+
const checkReactProps = (value) => {
|
|
513
|
+
for (const property of objectProperties(value)) {
|
|
514
|
+
if (property.type !== "Property") continue;
|
|
515
|
+
const key = objectPropertyKey(property);
|
|
516
|
+
const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);
|
|
517
|
+
if (prop?.kind === "value") checkReactHtmlProp(prop, property.value);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
386
520
|
const checkHtmlPropertySources = (sources, domTarget) => {
|
|
387
521
|
for (const source of sources) {
|
|
388
522
|
if (unwrapExpression(source)?.type !== "ObjectExpression") {
|
|
@@ -412,7 +546,7 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
412
546
|
if (kind === "safe" || kind === "unsafe" && waived) continue;
|
|
413
547
|
context.report({
|
|
414
548
|
node,
|
|
415
|
-
messageId: kind
|
|
549
|
+
messageId: messageIdFor(kind)
|
|
416
550
|
});
|
|
417
551
|
}
|
|
418
552
|
sinks.length = 0;
|
|
@@ -428,6 +562,9 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
428
562
|
const value = unwrapExpression(node.value);
|
|
429
563
|
checkReactHtmlProp(prop, value?.type === "JSXExpressionContainer" ? value.expression : value);
|
|
430
564
|
},
|
|
565
|
+
JSXSpreadAttribute(node) {
|
|
566
|
+
checkReactProps(node.argument);
|
|
567
|
+
},
|
|
431
568
|
Property(node) {
|
|
432
569
|
const key = objectPropertyKey(node);
|
|
433
570
|
const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);
|
|
@@ -447,12 +584,7 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
447
584
|
const invoked = invokedArguments(node);
|
|
448
585
|
const factory = staticCalleeName(callee);
|
|
449
586
|
if (factory !== null && REACT_ELEMENT_FACTORIES.has(factory)) {
|
|
450
|
-
|
|
451
|
-
if (property.type !== "Property") continue;
|
|
452
|
-
const key = objectPropertyKey(property);
|
|
453
|
-
const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);
|
|
454
|
-
if (prop?.kind === "value") checkReactHtmlProp(prop, property.value);
|
|
455
|
-
}
|
|
587
|
+
checkReactProps(invoked.args.at(1));
|
|
456
588
|
return;
|
|
457
589
|
}
|
|
458
590
|
if (callee?.type !== "MemberExpression") return;
|
|
@@ -474,15 +606,17 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
474
606
|
reportIfUnsafe(invoked.args.at(1));
|
|
475
607
|
return;
|
|
476
608
|
}
|
|
477
|
-
|
|
609
|
+
const attributeSink = HTML_ATTRIBUTE_SINKS.find((entry) => entry.name === method);
|
|
610
|
+
if (attributeSink !== void 0) {
|
|
611
|
+
if (attributeSink.namespaceIndex !== null && isKnownNonEmptyNamespace(invoked.args.at(attributeSink.namespaceIndex), context.sourceCode.getScope(node))) return;
|
|
478
612
|
if (invoked.status === "opaque") {
|
|
479
613
|
reportIfUnsafe(node);
|
|
480
614
|
return;
|
|
481
615
|
}
|
|
482
|
-
if (staticStringValue(invoked.args.at(
|
|
616
|
+
if (staticStringValue(invoked.args.at(attributeSink.nameIndex))?.toLowerCase() === "srcdoc") reportIfUnsafe(invoked.args.at(attributeSink.valueIndex));
|
|
483
617
|
return;
|
|
484
618
|
}
|
|
485
|
-
if (DOCUMENT_WRITE_METHODS.has(method) &&
|
|
619
|
+
if (DOCUMENT_WRITE_METHODS.has(method) && isDocumentSinkReceiver(callee.object, context.sourceCode.getScope(node))) {
|
|
486
620
|
if (invoked.status === "opaque") {
|
|
487
621
|
reportIfUnsafe(node);
|
|
488
622
|
return;
|
|
@@ -504,6 +638,6 @@ var no_unsafe_inner_html_default = eslintCompatPlugin({
|
|
|
504
638
|
} }
|
|
505
639
|
});
|
|
506
640
|
//#endregion
|
|
507
|
-
export { DOM_ELEMENT_PRODUCERS, REACT_HTML_PROPS, no_unsafe_inner_html_default as default };
|
|
641
|
+
export { DOCUMENT_WRITE_METHODS, DOM_ELEMENT_PRODUCERS, HTML_ATTRIBUTE_SINKS, REACT_ELEMENT_FACTORIES, REACT_HTML_PROPS, no_unsafe_inner_html_default as default };
|
|
508
642
|
|
|
509
643
|
//# sourceMappingURL=no-unsafe-inner-html.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unsafe-inner-html.mjs","names":["exhaustive"],"sources":["../src/no-unsafe-inner-html.ts"],"sourcesContent":["// Forbid injecting un-proven HTML into the DOM.\n//\n// Raw HTML may only reach the DOM from a value that is provably sanitized or\n// escaped. This rule covers common DOM and JSX sinks while allowing explicit\n// sanitizer calls and narrowly scoped provenance comments.\n//\n// Sinks, all sharing one allowlist:\n// • `__html` of a `dangerouslySetInnerHTML` object, whether the object is a\n// JSX attribute value or a property of any object literal (props passed\n// to `createElement` / `jsx()`, or spread into JSX).\n// • assignment to `innerHTML`, `outerHTML` or `srcdoc`, dot or static\n// bracket notation, and the same keys in an `Object.assign` source.\n// • the JSX `srcDoc` attribute.\n// • `insertAdjacentHTML`, `setHTMLUnsafe`, `createContextualFragment`,\n// `setAttribute(\"srcdoc\", …)`, and `write` / `writeln` on a document.\n//\n// In the default `allowlist` policy, a value is allowed when it is:\n// • a static string Literal or TemplateLiteral whose interpolations are all\n// independently static, OR\n// • passed through the shared HTML sanitizer allowlist (`escapeHtml`,\n// `escapeXml`, `sanitizeHtml`, `sanitizeDom`, `DOMPurify.sanitize`, and\n// related established names), including `.value` / `.data` / `.html`\n// result accessors; OR\n// • annotated by a `// safe-html: <provenance>` comment with non-empty text\n// on the line directly above the sink. One comment covers one sink: a\n// second sink starting on the same line needs its own annotation.\n// The `provenance` policy omits the sanitizer-name allowlist and requires the\n// comment for dynamic sanitizer results as well.\n//\n// The sanitizer allowlist preserves the shared plugin contract. For dynamic\n// values outside that list, function names are not proof: a local identity\n// function can be named `sanitizeHtml`. Add explicit provenance at the sink\n// until the codebase has a branded SafeHtml boundary.\n\nimport type { Scope, Variable } from \"@oxlint/plugins\";\nimport { eslintCompatPlugin } from \"@oxlint/plugins\";\n\nimport type { AstNode, LiteralArgumentResolution } from \"./utils.ts\";\nimport {\n getPropertyName,\n invokedCallee,\n isAstNode,\n isIdentifier,\n isStringLiteral,\n memberPropertyName,\n resolveLiteralArraySpreads,\n staticStringValue,\n unwrapExpression,\n} from \"./utils.ts\";\n\ntype DomElementProducer = {\n name: string;\n kind: \"property\" | \"method\" | \"collection\";\n receiver: \"document\" | \"element\" | \"either\";\n};\n\n// DOM element provenance and the generated equivalence corpus share this table.\nexport const DOM_ELEMENT_PRODUCERS = [\n { name: \"body\", kind: \"property\", receiver: \"document\" },\n { name: \"head\", kind: \"property\", receiver: \"document\" },\n { name: \"documentElement\", kind: \"property\", receiver: \"document\" },\n { name: \"activeElement\", kind: \"property\", receiver: \"document\" },\n { name: \"scrollingElement\", kind: \"property\", receiver: \"document\" },\n { name: \"fullscreenElement\", kind: \"property\", receiver: \"document\" },\n { name: \"createElement\", kind: \"method\", receiver: \"document\" },\n { name: \"createElementNS\", kind: \"method\", receiver: \"document\" },\n { name: \"getElementById\", kind: \"method\", receiver: \"document\" },\n { name: \"querySelector\", kind: \"method\", receiver: \"either\" },\n { name: \"closest\", kind: \"method\", receiver: \"element\" },\n { name: \"elementFromPoint\", kind: \"method\", receiver: \"document\" },\n { name: \"getElementsByClassName\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByTagName\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByTagNameNS\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByName\", kind: \"collection\", receiver: \"document\" },\n { name: \"querySelectorAll\", kind: \"collection\", receiver: \"either\" },\n { name: \"parentElement\", kind: \"property\", receiver: \"element\" },\n { name: \"firstElementChild\", kind: \"property\", receiver: \"element\" },\n { name: \"lastElementChild\", kind: \"property\", receiver: \"element\" },\n { name: \"nextElementSibling\", kind: \"property\", receiver: \"element\" },\n { name: \"previousElementSibling\", kind: \"property\", receiver: \"element\" },\n { name: \"offsetParent\", kind: \"property\", receiver: \"element\" },\n] as const satisfies readonly DomElementProducer[];\n\n// The provenance text after the marker must be non-empty.\nconst WAIVER_RE = /^\\s*safe-html:\\s*\\S/u;\n\nexport const REACT_HTML_PROPS = [\n { name: \"dangerouslySetInnerHTML\", kind: \"payload\", htmlKey: \"__html\" },\n { name: \"srcDoc\", kind: \"value\" },\n { name: \"srcdoc\", kind: \"value\" },\n] as const;\ntype ReactHtmlProp = (typeof REACT_HTML_PROPS)[number];\nconst REACT_ELEMENT_FACTORIES: ReadonlySet<string> = new Set([\n \"createElement\",\n \"React.createElement\",\n \"jsx\",\n \"jsxs\",\n \"jsxDEV\",\n]);\nconst HTML_PROPERTIES: ReadonlySet<string> = new Set([\n \"innerHTML\",\n \"outerHTML\",\n \"srcdoc\",\n]);\n// Methods whose first argument is parsed as HTML.\nconst HTML_FIRST_ARGUMENT_METHODS: ReadonlySet<string> = new Set([\n \"createContextualFragment\",\n \"setHTMLUnsafe\",\n]);\nconst DOCUMENT_WRITE_METHODS: ReadonlySet<string> = new Set([\n \"write\",\n \"writeln\",\n]);\nconst DOCUMENT_MEMBERS: ReadonlySet<string> = new Set([\n \"contentDocument\",\n \"document\",\n \"ownerDocument\",\n]);\n\nconst HTML_SANITIZER_LEAF_RE =\n /^(?:escape(?:html|xml)|sanitize(?:html|dom)|purify(?:html|dom)|dompurify)$/iu;\nconst SANITIZER_RESULT_MEMBERS = new Set([\"value\", \"data\", \"html\"]);\nconst SANITIZER_POLICY = {\n allowlist: \"allowlist\",\n provenance: \"provenance\",\n} as const;\nconst SANITIZER_POLICY_VALUES = Object.values(SANITIZER_POLICY);\ntype SanitizerPolicy = (typeof SANITIZER_POLICY)[keyof typeof SANITIZER_POLICY];\n\nconst sanitizerPolicyFrom = (option: unknown): SanitizerPolicy => {\n if (option === undefined) {\n return SANITIZER_POLICY.allowlist;\n }\n if (typeof option !== \"object\" || option === null || Array.isArray(option)) {\n throw new Error(\"no-unsafe-inner-html options must be an object\");\n }\n const policy = Reflect.get(option, \"sanitizerPolicy\");\n switch (policy) {\n case undefined:\n case SANITIZER_POLICY.allowlist:\n return SANITIZER_POLICY.allowlist;\n case SANITIZER_POLICY.provenance:\n return SANITIZER_POLICY.provenance;\n default:\n throw new Error(`unknown sanitizer policy: ${String(policy)}`);\n }\n};\n\n// Use the same static member-name resolution for sinks and safe-value proofs.\nconst staticCalleeName = (node: unknown): string | null => {\n const expression = unwrapExpression(node);\n if (isIdentifier(expression)) return expression.name;\n if (expression?.type !== \"MemberExpression\") return null;\n const receiver = staticCalleeName(expression.object);\n const property = memberPropertyName(expression);\n return receiver === null || property === null\n ? null\n : `${receiver}.${property}`;\n};\n\nconst isSanitizerCall = (node: unknown): boolean => {\n if (!isAstNode(node) || node.type !== \"CallExpression\") {\n return false;\n }\n const dotted = staticCalleeName(node.callee);\n if (dotted === null) {\n return false;\n }\n const parts = dotted.split(\".\");\n const leaf = parts.at(-1);\n if (leaf === undefined) {\n return false;\n }\n if (HTML_SANITIZER_LEAF_RE.test(leaf)) {\n return true;\n }\n return leaf === \"sanitize\" && /^dompurify$/iu.test(parts.at(-2) ?? \"\");\n};\n\nconst isSanitizerResult = (node: unknown): boolean => {\n const expression = unwrapExpression(node);\n if (expression?.type !== \"MemberExpression\") {\n return false;\n }\n const property = memberPropertyName(expression);\n return (\n property !== null &&\n SANITIZER_RESULT_MEMBERS.has(property) &&\n isSanitizerCall(expression.object)\n );\n};\n\ntype Located = { loc: { start: { line: number } } };\n\nconst hasLocation = (node: unknown): node is Located =>\n typeof node === \"object\" &&\n node !== null &&\n \"loc\" in node &&\n typeof node.loc === \"object\" &&\n node.loc !== null &&\n \"start\" in node.loc &&\n typeof node.loc.start === \"object\" &&\n node.loc.start !== null &&\n \"line\" in node.loc.start &&\n typeof node.loc.start.line === \"number\";\n\n// A node without location data never matches a waiver line.\nconst startLine = (node: unknown): number =>\n hasLocation(node) ? node.loc.start.line : Number.NaN;\n\ntype WaiverComment = {\n value: string;\n loc: { end: { line: number } };\n};\n\nconst isWaiverComment = (value: unknown): value is WaiverComment =>\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n typeof value.value === \"string\" &&\n WAIVER_RE.test(value.value) &&\n \"loc\" in value &&\n typeof value.loc === \"object\" &&\n value.loc !== null;\n\nconst jsxAttributeName = (node: unknown): string | null =>\n isAstNode(node) && node.type === \"JSXIdentifier\" && typeof node.name === \"string\"\n ? node.name\n : null;\n\n// A value is proven safe by its own static shape, independent of comments.\nconst isProvenSafeValue = (\n node: unknown,\n sanitizerPolicy: SanitizerPolicy,\n): boolean => {\n const expression = unwrapExpression(node);\n if (expression === null) {\n return false;\n }\n if (isStringLiteral(expression)) {\n return true;\n }\n if (\n sanitizerPolicy === SANITIZER_POLICY.allowlist &&\n (isSanitizerCall(expression) || isSanitizerResult(expression))\n ) {\n return true;\n }\n return (\n expression.type === \"TemplateLiteral\" &&\n Array.isArray(expression.expressions) &&\n expression.expressions.every((entry) =>\n isProvenSafeValue(entry, sanitizerPolicy),\n )\n );\n};\n\n// The static key of an object-literal Property: `a`, `\"a\"`, `[\"a\"]`.\nconst objectPropertyKey = (property: unknown): string | null => {\n if (!isAstNode(property)) {\n return null;\n }\n if (property.computed === true) {\n return staticStringValue(property.key);\n }\n return getPropertyName(property.key);\n};\n\nconst isOpaqueProperty = (property: AstNode): boolean =>\n property.type === \"SpreadElement\" ||\n (property.type === \"Property\" &&\n property.computed === true &&\n objectPropertyKey(property) === null);\n\nconst objectProperties = (node: unknown): AstNode[] => {\n const expression = unwrapExpression(node);\n if (\n expression?.type !== \"ObjectExpression\" ||\n !Array.isArray(expression.properties)\n ) {\n return [];\n }\n return expression.properties.filter(isAstNode);\n};\n\ntype AppliedArguments = LiteralArgumentResolution;\n\nconst appliedArgumentsFor = (args: unknown[]): AppliedArguments => {\n const applied = unwrapExpression(args.at(1));\n if (\n applied === null ||\n (applied.type === \"Literal\" && applied.value === null) ||\n isIdentifier(applied, \"undefined\")\n ) {\n return { status: \"known\", args: [] };\n }\n if (applied.type !== \"ArrayExpression\" || !Array.isArray(applied.elements)) {\n return { status: \"opaque\", args: [], spread: args.at(1), tail: [] };\n }\n return resolveLiteralArraySpreads(applied.elements);\n};\n\n// The arguments the invoked function receives: `f.call(thisArg, ...args)`\n// shifts them by one; `f.apply(thisArg, [...])` forwards a literal array.\nconst invokedArguments = (call: unknown): AppliedArguments => {\n if (!isAstNode(call)) {\n return { status: \"known\", args: [] };\n }\n const rawArguments = Array.isArray(call.arguments) ? call.arguments : [];\n const resolved = resolveLiteralArraySpreads(rawArguments);\n const callee = unwrapExpression(call.callee);\n if (callee?.type !== \"MemberExpression\") return resolved;\n const method = memberPropertyName(callee);\n if (method === \"call\") {\n return { ...resolved, args: resolved.args.slice(1) };\n }\n if (method !== \"apply\") return resolved;\n if (resolved.status === \"opaque\") {\n if (resolved.args.length >= 2) return appliedArgumentsFor(resolved.args);\n return { ...resolved, args: [], tail: [] };\n }\n return appliedArgumentsFor(resolved.args);\n};\n\n// `document.write`, `window.document.write`, `frame.contentDocument.write`,\n// `node.ownerDocument.write`.\nconst isDocumentReceiver = (node: unknown): boolean => {\n const receiver = unwrapExpression(node);\n if (isIdentifier(receiver, \"document\")) {\n return true;\n }\n if (receiver?.type !== \"MemberExpression\") {\n return false;\n }\n const name = memberPropertyName(receiver);\n return name !== null && DOCUMENT_MEMBERS.has(name);\n};\n\nexport default eslintCompatPlugin({\n meta: { name: \"no-unsafe-inner-html\" },\n rules: {\n \"no-unsafe-inner-html\": {\n meta: {\n type: \"problem\",\n schema: [\n {\n type: \"object\",\n properties: {\n sanitizerPolicy: {\n type: \"string\",\n enum: SANITIZER_POLICY_VALUES,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n unsafeInnerHtml:\n \"Dynamic HTML injected into the DOM must be static, proven by \" +\n \"the configured sanitizer policy, or have an adjacent \" +\n \"`// safe-html: <provenance>` comment naming the trusted source. \" +\n \"Function names outside the allowlist are not proof because a \" +\n \"local identity function can shadow them.\",\n unsafeInnerHtmlSpread:\n \"Do not spread an object into dangerouslySetInnerHTML. Keep \" +\n \"`__html` inline so this rule can prove the HTML value is \" +\n \"sanitized or escaped.\",\n },\n },\n createOnce(context) {\n type DomTargetOptions = {\n node: unknown;\n scope: Scope;\n seen?: Set<Variable>;\n kind?: \"element\" | \"collection\";\n };\n const isKnownDomTarget = ({\n node,\n scope,\n seen = new Set<Variable>(),\n kind = \"element\",\n }: DomTargetOptions): boolean => {\n const target = unwrapExpression(node);\n if (isIdentifier(target)) {\n let current: Scope | null = scope;\n while (current !== null) {\n const variable = current.set.get(target.name);\n if (variable === undefined) {\n current = current.upper;\n continue;\n }\n if (variable.defs.length === 0) {\n return kind === \"element\" && isDocumentReceiver(target);\n }\n if (seen.has(variable)) return false;\n seen.add(variable);\n const definition = variable.defs.at(0);\n if (\n variable.defs.length !== 1 ||\n definition?.type !== \"Variable\" ||\n definition.node.type !== \"VariableDeclarator\" ||\n definition.node.id.type !== \"Identifier\" ||\n definition.node.init === null ||\n variable.references.some(\n (reference) => reference.isWrite() && !reference.init,\n )\n ) {\n return false;\n }\n return isKnownDomTarget({\n node: definition.node.init,\n scope: context.sourceCode.getScope(definition.node),\n seen,\n kind,\n });\n }\n }\n const hasProducerReceiver = (\n receiver: unknown,\n producer: DomElementProducer,\n ): boolean => {\n if (\n producer.receiver !== \"element\" &&\n isDocumentReceiver(receiver)\n ) {\n return true;\n }\n return (\n producer.receiver !== \"document\" &&\n isKnownDomTarget({ node: receiver, scope, seen })\n );\n };\n const isElementCollection = (collection: unknown): boolean =>\n isKnownDomTarget({ node: collection, scope, seen, kind: \"collection\" });\n if (kind === \"element\" && target?.type === \"MemberExpression\") {\n const property = memberPropertyName(target);\n const producer = DOM_ELEMENT_PRODUCERS.find(\n (entry) => entry.kind === \"property\" && entry.name === property,\n );\n if (producer !== undefined) {\n return hasProducerReceiver(target.object, producer);\n }\n const index = unwrapExpression(target.property);\n if (\n target.computed === true &&\n index?.type === \"Literal\" &&\n typeof index.value === \"number\" &&\n Number.isInteger(index.value) &&\n index.value >= 0\n ) {\n return isElementCollection(target.object);\n }\n }\n if (target?.type === \"CallExpression\") {\n const callee = invokedCallee(target);\n if (callee?.type !== \"MemberExpression\") return false;\n const method = memberPropertyName(callee);\n if (\n kind === \"element\" &&\n method === \"item\" &&\n isElementCollection(callee.object)\n ) {\n return true;\n }\n const producer = DOM_ELEMENT_PRODUCERS.find(\n (entry) =>\n entry.kind === (kind === \"collection\" ? \"collection\" : \"method\") &&\n entry.name === method,\n );\n return (\n producer !== undefined &&\n hasProducerReceiver(callee.object, producer)\n );\n }\n return kind === \"element\" && isDocumentReceiver(target);\n };\n\n let sanitizerPolicy: SanitizerPolicy = SANITIZER_POLICY.allowlist;\n // Associate waivers after visiting the file, so source position decides\n // the first covered sink even when AST visitors inspect values out of order.\n const waiverLines = new Set<number>();\n type SinkObservation = {\n node: AstNode;\n kind: \"safe\" | \"unsafe\" | \"opaque-payload\";\n };\n const sinks: SinkObservation[] = [];\n const observeSink = (\n node: unknown,\n kind: SinkObservation[\"kind\"],\n ): void => {\n if (isAstNode(node)) sinks.push({ node, kind });\n };\n\n const consumeWaiver = (node: unknown): boolean => {\n const line = startLine(node) - 1;\n if (!waiverLines.has(line)) {\n return false;\n }\n waiverLines.delete(line);\n return true;\n };\n\n const reportIfUnsafe = (node: unknown): void => {\n observeSink(\n node,\n isProvenSafeValue(node, sanitizerPolicy) ? \"safe\" : \"unsafe\",\n );\n };\n\n // The value of a `dangerouslySetInnerHTML` prop: an inline object has\n // its `__html` checked and its spreads rejected; anything else is a\n // hoisted payload whose HTML this rule cannot see.\n const checkDangerousPayload = (value: unknown, htmlKey: string): void => {\n const expression = unwrapExpression(value);\n if (expression?.type !== \"ObjectExpression\") {\n reportIfUnsafe(value);\n return;\n }\n for (const property of objectProperties(expression)) {\n if (isOpaqueProperty(property)) {\n observeSink(property, \"opaque-payload\");\n continue;\n }\n if (\n property.type === \"Property\" &&\n objectPropertyKey(property) === htmlKey\n ) {\n reportIfUnsafe(property.value);\n }\n }\n };\n\n const checkReactHtmlProp = (prop: ReactHtmlProp, value: unknown): void => {\n switch (prop.kind) {\n case \"payload\":\n checkDangerousPayload(value, prop.htmlKey);\n return;\n case \"value\":\n reportIfUnsafe(value);\n return;\n default: {\n const exhaustive: never = prop;\n throw new Error(`Unknown React HTML prop: ${String(exhaustive)}`);\n }\n }\n };\n\n const checkHtmlPropertySources = (\n sources: unknown[],\n domTarget: boolean,\n ): void => {\n for (const source of sources) {\n const expression = unwrapExpression(source);\n if (expression?.type !== \"ObjectExpression\") {\n if (domTarget) {\n reportIfUnsafe(source);\n }\n continue;\n }\n for (const property of objectProperties(source)) {\n if (isOpaqueProperty(property)) {\n if (domTarget) {\n reportIfUnsafe(property);\n }\n continue;\n }\n const key =\n property.type === \"Property\"\n ? objectPropertyKey(property)\n : null;\n if (key !== null && HTML_PROPERTIES.has(key)) {\n reportIfUnsafe(property.value);\n }\n }\n }\n };\n\n return {\n before() {\n sanitizerPolicy = sanitizerPolicyFrom(context.options.at(0));\n waiverLines.clear();\n sinks.length = 0;\n },\n \"Program:exit\"() {\n sinks.sort((left, right) => left.node.range[0] - right.node.range[0]);\n for (const { node, kind } of sinks) {\n const waived = consumeWaiver(node);\n if (kind === \"safe\" || (kind === \"unsafe\" && waived)) continue;\n context.report({\n node,\n messageId:\n kind === \"opaque-payload\"\n ? \"unsafeInnerHtmlSpread\"\n : \"unsafeInnerHtml\",\n });\n }\n sinks.length = 0;\n },\n Program(node) {\n const comments: unknown[] = Array.isArray(node.comments)\n ? node.comments\n : [];\n for (const comment of comments) {\n if (isWaiverComment(comment)) {\n waiverLines.add(comment.loc.end.line);\n }\n }\n },\n\n JSXAttribute(node) {\n const name = jsxAttributeName(node.name);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === name);\n if (prop === undefined) return;\n const value = unwrapExpression(node.value);\n checkReactHtmlProp(\n prop,\n value?.type === \"JSXExpressionContainer\" ? value.expression : value,\n );\n },\n\n // Payload objects remain checked when hoisted or spread into JSX.\n // Direct value props require a recognized factory-call context below.\n Property(node) {\n const key = objectPropertyKey(node);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);\n if (prop?.kind !== \"payload\") return;\n const container = node.parent;\n if (isAstNode(container) && container.type === \"ObjectExpression\") {\n checkReactHtmlProp(prop, node.value);\n }\n },\n\n AssignmentExpression(node) {\n const target = unwrapExpression(node.left);\n if (target?.type !== \"MemberExpression\") {\n return;\n }\n const name = memberPropertyName(target);\n if (name !== null && HTML_PROPERTIES.has(name)) {\n reportIfUnsafe(node.right);\n }\n },\n\n CallExpression(node) {\n const call: unknown = node;\n const callee = isAstNode(call) ? invokedCallee(call) : null;\n const invoked = invokedArguments(node);\n const factory = staticCalleeName(callee);\n if (factory !== null && REACT_ELEMENT_FACTORIES.has(factory)) {\n for (const property of objectProperties(invoked.args.at(1))) {\n if (property.type !== \"Property\") continue;\n const key = objectPropertyKey(property);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);\n // Payload props are already checked by the Property visitor.\n if (prop?.kind === \"value\") {\n checkReactHtmlProp(prop, property.value);\n }\n }\n return;\n }\n if (callee?.type !== \"MemberExpression\") {\n return;\n }\n const method = memberPropertyName(callee);\n if (method === null) {\n return;\n }\n if (HTML_FIRST_ARGUMENT_METHODS.has(method)) {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n reportIfUnsafe(invoked.args.at(0));\n return;\n }\n if (method === \"insertAdjacentHTML\") {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n reportIfUnsafe(invoked.args.at(1));\n return;\n }\n if (method === \"setAttribute\") {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n const attribute = staticStringValue(invoked.args.at(0));\n if (attribute?.toLowerCase() === \"srcdoc\") {\n reportIfUnsafe(invoked.args.at(1));\n }\n return;\n }\n if (\n DOCUMENT_WRITE_METHODS.has(method) &&\n isDocumentReceiver(callee.object)\n ) {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n observeSink(\n node,\n invoked.args.every((argument) =>\n isProvenSafeValue(argument, sanitizerPolicy),\n )\n ? \"safe\"\n : \"unsafe\",\n );\n return;\n }\n if (isIdentifier(callee.object, \"Object\") && method === \"assign\") {\n const domTarget = isKnownDomTarget({\n node: invoked.args.at(0),\n scope: context.sourceCode.getScope(node),\n });\n checkHtmlPropertySources(\n [\n ...invoked.args.slice(1),\n ...(invoked.status === \"opaque\" ? invoked.tail : []),\n ],\n domTarget,\n );\n if (invoked.status === \"opaque\" && domTarget) {\n reportIfUnsafe(invoked.spread);\n }\n }\n },\n };\n },\n },\n },\n});\n"],"mappings":";;;AAyDA,MAAa,wBAAwB;CACnC;EAAE,MAAM;EAAQ,MAAM;EAAY,UAAU;CAAW;CACvD;EAAE,MAAM;EAAQ,MAAM;EAAY,UAAU;CAAW;CACvD;EAAE,MAAM;EAAmB,MAAM;EAAY,UAAU;CAAW;CAClE;EAAE,MAAM;EAAiB,MAAM;EAAY,UAAU;CAAW;CAChE;EAAE,MAAM;EAAoB,MAAM;EAAY,UAAU;CAAW;CACnE;EAAE,MAAM;EAAqB,MAAM;EAAY,UAAU;CAAW;CACpE;EAAE,MAAM;EAAiB,MAAM;EAAU,UAAU;CAAW;CAC9D;EAAE,MAAM;EAAmB,MAAM;EAAU,UAAU;CAAW;CAChE;EAAE,MAAM;EAAkB,MAAM;EAAU,UAAU;CAAW;CAC/D;EAAE,MAAM;EAAiB,MAAM;EAAU,UAAU;CAAS;CAC5D;EAAE,MAAM;EAAW,MAAM;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jC,mBAAmB,OAAO,MAAM,GAChC;MACA,IAAI,QAAQ,WAAW,UAAU;OAC/B,eAAe,IAAI;OACnB;MACF;MACA,YACE,MACA,QAAQ,KAAK,OAAO,aAClB,kBAAkB,UAAU,eAAe,CAC7C,IACI,SACA,QACN;MACA;KACF;KACA,IAAI,aAAa,OAAO,QAAQ,QAAQ,KAAK,WAAW,UAAU;MAChE,MAAM,YAAY,iBAAiB;OACjC,MAAM,QAAQ,KAAK,GAAG,CAAC;OACvB,OAAO,QAAQ,WAAW,SAAS,IAAI;MACzC,CAAC;MACD,yBACE,CACE,GAAG,QAAQ,KAAK,MAAM,CAAC,GACvB,GAAI,QAAQ,WAAW,WAAW,QAAQ,OAAO,CAAC,CACpD,GACA,SACF;MACA,IAAI,QAAQ,WAAW,YAAY,WACjC,eAAe,QAAQ,MAAM;KAEjC;IACF;GACF;EACF;CACF,EACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"no-unsafe-inner-html.mjs","names":["exhaustive"],"sources":["../src/no-unsafe-inner-html.ts"],"sourcesContent":["// Forbid injecting un-proven HTML into the DOM.\n//\n// Raw HTML may only reach the DOM from a value that is provably sanitized or\n// escaped. This rule covers common DOM and JSX sinks while allowing explicit\n// sanitizer calls and narrowly scoped provenance comments.\n//\n// Sinks, all sharing one allowlist:\n// • `__html` of a `dangerouslySetInnerHTML` object, whether the object is a\n// JSX attribute value or a property of any object literal (props passed\n// to `createElement` / `jsx()`, or spread into JSX).\n// • assignment to `innerHTML`, `outerHTML` or `srcdoc`, dot or static\n// bracket notation, and the same keys in an `Object.assign` source.\n// • the JSX `srcDoc` attribute.\n// • `insertAdjacentHTML`, `setHTMLUnsafe`, `createContextualFragment`,\n// `setAttribute(\"srcdoc\", …)` / `setAttributeNS(…, \"srcdoc\", …)`,\n// and `write` / `writeln` on a document.\n//\n// In the default `allowlist` policy, a value is allowed when it is:\n// • a static string Literal or TemplateLiteral whose interpolations are all\n// independently static, OR\n// • passed through the shared HTML sanitizer allowlist (`escapeHtml`,\n// `escapeXml`, `sanitizeHtml`, `sanitizeDom`, `DOMPurify.sanitize`, and\n// related established names), including `.value` / `.data` / `.html`\n// result accessors; OR\n// • annotated by a `// safe-html: <provenance>` comment with non-empty text\n// on the line directly above the sink. One comment covers one sink: a\n// second sink starting on the same line needs its own annotation.\n// The `provenance` policy omits the sanitizer-name allowlist and requires the\n// comment for dynamic sanitizer results as well.\n//\n// The sanitizer allowlist preserves the shared plugin contract. For dynamic\n// values outside that list, function names are not proof: a local identity\n// function can be named `sanitizeHtml`. Add explicit provenance at the sink\n// until the codebase has a branded SafeHtml boundary.\n\nimport type { Scope, Variable } from \"@oxlint/plugins\";\nimport { eslintCompatPlugin } from \"@oxlint/plugins\";\n\nimport type { AstNode, LiteralArgumentResolution } from \"./utils.ts\";\nimport {\n getPropertyName,\n invokedCallee,\n isAstNode,\n isIdentifier,\n isStringLiteral,\n memberPropertyName,\n resolveLiteralArraySpreads,\n staticStringValue,\n unwrapExpression,\n} from \"./utils.ts\";\n\ntype DomElementProducer = {\n name: string;\n kind: \"property\" | \"method\" | \"collection\" | \"collection-property\";\n receiver: \"document\" | \"element\" | \"either\";\n};\n\n// DOM element provenance and the generated equivalence corpus share this table.\nexport const DOM_ELEMENT_PRODUCERS = [\n { name: \"body\", kind: \"property\", receiver: \"document\" },\n { name: \"head\", kind: \"property\", receiver: \"document\" },\n { name: \"documentElement\", kind: \"property\", receiver: \"document\" },\n { name: \"activeElement\", kind: \"property\", receiver: \"document\" },\n { name: \"scrollingElement\", kind: \"property\", receiver: \"document\" },\n { name: \"fullscreenElement\", kind: \"property\", receiver: \"document\" },\n { name: \"createElement\", kind: \"method\", receiver: \"document\" },\n { name: \"createElementNS\", kind: \"method\", receiver: \"document\" },\n { name: \"getElementById\", kind: \"method\", receiver: \"document\" },\n { name: \"querySelector\", kind: \"method\", receiver: \"either\" },\n { name: \"closest\", kind: \"method\", receiver: \"element\" },\n { name: \"elementFromPoint\", kind: \"method\", receiver: \"document\" },\n { name: \"getElementsByClassName\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByTagName\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByTagNameNS\", kind: \"collection\", receiver: \"either\" },\n { name: \"getElementsByName\", kind: \"collection\", receiver: \"document\" },\n { name: \"querySelectorAll\", kind: \"collection\", receiver: \"either\" },\n { name: \"children\", kind: \"collection-property\", receiver: \"element\" },\n { name: \"parentElement\", kind: \"property\", receiver: \"element\" },\n { name: \"firstElementChild\", kind: \"property\", receiver: \"element\" },\n { name: \"lastElementChild\", kind: \"property\", receiver: \"element\" },\n { name: \"nextElementSibling\", kind: \"property\", receiver: \"element\" },\n { name: \"previousElementSibling\", kind: \"property\", receiver: \"element\" },\n { name: \"offsetParent\", kind: \"property\", receiver: \"element\" },\n] as const satisfies readonly DomElementProducer[];\n\n// The provenance text after the marker must be non-empty.\nconst WAIVER_RE = /^\\s*safe-html:\\s*\\S/u;\n\nexport const REACT_HTML_PROPS = [\n { name: \"dangerouslySetInnerHTML\", kind: \"payload\", htmlKey: \"__html\" },\n { name: \"srcDoc\", kind: \"value\" },\n { name: \"srcdoc\", kind: \"value\" },\n] as const;\ntype ReactHtmlProp = (typeof REACT_HTML_PROPS)[number];\nexport const REACT_ELEMENT_FACTORIES: ReadonlySet<string> = new Set([\n \"createElement\",\n \"React.createElement\",\n \"jsx\",\n \"jsxs\",\n \"jsxDEV\",\n]);\nconst HTML_PROPERTIES: ReadonlySet<string> = new Set([\n \"innerHTML\",\n \"outerHTML\",\n \"srcdoc\",\n]);\n// Methods whose first argument is parsed as HTML.\nconst HTML_FIRST_ARGUMENT_METHODS: ReadonlySet<string> = new Set([\n \"createContextualFragment\",\n \"setHTMLUnsafe\",\n]);\nexport const DOCUMENT_WRITE_METHODS: ReadonlySet<string> = new Set([\n \"write\",\n \"writeln\",\n]);\nexport const HTML_ATTRIBUTE_SINKS = [\n { name: \"setAttribute\", namespaceIndex: null, nameIndex: 0, valueIndex: 1 },\n { name: \"setAttributeNS\", namespaceIndex: 0, nameIndex: 1, valueIndex: 2 },\n] as const;\nconst DOCUMENT_MEMBERS: ReadonlySet<string> = new Set([\n \"contentDocument\",\n \"document\",\n \"ownerDocument\",\n]);\nconst FILE_SYSTEM_MODULES: ReadonlySet<string> = new Set([\n \"fs\",\n \"fs/promises\",\n \"node:fs\",\n \"node:fs/promises\",\n]);\nconst HTML_SANITIZER_LEAF_RE =\n /^(?:escape(?:html|xml)|sanitize(?:html|dom)|purify(?:html|dom)|dompurify)$/iu;\nconst SANITIZER_RESULT_MEMBERS = new Set([\"value\", \"data\", \"html\"]);\nconst SANITIZER_POLICY = {\n allowlist: \"allowlist\",\n provenance: \"provenance\",\n} as const;\nconst SANITIZER_POLICY_VALUES = Object.values(SANITIZER_POLICY);\ntype SanitizerPolicy = (typeof SANITIZER_POLICY)[keyof typeof SANITIZER_POLICY];\n\nconst sanitizerPolicyFrom = (option: unknown): SanitizerPolicy => {\n if (option === undefined) {\n return SANITIZER_POLICY.allowlist;\n }\n if (typeof option !== \"object\" || option === null || Array.isArray(option)) {\n throw new Error(\"no-unsafe-inner-html options must be an object\");\n }\n const policy = Reflect.get(option, \"sanitizerPolicy\");\n switch (policy) {\n case undefined:\n case SANITIZER_POLICY.allowlist:\n return SANITIZER_POLICY.allowlist;\n case SANITIZER_POLICY.provenance:\n return SANITIZER_POLICY.provenance;\n default:\n throw new Error(`unknown sanitizer policy: ${String(policy)}`);\n }\n};\n\n// Use the same static member-name resolution for sinks and safe-value proofs.\nconst staticCalleeName = (node: unknown): string | null => {\n const expression = unwrapExpression(node);\n if (isIdentifier(expression)) return expression.name;\n if (expression?.type !== \"MemberExpression\") return null;\n const receiver = staticCalleeName(expression.object);\n const property = memberPropertyName(expression);\n return receiver === null || property === null\n ? null\n : `${receiver}.${property}`;\n};\n\nconst isSanitizerCall = (node: unknown): boolean => {\n if (!isAstNode(node) || node.type !== \"CallExpression\") {\n return false;\n }\n const dotted = staticCalleeName(node.callee);\n if (dotted === null) {\n return false;\n }\n const parts = dotted.split(\".\");\n const leaf = parts.at(-1);\n if (leaf === undefined) {\n return false;\n }\n if (HTML_SANITIZER_LEAF_RE.test(leaf)) {\n return true;\n }\n return leaf === \"sanitize\" && /^dompurify$/iu.test(parts.at(-2) ?? \"\");\n};\n\nconst isSanitizerResult = (node: unknown): boolean => {\n const expression = unwrapExpression(node);\n if (expression?.type !== \"MemberExpression\") {\n return false;\n }\n const property = memberPropertyName(expression);\n return (\n property !== null &&\n SANITIZER_RESULT_MEMBERS.has(property) &&\n isSanitizerCall(expression.object)\n );\n};\n\ntype Located = { loc: { start: { line: number } } };\n\nconst hasLocation = (node: unknown): node is Located =>\n typeof node === \"object\" &&\n node !== null &&\n \"loc\" in node &&\n typeof node.loc === \"object\" &&\n node.loc !== null &&\n \"start\" in node.loc &&\n typeof node.loc.start === \"object\" &&\n node.loc.start !== null &&\n \"line\" in node.loc.start &&\n typeof node.loc.start.line === \"number\";\n\n// A node without location data never matches a waiver line.\nconst startLine = (node: unknown): number =>\n hasLocation(node) ? node.loc.start.line : Number.NaN;\n\ntype WaiverComment = {\n value: string;\n loc: { end: { line: number } };\n};\n\nconst isWaiverComment = (value: unknown): value is WaiverComment =>\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n typeof value.value === \"string\" &&\n WAIVER_RE.test(value.value) &&\n \"loc\" in value &&\n typeof value.loc === \"object\" &&\n value.loc !== null;\n\nconst jsxAttributeName = (node: unknown): string | null =>\n isAstNode(node) && node.type === \"JSXIdentifier\" && typeof node.name === \"string\"\n ? node.name\n : null;\n\n// A value is proven safe by its own static shape, independent of comments.\nconst isProvenSafeValue = (\n node: unknown,\n sanitizerPolicy: SanitizerPolicy,\n): boolean => {\n const expression = unwrapExpression(node);\n if (expression === null) {\n return false;\n }\n if (isStringLiteral(expression)) {\n return true;\n }\n if (\n sanitizerPolicy === SANITIZER_POLICY.allowlist &&\n (isSanitizerCall(expression) || isSanitizerResult(expression))\n ) {\n return true;\n }\n return (\n expression.type === \"TemplateLiteral\" &&\n Array.isArray(expression.expressions) &&\n expression.expressions.every((entry) =>\n isProvenSafeValue(entry, sanitizerPolicy),\n )\n );\n};\n\n// The static key of an object-literal Property: `a`, `\"a\"`, `[\"a\"]`.\nconst objectPropertyKey = (property: unknown): string | null => {\n if (!isAstNode(property)) {\n return null;\n }\n if (property.computed === true) {\n return staticStringValue(property.key);\n }\n return getPropertyName(property.key);\n};\n\nconst isOpaqueProperty = (property: AstNode): boolean =>\n property.type === \"SpreadElement\" ||\n (property.type === \"Property\" &&\n property.computed === true &&\n objectPropertyKey(property) === null);\n\nconst objectProperties = (node: unknown): AstNode[] => {\n const expression = unwrapExpression(node);\n if (\n expression?.type !== \"ObjectExpression\" ||\n !Array.isArray(expression.properties)\n ) {\n return [];\n }\n const properties: AstNode[] = [];\n for (const property of expression.properties.filter(isAstNode)) {\n if (\n property.type === \"SpreadElement\" &&\n unwrapExpression(property.argument)?.type === \"ObjectExpression\"\n ) {\n properties.push(...objectProperties(property.argument));\n continue;\n }\n properties.push(property);\n }\n return properties;\n};\n\ntype AppliedArguments = LiteralArgumentResolution;\n\nconst appliedArgumentsFor = (args: unknown[]): AppliedArguments => {\n const applied = unwrapExpression(args.at(1));\n if (\n applied === null ||\n (applied.type === \"Literal\" && applied.value === null) ||\n isIdentifier(applied, \"undefined\")\n ) {\n return { status: \"known\", args: [] };\n }\n if (applied.type !== \"ArrayExpression\" || !Array.isArray(applied.elements)) {\n return { status: \"opaque\", args: [], spread: args.at(1), tail: [] };\n }\n return resolveLiteralArraySpreads(applied.elements);\n};\n\n// The arguments the invoked function receives: `f.call(thisArg, ...args)`\n// shifts them by one; `f.apply(thisArg, [...])` forwards a literal array.\nconst invokedArguments = (call: unknown): AppliedArguments => {\n if (!isAstNode(call)) {\n return { status: \"known\", args: [] };\n }\n const rawArguments = Array.isArray(call.arguments) ? call.arguments : [];\n const resolved = resolveLiteralArraySpreads(rawArguments);\n const callee = unwrapExpression(call.callee);\n if (callee?.type !== \"MemberExpression\") return resolved;\n const method = memberPropertyName(callee);\n if (method === \"call\") {\n return { ...resolved, args: resolved.args.slice(1) };\n }\n if (method !== \"apply\") return resolved;\n if (resolved.status === \"opaque\") {\n if (resolved.args.length >= 2) return appliedArgumentsFor(resolved.args);\n return { ...resolved, args: [], tail: [] };\n }\n return appliedArgumentsFor(resolved.args);\n};\n\nexport default eslintCompatPlugin({\n meta: { name: \"no-unsafe-inner-html\" },\n rules: {\n \"no-unsafe-inner-html\": {\n meta: {\n type: \"problem\",\n schema: [\n {\n type: \"object\",\n properties: {\n sanitizerPolicy: {\n type: \"string\",\n enum: SANITIZER_POLICY_VALUES,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n unsafeInnerHtml:\n \"Dynamic HTML injected into the DOM must be static, proven by \" +\n \"the configured sanitizer policy, or have an adjacent \" +\n \"`// safe-html: <provenance>` comment naming the trusted source. \" +\n \"Function names outside the allowlist are not proof because a \" +\n \"local identity function can shadow them.\",\n unsafeInnerHtmlSpread:\n \"Do not spread an object in dangerouslySetInnerHTML. Keep \" +\n \"`__html` inline so this rule can prove the HTML value is \" +\n \"sanitized or escaped.\",\n unsafeInnerHtmlComputedKey:\n \"Do not use an unresolved computed key in \" +\n \"dangerouslySetInnerHTML. Write an explicit `__html` property \" +\n \"so this rule can \" +\n \"prove the HTML value is sanitized or escaped.\",\n },\n },\n createOnce(context) {\n type BindingOptions = {\n node: unknown;\n scope: Scope;\n seen: Set<Variable>;\n };\n type BindingSource = {\n kind: \"expression\" | \"iteration\";\n node: AstNode | null;\n scope: Scope;\n };\n // All document, element and collection checks share one stable-binding path.\n const resolveStableBinding = ({\n node,\n scope,\n seen,\n }: BindingOptions): BindingSource | null => {\n let target = unwrapExpression(node);\n while (isIdentifier(target)) {\n let current: Scope | null = scope;\n let variable: Variable | undefined;\n while (current !== null) {\n variable = current.set.get(target.name);\n if (variable !== undefined) break;\n current = current.upper;\n }\n if (variable === undefined || variable.defs.length === 0) {\n return { kind: \"expression\", node: target, scope };\n }\n if (seen.has(variable)) return null;\n seen.add(variable);\n const definition = variable.defs.at(0);\n if (\n variable.defs.length !== 1 ||\n definition?.type !== \"Variable\" ||\n definition.node.type !== \"VariableDeclarator\" ||\n definition.node.id.type !== \"Identifier\" ||\n variable.references.some(\n (reference) => reference.isWrite() && !reference.init,\n )\n ) {\n return null;\n }\n const declarator = definition.node;\n if (declarator.init !== null) {\n target = unwrapExpression(declarator.init);\n scope = context.sourceCode.getScope(declarator);\n continue;\n }\n const declaration = declarator.parent;\n if (declaration.type !== \"VariableDeclaration\") return null;\n const loop = declaration.parent;\n if (loop.type !== \"ForOfStatement\" || loop.left !== declaration) {\n return null;\n }\n return {\n kind: \"iteration\",\n node: unwrapExpression(loop.right),\n scope: context.sourceCode.getScope(loop.right),\n };\n }\n return { kind: \"expression\", node: target, scope };\n };\n const isKnownNonEmptyNamespace = (\n namespace: unknown,\n scope: Scope,\n ): boolean => {\n const source = resolveStableBinding({\n node: namespace,\n scope,\n seen: new Set<Variable>(),\n });\n if (source?.kind !== \"expression\") return false;\n const text = staticStringValue(source.node);\n // DOM normalizes the empty namespace to null. Unknowns stay checked.\n if (text !== null) return text !== \"\";\n if (source.node?.type !== \"Literal\") return false;\n const { value } = source.node;\n return (\n typeof value === \"number\" ||\n typeof value === \"boolean\" ||\n typeof value === \"bigint\"\n );\n };\n\n const variableFor = (\n identifier: { name: string },\n initialScope: Scope,\n ): Variable | undefined => {\n let current: Scope | null = initialScope;\n while (current !== null) {\n const variable = current.set.get(identifier.name);\n if (variable !== undefined) return variable;\n current = current.upper;\n }\n return undefined;\n };\n const isKnownNonDocumentReceiver = (\n node: unknown,\n scope: Scope,\n ): boolean => {\n const isUnshadowedGlobal = (\n identifier: unknown,\n name: string,\n ): boolean =>\n isIdentifier(identifier, name) &&\n variableFor(identifier, scope) === undefined;\n const isFileSystemImport = (identifier: unknown): boolean => {\n if (!isIdentifier(identifier)) return false;\n const variable = variableFor(identifier, scope);\n if (variable?.defs.length !== 1) return false;\n const definition = variable.defs.at(0);\n return (\n definition?.type === \"ImportBinding\" &&\n definition.parent?.type === \"ImportDeclaration\" &&\n FILE_SYSTEM_MODULES.has(definition.parent.source.value)\n );\n };\n const root = unwrapExpression(node);\n if (isUnshadowedGlobal(root, \"Bun\") || isFileSystemImport(root)) {\n return true;\n }\n return (\n root?.type === \"MemberExpression\" &&\n (memberPropertyName(root) === \"stdout\" ||\n memberPropertyName(root) === \"stderr\") &&\n isUnshadowedGlobal(unwrapExpression(root.object), \"process\")\n );\n };\n const isDocumentReceiver = (node: unknown, scope: Scope): boolean => {\n if (isKnownNonDocumentReceiver(node, scope)) return false;\n const source = resolveStableBinding({\n node,\n scope,\n seen: new Set<Variable>(),\n });\n if (source === null || source.kind !== \"expression\") return true;\n const receiver = source.node;\n if (isIdentifier(receiver, \"document\")) return true;\n if (receiver?.type !== \"MemberExpression\") return false;\n const name = memberPropertyName(receiver);\n return name !== null && DOCUMENT_MEMBERS.has(name);\n };\n\n const isDocumentSinkReceiver = (node: unknown, scope: Scope): boolean => {\n if (isKnownNonDocumentReceiver(node, scope)) return false;\n const receiver = unwrapExpression(node);\n if (!isIdentifier(receiver)) return true;\n let current: Scope | null = scope;\n let variable: Variable | undefined;\n while (current !== null) {\n variable = current.set.get(receiver.name);\n if (variable !== undefined) break;\n current = current.upper;\n }\n if (variable === undefined || variable.defs.length !== 1) return true;\n const definition = variable.defs.at(0);\n if (\n definition?.type !== \"Variable\" ||\n definition.node.type !== \"VariableDeclarator\" ||\n definition.node.id.type !== \"Identifier\" ||\n definition.node.init === null ||\n unwrapExpression(definition.node.init)?.type !== \"ObjectExpression\" ||\n definition.node.parent.type !== \"VariableDeclaration\" ||\n definition.node.parent.kind !== \"const\" ||\n variable.scope.variableScope !== scope.variableScope ||\n variable.references.some(\n (reference) => reference.isWrite() && !reference.init,\n )\n ) {\n return true;\n }\n return false;\n };\n type DomTargetOptions = {\n node: unknown;\n scope: Scope;\n seen?: Set<Variable>;\n kind?: \"element\" | \"collection\";\n };\n const isKnownDomTarget = ({\n node,\n scope,\n seen = new Set<Variable>(),\n kind = \"element\",\n }: DomTargetOptions): boolean => {\n const source = resolveStableBinding({ node, scope, seen });\n // An unstable binding may have been reassigned to a DOM target. Fail\n // closed unless the resolver can prove a stable non-DOM value.\n if (source === null) return true;\n if (source.kind === \"iteration\") {\n return (\n kind === \"element\" &&\n isKnownDomTarget({\n node: source.node,\n scope: source.scope,\n seen,\n kind: \"collection\",\n })\n );\n }\n const target = source.node;\n scope = source.scope;\n const hasProducerReceiver = (\n receiver: unknown,\n producer: DomElementProducer,\n ): boolean => {\n if (\n producer.receiver !== \"element\" &&\n isDocumentReceiver(receiver, scope)\n ) {\n return true;\n }\n return (\n producer.receiver !== \"document\" &&\n isKnownDomTarget({ node: receiver, scope, seen })\n );\n };\n const isElementCollection = (collection: unknown): boolean =>\n isKnownDomTarget({ node: collection, scope, seen, kind: \"collection\" });\n if (target?.type === \"MemberExpression\") {\n const property = memberPropertyName(target);\n const producer = DOM_ELEMENT_PRODUCERS.find(\n (entry) =>\n entry.kind ===\n (kind === \"collection\" ? \"collection-property\" : \"property\") &&\n entry.name === property,\n );\n if (producer !== undefined) {\n return hasProducerReceiver(target.object, producer);\n }\n const index = unwrapExpression(target.property);\n if (\n kind === \"element\" &&\n target.computed === true &&\n index?.type === \"Literal\" &&\n typeof index.value === \"number\" &&\n Number.isInteger(index.value) &&\n index.value >= 0\n ) {\n return isElementCollection(target.object);\n }\n }\n if (target?.type === \"CallExpression\") {\n const callee = invokedCallee(target);\n if (callee?.type !== \"MemberExpression\") return false;\n const method = memberPropertyName(callee);\n if (\n kind === \"element\" &&\n method === \"item\" &&\n isElementCollection(callee.object)\n ) {\n return true;\n }\n const producer = DOM_ELEMENT_PRODUCERS.find(\n (entry) =>\n entry.kind === (kind === \"collection\" ? \"collection\" : \"method\") &&\n entry.name === method,\n );\n return (\n producer !== undefined &&\n hasProducerReceiver(callee.object, producer)\n );\n }\n return kind === \"element\" && isDocumentReceiver(target, scope);\n };\n\n let sanitizerPolicy: SanitizerPolicy = SANITIZER_POLICY.allowlist;\n // Associate waivers after visiting the file, so source position decides\n // the first covered sink even when AST visitors inspect values out of order.\n const waiverLines = new Set<number>();\n type SinkObservation = {\n node: AstNode;\n kind:\n | \"safe\"\n | \"unsafe\"\n | \"opaque-payload-spread\"\n | \"opaque-payload-computed-key\";\n };\n const sinks: SinkObservation[] = [];\n const observeSink = (\n node: unknown,\n kind: SinkObservation[\"kind\"],\n ): void => {\n if (isAstNode(node)) sinks.push({ node, kind });\n };\n const messageIdFor = (kind: SinkObservation[\"kind\"]) => {\n if (kind === \"opaque-payload-spread\") {\n return \"unsafeInnerHtmlSpread\";\n }\n if (kind === \"opaque-payload-computed-key\") {\n return \"unsafeInnerHtmlComputedKey\";\n }\n return \"unsafeInnerHtml\";\n };\n\n const consumeWaiver = (node: unknown): boolean => {\n const line = startLine(node) - 1;\n if (!waiverLines.has(line)) {\n return false;\n }\n waiverLines.delete(line);\n return true;\n };\n\n const reportIfUnsafe = (node: unknown): void => {\n observeSink(\n node,\n isProvenSafeValue(node, sanitizerPolicy) ? \"safe\" : \"unsafe\",\n );\n };\n\n // The value of a `dangerouslySetInnerHTML` prop: an inline object has\n // its `__html` checked and its spreads rejected; anything else is a\n // hoisted payload whose HTML this rule cannot see.\n const checkDangerousPayload = (value: unknown, htmlKey: string): void => {\n const expression = unwrapExpression(value);\n if (expression?.type !== \"ObjectExpression\") {\n reportIfUnsafe(value);\n return;\n }\n for (const property of objectProperties(expression)) {\n if (isOpaqueProperty(property)) {\n observeSink(\n property,\n property.type === \"SpreadElement\"\n ? \"opaque-payload-spread\"\n : \"opaque-payload-computed-key\",\n );\n continue;\n }\n if (\n property.type === \"Property\" &&\n objectPropertyKey(property) === htmlKey\n ) {\n reportIfUnsafe(property.value);\n }\n }\n };\n\n const checkReactHtmlProp = (prop: ReactHtmlProp, value: unknown): void => {\n switch (prop.kind) {\n case \"payload\":\n checkDangerousPayload(value, prop.htmlKey);\n return;\n case \"value\":\n reportIfUnsafe(value);\n return;\n default: {\n const exhaustive: never = prop;\n throw new Error(`Unknown React HTML prop: ${String(exhaustive)}`);\n }\n }\n };\n\n const checkReactProps = (value: unknown): void => {\n for (const property of objectProperties(value)) {\n if (property.type !== \"Property\") continue;\n const key = objectPropertyKey(property);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);\n // Payload properties are checked once by the Property visitor.\n if (prop?.kind === \"value\") checkReactHtmlProp(prop, property.value);\n }\n };\n\n const checkHtmlPropertySources = (\n sources: unknown[],\n domTarget: boolean,\n ): void => {\n for (const source of sources) {\n const expression = unwrapExpression(source);\n if (expression?.type !== \"ObjectExpression\") {\n if (domTarget) {\n reportIfUnsafe(source);\n }\n continue;\n }\n for (const property of objectProperties(source)) {\n if (isOpaqueProperty(property)) {\n if (domTarget) {\n reportIfUnsafe(property);\n }\n continue;\n }\n const key =\n property.type === \"Property\"\n ? objectPropertyKey(property)\n : null;\n if (key !== null && HTML_PROPERTIES.has(key)) {\n reportIfUnsafe(property.value);\n }\n }\n }\n };\n\n return {\n before() {\n sanitizerPolicy = sanitizerPolicyFrom(context.options.at(0));\n waiverLines.clear();\n sinks.length = 0;\n },\n \"Program:exit\"() {\n sinks.sort((left, right) => left.node.range[0] - right.node.range[0]);\n for (const { node, kind } of sinks) {\n const waived = consumeWaiver(node);\n if (kind === \"safe\" || (kind === \"unsafe\" && waived)) continue;\n context.report({\n node,\n messageId: messageIdFor(kind),\n });\n }\n sinks.length = 0;\n },\n Program(node) {\n const comments: unknown[] = Array.isArray(node.comments)\n ? node.comments\n : [];\n for (const comment of comments) {\n if (isWaiverComment(comment)) {\n waiverLines.add(comment.loc.end.line);\n }\n }\n },\n\n JSXAttribute(node) {\n const name = jsxAttributeName(node.name);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === name);\n if (prop === undefined) return;\n const value = unwrapExpression(node.value);\n checkReactHtmlProp(\n prop,\n value?.type === \"JSXExpressionContainer\" ? value.expression : value,\n );\n },\n\n JSXSpreadAttribute(node) {\n checkReactProps(node.argument);\n },\n\n // Payload objects remain checked when hoisted or spread into JSX.\n // Direct value props use the JSX and factory props contexts.\n Property(node) {\n const key = objectPropertyKey(node);\n const prop = REACT_HTML_PROPS.find((entry) => entry.name === key);\n if (prop?.kind !== \"payload\") return;\n const container = node.parent;\n if (isAstNode(container) && container.type === \"ObjectExpression\") {\n checkReactHtmlProp(prop, node.value);\n }\n },\n\n AssignmentExpression(node) {\n const target = unwrapExpression(node.left);\n if (target?.type !== \"MemberExpression\") {\n return;\n }\n const name = memberPropertyName(target);\n if (name !== null && HTML_PROPERTIES.has(name)) {\n reportIfUnsafe(node.right);\n }\n },\n\n CallExpression(node) {\n const call: unknown = node;\n const callee = isAstNode(call) ? invokedCallee(call) : null;\n const invoked = invokedArguments(node);\n const factory = staticCalleeName(callee);\n if (factory !== null && REACT_ELEMENT_FACTORIES.has(factory)) {\n checkReactProps(invoked.args.at(1));\n return;\n }\n if (callee?.type !== \"MemberExpression\") {\n return;\n }\n const method = memberPropertyName(callee);\n if (method === null) {\n return;\n }\n if (HTML_FIRST_ARGUMENT_METHODS.has(method)) {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n reportIfUnsafe(invoked.args.at(0));\n return;\n }\n if (method === \"insertAdjacentHTML\") {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n reportIfUnsafe(invoked.args.at(1));\n return;\n }\n const attributeSink = HTML_ATTRIBUTE_SINKS.find(\n (entry) => entry.name === method,\n );\n if (attributeSink !== undefined) {\n if (\n attributeSink.namespaceIndex !== null &&\n isKnownNonEmptyNamespace(\n invoked.args.at(attributeSink.namespaceIndex),\n context.sourceCode.getScope(node),\n )\n ) {\n return;\n }\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n const attribute = staticStringValue(\n invoked.args.at(attributeSink.nameIndex),\n );\n if (attribute?.toLowerCase() === \"srcdoc\") {\n reportIfUnsafe(invoked.args.at(attributeSink.valueIndex));\n }\n return;\n }\n if (\n DOCUMENT_WRITE_METHODS.has(method) &&\n isDocumentSinkReceiver(\n callee.object,\n context.sourceCode.getScope(node),\n )\n ) {\n if (invoked.status === \"opaque\") {\n reportIfUnsafe(node);\n return;\n }\n observeSink(\n node,\n invoked.args.every((argument) =>\n isProvenSafeValue(argument, sanitizerPolicy),\n )\n ? \"safe\"\n : \"unsafe\",\n );\n return;\n }\n if (isIdentifier(callee.object, \"Object\") && method === \"assign\") {\n const domTarget = isKnownDomTarget({\n node: invoked.args.at(0),\n scope: context.sourceCode.getScope(node),\n });\n checkHtmlPropertySources(\n [\n ...invoked.args.slice(1),\n ...(invoked.status === \"opaque\" ? invoked.tail : []),\n ],\n domTarget,\n );\n if (invoked.status === \"opaque\" && domTarget) {\n reportIfUnsafe(invoked.spread);\n }\n }\n },\n };\n },\n },\n },\n});\n"],"mappings":";;;AA0DA,MAAa,wBAAwB;CACnC;EAAE,MAAM;EAAQ,MAAM;EAAY,UAAU;CAAW;CACvD;EAAE,MAAM;EAAQ,MAAM;EAAY,UAAU;CAAW;CACvD;EAAE,MAAM;EAAmB,MAAM;EAAY,UAAU;CAAW;CAClE;EAAE,MAAM;EAAiB,MAAM;EAAY,UAAU;CAAW;CAChE;EAAE,MAAM;EAAoB,MAAM;EAAY,UAAU;CAAW;CACnE;EAAE,MAAM;EAAqB,MAAM;EAAY,UAAU;CAAW;CACpE;EAAE,MAAM;EAAiB,MAAM;EAAU,UAAU;CAAW;CAC9D;EAAE,MAAM;EAAmB,MAAM;EAAU,UAAU;CAAW;CAChE;EAAE,MAAM;EAAkB,MAAM;EAAU,UAAU;CAAW;CAC/D;EAAE,MAAM;EAAiB,MAAM;EAAU,UAAU;CAAS;CAC5D;EAAE,MAAM;EAAW,MAAM;EAAU,UAAU;CAAU;CACvD;EAAE,MAAM;EAAoB,MAAM;EAAU,UAAU;CAAW;CACjE;EAAE,MAAM;EAA0B,MAAM;EAAc,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;MACA,YACE,MACA,QAAQ,KAAK,OAAO,aAClB,kBAAkB,UAAU,eAAe,CAC7C,IACI,SACA,QACN;MACA;KACF;KACA,IAAI,aAAa,OAAO,QAAQ,QAAQ,KAAK,WAAW,UAAU;MAChE,MAAM,YAAY,iBAAiB;OACjC,MAAM,QAAQ,KAAK,GAAG,CAAC;OACvB,OAAO,QAAQ,WAAW,SAAS,IAAI;MACzC,CAAC;MACD,yBACE,CACE,GAAG,QAAQ,KAAK,MAAM,CAAC,GACvB,GAAI,QAAQ,WAAW,WAAW,QAAQ,OAAO,CAAC,CACpD,GACA,SACF;MACA,IAAI,QAAQ,WAAW,YAAY,WACjC,eAAe,QAAQ,MAAM;KAEjC;IACF;GACF;EACF;CACF,EACF;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isAstNode,
|
|
1
|
+
import { a as isAstNode, f as unwrapExpression, o as isIdentifier, r as getPropertyName, s as isStringLiteral, t as filenameForContext, u as resolveLiteralArraySpreads } from "./utils.mjs";
|
|
2
2
|
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|