@node9/policy-engine 2.52.0 → 2.54.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/index.d.mts +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +166 -9
- package/dist/index.mjs +166 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -973,7 +973,8 @@ interface PolicyVerdict {
|
|
|
973
973
|
/**
|
|
974
974
|
* False when NO human may override this verdict: the SSRF tier-1 floors,
|
|
975
975
|
* whose own reason string already tells the user "This address cannot be
|
|
976
|
-
* allowlisted"
|
|
976
|
+
* allowlisted", and a credential-file block (NOT_OVERRIDABLE_CHECKS,
|
|
977
|
+
* node9Firewall#441). Absent means an override is a legitimate product decision,
|
|
977
978
|
* which is every other verdict.
|
|
978
979
|
*
|
|
979
980
|
* It exists because the host downgrades a hard block into a review whenever a
|
|
@@ -1355,6 +1356,8 @@ interface LegacyPolicyKnobs {
|
|
|
1355
1356
|
registrySignals?: boolean;
|
|
1356
1357
|
newPackage?: string;
|
|
1357
1358
|
installScript?: string;
|
|
1359
|
+
lookalike?: string;
|
|
1360
|
+
establishedAge?: string;
|
|
1358
1361
|
maxAgeHours?: number;
|
|
1359
1362
|
onlineFallback?: boolean;
|
|
1360
1363
|
allow?: string[];
|
|
@@ -1446,11 +1449,12 @@ declare function levelCheckValue(mode: string | undefined, id: string): Verdict
|
|
|
1446
1449
|
/** Every check a level changes, with its value. */
|
|
1447
1450
|
declare function levelChecks(mode: string | undefined): Readonly<Record<string, Verdict>>;
|
|
1448
1451
|
/** The package registry signals (`loading.malicious-package` tuning), which
|
|
1449
|
-
* allow only review or off
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1452
|
+
* allow only review or off, as a level sets them: Soft turns every signal off;
|
|
1453
|
+
* Strict and Block all ask about a young release of an established package
|
|
1454
|
+
* too (`establishedAge`, node9Firewall#385 wave 3); Standard and Audit keep
|
|
1455
|
+
* the defaults. Only the keys returned are written. */
|
|
1456
|
+
declare function levelPackageSignals(mode: string | undefined): Partial<Record<PackageSignal, 'review' | 'off'>> | undefined;
|
|
1457
|
+
type PackageSignal = 'newPackage' | 'installScript' | 'lookalike' | 'establishedAge';
|
|
1454
1458
|
|
|
1455
1459
|
interface PipeChainAnalysis {
|
|
1456
1460
|
isPipeline: boolean;
|
|
@@ -2434,7 +2438,7 @@ declare const LONG_OUTPUT_THRESHOLD_BYTES: number;
|
|
|
2434
2438
|
* and fails CI when the hash drifts without a version bump — forgetting
|
|
2435
2439
|
* is loud, not silent.
|
|
2436
2440
|
*/
|
|
2437
|
-
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
2441
|
+
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
2438
2442
|
/**
|
|
2439
2443
|
* SHA-256 prefix of the detector-source files
|
|
2440
2444
|
* (canonical.ts + pii.ts + destructive-regex.ts).
|
|
@@ -2445,7 +2449,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
|
2445
2449
|
* files changed, this hash must change too, and you must consciously
|
|
2446
2450
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2447
2451
|
*/
|
|
2448
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2452
|
+
declare const CANONICAL_EXTRACTOR_HASH = "5ec00461a49e1858";
|
|
2449
2453
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2450
2454
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2451
2455
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -973,7 +973,8 @@ interface PolicyVerdict {
|
|
|
973
973
|
/**
|
|
974
974
|
* False when NO human may override this verdict: the SSRF tier-1 floors,
|
|
975
975
|
* whose own reason string already tells the user "This address cannot be
|
|
976
|
-
* allowlisted"
|
|
976
|
+
* allowlisted", and a credential-file block (NOT_OVERRIDABLE_CHECKS,
|
|
977
|
+
* node9Firewall#441). Absent means an override is a legitimate product decision,
|
|
977
978
|
* which is every other verdict.
|
|
978
979
|
*
|
|
979
980
|
* It exists because the host downgrades a hard block into a review whenever a
|
|
@@ -1355,6 +1356,8 @@ interface LegacyPolicyKnobs {
|
|
|
1355
1356
|
registrySignals?: boolean;
|
|
1356
1357
|
newPackage?: string;
|
|
1357
1358
|
installScript?: string;
|
|
1359
|
+
lookalike?: string;
|
|
1360
|
+
establishedAge?: string;
|
|
1358
1361
|
maxAgeHours?: number;
|
|
1359
1362
|
onlineFallback?: boolean;
|
|
1360
1363
|
allow?: string[];
|
|
@@ -1446,11 +1449,12 @@ declare function levelCheckValue(mode: string | undefined, id: string): Verdict
|
|
|
1446
1449
|
/** Every check a level changes, with its value. */
|
|
1447
1450
|
declare function levelChecks(mode: string | undefined): Readonly<Record<string, Verdict>>;
|
|
1448
1451
|
/** The package registry signals (`loading.malicious-package` tuning), which
|
|
1449
|
-
* allow only review or off
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1452
|
+
* allow only review or off, as a level sets them: Soft turns every signal off;
|
|
1453
|
+
* Strict and Block all ask about a young release of an established package
|
|
1454
|
+
* too (`establishedAge`, node9Firewall#385 wave 3); Standard and Audit keep
|
|
1455
|
+
* the defaults. Only the keys returned are written. */
|
|
1456
|
+
declare function levelPackageSignals(mode: string | undefined): Partial<Record<PackageSignal, 'review' | 'off'>> | undefined;
|
|
1457
|
+
type PackageSignal = 'newPackage' | 'installScript' | 'lookalike' | 'establishedAge';
|
|
1454
1458
|
|
|
1455
1459
|
interface PipeChainAnalysis {
|
|
1456
1460
|
isPipeline: boolean;
|
|
@@ -2434,7 +2438,7 @@ declare const LONG_OUTPUT_THRESHOLD_BYTES: number;
|
|
|
2434
2438
|
* and fails CI when the hash drifts without a version bump — forgetting
|
|
2435
2439
|
* is loud, not silent.
|
|
2436
2440
|
*/
|
|
2437
|
-
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
2441
|
+
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
2438
2442
|
/**
|
|
2439
2443
|
* SHA-256 prefix of the detector-source files
|
|
2440
2444
|
* (canonical.ts + pii.ts + destructive-regex.ts).
|
|
@@ -2445,7 +2449,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
|
2445
2449
|
* files changed, this hash must change too, and you must consciously
|
|
2446
2450
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2447
2451
|
*/
|
|
2448
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2452
|
+
declare const CANONICAL_EXTRACTOR_HASH = "5ec00461a49e1858";
|
|
2449
2453
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2450
2454
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2451
2455
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2711,7 +2711,7 @@ var CHECK_TEXT = {
|
|
|
2711
2711
|
advice: "Fixed at Block. A person accepts the change on the machine (node9 mcp pin update)."
|
|
2712
2712
|
},
|
|
2713
2713
|
"loading.malicious-package": {
|
|
2714
|
-
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only. A new release built from the same repository as the one before it (registry provenance) and an install script the package has always run do not stop; a release that lost the provenance its previous release had does.",
|
|
2714
|
+
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only. A new release built from the same repository as the one before it (registry provenance) and an install script the package has always run do not stop; a release that lost the provenance its previous release had does. A name that looks like a popular package and has no standing of its own, a name no package on npm or PyPI has, or a package npm removed as malicious also stops for review (the lookalike tuning). A fresh release of a package over a year old that released within the last six months is its normal cadence: Standard lets it through, Strict asks (the establishedAge tuning).",
|
|
2715
2715
|
example: "npm install of a package flagged as malware",
|
|
2716
2716
|
advice: "Keep Block for known-malicious packages; brand-new packages already stop for Review."
|
|
2717
2717
|
},
|
|
@@ -2815,7 +2815,12 @@ function levelChecks(mode) {
|
|
|
2815
2815
|
return LEVEL_CHECKS[levelOf(mode)];
|
|
2816
2816
|
}
|
|
2817
2817
|
function levelPackageSignals(mode) {
|
|
2818
|
-
|
|
2818
|
+
const level = levelOf(mode);
|
|
2819
|
+
if (level === "soft") {
|
|
2820
|
+
return { newPackage: "off", installScript: "off", lookalike: "off", establishedAge: "off" };
|
|
2821
|
+
}
|
|
2822
|
+
if (level === "strict" || level === "block-all") return { establishedAge: "review" };
|
|
2823
|
+
return void 0;
|
|
2819
2824
|
}
|
|
2820
2825
|
|
|
2821
2826
|
// src/owasp.ts
|
|
@@ -5205,6 +5210,95 @@ function protectedLiteral(code, isProtected) {
|
|
|
5205
5210
|
}
|
|
5206
5211
|
return null;
|
|
5207
5212
|
}
|
|
5213
|
+
var READ_CALL = {
|
|
5214
|
+
python: String.raw`(?:\b(?:io|codecs)\.)?\bopen|\b(?:dotenv_values|load_dotenv|get_key|read_file|loadtxt|read_csv)`,
|
|
5215
|
+
node: String.raw`\b(?:readFileSync|readFile|createReadStream|readTextFile(?:Sync)?|readFileStr|openSync|file)`,
|
|
5216
|
+
perl: String.raw`\b(?:open|sysopen|read_file|slurp)`,
|
|
5217
|
+
ruby: String.raw`\b(?:File|IO)\.(?:read|binread|readlines|foreach|open)|\bDotenv\.(?:load|parse|overload)`,
|
|
5218
|
+
php: String.raw`\b(?:file_get_contents|fopen|file|readfile|parse_ini_file|highlight_file|show_source)`
|
|
5219
|
+
};
|
|
5220
|
+
var ARG = String.raw`(?:(?:(?:my|our|local)\s+)?[\w.$]+(?:\s*\(\s*\))?|'[^'\n]{0,8}'|"[^"\n]{0,8}")\s*,\s*`;
|
|
5221
|
+
var WRAP = String.raw`(?:(?:new\s+)?[\w.$]+\s*\(\s*(?:${ARG}){0,3}){0,3}`;
|
|
5222
|
+
var STR_PREFIX = String.raw`[rRbBuUfF]{0,2}`;
|
|
5223
|
+
var WRITE_MODE_LITERAL = String.raw`['"](?=[rbtU+]*w|(?![^'"]*\+)[rbtU]*[ax])[rwaxbtU+]{1,4}['"]`;
|
|
5224
|
+
var WRITE_MODE = String.raw`\s*,\s*(?:mode\s*=\s*)?${WRITE_MODE_LITERAL}`;
|
|
5225
|
+
var WRITE_MODE_AFTER = new RegExp(`^(?:\\s*\\)){0,3}${WRITE_MODE}`);
|
|
5226
|
+
var PERL_WRITE_BEFORE = /['"]\s*(?:\+?[>|]|>>)\s*['"]\s*,\s*$/;
|
|
5227
|
+
var readCallBefore = (language) => new RegExp(
|
|
5228
|
+
String.raw`(?:${READ_CALL[language]})(?![\w$])\s*\(?\s*(?:${ARG}){0,3}${WRAP}${STR_PREFIX}$`
|
|
5229
|
+
);
|
|
5230
|
+
var READ_BEFORE = {
|
|
5231
|
+
python: readCallBefore("python"),
|
|
5232
|
+
node: readCallBefore("node"),
|
|
5233
|
+
perl: readCallBefore("perl"),
|
|
5234
|
+
ruby: readCallBefore("ruby"),
|
|
5235
|
+
php: readCallBefore("php")
|
|
5236
|
+
};
|
|
5237
|
+
var READ_AFTER = {
|
|
5238
|
+
python: new RegExp(
|
|
5239
|
+
String.raw`^\s*\)\s*\.\s*(?:read_text|read_bytes|open)\s*\((?!\s*(?:mode\s*=\s*)?${WRITE_MODE_LITERAL})`
|
|
5240
|
+
)
|
|
5241
|
+
};
|
|
5242
|
+
var ASSIGNED = new RegExp(String.raw`([$\w]+)\s*=\s*${WRAP}${STR_PREFIX}$`);
|
|
5243
|
+
var openedName = (language) => new RegExp(
|
|
5244
|
+
String.raw`(?:${READ_CALL[language]})(?![\w$])\s*\(?\s*(?:${ARG}){0,3}${WRAP}([$\w]+)(?!${WRITE_MODE})\s*[),]` + (language === "python" ? String.raw`|\bPath\s*\(\s*([$\w]+)\s*\)\s*\.\s*(?:read_text|read_bytes|open)\s*\(` : ""),
|
|
5245
|
+
"g"
|
|
5246
|
+
);
|
|
5247
|
+
var OPENED_NAME = {
|
|
5248
|
+
python: openedName("python"),
|
|
5249
|
+
node: openedName("node"),
|
|
5250
|
+
perl: openedName("perl"),
|
|
5251
|
+
ruby: openedName("ruby"),
|
|
5252
|
+
php: openedName("php")
|
|
5253
|
+
};
|
|
5254
|
+
var DOTENV = {
|
|
5255
|
+
node: {
|
|
5256
|
+
load: /\brequire\s*\(\s*['"`]dotenv(?:\/config)?['"`]\s*\)|\bimport\s*(?:[\w${}\s,*]+\s+from\s*)?['"`]dotenv(?:\/config)?['"`]|\bimport\s*\(\s*['"`]dotenv(?:\/config)?['"`]\s*\)/,
|
|
5257
|
+
values: /\.parsed\b|[(,]\s*(?:require\s*\(\s*['"`]dotenv['"`]\s*\)|dotenv)\s*\.\s*config\s*\(/,
|
|
5258
|
+
env: /\b(?:process|Deno|Bun)\s*\.\s*env\b/,
|
|
5259
|
+
literalPath: /\bconfig\s*\(\s*\{[^)]*\bpath\s*:\s*['"`]/
|
|
5260
|
+
},
|
|
5261
|
+
python: {
|
|
5262
|
+
load: /\b(?:load_dotenv|dotenv_values|get_key)\s*\(/,
|
|
5263
|
+
values: /\b(?:dotenv_values|get_key)\s*\(/,
|
|
5264
|
+
env: /\b(?:environ|getenv)\b/,
|
|
5265
|
+
literalPath: /\b(?:load_dotenv|dotenv_values)\s*\(\s*(?:dotenv_path\s*=\s*)?[rRbBuU]?['"]/
|
|
5266
|
+
}
|
|
5267
|
+
};
|
|
5268
|
+
var DOTENV_PATH_OPTION = /\bconfig\s*\(\s*\{[^)]*\bpath\s*:\s*$/;
|
|
5269
|
+
function inlineReadPaths(language, code, preload = {}) {
|
|
5270
|
+
const out = [];
|
|
5271
|
+
const before = READ_BEFORE[language];
|
|
5272
|
+
const after = READ_AFTER[language];
|
|
5273
|
+
const assigned = /* @__PURE__ */ new Map();
|
|
5274
|
+
for (const m of code.matchAll(STRING_LITERAL)) {
|
|
5275
|
+
const raw = m[2].trim();
|
|
5276
|
+
const value = raw.replace(/^[<+]\s*/, "");
|
|
5277
|
+
if (!value) continue;
|
|
5278
|
+
const head = code.slice(Math.max(0, m.index - 160), m.index);
|
|
5279
|
+
const tail = code.slice(m.index + m[0].length, m.index + m[0].length + 40);
|
|
5280
|
+
if (/^[>|]/.test(raw) || WRITE_MODE_AFTER.test(tail) || PERL_WRITE_BEFORE.test(head)) continue;
|
|
5281
|
+
if (before.test(head) || after?.test(tail) || language === "node" && DOTENV_PATH_OPTION.test(head)) {
|
|
5282
|
+
out.push(value);
|
|
5283
|
+
continue;
|
|
5284
|
+
}
|
|
5285
|
+
const name = ASSIGNED.exec(head)?.[1];
|
|
5286
|
+
if (name) assigned.set(name, [...assigned.get(name) ?? [], value]);
|
|
5287
|
+
}
|
|
5288
|
+
if (assigned.size > 0) {
|
|
5289
|
+
const opened = /* @__PURE__ */ new Set();
|
|
5290
|
+
for (const m of code.matchAll(OPENED_NAME[language])) opened.add(m[1] ?? m[2]);
|
|
5291
|
+
for (const [name, values] of assigned) if (opened.has(name)) out.push(...values);
|
|
5292
|
+
}
|
|
5293
|
+
if (language === "python" || language === "node") {
|
|
5294
|
+
const d = DOTENV[language];
|
|
5295
|
+
const readsEnv = d.env.test(code);
|
|
5296
|
+
const loads = /dotenv/.test(code) && d.load.test(code) && !d.literalPath.test(code);
|
|
5297
|
+
if ((loads || preload.dotenv) && (readsEnv || d.values.test(code))) out.push(".env");
|
|
5298
|
+
if (readsEnv) out.push(...preload.envFiles ?? []);
|
|
5299
|
+
}
|
|
5300
|
+
return out;
|
|
5301
|
+
}
|
|
5208
5302
|
function amplifies(language, code) {
|
|
5209
5303
|
const loop = language === "python" ? /\bwhile\s+(?:True|1)\s*:/ : language === "node" ? /\bwhile\s*\(\s*(?:true|1)\s*\)|\bfor\s*\(\s*;\s*;\s*\)|\bsetInterval\s*\(/ : /\bwhile\s*\(?\s*(?:1|true)\s*\)?|\bloop\s+do\b|\bfor\s*\(\s*;\s*;\s*\)/;
|
|
5210
5304
|
const m = loop.exec(code);
|
|
@@ -6834,6 +6928,7 @@ function attachedCode(interp, flag) {
|
|
|
6834
6928
|
if (letters === "ep" && /^[ep]*$/i.test(rest)) rest = "";
|
|
6835
6929
|
return rest === "" ? null : rest;
|
|
6836
6930
|
}
|
|
6931
|
+
var NODE_VALUE_FLAG = /^(-r|--require|--import|--loader|--experimental-loader|--env-file|--env-file-if-exists|--input-type|-C|--conditions)(?:=(.*))?$/;
|
|
6837
6932
|
function inlineExecCall(stmt, pipeFed) {
|
|
6838
6933
|
const cmd = stmt?.Cmd;
|
|
6839
6934
|
if (!cmd || cmd.kind !== "CallExpr") return null;
|
|
@@ -6858,15 +6953,28 @@ function inlineExecCall(stmt, pipeFed) {
|
|
|
6858
6953
|
const fromStdin = () => {
|
|
6859
6954
|
if (stdinFed) {
|
|
6860
6955
|
const { code, source } = stdinCodeOf(redirs);
|
|
6861
|
-
return { interp, code: [code], source };
|
|
6956
|
+
return { interp, code: [code], source, preload };
|
|
6862
6957
|
}
|
|
6863
6958
|
return { interp, code: [null], source: "pipe" };
|
|
6864
6959
|
};
|
|
6865
6960
|
let positionals2 = 0;
|
|
6866
6961
|
let selectedProgram = false;
|
|
6867
6962
|
const codes = [];
|
|
6963
|
+
const preload = {};
|
|
6964
|
+
const nodeFamily = inlineLanguageOf(interp) === "node";
|
|
6868
6965
|
for (let i = 0; i < args.length; i++) {
|
|
6869
6966
|
const a = args[i];
|
|
6967
|
+
if (nodeFamily && !selectedProgram && codes.length === 0 && a != null) {
|
|
6968
|
+
const flag = NODE_VALUE_FLAG.exec(a);
|
|
6969
|
+
if (flag) {
|
|
6970
|
+
const value = flag[2] ?? args[++i];
|
|
6971
|
+
if (value != null) {
|
|
6972
|
+
if (/^--env-file/.test(flag[1])) (preload.envFiles ??= []).push(value);
|
|
6973
|
+
else if (/^dotenv\/config(?:\.js)?$/.test(value)) preload.dotenv = true;
|
|
6974
|
+
}
|
|
6975
|
+
continue;
|
|
6976
|
+
}
|
|
6977
|
+
}
|
|
6870
6978
|
if (a == null) {
|
|
6871
6979
|
if (codes.length > 0) break;
|
|
6872
6980
|
positionals2++;
|
|
@@ -6903,7 +7011,12 @@ function inlineExecCall(stmt, pipeFed) {
|
|
|
6903
7011
|
}
|
|
6904
7012
|
}
|
|
6905
7013
|
if (codes.length > 0) {
|
|
6906
|
-
return {
|
|
7014
|
+
return {
|
|
7015
|
+
interp,
|
|
7016
|
+
code: codes,
|
|
7017
|
+
source: codes.includes(null) ? "variable" : void 0,
|
|
7018
|
+
preload
|
|
7019
|
+
};
|
|
6907
7020
|
}
|
|
6908
7021
|
if (positionals2 === 0 && (stdinFed || pipeFed)) {
|
|
6909
7022
|
if (!/^(bash|sh|zsh)$/i.test(interp)) return fromStdin();
|
|
@@ -7922,7 +8035,7 @@ var FS_OP_CACHE_MAX = 5e3;
|
|
|
7922
8035
|
var fsOpCache = /* @__PURE__ */ new Map();
|
|
7923
8036
|
function analyzeFsOperation(command) {
|
|
7924
8037
|
const normalized = normalizeCommandForPolicy(command);
|
|
7925
|
-
if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command))
|
|
8038
|
+
if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command) && !runsInlineInterpreter(command, normalized))
|
|
7926
8039
|
return null;
|
|
7927
8040
|
if (fsOpCache.has(command)) {
|
|
7928
8041
|
const hit = fsOpCache.get(command) ?? null;
|
|
@@ -7930,7 +8043,8 @@ function analyzeFsOperation(command) {
|
|
|
7930
8043
|
fsOpCache.set(command, hit);
|
|
7931
8044
|
return hit;
|
|
7932
8045
|
}
|
|
7933
|
-
const
|
|
8046
|
+
const direct = analyzeFsOperationImpl(command) ?? (INDIRECT_SHAPE_RE.test(command) ? structuralJailRead(command) : null);
|
|
8047
|
+
const computed = direct?.verdict === "block" || !runsInlineInterpreter(command, normalized) ? direct : stricter(direct, inlineCodeJailRead(command));
|
|
7934
8048
|
if (fsOpCache.size >= FS_OP_CACHE_MAX) {
|
|
7935
8049
|
const oldest = fsOpCache.keys().next().value;
|
|
7936
8050
|
if (oldest !== void 0) fsOpCache.delete(oldest);
|
|
@@ -8740,6 +8854,26 @@ function structuralJailRead(command) {
|
|
|
8740
8854
|
}
|
|
8741
8855
|
return review;
|
|
8742
8856
|
}
|
|
8857
|
+
var INLINE_INTERP_PRESCREEN_RE = /(?:^|[^\w-])(?:python|node|tsx|ts-node|deno|bun|perl|ruby|irb|php)(?![A-Za-z_])/i;
|
|
8858
|
+
var runsInlineInterpreter = (command, normalized) => INLINE_INTERP_PRESCREEN_RE.test(command) || INLINE_INTERP_PRESCREEN_RE.test(normalized);
|
|
8859
|
+
function inlineCodeJailRead(command) {
|
|
8860
|
+
const calls = inlineExecCalls(command);
|
|
8861
|
+
if (calls === PARSE_FAIL) return null;
|
|
8862
|
+
let review = null;
|
|
8863
|
+
for (const call of calls) {
|
|
8864
|
+
const language = inlineLanguageOf(call.interp);
|
|
8865
|
+
if (language === null) continue;
|
|
8866
|
+
for (const code of call.code) {
|
|
8867
|
+
if (code === null) continue;
|
|
8868
|
+
for (const p of inlineReadPaths(language, code, call.preload)) {
|
|
8869
|
+
const hit = matchSensitivePath(p);
|
|
8870
|
+
if (hit?.verdict === "block") return hit;
|
|
8871
|
+
review ??= hit;
|
|
8872
|
+
}
|
|
8873
|
+
}
|
|
8874
|
+
}
|
|
8875
|
+
return review;
|
|
8876
|
+
}
|
|
8743
8877
|
function baseWord(w) {
|
|
8744
8878
|
return (w ?? "").split("/").pop()?.toLowerCase() ?? "";
|
|
8745
8879
|
}
|
|
@@ -17033,6 +17167,16 @@ var TUNING_FIELDS = [
|
|
|
17033
17167
|
name: "installScript",
|
|
17034
17168
|
legacy: ["packageCheck", "installScript"]
|
|
17035
17169
|
},
|
|
17170
|
+
{
|
|
17171
|
+
checkId: "loading.malicious-package",
|
|
17172
|
+
name: "lookalike",
|
|
17173
|
+
legacy: ["packageCheck", "lookalike"]
|
|
17174
|
+
},
|
|
17175
|
+
{
|
|
17176
|
+
checkId: "loading.malicious-package",
|
|
17177
|
+
name: "establishedAge",
|
|
17178
|
+
legacy: ["packageCheck", "establishedAge"]
|
|
17179
|
+
},
|
|
17036
17180
|
{
|
|
17037
17181
|
checkId: "loading.malicious-package",
|
|
17038
17182
|
name: "onlineFallback",
|
|
@@ -17062,7 +17206,11 @@ function tuningFromLegacyPolicy(policy) {
|
|
|
17062
17206
|
const out = {};
|
|
17063
17207
|
const p = policy;
|
|
17064
17208
|
if (policy.packageCheck?.registrySignals === false) {
|
|
17065
|
-
out["loading.malicious-package"] = {
|
|
17209
|
+
out["loading.malicious-package"] = {
|
|
17210
|
+
newPackage: "off",
|
|
17211
|
+
installScript: "off",
|
|
17212
|
+
lookalike: "off"
|
|
17213
|
+
};
|
|
17066
17214
|
}
|
|
17067
17215
|
for (const f of TUNING_FIELDS) {
|
|
17068
17216
|
const [block, key] = f.legacy;
|
|
@@ -17081,6 +17229,7 @@ function tuningToLegacyPolicy(policy, tuning) {
|
|
|
17081
17229
|
if (normalized.registrySignals === false) {
|
|
17082
17230
|
normalized.newPackage ??= "off";
|
|
17083
17231
|
normalized.installScript ??= "off";
|
|
17232
|
+
normalized.lookalike ??= "off";
|
|
17084
17233
|
}
|
|
17085
17234
|
delete normalized.registrySignals;
|
|
17086
17235
|
}
|
|
@@ -18256,7 +18405,15 @@ function egressPolicyVerdict(eg) {
|
|
|
18256
18405
|
checkId: "network.unknown-host"
|
|
18257
18406
|
};
|
|
18258
18407
|
}
|
|
18408
|
+
var NOT_OVERRIDABLE_CHECKS = /* @__PURE__ */ new Set([
|
|
18409
|
+
"data.credential-files",
|
|
18410
|
+
"data.credential-files-other"
|
|
18411
|
+
]);
|
|
18259
18412
|
async function evaluatePolicy(config, toolName, args, context = {}, hostHooks = {}) {
|
|
18413
|
+
const v = await evaluatePolicyVerdict(config, toolName, args, context, hostHooks);
|
|
18414
|
+
return v.decision === "block" && v.checkId !== void 0 && NOT_OVERRIDABLE_CHECKS.has(v.checkId) ? { ...v, overridable: false } : v;
|
|
18415
|
+
}
|
|
18416
|
+
async function evaluatePolicyVerdict(config, toolName, args, context = {}, hostHooks = {}) {
|
|
18260
18417
|
let protectedVerdict = null;
|
|
18261
18418
|
const layers = inspectionLayers(config.policy);
|
|
18262
18419
|
if (context.agent !== "Terminal") {
|
|
@@ -20470,8 +20627,8 @@ function matchCanaryArgs(args, values) {
|
|
|
20470
20627
|
|
|
20471
20628
|
// src/scan/canonical.ts
|
|
20472
20629
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20473
|
-
var CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
20474
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
20630
|
+
var CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
20631
|
+
var CANONICAL_EXTRACTOR_HASH = "5ec00461a49e1858";
|
|
20475
20632
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20476
20633
|
function extractCanonicalFindings(call, ctx) {
|
|
20477
20634
|
const out = [];
|
package/dist/index.mjs
CHANGED
|
@@ -2448,7 +2448,7 @@ var CHECK_TEXT = {
|
|
|
2448
2448
|
advice: "Fixed at Block. A person accepts the change on the machine (node9 mcp pin update)."
|
|
2449
2449
|
},
|
|
2450
2450
|
"loading.malicious-package": {
|
|
2451
|
-
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only. A new release built from the same repository as the one before it (registry provenance) and an install script the package has always run do not stop; a release that lost the provenance its previous release had does.",
|
|
2451
|
+
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only. A new release built from the same repository as the one before it (registry provenance) and an install script the package has always run do not stop; a release that lost the provenance its previous release had does. A name that looks like a popular package and has no standing of its own, a name no package on npm or PyPI has, or a package npm removed as malicious also stops for review (the lookalike tuning). A fresh release of a package over a year old that released within the last six months is its normal cadence: Standard lets it through, Strict asks (the establishedAge tuning).",
|
|
2452
2452
|
example: "npm install of a package flagged as malware",
|
|
2453
2453
|
advice: "Keep Block for known-malicious packages; brand-new packages already stop for Review."
|
|
2454
2454
|
},
|
|
@@ -2552,7 +2552,12 @@ function levelChecks(mode) {
|
|
|
2552
2552
|
return LEVEL_CHECKS[levelOf(mode)];
|
|
2553
2553
|
}
|
|
2554
2554
|
function levelPackageSignals(mode) {
|
|
2555
|
-
|
|
2555
|
+
const level = levelOf(mode);
|
|
2556
|
+
if (level === "soft") {
|
|
2557
|
+
return { newPackage: "off", installScript: "off", lookalike: "off", establishedAge: "off" };
|
|
2558
|
+
}
|
|
2559
|
+
if (level === "strict" || level === "block-all") return { establishedAge: "review" };
|
|
2560
|
+
return void 0;
|
|
2556
2561
|
}
|
|
2557
2562
|
|
|
2558
2563
|
// src/owasp.ts
|
|
@@ -4942,6 +4947,95 @@ function protectedLiteral(code, isProtected) {
|
|
|
4942
4947
|
}
|
|
4943
4948
|
return null;
|
|
4944
4949
|
}
|
|
4950
|
+
var READ_CALL = {
|
|
4951
|
+
python: String.raw`(?:\b(?:io|codecs)\.)?\bopen|\b(?:dotenv_values|load_dotenv|get_key|read_file|loadtxt|read_csv)`,
|
|
4952
|
+
node: String.raw`\b(?:readFileSync|readFile|createReadStream|readTextFile(?:Sync)?|readFileStr|openSync|file)`,
|
|
4953
|
+
perl: String.raw`\b(?:open|sysopen|read_file|slurp)`,
|
|
4954
|
+
ruby: String.raw`\b(?:File|IO)\.(?:read|binread|readlines|foreach|open)|\bDotenv\.(?:load|parse|overload)`,
|
|
4955
|
+
php: String.raw`\b(?:file_get_contents|fopen|file|readfile|parse_ini_file|highlight_file|show_source)`
|
|
4956
|
+
};
|
|
4957
|
+
var ARG = String.raw`(?:(?:(?:my|our|local)\s+)?[\w.$]+(?:\s*\(\s*\))?|'[^'\n]{0,8}'|"[^"\n]{0,8}")\s*,\s*`;
|
|
4958
|
+
var WRAP = String.raw`(?:(?:new\s+)?[\w.$]+\s*\(\s*(?:${ARG}){0,3}){0,3}`;
|
|
4959
|
+
var STR_PREFIX = String.raw`[rRbBuUfF]{0,2}`;
|
|
4960
|
+
var WRITE_MODE_LITERAL = String.raw`['"](?=[rbtU+]*w|(?![^'"]*\+)[rbtU]*[ax])[rwaxbtU+]{1,4}['"]`;
|
|
4961
|
+
var WRITE_MODE = String.raw`\s*,\s*(?:mode\s*=\s*)?${WRITE_MODE_LITERAL}`;
|
|
4962
|
+
var WRITE_MODE_AFTER = new RegExp(`^(?:\\s*\\)){0,3}${WRITE_MODE}`);
|
|
4963
|
+
var PERL_WRITE_BEFORE = /['"]\s*(?:\+?[>|]|>>)\s*['"]\s*,\s*$/;
|
|
4964
|
+
var readCallBefore = (language) => new RegExp(
|
|
4965
|
+
String.raw`(?:${READ_CALL[language]})(?![\w$])\s*\(?\s*(?:${ARG}){0,3}${WRAP}${STR_PREFIX}$`
|
|
4966
|
+
);
|
|
4967
|
+
var READ_BEFORE = {
|
|
4968
|
+
python: readCallBefore("python"),
|
|
4969
|
+
node: readCallBefore("node"),
|
|
4970
|
+
perl: readCallBefore("perl"),
|
|
4971
|
+
ruby: readCallBefore("ruby"),
|
|
4972
|
+
php: readCallBefore("php")
|
|
4973
|
+
};
|
|
4974
|
+
var READ_AFTER = {
|
|
4975
|
+
python: new RegExp(
|
|
4976
|
+
String.raw`^\s*\)\s*\.\s*(?:read_text|read_bytes|open)\s*\((?!\s*(?:mode\s*=\s*)?${WRITE_MODE_LITERAL})`
|
|
4977
|
+
)
|
|
4978
|
+
};
|
|
4979
|
+
var ASSIGNED = new RegExp(String.raw`([$\w]+)\s*=\s*${WRAP}${STR_PREFIX}$`);
|
|
4980
|
+
var openedName = (language) => new RegExp(
|
|
4981
|
+
String.raw`(?:${READ_CALL[language]})(?![\w$])\s*\(?\s*(?:${ARG}){0,3}${WRAP}([$\w]+)(?!${WRITE_MODE})\s*[),]` + (language === "python" ? String.raw`|\bPath\s*\(\s*([$\w]+)\s*\)\s*\.\s*(?:read_text|read_bytes|open)\s*\(` : ""),
|
|
4982
|
+
"g"
|
|
4983
|
+
);
|
|
4984
|
+
var OPENED_NAME = {
|
|
4985
|
+
python: openedName("python"),
|
|
4986
|
+
node: openedName("node"),
|
|
4987
|
+
perl: openedName("perl"),
|
|
4988
|
+
ruby: openedName("ruby"),
|
|
4989
|
+
php: openedName("php")
|
|
4990
|
+
};
|
|
4991
|
+
var DOTENV = {
|
|
4992
|
+
node: {
|
|
4993
|
+
load: /\brequire\s*\(\s*['"`]dotenv(?:\/config)?['"`]\s*\)|\bimport\s*(?:[\w${}\s,*]+\s+from\s*)?['"`]dotenv(?:\/config)?['"`]|\bimport\s*\(\s*['"`]dotenv(?:\/config)?['"`]\s*\)/,
|
|
4994
|
+
values: /\.parsed\b|[(,]\s*(?:require\s*\(\s*['"`]dotenv['"`]\s*\)|dotenv)\s*\.\s*config\s*\(/,
|
|
4995
|
+
env: /\b(?:process|Deno|Bun)\s*\.\s*env\b/,
|
|
4996
|
+
literalPath: /\bconfig\s*\(\s*\{[^)]*\bpath\s*:\s*['"`]/
|
|
4997
|
+
},
|
|
4998
|
+
python: {
|
|
4999
|
+
load: /\b(?:load_dotenv|dotenv_values|get_key)\s*\(/,
|
|
5000
|
+
values: /\b(?:dotenv_values|get_key)\s*\(/,
|
|
5001
|
+
env: /\b(?:environ|getenv)\b/,
|
|
5002
|
+
literalPath: /\b(?:load_dotenv|dotenv_values)\s*\(\s*(?:dotenv_path\s*=\s*)?[rRbBuU]?['"]/
|
|
5003
|
+
}
|
|
5004
|
+
};
|
|
5005
|
+
var DOTENV_PATH_OPTION = /\bconfig\s*\(\s*\{[^)]*\bpath\s*:\s*$/;
|
|
5006
|
+
function inlineReadPaths(language, code, preload = {}) {
|
|
5007
|
+
const out = [];
|
|
5008
|
+
const before = READ_BEFORE[language];
|
|
5009
|
+
const after = READ_AFTER[language];
|
|
5010
|
+
const assigned = /* @__PURE__ */ new Map();
|
|
5011
|
+
for (const m of code.matchAll(STRING_LITERAL)) {
|
|
5012
|
+
const raw = m[2].trim();
|
|
5013
|
+
const value = raw.replace(/^[<+]\s*/, "");
|
|
5014
|
+
if (!value) continue;
|
|
5015
|
+
const head = code.slice(Math.max(0, m.index - 160), m.index);
|
|
5016
|
+
const tail = code.slice(m.index + m[0].length, m.index + m[0].length + 40);
|
|
5017
|
+
if (/^[>|]/.test(raw) || WRITE_MODE_AFTER.test(tail) || PERL_WRITE_BEFORE.test(head)) continue;
|
|
5018
|
+
if (before.test(head) || after?.test(tail) || language === "node" && DOTENV_PATH_OPTION.test(head)) {
|
|
5019
|
+
out.push(value);
|
|
5020
|
+
continue;
|
|
5021
|
+
}
|
|
5022
|
+
const name = ASSIGNED.exec(head)?.[1];
|
|
5023
|
+
if (name) assigned.set(name, [...assigned.get(name) ?? [], value]);
|
|
5024
|
+
}
|
|
5025
|
+
if (assigned.size > 0) {
|
|
5026
|
+
const opened = /* @__PURE__ */ new Set();
|
|
5027
|
+
for (const m of code.matchAll(OPENED_NAME[language])) opened.add(m[1] ?? m[2]);
|
|
5028
|
+
for (const [name, values] of assigned) if (opened.has(name)) out.push(...values);
|
|
5029
|
+
}
|
|
5030
|
+
if (language === "python" || language === "node") {
|
|
5031
|
+
const d = DOTENV[language];
|
|
5032
|
+
const readsEnv = d.env.test(code);
|
|
5033
|
+
const loads = /dotenv/.test(code) && d.load.test(code) && !d.literalPath.test(code);
|
|
5034
|
+
if ((loads || preload.dotenv) && (readsEnv || d.values.test(code))) out.push(".env");
|
|
5035
|
+
if (readsEnv) out.push(...preload.envFiles ?? []);
|
|
5036
|
+
}
|
|
5037
|
+
return out;
|
|
5038
|
+
}
|
|
4945
5039
|
function amplifies(language, code) {
|
|
4946
5040
|
const loop = language === "python" ? /\bwhile\s+(?:True|1)\s*:/ : language === "node" ? /\bwhile\s*\(\s*(?:true|1)\s*\)|\bfor\s*\(\s*;\s*;\s*\)|\bsetInterval\s*\(/ : /\bwhile\s*\(?\s*(?:1|true)\s*\)?|\bloop\s+do\b|\bfor\s*\(\s*;\s*;\s*\)/;
|
|
4947
5041
|
const m = loop.exec(code);
|
|
@@ -6571,6 +6665,7 @@ function attachedCode(interp, flag) {
|
|
|
6571
6665
|
if (letters === "ep" && /^[ep]*$/i.test(rest)) rest = "";
|
|
6572
6666
|
return rest === "" ? null : rest;
|
|
6573
6667
|
}
|
|
6668
|
+
var NODE_VALUE_FLAG = /^(-r|--require|--import|--loader|--experimental-loader|--env-file|--env-file-if-exists|--input-type|-C|--conditions)(?:=(.*))?$/;
|
|
6574
6669
|
function inlineExecCall(stmt, pipeFed) {
|
|
6575
6670
|
const cmd = stmt?.Cmd;
|
|
6576
6671
|
if (!cmd || cmd.kind !== "CallExpr") return null;
|
|
@@ -6595,15 +6690,28 @@ function inlineExecCall(stmt, pipeFed) {
|
|
|
6595
6690
|
const fromStdin = () => {
|
|
6596
6691
|
if (stdinFed) {
|
|
6597
6692
|
const { code, source } = stdinCodeOf(redirs);
|
|
6598
|
-
return { interp, code: [code], source };
|
|
6693
|
+
return { interp, code: [code], source, preload };
|
|
6599
6694
|
}
|
|
6600
6695
|
return { interp, code: [null], source: "pipe" };
|
|
6601
6696
|
};
|
|
6602
6697
|
let positionals2 = 0;
|
|
6603
6698
|
let selectedProgram = false;
|
|
6604
6699
|
const codes = [];
|
|
6700
|
+
const preload = {};
|
|
6701
|
+
const nodeFamily = inlineLanguageOf(interp) === "node";
|
|
6605
6702
|
for (let i = 0; i < args.length; i++) {
|
|
6606
6703
|
const a = args[i];
|
|
6704
|
+
if (nodeFamily && !selectedProgram && codes.length === 0 && a != null) {
|
|
6705
|
+
const flag = NODE_VALUE_FLAG.exec(a);
|
|
6706
|
+
if (flag) {
|
|
6707
|
+
const value = flag[2] ?? args[++i];
|
|
6708
|
+
if (value != null) {
|
|
6709
|
+
if (/^--env-file/.test(flag[1])) (preload.envFiles ??= []).push(value);
|
|
6710
|
+
else if (/^dotenv\/config(?:\.js)?$/.test(value)) preload.dotenv = true;
|
|
6711
|
+
}
|
|
6712
|
+
continue;
|
|
6713
|
+
}
|
|
6714
|
+
}
|
|
6607
6715
|
if (a == null) {
|
|
6608
6716
|
if (codes.length > 0) break;
|
|
6609
6717
|
positionals2++;
|
|
@@ -6640,7 +6748,12 @@ function inlineExecCall(stmt, pipeFed) {
|
|
|
6640
6748
|
}
|
|
6641
6749
|
}
|
|
6642
6750
|
if (codes.length > 0) {
|
|
6643
|
-
return {
|
|
6751
|
+
return {
|
|
6752
|
+
interp,
|
|
6753
|
+
code: codes,
|
|
6754
|
+
source: codes.includes(null) ? "variable" : void 0,
|
|
6755
|
+
preload
|
|
6756
|
+
};
|
|
6644
6757
|
}
|
|
6645
6758
|
if (positionals2 === 0 && (stdinFed || pipeFed)) {
|
|
6646
6759
|
if (!/^(bash|sh|zsh)$/i.test(interp)) return fromStdin();
|
|
@@ -7659,7 +7772,7 @@ var FS_OP_CACHE_MAX = 5e3;
|
|
|
7659
7772
|
var fsOpCache = /* @__PURE__ */ new Map();
|
|
7660
7773
|
function analyzeFsOperation(command) {
|
|
7661
7774
|
const normalized = normalizeCommandForPolicy(command);
|
|
7662
|
-
if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command))
|
|
7775
|
+
if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command) && !runsInlineInterpreter(command, normalized))
|
|
7663
7776
|
return null;
|
|
7664
7777
|
if (fsOpCache.has(command)) {
|
|
7665
7778
|
const hit = fsOpCache.get(command) ?? null;
|
|
@@ -7667,7 +7780,8 @@ function analyzeFsOperation(command) {
|
|
|
7667
7780
|
fsOpCache.set(command, hit);
|
|
7668
7781
|
return hit;
|
|
7669
7782
|
}
|
|
7670
|
-
const
|
|
7783
|
+
const direct = analyzeFsOperationImpl(command) ?? (INDIRECT_SHAPE_RE.test(command) ? structuralJailRead(command) : null);
|
|
7784
|
+
const computed = direct?.verdict === "block" || !runsInlineInterpreter(command, normalized) ? direct : stricter(direct, inlineCodeJailRead(command));
|
|
7671
7785
|
if (fsOpCache.size >= FS_OP_CACHE_MAX) {
|
|
7672
7786
|
const oldest = fsOpCache.keys().next().value;
|
|
7673
7787
|
if (oldest !== void 0) fsOpCache.delete(oldest);
|
|
@@ -8477,6 +8591,26 @@ function structuralJailRead(command) {
|
|
|
8477
8591
|
}
|
|
8478
8592
|
return review;
|
|
8479
8593
|
}
|
|
8594
|
+
var INLINE_INTERP_PRESCREEN_RE = /(?:^|[^\w-])(?:python|node|tsx|ts-node|deno|bun|perl|ruby|irb|php)(?![A-Za-z_])/i;
|
|
8595
|
+
var runsInlineInterpreter = (command, normalized) => INLINE_INTERP_PRESCREEN_RE.test(command) || INLINE_INTERP_PRESCREEN_RE.test(normalized);
|
|
8596
|
+
function inlineCodeJailRead(command) {
|
|
8597
|
+
const calls = inlineExecCalls(command);
|
|
8598
|
+
if (calls === PARSE_FAIL) return null;
|
|
8599
|
+
let review = null;
|
|
8600
|
+
for (const call of calls) {
|
|
8601
|
+
const language = inlineLanguageOf(call.interp);
|
|
8602
|
+
if (language === null) continue;
|
|
8603
|
+
for (const code of call.code) {
|
|
8604
|
+
if (code === null) continue;
|
|
8605
|
+
for (const p of inlineReadPaths(language, code, call.preload)) {
|
|
8606
|
+
const hit = matchSensitivePath(p);
|
|
8607
|
+
if (hit?.verdict === "block") return hit;
|
|
8608
|
+
review ??= hit;
|
|
8609
|
+
}
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8612
|
+
return review;
|
|
8613
|
+
}
|
|
8480
8614
|
function baseWord(w) {
|
|
8481
8615
|
return (w ?? "").split("/").pop()?.toLowerCase() ?? "";
|
|
8482
8616
|
}
|
|
@@ -16770,6 +16904,16 @@ var TUNING_FIELDS = [
|
|
|
16770
16904
|
name: "installScript",
|
|
16771
16905
|
legacy: ["packageCheck", "installScript"]
|
|
16772
16906
|
},
|
|
16907
|
+
{
|
|
16908
|
+
checkId: "loading.malicious-package",
|
|
16909
|
+
name: "lookalike",
|
|
16910
|
+
legacy: ["packageCheck", "lookalike"]
|
|
16911
|
+
},
|
|
16912
|
+
{
|
|
16913
|
+
checkId: "loading.malicious-package",
|
|
16914
|
+
name: "establishedAge",
|
|
16915
|
+
legacy: ["packageCheck", "establishedAge"]
|
|
16916
|
+
},
|
|
16773
16917
|
{
|
|
16774
16918
|
checkId: "loading.malicious-package",
|
|
16775
16919
|
name: "onlineFallback",
|
|
@@ -16799,7 +16943,11 @@ function tuningFromLegacyPolicy(policy) {
|
|
|
16799
16943
|
const out = {};
|
|
16800
16944
|
const p = policy;
|
|
16801
16945
|
if (policy.packageCheck?.registrySignals === false) {
|
|
16802
|
-
out["loading.malicious-package"] = {
|
|
16946
|
+
out["loading.malicious-package"] = {
|
|
16947
|
+
newPackage: "off",
|
|
16948
|
+
installScript: "off",
|
|
16949
|
+
lookalike: "off"
|
|
16950
|
+
};
|
|
16803
16951
|
}
|
|
16804
16952
|
for (const f of TUNING_FIELDS) {
|
|
16805
16953
|
const [block, key] = f.legacy;
|
|
@@ -16818,6 +16966,7 @@ function tuningToLegacyPolicy(policy, tuning) {
|
|
|
16818
16966
|
if (normalized.registrySignals === false) {
|
|
16819
16967
|
normalized.newPackage ??= "off";
|
|
16820
16968
|
normalized.installScript ??= "off";
|
|
16969
|
+
normalized.lookalike ??= "off";
|
|
16821
16970
|
}
|
|
16822
16971
|
delete normalized.registrySignals;
|
|
16823
16972
|
}
|
|
@@ -17993,7 +18142,15 @@ function egressPolicyVerdict(eg) {
|
|
|
17993
18142
|
checkId: "network.unknown-host"
|
|
17994
18143
|
};
|
|
17995
18144
|
}
|
|
18145
|
+
var NOT_OVERRIDABLE_CHECKS = /* @__PURE__ */ new Set([
|
|
18146
|
+
"data.credential-files",
|
|
18147
|
+
"data.credential-files-other"
|
|
18148
|
+
]);
|
|
17996
18149
|
async function evaluatePolicy(config, toolName, args, context = {}, hostHooks = {}) {
|
|
18150
|
+
const v = await evaluatePolicyVerdict(config, toolName, args, context, hostHooks);
|
|
18151
|
+
return v.decision === "block" && v.checkId !== void 0 && NOT_OVERRIDABLE_CHECKS.has(v.checkId) ? { ...v, overridable: false } : v;
|
|
18152
|
+
}
|
|
18153
|
+
async function evaluatePolicyVerdict(config, toolName, args, context = {}, hostHooks = {}) {
|
|
17997
18154
|
let protectedVerdict = null;
|
|
17998
18155
|
const layers = inspectionLayers(config.policy);
|
|
17999
18156
|
if (context.agent !== "Terminal") {
|
|
@@ -20207,8 +20364,8 @@ function matchCanaryArgs(args, values) {
|
|
|
20207
20364
|
|
|
20208
20365
|
// src/scan/canonical.ts
|
|
20209
20366
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20210
|
-
var CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
20211
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
20367
|
+
var CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
20368
|
+
var CANONICAL_EXTRACTOR_HASH = "5ec00461a49e1858";
|
|
20212
20369
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20213
20370
|
function extractCanonicalFindings(call, ctx) {
|
|
20214
20371
|
const out = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node9/policy-engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.54.0",
|
|
4
4
|
"description": "Shared policy evaluation engine for node9 — DLP, smart rules, AST shell parsing, shields, loop detection. Pure functions, no I/O. Used by both node9-proxy and the node9 SaaS firewall.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://node9.ai",
|