@profullstack/threatcrush 0.13.26 → 0.13.28
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/daemon.js +44 -10
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +47 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22822,6 +22822,9 @@ function detectXSS(bytes) {
|
|
|
22822
22822
|
var SEVERITY_POINTS = { CRITICAL: 5, ERROR: 4, WARNING: 3, NOTICE: 2 };
|
|
22823
22823
|
var DEFAULT_ANOMALY_THRESHOLD = 5;
|
|
22824
22824
|
var DEFAULT_EXCLUDED_RULE_IDS = [941130];
|
|
22825
|
+
var ARGUMENT_EXCLUSIONS = [
|
|
22826
|
+
{ ruleIds: [942100], path: /^\/rest\/v1\//, arg: "select", value: /^[A-Za-z0-9_*,.:!()>-]+$/ }
|
|
22827
|
+
];
|
|
22825
22828
|
var ATTACK_TYPES = {
|
|
22826
22829
|
"attack-sqli": "sqli",
|
|
22827
22830
|
"attack-xss": "xss",
|
|
@@ -22955,18 +22958,31 @@ var RequestContext = class {
|
|
|
22955
22958
|
values(target) {
|
|
22956
22959
|
let slots = this.slots.get(target);
|
|
22957
22960
|
if (!slots) {
|
|
22958
|
-
slots = this.derive(target).map((value) => ({ value, cache: /* @__PURE__ */ new Map() }));
|
|
22961
|
+
slots = target === "ARGS" ? this.args() : this.derive(target).map((value) => ({ value, cache: /* @__PURE__ */ new Map() }));
|
|
22959
22962
|
this.slots.set(target, slots);
|
|
22960
22963
|
}
|
|
22961
22964
|
return slots;
|
|
22962
22965
|
}
|
|
22963
|
-
|
|
22964
|
-
|
|
22965
|
-
const relative4 = uri.replace(ABSOLUTE_FORM, "");
|
|
22966
|
+
/** apr_uri_parse: path up to ? or #, query up to #, authority dropped. */
|
|
22967
|
+
split() {
|
|
22968
|
+
const relative4 = this.req.uri.replace(ABSOLUTE_FORM, "");
|
|
22966
22969
|
const q = relative4.search(/[?#]/);
|
|
22967
22970
|
const path = q === -1 ? relative4 : relative4.slice(0, q);
|
|
22968
22971
|
const hasQuery = q !== -1 && relative4[q] === "?";
|
|
22969
|
-
|
|
22972
|
+
return { path, query: hasQuery ? relative4.slice(q + 1).split("#")[0] : void 0 };
|
|
22973
|
+
}
|
|
22974
|
+
args() {
|
|
22975
|
+
const { path, query } = this.split();
|
|
22976
|
+
if (query === void 0) return [];
|
|
22977
|
+
const exclusions = ARGUMENT_EXCLUSIONS.filter((e) => e.path.test(path));
|
|
22978
|
+
return parseArguments(query).map(({ name, value }) => {
|
|
22979
|
+
const ids = exclusions.filter((e) => e.arg === name && e.value.test(value)).flatMap((e) => e.ruleIds);
|
|
22980
|
+
return { value, cache: /* @__PURE__ */ new Map(), ...ids.length ? { excluded: new Set(ids) } : {} };
|
|
22981
|
+
});
|
|
22982
|
+
}
|
|
22983
|
+
derive(target) {
|
|
22984
|
+
const { uri } = this.req;
|
|
22985
|
+
const { path, query } = this.split();
|
|
22970
22986
|
switch (target) {
|
|
22971
22987
|
case "REQUEST_LINE":
|
|
22972
22988
|
return this.req.method && this.req.protocol ? [`${this.req.method} ${uri} ${this.req.protocol}`] : [];
|
|
@@ -23118,7 +23134,9 @@ var CrsEngine = class {
|
|
|
23118
23134
|
const hit = new Uint8Array(this.rules.length);
|
|
23119
23135
|
for (const [target, rules] of this.byTarget) {
|
|
23120
23136
|
for (const slot of ctx.values(target)) {
|
|
23121
|
-
for (const index of this.slotMatches(target, rules, slot))
|
|
23137
|
+
for (const index of this.slotMatches(target, rules, slot)) {
|
|
23138
|
+
if (!slot.excluded?.has(this.rules[index].rule.id)) hit[index] = 1;
|
|
23139
|
+
}
|
|
23122
23140
|
}
|
|
23123
23141
|
}
|
|
23124
23142
|
for (const compiled of this.chained) {
|
|
@@ -31633,10 +31651,12 @@ var IpcServer = class {
|
|
|
31633
31651
|
}
|
|
31634
31652
|
const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
31635
31653
|
if (isRoot4) {
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31639
|
-
|
|
31654
|
+
const gid = admGid();
|
|
31655
|
+
if (gid !== null) {
|
|
31656
|
+
try {
|
|
31657
|
+
nodeFs.chownSync(PATHS.socket, 0, gid);
|
|
31658
|
+
} catch {
|
|
31659
|
+
}
|
|
31640
31660
|
}
|
|
31641
31661
|
}
|
|
31642
31662
|
resolve6();
|
|
@@ -31841,6 +31861,20 @@ var IpcServer = class {
|
|
|
31841
31861
|
}
|
|
31842
31862
|
}
|
|
31843
31863
|
};
|
|
31864
|
+
function admGid(readGroup = () => (0, import_node_fs24.readFileSync)("/etc/group", "utf-8"), statAuthLog = () => (0, import_node_fs24.statSync)("/var/log/auth.log")) {
|
|
31865
|
+
try {
|
|
31866
|
+
for (const line of readGroup().split("\n")) {
|
|
31867
|
+
const [name, , gid] = line.split(":");
|
|
31868
|
+
if (name === "adm" && gid !== void 0 && /^\d+$/.test(gid)) return Number(gid);
|
|
31869
|
+
}
|
|
31870
|
+
} catch {
|
|
31871
|
+
}
|
|
31872
|
+
try {
|
|
31873
|
+
return statAuthLog().gid;
|
|
31874
|
+
} catch {
|
|
31875
|
+
return null;
|
|
31876
|
+
}
|
|
31877
|
+
}
|
|
31844
31878
|
|
|
31845
31879
|
// src/daemon/module-host.ts
|
|
31846
31880
|
var import_node_fs28 = require("fs");
|
|
@@ -36122,9 +36156,9 @@ function ensureSystemDirs(configDir) {
|
|
|
36122
36156
|
// it here only lasts until the next reboot. The unit's RuntimeDirectory=
|
|
36123
36157
|
// recreates it on every start instead.
|
|
36124
36158
|
];
|
|
36125
|
-
let
|
|
36159
|
+
let admGid2 = null;
|
|
36126
36160
|
try {
|
|
36127
|
-
|
|
36161
|
+
admGid2 = (0, import_node_fs37.statSync)("/var/log/auth.log").gid;
|
|
36128
36162
|
} catch {
|
|
36129
36163
|
}
|
|
36130
36164
|
for (const { path, groupWritable, sticky } of dirs) {
|
|
@@ -36133,7 +36167,7 @@ function ensureSystemDirs(configDir) {
|
|
|
36133
36167
|
} catch {
|
|
36134
36168
|
}
|
|
36135
36169
|
try {
|
|
36136
|
-
if (groupWritable &&
|
|
36170
|
+
if (groupWritable && admGid2 !== null) {
|
|
36137
36171
|
(0, import_node_fs37.chmodSync)(path, sticky ? 1533 : 509);
|
|
36138
36172
|
(0, import_node_child_process13.execSync)(`chgrp adm ${path}`, { stdio: "ignore" });
|
|
36139
36173
|
} else {
|