tslaws 0.10.0 → 1.1.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/README.md +13 -2
- package/bin/tslaws.js +8 -2
- package/dist/badge.d.ts +64 -0
- package/dist/badge.js +121 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +25 -5
- package/dist/bundled.js +2 -2
- package/dist/bundlerPlugins.d.ts +2 -0
- package/dist/bundlerPlugins.js +7 -0
- package/dist/certificates.d.ts +139 -0
- package/dist/certificates.js +433 -0
- package/dist/chc.d.ts +97 -0
- package/dist/chc.js +307 -0
- package/dist/check.d.ts +13 -1
- package/dist/check.js +218 -31
- package/dist/cli.d.ts +18 -0
- package/dist/cli.js +242 -34
- package/dist/compile.d.ts +15 -5
- package/dist/compile.js +203 -70
- package/dist/coverage.d.ts +38 -1
- package/dist/coverage.js +123 -19
- package/dist/e2eApi.js +3 -1
- package/dist/generators.js +12 -2
- package/dist/github.d.ts +49 -5
- package/dist/github.js +107 -24
- package/dist/githubCli.d.ts +28 -0
- package/dist/githubCli.js +1113 -212
- package/dist/hints.js +2 -1
- package/dist/init.js +42 -0
- package/dist/isolate.d.ts +33 -0
- package/dist/isolate.js +262 -0
- package/dist/isolatedCheck.d.ts +1 -0
- package/dist/isolatedCheck.js +16 -0
- package/dist/lawHost.d.ts +50 -0
- package/dist/lawHost.js +197 -0
- package/dist/lawRuntime.d.ts +45 -0
- package/dist/lawRuntime.js +321 -0
- package/dist/lock.d.ts +49 -9
- package/dist/lock.js +132 -21
- package/dist/mcp.js +28 -7
- package/dist/mutate.d.ts +4 -0
- package/dist/mutate.js +7 -1
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +4 -0
- package/dist/pluginHooks.d.ts +20 -0
- package/dist/pluginHooks.js +57 -0
- package/dist/pluginHost.d.ts +5 -0
- package/dist/pluginHost.js +43 -0
- package/dist/pluginWorker.d.ts +1 -0
- package/dist/pluginWorker.js +40 -0
- package/dist/plural.d.ts +2 -0
- package/dist/plural.js +4 -0
- package/dist/pool.d.ts +80 -7
- package/dist/pool.js +222 -11
- package/dist/projects.d.ts +43 -1
- package/dist/projects.js +283 -11
- package/dist/promote.d.ts +56 -2
- package/dist/promote.js +429 -13
- package/dist/property.js +5 -1
- package/dist/propertyWorker.js +9 -4
- package/dist/proposals.d.ts +52 -4
- package/dist/proposals.js +484 -21
- package/dist/reporters.js +5 -1
- package/dist/runtimeEnv.d.ts +13 -5
- package/dist/runtimeEnv.js +48 -10
- package/dist/sandbox.d.ts +98 -0
- package/dist/sandbox.js +673 -0
- package/dist/sandboxGuard.d.ts +56 -0
- package/dist/sandboxGuard.js +249 -0
- package/dist/seal.d.ts +9 -0
- package/dist/seal.js +426 -0
- package/dist/security/cli.d.ts +6 -0
- package/dist/security/cli.js +39 -0
- package/dist/security/cwe.d.ts +14 -0
- package/dist/security/cwe.js +40 -0
- package/dist/security/deps/cache.d.ts +28 -0
- package/dist/security/deps/cache.js +107 -0
- package/dist/security/deps/config.d.ts +16 -0
- package/dist/security/deps/config.js +43 -0
- package/dist/security/deps/imports.d.ts +4 -0
- package/dist/security/deps/imports.js +33 -0
- package/dist/security/deps/lockfiles.d.ts +23 -0
- package/dist/security/deps/lockfiles.js +153 -0
- package/dist/security/deps/osv.d.ts +66 -0
- package/dist/security/deps/osv.js +137 -0
- package/dist/security/deps/run.d.ts +54 -0
- package/dist/security/deps/run.js +135 -0
- package/dist/security/deps/severity.d.ts +26 -0
- package/dist/security/deps/severity.js +78 -0
- package/dist/security/generators.d.ts +9 -0
- package/dist/security/generators.js +36 -0
- package/dist/security/index.d.ts +27 -0
- package/dist/security/index.js +18 -0
- package/dist/security/integers.d.ts +31 -0
- package/dist/security/integers.js +105 -0
- package/dist/security/law.d.ts +54 -0
- package/dist/security/law.js +54 -0
- package/dist/security/pathTraversal.d.ts +29 -0
- package/dist/security/pathTraversal.js +146 -0
- package/dist/security/prototypePollution.d.ts +30 -0
- package/dist/security/prototypePollution.js +142 -0
- package/dist/security/redirect.d.ts +21 -0
- package/dist/security/redirect.js +154 -0
- package/dist/security/redos.d.ts +21 -0
- package/dist/security/redos.js +93 -0
- package/dist/security/validation.d.ts +25 -0
- package/dist/security/validation.js +89 -0
- package/dist/security/xss.d.ts +21 -0
- package/dist/security/xss.js +90 -0
- package/dist/settings.d.ts +20 -0
- package/dist/settings.js +32 -0
- package/dist/smt.d.ts +37 -1
- package/dist/smt.js +277 -111
- package/dist/smtWorker.d.ts +1 -0
- package/dist/smtWorker.js +26 -0
- package/dist/solvers.d.ts +9 -0
- package/dist/solvers.js +11 -5
- package/dist/symbolic.d.ts +54 -1
- package/dist/symbolic.js +239 -13
- package/dist/tsconfigResolve.d.ts +28 -0
- package/dist/tsconfigResolve.js +141 -0
- package/dist/types.d.ts +33 -0
- package/hooks/claude-hook.mjs +2 -0
- package/package.json +19 -7
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Severity = 'unknown' | 'low' | 'moderate' | 'high' | 'critical';
|
|
2
|
+
/** 0 for unknown, up to 4 for critical. */
|
|
3
|
+
export declare function severityRank(severity: Severity): number;
|
|
4
|
+
/** `medium` is read as `moderate`. Undefined for text that names no level. */
|
|
5
|
+
export declare function parseSeverity(text: unknown): Severity | undefined;
|
|
6
|
+
/** The CVSS v3.0 and v3.1 base score of a vector string, or undefined for any other vector (v2 and v4 are not read). */
|
|
7
|
+
export declare function cvssScore(vector: string): number | undefined;
|
|
8
|
+
export declare function severityOfScore(score: number): Severity;
|
|
9
|
+
interface Rated {
|
|
10
|
+
id?: string;
|
|
11
|
+
severity?: {
|
|
12
|
+
type?: string;
|
|
13
|
+
score?: string;
|
|
14
|
+
}[];
|
|
15
|
+
database_specific?: {
|
|
16
|
+
severity?: unknown;
|
|
17
|
+
};
|
|
18
|
+
affected?: {
|
|
19
|
+
ecosystem_specific?: {
|
|
20
|
+
severity?: unknown;
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
/** The severity of an OSV record: the rating it names, else its CVSS v3 score; `MAL-` records (malicious packages) are critical. */
|
|
25
|
+
export declare function severityOf(vuln: Rated): Severity;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Advisory severity: the GitHub rating when the record has one, otherwise the CVSS v3 base score worked out from the vector.
|
|
2
|
+
const ranks = { unknown: 0, low: 1, moderate: 2, high: 3, critical: 4 };
|
|
3
|
+
/** 0 for unknown, up to 4 for critical. */
|
|
4
|
+
export function severityRank(severity) {
|
|
5
|
+
return ranks[severity];
|
|
6
|
+
}
|
|
7
|
+
/** `medium` is read as `moderate`. Undefined for text that names no level. */
|
|
8
|
+
export function parseSeverity(text) {
|
|
9
|
+
if (typeof text !== 'string')
|
|
10
|
+
return undefined;
|
|
11
|
+
const lower = text.trim().toLowerCase();
|
|
12
|
+
if (lower === 'medium')
|
|
13
|
+
return 'moderate';
|
|
14
|
+
return lower === 'low' || lower === 'moderate' || lower === 'high' || lower === 'critical' ? lower : undefined;
|
|
15
|
+
}
|
|
16
|
+
const weights = {
|
|
17
|
+
AV: { N: 0.85, A: 0.62, L: 0.55, P: 0.2 },
|
|
18
|
+
AC: { L: 0.77, H: 0.44 },
|
|
19
|
+
UI: { N: 0.85, R: 0.62 },
|
|
20
|
+
CIA: { H: 0.56, L: 0.22, N: 0 },
|
|
21
|
+
};
|
|
22
|
+
function roundUp(value) {
|
|
23
|
+
const scaled = Math.round(value * 100000);
|
|
24
|
+
return scaled % 10000 === 0 ? scaled / 100000 : (Math.floor(scaled / 10000) + 1) / 10;
|
|
25
|
+
}
|
|
26
|
+
/** The CVSS v3.0 and v3.1 base score of a vector string, or undefined for any other vector (v2 and v4 are not read). */
|
|
27
|
+
export function cvssScore(vector) {
|
|
28
|
+
if (!/^CVSS:3\.[01]\//.test(vector))
|
|
29
|
+
return undefined;
|
|
30
|
+
const metrics = new Map(vector
|
|
31
|
+
.split('/')
|
|
32
|
+
.slice(1)
|
|
33
|
+
.map((part) => part.split(':')));
|
|
34
|
+
const get = (key) => metrics.get(key);
|
|
35
|
+
const changed = get('S') === 'C';
|
|
36
|
+
const av = weights.AV[get('AV')];
|
|
37
|
+
const ac = weights.AC[get('AC')];
|
|
38
|
+
const ui = weights.UI[get('UI')];
|
|
39
|
+
const privilege = get('PR');
|
|
40
|
+
const pr = privilege === 'N'
|
|
41
|
+
? 0.85
|
|
42
|
+
: privilege === 'L'
|
|
43
|
+
? changed
|
|
44
|
+
? 0.68
|
|
45
|
+
: 0.62
|
|
46
|
+
: privilege === 'H'
|
|
47
|
+
? changed
|
|
48
|
+
? 0.5
|
|
49
|
+
: 0.27
|
|
50
|
+
: undefined;
|
|
51
|
+
const c = weights.CIA[get('C')];
|
|
52
|
+
const i = weights.CIA[get('I')];
|
|
53
|
+
const a = weights.CIA[get('A')];
|
|
54
|
+
if ([av, ac, ui, pr, c, i, a].some((n) => n === undefined) || (get('S') !== 'C' && get('S') !== 'U'))
|
|
55
|
+
return undefined;
|
|
56
|
+
const iss = 1 - (1 - c) * (1 - i) * (1 - a);
|
|
57
|
+
const impact = changed ? 7.52 * (iss - 0.029) - 3.25 * (iss - 0.02) ** 15 : 6.42 * iss;
|
|
58
|
+
if (impact <= 0)
|
|
59
|
+
return 0;
|
|
60
|
+
const exploitability = 8.22 * av * ac * pr * ui;
|
|
61
|
+
return roundUp(Math.min(changed ? 1.08 * (impact + exploitability) : impact + exploitability, 10));
|
|
62
|
+
}
|
|
63
|
+
export function severityOfScore(score) {
|
|
64
|
+
return score >= 9 ? 'critical' : score >= 7 ? 'high' : score >= 4 ? 'moderate' : score > 0 ? 'low' : 'unknown';
|
|
65
|
+
}
|
|
66
|
+
/** The severity of an OSV record: the rating it names, else its CVSS v3 score; `MAL-` records (malicious packages) are critical. */
|
|
67
|
+
export function severityOf(vuln) {
|
|
68
|
+
const named = parseSeverity(vuln.database_specific?.severity) ??
|
|
69
|
+
vuln.affected?.map((a) => parseSeverity(a.ecosystem_specific?.severity)).find((s) => s !== undefined);
|
|
70
|
+
if (named !== undefined)
|
|
71
|
+
return named;
|
|
72
|
+
for (const entry of vuln.severity ?? []) {
|
|
73
|
+
const score = typeof entry.score === 'string' ? cvssScore(entry.score) : undefined;
|
|
74
|
+
if (score !== undefined)
|
|
75
|
+
return severityOfScore(score);
|
|
76
|
+
}
|
|
77
|
+
return vuln.id?.startsWith('MAL-') === true ? 'critical' : 'unknown';
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the generator for each payload type (`PathPayload`, `HtmlPayload`, `PollutionPayload`, `PollutionPath`,
|
|
3
|
+
* `UntrustedInput`, `RedosAttack`, `IntPair`, `RedirectTarget`) in the same registry `arbitrary()` writes to. `tslaws/security` runs
|
|
4
|
+
* it when it loads, and the runner when a law parameter has one of these types declared by tslaws; call it again only to
|
|
5
|
+
* restore these after a test replaced one.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerSecurityGenerators(): void;
|
|
8
|
+
/** The type names `registerSecurityGenerators` fills in. */
|
|
9
|
+
export declare const securityTypeNames: ReadonlySet<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The generators a law parameter gets from the name of its type (`PathPayload`, `HtmlPayload`, ...). Kept apart from
|
|
2
|
+
// index.ts so the runner can register them without loading the OSV check and the config reader.
|
|
3
|
+
import * as fc from 'fast-check';
|
|
4
|
+
import { htmlPayloads } from "./xss.js";
|
|
5
|
+
import { intPairs } from "./integers.js";
|
|
6
|
+
import { pathPayloads } from "./pathTraversal.js";
|
|
7
|
+
import { pollutionPaths, pollutionPayloads } from "./prototypePollution.js";
|
|
8
|
+
import { redirectTargets } from "./redirect.js";
|
|
9
|
+
import { redosAttacks } from "./redos.js";
|
|
10
|
+
import { validationCorpus } from "./validation.js";
|
|
11
|
+
/** The generators a law parameter gets from its type name. */
|
|
12
|
+
const generators = {
|
|
13
|
+
PathPayload: pathPayloads(),
|
|
14
|
+
HtmlPayload: htmlPayloads(),
|
|
15
|
+
PollutionPayload: pollutionPayloads(),
|
|
16
|
+
PollutionPath: pollutionPaths(),
|
|
17
|
+
UntrustedInput: fc.oneof(fc.constantFrom(...validationCorpus), fc.string({ unit: 'binary' })),
|
|
18
|
+
RedosAttack: redosAttacks(),
|
|
19
|
+
IntPair: intPairs(),
|
|
20
|
+
RedirectTarget: redirectTargets(),
|
|
21
|
+
};
|
|
22
|
+
const registryKey = Symbol.for('tslaws.arbitraries');
|
|
23
|
+
/**
|
|
24
|
+
* Registers the generator for each payload type (`PathPayload`, `HtmlPayload`, `PollutionPayload`, `PollutionPath`,
|
|
25
|
+
* `UntrustedInput`, `RedosAttack`, `IntPair`, `RedirectTarget`) in the same registry `arbitrary()` writes to. `tslaws/security` runs
|
|
26
|
+
* it when it loads, and the runner when a law parameter has one of these types declared by tslaws; call it again only to
|
|
27
|
+
* restore these after a test replaced one.
|
|
28
|
+
*/
|
|
29
|
+
export function registerSecurityGenerators() {
|
|
30
|
+
const holder = globalThis;
|
|
31
|
+
const registry = (holder[registryKey] ??= new Map());
|
|
32
|
+
for (const [name, generator] of Object.entries(generators))
|
|
33
|
+
registry.set(name, generator);
|
|
34
|
+
}
|
|
35
|
+
/** The type names `registerSecurityGenerators` fills in. */
|
|
36
|
+
export const securityTypeNames = new Set(Object.keys(generators));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { cweCatalog, cweLabel, CweViolation } from './cwe.ts';
|
|
2
|
+
export type { CweId } from './cwe.ts';
|
|
3
|
+
export { securityLaw } from './law.ts';
|
|
4
|
+
export type { SecurityLaw, SecurityLawSpec, SecurityOutcome } from './law.ts';
|
|
5
|
+
export { pathCorpus, pathPayloads, pathTraversal } from './pathTraversal.ts';
|
|
6
|
+
export type { PathPayload, PathTraversalOptions } from './pathTraversal.ts';
|
|
7
|
+
export { htmlCorpus, htmlEscaping, htmlPayloads } from './xss.ts';
|
|
8
|
+
export type { HtmlEscapeOptions, HtmlPayload } from './xss.ts';
|
|
9
|
+
export { marker as pollutionMarker, pollutionCorpus, pollutionPathCorpus, pollutionPaths, pollutionPayloads, prototypeSafeMerge, prototypeSafeParse, prototypeSafeSet, } from './prototypePollution.ts';
|
|
10
|
+
export type { PollutionPath, PollutionPayload, PrototypeSafeSetOptions } from './prototypePollution.ts';
|
|
11
|
+
export { redos, redosAttacks } from './redos.ts';
|
|
12
|
+
export type { RedosAttack, RedosOptions } from './redos.ts';
|
|
13
|
+
export { inputValidation, mutations, validationCorpus } from './validation.ts';
|
|
14
|
+
export type { UntrustedInput, ValidationOptions } from './validation.ts';
|
|
15
|
+
export { intPairs, safeArithmetic } from './integers.ts';
|
|
16
|
+
export type { IntPair, SafeArithmeticOptions } from './integers.ts';
|
|
17
|
+
export { openRedirect, redirectCorpus, redirectTargets } from './redirect.ts';
|
|
18
|
+
export type { OpenRedirectOptions, RedirectTarget } from './redirect.ts';
|
|
19
|
+
export { checkDeps, renderDeps } from './deps/run.ts';
|
|
20
|
+
export type { DepsOptions, DepsReport, Finding } from './deps/run.ts';
|
|
21
|
+
export { defaultSecurityConfig, parseSecurityConfig } from './deps/config.ts';
|
|
22
|
+
export type { SecurityConfig } from './deps/config.ts';
|
|
23
|
+
export type { Advisory, FetchLike } from './deps/osv.ts';
|
|
24
|
+
export { severityRank } from './deps/severity.ts';
|
|
25
|
+
export type { Severity } from './deps/severity.ts';
|
|
26
|
+
import { registerSecurityGenerators } from './generators.ts';
|
|
27
|
+
export { registerSecurityGenerators };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// `tslaws/security`: CWE-tagged law builders for a project's own functions, and the OSV check of covered dependencies.
|
|
2
|
+
// A builder returns a SecurityLaw: use `.holds(input)` as a law body, or `.run()` / `.assert()` in a plain test.
|
|
3
|
+
export { cweCatalog, cweLabel, CweViolation } from "./cwe.js";
|
|
4
|
+
export { securityLaw } from "./law.js";
|
|
5
|
+
export { pathCorpus, pathPayloads, pathTraversal } from "./pathTraversal.js";
|
|
6
|
+
export { htmlCorpus, htmlEscaping, htmlPayloads } from "./xss.js";
|
|
7
|
+
export { marker as pollutionMarker, pollutionCorpus, pollutionPathCorpus, pollutionPaths, pollutionPayloads, prototypeSafeMerge, prototypeSafeParse, prototypeSafeSet, } from "./prototypePollution.js";
|
|
8
|
+
export { redos, redosAttacks } from "./redos.js";
|
|
9
|
+
export { inputValidation, mutations, validationCorpus } from "./validation.js";
|
|
10
|
+
export { intPairs, safeArithmetic } from "./integers.js";
|
|
11
|
+
export { openRedirect, redirectCorpus, redirectTargets } from "./redirect.js";
|
|
12
|
+
export { checkDeps, renderDeps } from "./deps/run.js";
|
|
13
|
+
export { defaultSecurityConfig, parseSecurityConfig } from "./deps/config.js";
|
|
14
|
+
export { severityRank } from "./deps/severity.js";
|
|
15
|
+
import { registerSecurityGenerators } from "./generators.js";
|
|
16
|
+
export { registerSecurityGenerators };
|
|
17
|
+
/** Registers the generator for each payload type when `tslaws/security` loads. */
|
|
18
|
+
registerSecurityGenerators();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
import type { SecurityLaw } from './law.ts';
|
|
3
|
+
/** Two operands for a law parameter: `law add(p: IntPair) => safeAdd.holds(p)`. Generated by `intPairs`. */
|
|
4
|
+
export interface IntPair {
|
|
5
|
+
a: number;
|
|
6
|
+
b: number;
|
|
7
|
+
}
|
|
8
|
+
/** Operands at the edges of 8, 16, 32 and 53 bits, plus uniform safe integers and numbers whose product or sum crosses 2^53. */
|
|
9
|
+
export declare function intPairs(options?: {
|
|
10
|
+
unsafeInputs?: boolean;
|
|
11
|
+
}): fc.Arbitrary<IntPair>;
|
|
12
|
+
export interface SafeArithmeticOptions {
|
|
13
|
+
/** The exact operation: `add`, `sub`, `mul`, or your own on bigints (a pow, a ceil-div, a size computation). */
|
|
14
|
+
exact: 'add' | 'sub' | 'mul' | ((a: bigint, b: bigint) => bigint);
|
|
15
|
+
/**
|
|
16
|
+
* What an out-of-range result may be. `refuse` (the default): the helper throws or returns NaN, null or undefined.
|
|
17
|
+
* `saturate`: it may also return the safe-integer limit of the right sign.
|
|
18
|
+
*/
|
|
19
|
+
overflow?: 'refuse' | 'saturate';
|
|
20
|
+
/**
|
|
21
|
+
* Also feed operands that are not safe integers (above 2^53, fractions, NaN, Infinity); the helper must refuse them
|
|
22
|
+
* (CWE-681: a conversion that quietly loses precision). Default false.
|
|
23
|
+
*/
|
|
24
|
+
unsafeInputs?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* CWE-190 and CWE-681. For safe-integer operands `op(a, b)` must return the exact result when it is a safe integer,
|
|
28
|
+
* and otherwise throw (or return NaN, null or undefined; or saturate, if allowed). A result that is rounded, wrapped
|
|
29
|
+
* or past 2^53 - 1 fails, as does an unrefused operand that is not a safe integer when `unsafeInputs` is set.
|
|
30
|
+
*/
|
|
31
|
+
export declare function safeArithmetic(op: (a: number, b: number) => unknown, options: SafeArithmeticOptions): SecurityLaw<IntPair>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// CWE-190 / CWE-681: an arithmetic helper on integers never returns a wrong or unsafe result silently.
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
import { show } from "./cwe.js";
|
|
4
|
+
import { securityLaw } from "./law.js";
|
|
5
|
+
const max = Number.MAX_SAFE_INTEGER;
|
|
6
|
+
const edges = [
|
|
7
|
+
0,
|
|
8
|
+
1,
|
|
9
|
+
-1,
|
|
10
|
+
2,
|
|
11
|
+
-2,
|
|
12
|
+
255,
|
|
13
|
+
256,
|
|
14
|
+
65535,
|
|
15
|
+
65536,
|
|
16
|
+
2 ** 31 - 1,
|
|
17
|
+
2 ** 31,
|
|
18
|
+
-(2 ** 31),
|
|
19
|
+
2 ** 32 - 1,
|
|
20
|
+
2 ** 32,
|
|
21
|
+
2 ** 26,
|
|
22
|
+
2 ** 26 + 1,
|
|
23
|
+
2 ** 27,
|
|
24
|
+
2 ** 52,
|
|
25
|
+
2 ** 53 - 2,
|
|
26
|
+
max - 1,
|
|
27
|
+
max,
|
|
28
|
+
-max,
|
|
29
|
+
-max + 1,
|
|
30
|
+
];
|
|
31
|
+
/** Operands at the edges of 8, 16, 32 and 53 bits, plus uniform safe integers and numbers whose product or sum crosses 2^53. */
|
|
32
|
+
export function intPairs(options = {}) {
|
|
33
|
+
const near = fc.constantFrom(...edges);
|
|
34
|
+
const wide = fc.integer({ min: -max, max });
|
|
35
|
+
const bits = fc
|
|
36
|
+
.tuple(fc.integer({ min: 1, max: 53 }), fc.boolean())
|
|
37
|
+
.chain(([n, negative]) => fc.integer({ min: 0, max: 2 ** n - 1 }).map((v) => (negative ? -v : v)));
|
|
38
|
+
const operand = fc.oneof({ weight: 4, arbitrary: near }, { weight: 2, arbitrary: wide }, { weight: 4, arbitrary: bits });
|
|
39
|
+
const safe = fc.record({ a: operand, b: operand });
|
|
40
|
+
if (options.unsafeInputs !== true)
|
|
41
|
+
return safe;
|
|
42
|
+
const unsafe = fc.constantFrom(max + 1, max + 2, -max - 2, 2 ** 53 + 2, 2 ** 60, 1.5, -0.5, NaN, Infinity, -Infinity);
|
|
43
|
+
return fc.oneof({ weight: 6, arbitrary: safe }, { weight: 1, arbitrary: fc.record({ a: unsafe, b: operand }) }, { weight: 1, arbitrary: fc.record({ a: operand, b: unsafe }) });
|
|
44
|
+
}
|
|
45
|
+
const operations = {
|
|
46
|
+
add: (a, b) => a + b,
|
|
47
|
+
sub: (a, b) => a - b,
|
|
48
|
+
mul: (a, b) => a * b,
|
|
49
|
+
};
|
|
50
|
+
const bigMax = BigInt(max);
|
|
51
|
+
/**
|
|
52
|
+
* CWE-190 and CWE-681. For safe-integer operands `op(a, b)` must return the exact result when it is a safe integer,
|
|
53
|
+
* and otherwise throw (or return NaN, null or undefined; or saturate, if allowed). A result that is rounded, wrapped
|
|
54
|
+
* or past 2^53 - 1 fails, as does an unrefused operand that is not a safe integer when `unsafeInputs` is set.
|
|
55
|
+
*/
|
|
56
|
+
export function safeArithmetic(op, options) {
|
|
57
|
+
const exactOf = typeof options.exact === 'function' ? options.exact : operations[options.exact];
|
|
58
|
+
const refused = (r) => r === undefined || r === null || (typeof r === 'number' && Number.isNaN(r));
|
|
59
|
+
return securityLaw({
|
|
60
|
+
id: 'safe-arithmetic',
|
|
61
|
+
cwe: ['CWE-190', 'CWE-681'],
|
|
62
|
+
title: 'an integer helper returns the exact result or refuses; it never overflows or rounds silently',
|
|
63
|
+
input: intPairs({ unsafeInputs: options.unsafeInputs }),
|
|
64
|
+
corpus: edges.flatMap((a) => [
|
|
65
|
+
{ a, b: max },
|
|
66
|
+
{ a, b: -max },
|
|
67
|
+
{ a, b: 2 ** 27 },
|
|
68
|
+
]),
|
|
69
|
+
verdict: ({ a, b }) => {
|
|
70
|
+
const call = `op(${show(a)}, ${show(b)})`;
|
|
71
|
+
let result;
|
|
72
|
+
try {
|
|
73
|
+
result = op(a, b);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b))
|
|
79
|
+
return options.unsafeInputs === true && !refused(result)
|
|
80
|
+
? { cwe: ['CWE-681'], detail: `${call} returned ${show(result)} for an operand that is not a safe integer` }
|
|
81
|
+
: undefined;
|
|
82
|
+
if (refused(result))
|
|
83
|
+
return undefined;
|
|
84
|
+
const exact = exactOf(BigInt(a), BigInt(b));
|
|
85
|
+
if (typeof result === 'bigint')
|
|
86
|
+
return result === exact
|
|
87
|
+
? undefined
|
|
88
|
+
: { cwe: ['CWE-190'], detail: `${call} returned ${show(String(result))}, not ${show(String(exact))}` };
|
|
89
|
+
if (typeof result !== 'number')
|
|
90
|
+
return { cwe: ['CWE-681'], detail: `${call} returned ${show(result)}, not a number` };
|
|
91
|
+
const inRange = exact <= bigMax && exact >= -bigMax;
|
|
92
|
+
if (!inRange) {
|
|
93
|
+
if (options.overflow === 'saturate' && result === (exact > 0n ? max : -max))
|
|
94
|
+
return undefined;
|
|
95
|
+
return {
|
|
96
|
+
cwe: ['CWE-190'],
|
|
97
|
+
detail: `${call} returned ${show(result)}, but the exact result ${exact} is not a safe integer`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (!Number.isSafeInteger(result) || BigInt(result) !== exact)
|
|
101
|
+
return { cwe: ['CWE-190'], detail: `${call} returned ${show(result)}, but the exact result is ${exact}` };
|
|
102
|
+
return undefined;
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
import type { CweId } from './cwe.ts';
|
|
3
|
+
/** The result of `SecurityLaw.run`, for a plain test or a script outside `tslaws check`. */
|
|
4
|
+
export interface SecurityOutcome {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
cwe: readonly CweId[];
|
|
8
|
+
runs: number;
|
|
9
|
+
seed: number;
|
|
10
|
+
/** The first failing input, shown as JSON. */
|
|
11
|
+
counterexample?: string;
|
|
12
|
+
/** `[CWE-22] ...`: the CWE tag and why the input breaks the property. */
|
|
13
|
+
message?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SecurityLaw<I> {
|
|
16
|
+
/** Stable name of the builder, as in `path-traversal`. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly cwe: readonly CweId[];
|
|
19
|
+
readonly title: string;
|
|
20
|
+
/** Adversarial inputs for the law's parameter. */
|
|
21
|
+
readonly input: fc.Arbitrary<I>;
|
|
22
|
+
/** Why `input` breaks the property, or undefined when it holds. Does not throw for a violation. */
|
|
23
|
+
verdict(input: I): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Use it as the body of a law: `law x(p: PathPayload) => traversal.holds(p)`. Checks the builder's fixed corpus of
|
|
26
|
+
* attacks and then `input`; returns true, or throws a CweViolation so the report carries the CWE and the reason.
|
|
27
|
+
*/
|
|
28
|
+
holds(input: I): true;
|
|
29
|
+
/** Runs the property on its own with fast-check (corpus first), without the `tslaws check` runner. */
|
|
30
|
+
run(options?: {
|
|
31
|
+
runs?: number;
|
|
32
|
+
seed?: number;
|
|
33
|
+
}): SecurityOutcome;
|
|
34
|
+
/** `run`, then throws a CweViolation if it failed. */
|
|
35
|
+
assert(options?: {
|
|
36
|
+
runs?: number;
|
|
37
|
+
seed?: number;
|
|
38
|
+
}): void;
|
|
39
|
+
}
|
|
40
|
+
export interface SecurityLawSpec<I> {
|
|
41
|
+
id: string;
|
|
42
|
+
cwe: readonly CweId[];
|
|
43
|
+
title: string;
|
|
44
|
+
input: fc.Arbitrary<I>;
|
|
45
|
+
/** Fixed attacks checked on every call before the generated input. */
|
|
46
|
+
corpus?: readonly I[];
|
|
47
|
+
/** Returns the reason an input breaks the property, or undefined. The reason already carries its CWE tag choice. */
|
|
48
|
+
verdict(input: I): {
|
|
49
|
+
cwe?: readonly CweId[];
|
|
50
|
+
detail: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** Builds a SecurityLaw from a verdict. */
|
|
54
|
+
export declare function securityLaw<I>(spec: SecurityLawSpec<I>): SecurityLaw<I>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The shape every builder of the pack returns: a generator of adversarial inputs plus a check, tagged with its CWE.
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
import { CweViolation, cweLabel, show } from "./cwe.js";
|
|
4
|
+
/** Builds a SecurityLaw from a verdict. */
|
|
5
|
+
export function securityLaw(spec) {
|
|
6
|
+
const failure = (input) => {
|
|
7
|
+
const found = spec.verdict(input);
|
|
8
|
+
return found === undefined ? undefined : new CweViolation(found.cwe ?? spec.cwe, found.detail);
|
|
9
|
+
};
|
|
10
|
+
const holds = (input) => {
|
|
11
|
+
for (const attack of spec.corpus ?? []) {
|
|
12
|
+
const bad = failure(attack);
|
|
13
|
+
if (bad !== undefined)
|
|
14
|
+
throw bad;
|
|
15
|
+
}
|
|
16
|
+
const bad = failure(input);
|
|
17
|
+
if (bad !== undefined)
|
|
18
|
+
throw bad;
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
const runDetailed = (options = {}) => {
|
|
22
|
+
const runs = options.runs ?? 200;
|
|
23
|
+
const seed = options.seed ?? Date.now() % 2 ** 31;
|
|
24
|
+
const base = { id: spec.id, cwe: spec.cwe, runs, seed };
|
|
25
|
+
for (const attack of spec.corpus ?? []) {
|
|
26
|
+
const bad = failure(attack);
|
|
27
|
+
if (bad !== undefined)
|
|
28
|
+
return [{ ok: false, ...base, counterexample: show(attack), message: bad.message }, bad];
|
|
29
|
+
}
|
|
30
|
+
const details = fc.check(fc.property(spec.input, (input) => failure(input) === undefined), { numRuns: runs, seed });
|
|
31
|
+
if (!details.failed)
|
|
32
|
+
return [{ ok: true, ...base }, undefined];
|
|
33
|
+
const counter = details.counterexample?.[0];
|
|
34
|
+
const bad = failure(counter);
|
|
35
|
+
return [{ ok: false, ...base, counterexample: show(counter), message: bad?.message }, bad];
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
id: spec.id,
|
|
39
|
+
cwe: spec.cwe,
|
|
40
|
+
title: spec.title,
|
|
41
|
+
input: spec.input,
|
|
42
|
+
verdict: (input) => {
|
|
43
|
+
const found = spec.verdict(input);
|
|
44
|
+
return found === undefined ? undefined : `[${cweLabel(found.cwe ?? spec.cwe)}] ${found.detail}`;
|
|
45
|
+
},
|
|
46
|
+
holds,
|
|
47
|
+
run: (options) => runDetailed(options)[0],
|
|
48
|
+
assert: (options) => {
|
|
49
|
+
const [outcome, bad] = runDetailed(options);
|
|
50
|
+
if (!outcome.ok)
|
|
51
|
+
throw new CweViolation(bad?.cwe ?? spec.cwe, `${bad?.detail ?? 'failed'} (input ${outcome.counterexample ?? '?'})`);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
import type { SecurityLaw } from './law.ts';
|
|
3
|
+
/** A hostile path for a law parameter: `law safe(p: PathPayload) => traversal.holds(p)`. Generated by `pathPayloads`. */
|
|
4
|
+
export type PathPayload = string & {
|
|
5
|
+
readonly __tslawsPath: true;
|
|
6
|
+
};
|
|
7
|
+
/** The fixed attacks `holds` checks on every call. */
|
|
8
|
+
export declare const pathCorpus: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* Paths a sanitiser must not let out of its base: `../`, encoded and double-encoded dots, absolute roots, drive
|
|
11
|
+
* letters, UNC shares, a null byte and Windows separators, mixed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function pathPayloads(): fc.Arbitrary<PathPayload>;
|
|
14
|
+
export interface PathTraversalOptions {
|
|
15
|
+
/** The directory the result must stay inside. */
|
|
16
|
+
base: string;
|
|
17
|
+
/**
|
|
18
|
+
* Which path rules the result is read under. `both` (the default) needs it to stay inside under POSIX and Windows
|
|
19
|
+
* rules, since the same string reaches either. `posix` and `win32` check one.
|
|
20
|
+
*/
|
|
21
|
+
flavour?: 'posix' | 'win32' | 'both';
|
|
22
|
+
/** Also read the result as URL-encoded once, for code that decodes the path later. Default false. */
|
|
23
|
+
checkDecoded?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* CWE-22. `sanitise(input)` must return a path that, resolved against `base`, stays inside it (or throw, or return
|
|
27
|
+
* nothing, to refuse the input). The result may be relative to `base` or absolute. A null byte in the result fails too.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pathTraversal(sanitise: (input: string) => unknown, options: PathTraversalOptions): SecurityLaw<PathPayload>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// CWE-22: a path sanitiser never returns a path outside a base directory.
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
import { posix, win32 } from 'node:path';
|
|
4
|
+
import { show } from "./cwe.js";
|
|
5
|
+
import { securityLaw } from "./law.js";
|
|
6
|
+
const tokens = [
|
|
7
|
+
'..',
|
|
8
|
+
'.',
|
|
9
|
+
'...',
|
|
10
|
+
'....',
|
|
11
|
+
'%2e%2e',
|
|
12
|
+
'%2E%2E',
|
|
13
|
+
'%252e%252e',
|
|
14
|
+
'..%c0%af',
|
|
15
|
+
'..%ef%bc%8f',
|
|
16
|
+
'\u2025',
|
|
17
|
+
'%u002e%u002e',
|
|
18
|
+
];
|
|
19
|
+
const separators = [
|
|
20
|
+
'/',
|
|
21
|
+
'\\',
|
|
22
|
+
'//',
|
|
23
|
+
'\\\\',
|
|
24
|
+
'/./',
|
|
25
|
+
'\\/',
|
|
26
|
+
'/\\',
|
|
27
|
+
'%2f',
|
|
28
|
+
'%5c',
|
|
29
|
+
'%252f',
|
|
30
|
+
'..;/',
|
|
31
|
+
'%00/',
|
|
32
|
+
'\0/',
|
|
33
|
+
'\uff0f',
|
|
34
|
+
'%c0%af',
|
|
35
|
+
];
|
|
36
|
+
const roots = [
|
|
37
|
+
'',
|
|
38
|
+
'/',
|
|
39
|
+
'\\',
|
|
40
|
+
'C:\\',
|
|
41
|
+
'c:/',
|
|
42
|
+
'C:',
|
|
43
|
+
'\\\\server\\share\\',
|
|
44
|
+
'//server/share/',
|
|
45
|
+
'\\\\?\\C:\\',
|
|
46
|
+
'/etc/',
|
|
47
|
+
'file:///',
|
|
48
|
+
'~/',
|
|
49
|
+
'%2f',
|
|
50
|
+
'\0',
|
|
51
|
+
];
|
|
52
|
+
const names = ['etc', 'passwd', 'win.ini', 'a', 'b', 'secret.txt', '.env', 'index.html', '..%00.png', ''];
|
|
53
|
+
const suffixes = ['', '\0', '\0.png', '%00', '%00.png', ' ', '.', '/', '\\', '...', '::$DATA'];
|
|
54
|
+
/** The fixed attacks `holds` checks on every call. */
|
|
55
|
+
export const pathCorpus = [
|
|
56
|
+
'../etc/passwd',
|
|
57
|
+
'..\\windows\\win.ini',
|
|
58
|
+
'../../../../../../etc/passwd',
|
|
59
|
+
'....//....//etc/passwd',
|
|
60
|
+
'..././..././etc/passwd',
|
|
61
|
+
'%2e%2e%2f%2e%2e%2fetc%2fpasswd',
|
|
62
|
+
'%252e%252e%252fetc%252fpasswd',
|
|
63
|
+
'..%2fetc',
|
|
64
|
+
'..%5cwindows',
|
|
65
|
+
'/etc/passwd',
|
|
66
|
+
'C:\\Windows\\win.ini',
|
|
67
|
+
'c:/windows/win.ini',
|
|
68
|
+
'\\\\server\\share\\x',
|
|
69
|
+
'//server/share/x',
|
|
70
|
+
'a/../../b',
|
|
71
|
+
'a\\..\\..\\b',
|
|
72
|
+
'file.txt\0.png',
|
|
73
|
+
'..\0/etc',
|
|
74
|
+
'..%00/etc',
|
|
75
|
+
'%c0%ae%c0%ae/etc',
|
|
76
|
+
'..\uff0fetc',
|
|
77
|
+
'\u2025/etc',
|
|
78
|
+
'..;/etc',
|
|
79
|
+
'~/.ssh/id_rsa',
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Paths a sanitiser must not let out of its base: `../`, encoded and double-encoded dots, absolute roots, drive
|
|
83
|
+
* letters, UNC shares, a null byte and Windows separators, mixed.
|
|
84
|
+
*/
|
|
85
|
+
export function pathPayloads() {
|
|
86
|
+
const segment = fc.tuple(fc.constantFrom(...tokens, ...names), fc.constantFrom(...separators)).map(([t, s]) => t + s);
|
|
87
|
+
const built = fc
|
|
88
|
+
.tuple(fc.constantFrom(...roots), fc.array(segment, { minLength: 0, maxLength: 6 }), fc.constantFrom(...names), fc.constantFrom(...suffixes))
|
|
89
|
+
.map(([root, parts, name, suffix]) => root + parts.join('') + name + suffix);
|
|
90
|
+
return fc
|
|
91
|
+
.oneof({ weight: 8, arbitrary: built }, { weight: 1, arbitrary: fc.string() }, { weight: 1, arbitrary: fc.constantFrom(...pathCorpus) })
|
|
92
|
+
.map((p) => p);
|
|
93
|
+
}
|
|
94
|
+
function inside(flavour, base, target) {
|
|
95
|
+
const p = flavour === 'posix' ? posix : win32;
|
|
96
|
+
const root = p.resolve(base);
|
|
97
|
+
const relative = p.relative(root, p.resolve(root, target));
|
|
98
|
+
return !p.isAbsolute(relative) && relative.split(/[\\/]/)[0] !== '..';
|
|
99
|
+
}
|
|
100
|
+
function decoded(text) {
|
|
101
|
+
try {
|
|
102
|
+
return decodeURIComponent(text);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return text;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* CWE-22. `sanitise(input)` must return a path that, resolved against `base`, stays inside it (or throw, or return
|
|
110
|
+
* nothing, to refuse the input). The result may be relative to `base` or absolute. A null byte in the result fails too.
|
|
111
|
+
*/
|
|
112
|
+
export function pathTraversal(sanitise, options) {
|
|
113
|
+
const flavours = options.flavour === 'both' || options.flavour === undefined ? ['posix', 'win32'] : [options.flavour];
|
|
114
|
+
const read = (result, input) => {
|
|
115
|
+
for (const text of options.checkDecoded === true ? [result, decoded(result)] : [result]) {
|
|
116
|
+
if (text.includes('\0'))
|
|
117
|
+
return `sanitise(${show(input)}) returned ${show(result)}, which holds a null byte`;
|
|
118
|
+
for (const flavour of flavours)
|
|
119
|
+
if (!inside(flavour, options.base, text))
|
|
120
|
+
return `sanitise(${show(input)}) returned ${show(result)}, outside ${show(options.base)} under ${flavour} rules`;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
};
|
|
124
|
+
return securityLaw({
|
|
125
|
+
id: 'path-traversal',
|
|
126
|
+
cwe: ['CWE-22'],
|
|
127
|
+
title: 'a path sanitiser never returns a path outside its base',
|
|
128
|
+
input: pathPayloads(),
|
|
129
|
+
corpus: pathCorpus,
|
|
130
|
+
verdict: (input) => {
|
|
131
|
+
let result;
|
|
132
|
+
try {
|
|
133
|
+
result = sanitise(input);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
if (result === undefined || result === null || result === false)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (typeof result !== 'string')
|
|
141
|
+
return { detail: `sanitise(${show(input)}) returned ${show(result)}, not a path string` };
|
|
142
|
+
const detail = read(result, input);
|
|
143
|
+
return detail === undefined ? undefined : { detail };
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
import type { SecurityLaw } from './law.ts';
|
|
3
|
+
/** Hostile JSON text for a law parameter. Generated by `pollutionPayloads`. */
|
|
4
|
+
export type PollutionPayload = string & {
|
|
5
|
+
readonly __tslawsPollution: true;
|
|
6
|
+
};
|
|
7
|
+
/** A hostile dotted path (`a.__proto__.x`) for a law parameter. Generated by `pollutionPaths`. */
|
|
8
|
+
export type PollutionPath = string & {
|
|
9
|
+
readonly __tslawsPollutionPath: true;
|
|
10
|
+
};
|
|
11
|
+
/** The property every payload tries to plant. */
|
|
12
|
+
export declare const marker = "tslawsPolluted";
|
|
13
|
+
/** JSON objects whose keys walk to a shared prototype and plant `tslawsPolluted`; `JSON.parse` makes `__proto__` an own key. */
|
|
14
|
+
export declare function pollutionPayloads(): fc.Arbitrary<PollutionPayload>;
|
|
15
|
+
/** Dotted paths that walk through a prototype key to `tslawsPolluted`. */
|
|
16
|
+
export declare function pollutionPaths(): fc.Arbitrary<PollutionPath>;
|
|
17
|
+
/** The fixed JSON attacks `merge` and `parse` laws check on every call. */
|
|
18
|
+
export declare const pollutionCorpus: readonly PollutionPayload[];
|
|
19
|
+
/** The fixed paths `set` laws check on every call. */
|
|
20
|
+
export declare const pollutionPathCorpus: readonly PollutionPath[];
|
|
21
|
+
/** CWE-1321 for `merge(target, source)`: merging parsed hostile JSON into an object must leave the shared prototypes alone. */
|
|
22
|
+
export declare function prototypeSafeMerge(merge: (target: any, source: any) => unknown): SecurityLaw<PollutionPayload>;
|
|
23
|
+
export interface PrototypeSafeSetOptions {
|
|
24
|
+
/** `dotted` (default): `set(target, 'a.b', value)`. `array`: `set(target, ['a', 'b'], value)`. */
|
|
25
|
+
pathFormat?: 'dotted' | 'array';
|
|
26
|
+
}
|
|
27
|
+
/** CWE-1321 for `set(target, path, value)`: a path through `__proto__` or `constructor.prototype` must not reach a shared prototype. */
|
|
28
|
+
export declare function prototypeSafeSet(set: (target: any, path: any, value: unknown) => unknown, options?: PrototypeSafeSetOptions): SecurityLaw<PollutionPath>;
|
|
29
|
+
/** CWE-1321 for `parse(text)`: parsing hostile JSON (a parser that merges, revives or assigns by key) must leave the shared prototypes alone. */
|
|
30
|
+
export declare function prototypeSafeParse(parse: (text: string) => unknown): SecurityLaw<PollutionPayload>;
|