@node9/policy-engine 2.55.0 → 2.55.2
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +81 -3
- package/dist/index.mjs +81 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2455,7 +2455,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
|
2455
2455
|
* files changed, this hash must change too, and you must consciously
|
|
2456
2456
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2457
2457
|
*/
|
|
2458
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2458
|
+
declare const CANONICAL_EXTRACTOR_HASH = "40803f3331f55a36";
|
|
2459
2459
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2460
2460
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2461
2461
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2455,7 +2455,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
|
2455
2455
|
* files changed, this hash must change too, and you must consciously
|
|
2456
2456
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2457
2457
|
*/
|
|
2458
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2458
|
+
declare const CANONICAL_EXTRACTOR_HASH = "40803f3331f55a36";
|
|
2459
2459
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2460
2460
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2461
2461
|
/**
|
package/dist/index.js
CHANGED
|
@@ -12989,6 +12989,62 @@ function validateAssignedSecret(raw, before = "") {
|
|
|
12989
12989
|
const mixed = /[0-9]/.test(value) && /[A-Za-z]/.test(value);
|
|
12990
12990
|
return looksGenerated(value, 12, mixed ? 3 : 3.5);
|
|
12991
12991
|
}
|
|
12992
|
+
var INLINE_SECRET_NAMES = /* @__PURE__ */ new Set([
|
|
12993
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
12994
|
+
"AWS_SESSION_TOKEN",
|
|
12995
|
+
"GITHUB_TOKEN",
|
|
12996
|
+
"GH_TOKEN",
|
|
12997
|
+
"NPM_TOKEN",
|
|
12998
|
+
"OPENAI_API_KEY",
|
|
12999
|
+
"ANTHROPIC_API_KEY",
|
|
13000
|
+
"DATABASE_URL"
|
|
13001
|
+
]);
|
|
13002
|
+
var INLINE_SECRET_PARTS_RE = /([A-Z][A-Z0-9_]*)=([\s\S]+)$/;
|
|
13003
|
+
var INLINE_REFERENCE_RE = /[$`]/;
|
|
13004
|
+
var INLINE_FIXTURE_WORDS = /* @__PURE__ */ new Set([
|
|
13005
|
+
...["dummy", "fake", "mock", "stub", "placeholder", "changeme", "redacted", "sample"],
|
|
13006
|
+
...["test", "tests", "testing", "real", "invalid", "bogus", "nonexistent", "notreal"]
|
|
13007
|
+
]);
|
|
13008
|
+
var INLINE_PLACEHOLDER_WORDS = /* @__PURE__ */ new Set([
|
|
13009
|
+
...["pass", "password", "passwd", "pwd", "secret", "token", "key", "apikey", "value"],
|
|
13010
|
+
...["admin", "administrator", "root", "user", "guest", "demo", "default", "letmein", "qwerty"],
|
|
13011
|
+
...["test", "testing", "example", "sample", "dummy", "fake", "mock", "stub", "placeholder"],
|
|
13012
|
+
...["changeme", "change", "replace", "insert", "paste", "fill", "put", "set", "me", "in", "it"],
|
|
13013
|
+
...["your", "my", "the", "a", "here", "goes", "string", "foo", "bar", "baz", "todo", "fixme"],
|
|
13014
|
+
...["redacted", "hidden", "omitted", "removed", "masked", "none", "null", "undefined", "nil"],
|
|
13015
|
+
...["xxx", "postgres", "mysql", "mariadb", "redis", "mongo", "dev", "development", "local"],
|
|
13016
|
+
...["localhost", "docker", "ci", "invalid", "unset", "empty", "missing", "skip", "noop"]
|
|
13017
|
+
]);
|
|
13018
|
+
function isInlinePlaceholder(value) {
|
|
13019
|
+
const lower2 = value.toLowerCase();
|
|
13020
|
+
if (/^(.)\1*$/.test(value)) return true;
|
|
13021
|
+
if (/^<.*>$/.test(value) || /^\[.*\]$/.test(value)) return true;
|
|
13022
|
+
if (BASIC_TEMPLATE_MARKERS.some((m) => lower2.includes(m))) return true;
|
|
13023
|
+
if (hasSequentialRun(value)) return true;
|
|
13024
|
+
const words = lower2.split(/[^a-z]+/).filter(Boolean);
|
|
13025
|
+
if (words.some((w) => INLINE_FIXTURE_WORDS.has(w))) return true;
|
|
13026
|
+
return words.length > 0 && words.every((w) => INLINE_PLACEHOLDER_WORDS.has(w));
|
|
13027
|
+
}
|
|
13028
|
+
function validateInlineSecretAssignment(raw) {
|
|
13029
|
+
const parts = raw.match(INLINE_SECRET_PARTS_RE);
|
|
13030
|
+
if (!parts) return false;
|
|
13031
|
+
const name = parts[1];
|
|
13032
|
+
let value = parts[2];
|
|
13033
|
+
const quote = value.charAt(0);
|
|
13034
|
+
if ((quote === '"' || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1);
|
|
13035
|
+
if (value === "") return false;
|
|
13036
|
+
if (quote !== "'" && INLINE_REFERENCE_RE.test(value)) return false;
|
|
13037
|
+
if (isInlinePlaceholder(value)) return false;
|
|
13038
|
+
if (rejectedByStructuredValidator(value)) return false;
|
|
13039
|
+
if (name === "DATABASE_URL") {
|
|
13040
|
+
const password = capturedValue(value, DB_URL_PASSWORD_RE);
|
|
13041
|
+
return password !== null && !isInlinePlaceholder(password);
|
|
13042
|
+
}
|
|
13043
|
+
if (INLINE_SECRET_NAMES.has(name)) return true;
|
|
13044
|
+
if (!nameHoldsCredential(name)) return false;
|
|
13045
|
+
if (value.length < 8 || IDENTIFIER_VALUE_RE.test(value)) return false;
|
|
13046
|
+
return true;
|
|
13047
|
+
}
|
|
12992
13048
|
var CIPHER_KEY_NAME_RE = /^([A-Za-z_][\w.]{0,40})/;
|
|
12993
13049
|
var CIPHER_NAME_PARTS = /* @__PURE__ */ new Set([
|
|
12994
13050
|
"cipher",
|
|
@@ -13703,6 +13759,26 @@ var DLP_PATTERNS = [
|
|
|
13703
13759
|
keywords: ["pass", "pwd", "secret", "token", "key", "ticket"],
|
|
13704
13760
|
validate: validateAssignedSecret,
|
|
13705
13761
|
argumentsOnly: true
|
|
13762
|
+
},
|
|
13763
|
+
// ── Known secret variable assigned a literal ──────────────────────────────
|
|
13764
|
+
// `AWS_SECRET_ACCESS_KEY=… aws s3 ls`, `export GH_TOKEN=… && gh api`, `env
|
|
13765
|
+
// NPM_TOKEN=… npm publish`, and a `*_SECRET` / `*_TOKEN` / `*_PASSWORD` /
|
|
13766
|
+
// `*_API_KEY` name in the same place. The name starts a shell word (the
|
|
13767
|
+
// start of the text, a space, a newline, `;`, `&`, `|`, `(`), so an
|
|
13768
|
+
// assignment given as an argument (`docker run -e GITHUB_TOKEN=…`) is the
|
|
13769
|
+
// same handoff and counts too; the value is the rest of the word, or a
|
|
13770
|
+
// quoted string. The validator decides by the
|
|
13771
|
+
// name (node9Firewall#451): see validateInlineSecretAssignment. review, as
|
|
13772
|
+
// every name-based finding: the shape of the value is not checked, so a
|
|
13773
|
+
// human confirms rather than the gate deciding alone.
|
|
13774
|
+
{
|
|
13775
|
+
name: "Inline Secret Assignment",
|
|
13776
|
+
regex: /(?:^|[\s;&|(])((?:AWS_SECRET_ACCESS_KEY|AWS_SESSION_TOKEN|GITHUB_TOKEN|GH_TOKEN|NPM_TOKEN|OPENAI_API_KEY|ANTHROPIC_API_KEY|DATABASE_URL)|[A-Z][A-Z0-9_]{0,60}_(?:SECRET|TOKEN|PASSWORD|API_KEY))=("[^"\n]{1,512}"|'[^'\n]{1,512}'|[^\s;&|"'`()<>]{1,512})/,
|
|
13777
|
+
severity: "review",
|
|
13778
|
+
keywords: ["_secret", "_token", "_password", "_api_key", "database_url"],
|
|
13779
|
+
validate: validateInlineSecretAssignment,
|
|
13780
|
+
redactGroup: 2,
|
|
13781
|
+
argumentsOnly: true
|
|
13706
13782
|
}
|
|
13707
13783
|
];
|
|
13708
13784
|
var DLP_PATTERNS_GLOBAL = DLP_PATTERNS.map(
|
|
@@ -13798,12 +13874,14 @@ function assertBuiltinPatternsAreSafe() {
|
|
|
13798
13874
|
}
|
|
13799
13875
|
}
|
|
13800
13876
|
assertBuiltinPatternsAreSafe();
|
|
13801
|
-
function maskSecret(raw, pattern) {
|
|
13877
|
+
function maskSecret(raw, pattern, redactGroup) {
|
|
13802
13878
|
const match = raw.match(pattern);
|
|
13803
13879
|
if (!match) return "****";
|
|
13804
13880
|
const secret = match[0];
|
|
13805
13881
|
if (secret.length < 8) return "****";
|
|
13806
13882
|
const prefix = secret.slice(0, 4);
|
|
13883
|
+
const group = redactGroup !== void 0 ? match[redactGroup] : void 0;
|
|
13884
|
+
if (typeof group === "string" && group.length < 8) return `${prefix}****`;
|
|
13807
13885
|
const suffix = secret.slice(-4);
|
|
13808
13886
|
const stars = "*".repeat(Math.min(secret.length - 8, 12));
|
|
13809
13887
|
return `${prefix}${stars}${suffix}`;
|
|
@@ -13858,7 +13936,7 @@ function matchArgumentText(text, fieldPath, budget) {
|
|
|
13858
13936
|
const match = {
|
|
13859
13937
|
patternName: pattern.name,
|
|
13860
13938
|
fieldPath,
|
|
13861
|
-
redactedSample: maskSecret(raw, pattern.regex),
|
|
13939
|
+
redactedSample: maskSecret(raw, pattern.regex, pattern.redactGroup),
|
|
13862
13940
|
severity
|
|
13863
13941
|
};
|
|
13864
13942
|
if (severity === "block") return match;
|
|
@@ -20958,7 +21036,7 @@ function matchCanaryArgs(args, values) {
|
|
|
20958
21036
|
// src/scan/canonical.ts
|
|
20959
21037
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20960
21038
|
var CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
20961
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
21039
|
+
var CANONICAL_EXTRACTOR_HASH = "40803f3331f55a36";
|
|
20962
21040
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20963
21041
|
function extractCanonicalFindings(call, ctx) {
|
|
20964
21042
|
const out = [];
|
package/dist/index.mjs
CHANGED
|
@@ -12726,6 +12726,62 @@ function validateAssignedSecret(raw, before = "") {
|
|
|
12726
12726
|
const mixed = /[0-9]/.test(value) && /[A-Za-z]/.test(value);
|
|
12727
12727
|
return looksGenerated(value, 12, mixed ? 3 : 3.5);
|
|
12728
12728
|
}
|
|
12729
|
+
var INLINE_SECRET_NAMES = /* @__PURE__ */ new Set([
|
|
12730
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
12731
|
+
"AWS_SESSION_TOKEN",
|
|
12732
|
+
"GITHUB_TOKEN",
|
|
12733
|
+
"GH_TOKEN",
|
|
12734
|
+
"NPM_TOKEN",
|
|
12735
|
+
"OPENAI_API_KEY",
|
|
12736
|
+
"ANTHROPIC_API_KEY",
|
|
12737
|
+
"DATABASE_URL"
|
|
12738
|
+
]);
|
|
12739
|
+
var INLINE_SECRET_PARTS_RE = /([A-Z][A-Z0-9_]*)=([\s\S]+)$/;
|
|
12740
|
+
var INLINE_REFERENCE_RE = /[$`]/;
|
|
12741
|
+
var INLINE_FIXTURE_WORDS = /* @__PURE__ */ new Set([
|
|
12742
|
+
...["dummy", "fake", "mock", "stub", "placeholder", "changeme", "redacted", "sample"],
|
|
12743
|
+
...["test", "tests", "testing", "real", "invalid", "bogus", "nonexistent", "notreal"]
|
|
12744
|
+
]);
|
|
12745
|
+
var INLINE_PLACEHOLDER_WORDS = /* @__PURE__ */ new Set([
|
|
12746
|
+
...["pass", "password", "passwd", "pwd", "secret", "token", "key", "apikey", "value"],
|
|
12747
|
+
...["admin", "administrator", "root", "user", "guest", "demo", "default", "letmein", "qwerty"],
|
|
12748
|
+
...["test", "testing", "example", "sample", "dummy", "fake", "mock", "stub", "placeholder"],
|
|
12749
|
+
...["changeme", "change", "replace", "insert", "paste", "fill", "put", "set", "me", "in", "it"],
|
|
12750
|
+
...["your", "my", "the", "a", "here", "goes", "string", "foo", "bar", "baz", "todo", "fixme"],
|
|
12751
|
+
...["redacted", "hidden", "omitted", "removed", "masked", "none", "null", "undefined", "nil"],
|
|
12752
|
+
...["xxx", "postgres", "mysql", "mariadb", "redis", "mongo", "dev", "development", "local"],
|
|
12753
|
+
...["localhost", "docker", "ci", "invalid", "unset", "empty", "missing", "skip", "noop"]
|
|
12754
|
+
]);
|
|
12755
|
+
function isInlinePlaceholder(value) {
|
|
12756
|
+
const lower2 = value.toLowerCase();
|
|
12757
|
+
if (/^(.)\1*$/.test(value)) return true;
|
|
12758
|
+
if (/^<.*>$/.test(value) || /^\[.*\]$/.test(value)) return true;
|
|
12759
|
+
if (BASIC_TEMPLATE_MARKERS.some((m) => lower2.includes(m))) return true;
|
|
12760
|
+
if (hasSequentialRun(value)) return true;
|
|
12761
|
+
const words = lower2.split(/[^a-z]+/).filter(Boolean);
|
|
12762
|
+
if (words.some((w) => INLINE_FIXTURE_WORDS.has(w))) return true;
|
|
12763
|
+
return words.length > 0 && words.every((w) => INLINE_PLACEHOLDER_WORDS.has(w));
|
|
12764
|
+
}
|
|
12765
|
+
function validateInlineSecretAssignment(raw) {
|
|
12766
|
+
const parts = raw.match(INLINE_SECRET_PARTS_RE);
|
|
12767
|
+
if (!parts) return false;
|
|
12768
|
+
const name = parts[1];
|
|
12769
|
+
let value = parts[2];
|
|
12770
|
+
const quote = value.charAt(0);
|
|
12771
|
+
if ((quote === '"' || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1);
|
|
12772
|
+
if (value === "") return false;
|
|
12773
|
+
if (quote !== "'" && INLINE_REFERENCE_RE.test(value)) return false;
|
|
12774
|
+
if (isInlinePlaceholder(value)) return false;
|
|
12775
|
+
if (rejectedByStructuredValidator(value)) return false;
|
|
12776
|
+
if (name === "DATABASE_URL") {
|
|
12777
|
+
const password = capturedValue(value, DB_URL_PASSWORD_RE);
|
|
12778
|
+
return password !== null && !isInlinePlaceholder(password);
|
|
12779
|
+
}
|
|
12780
|
+
if (INLINE_SECRET_NAMES.has(name)) return true;
|
|
12781
|
+
if (!nameHoldsCredential(name)) return false;
|
|
12782
|
+
if (value.length < 8 || IDENTIFIER_VALUE_RE.test(value)) return false;
|
|
12783
|
+
return true;
|
|
12784
|
+
}
|
|
12729
12785
|
var CIPHER_KEY_NAME_RE = /^([A-Za-z_][\w.]{0,40})/;
|
|
12730
12786
|
var CIPHER_NAME_PARTS = /* @__PURE__ */ new Set([
|
|
12731
12787
|
"cipher",
|
|
@@ -13440,6 +13496,26 @@ var DLP_PATTERNS = [
|
|
|
13440
13496
|
keywords: ["pass", "pwd", "secret", "token", "key", "ticket"],
|
|
13441
13497
|
validate: validateAssignedSecret,
|
|
13442
13498
|
argumentsOnly: true
|
|
13499
|
+
},
|
|
13500
|
+
// ── Known secret variable assigned a literal ──────────────────────────────
|
|
13501
|
+
// `AWS_SECRET_ACCESS_KEY=… aws s3 ls`, `export GH_TOKEN=… && gh api`, `env
|
|
13502
|
+
// NPM_TOKEN=… npm publish`, and a `*_SECRET` / `*_TOKEN` / `*_PASSWORD` /
|
|
13503
|
+
// `*_API_KEY` name in the same place. The name starts a shell word (the
|
|
13504
|
+
// start of the text, a space, a newline, `;`, `&`, `|`, `(`), so an
|
|
13505
|
+
// assignment given as an argument (`docker run -e GITHUB_TOKEN=…`) is the
|
|
13506
|
+
// same handoff and counts too; the value is the rest of the word, or a
|
|
13507
|
+
// quoted string. The validator decides by the
|
|
13508
|
+
// name (node9Firewall#451): see validateInlineSecretAssignment. review, as
|
|
13509
|
+
// every name-based finding: the shape of the value is not checked, so a
|
|
13510
|
+
// human confirms rather than the gate deciding alone.
|
|
13511
|
+
{
|
|
13512
|
+
name: "Inline Secret Assignment",
|
|
13513
|
+
regex: /(?:^|[\s;&|(])((?:AWS_SECRET_ACCESS_KEY|AWS_SESSION_TOKEN|GITHUB_TOKEN|GH_TOKEN|NPM_TOKEN|OPENAI_API_KEY|ANTHROPIC_API_KEY|DATABASE_URL)|[A-Z][A-Z0-9_]{0,60}_(?:SECRET|TOKEN|PASSWORD|API_KEY))=("[^"\n]{1,512}"|'[^'\n]{1,512}'|[^\s;&|"'`()<>]{1,512})/,
|
|
13514
|
+
severity: "review",
|
|
13515
|
+
keywords: ["_secret", "_token", "_password", "_api_key", "database_url"],
|
|
13516
|
+
validate: validateInlineSecretAssignment,
|
|
13517
|
+
redactGroup: 2,
|
|
13518
|
+
argumentsOnly: true
|
|
13443
13519
|
}
|
|
13444
13520
|
];
|
|
13445
13521
|
var DLP_PATTERNS_GLOBAL = DLP_PATTERNS.map(
|
|
@@ -13535,12 +13611,14 @@ function assertBuiltinPatternsAreSafe() {
|
|
|
13535
13611
|
}
|
|
13536
13612
|
}
|
|
13537
13613
|
assertBuiltinPatternsAreSafe();
|
|
13538
|
-
function maskSecret(raw, pattern) {
|
|
13614
|
+
function maskSecret(raw, pattern, redactGroup) {
|
|
13539
13615
|
const match = raw.match(pattern);
|
|
13540
13616
|
if (!match) return "****";
|
|
13541
13617
|
const secret = match[0];
|
|
13542
13618
|
if (secret.length < 8) return "****";
|
|
13543
13619
|
const prefix = secret.slice(0, 4);
|
|
13620
|
+
const group = redactGroup !== void 0 ? match[redactGroup] : void 0;
|
|
13621
|
+
if (typeof group === "string" && group.length < 8) return `${prefix}****`;
|
|
13544
13622
|
const suffix = secret.slice(-4);
|
|
13545
13623
|
const stars = "*".repeat(Math.min(secret.length - 8, 12));
|
|
13546
13624
|
return `${prefix}${stars}${suffix}`;
|
|
@@ -13595,7 +13673,7 @@ function matchArgumentText(text, fieldPath, budget) {
|
|
|
13595
13673
|
const match = {
|
|
13596
13674
|
patternName: pattern.name,
|
|
13597
13675
|
fieldPath,
|
|
13598
|
-
redactedSample: maskSecret(raw, pattern.regex),
|
|
13676
|
+
redactedSample: maskSecret(raw, pattern.regex, pattern.redactGroup),
|
|
13599
13677
|
severity
|
|
13600
13678
|
};
|
|
13601
13679
|
if (severity === "block") return match;
|
|
@@ -20695,7 +20773,7 @@ function matchCanaryArgs(args, values) {
|
|
|
20695
20773
|
// src/scan/canonical.ts
|
|
20696
20774
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20697
20775
|
var CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
|
|
20698
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
20776
|
+
var CANONICAL_EXTRACTOR_HASH = "40803f3331f55a36";
|
|
20699
20777
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20700
20778
|
function extractCanonicalFindings(call, ctx) {
|
|
20701
20779
|
const out = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node9/policy-engine",
|
|
3
|
-
"version": "2.55.
|
|
3
|
+
"version": "2.55.2",
|
|
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",
|