@profullstack/threatcrush 0.13.27 → 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 +24 -6
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -9097,6 +9097,9 @@ function detectXSS(bytes) {
|
|
|
9097
9097
|
var SEVERITY_POINTS = { CRITICAL: 5, ERROR: 4, WARNING: 3, NOTICE: 2 };
|
|
9098
9098
|
var DEFAULT_ANOMALY_THRESHOLD = 5;
|
|
9099
9099
|
var DEFAULT_EXCLUDED_RULE_IDS = [941130];
|
|
9100
|
+
var ARGUMENT_EXCLUSIONS = [
|
|
9101
|
+
{ ruleIds: [942100], path: /^\/rest\/v1\//, arg: "select", value: /^[A-Za-z0-9_*,.:!()>-]+$/ }
|
|
9102
|
+
];
|
|
9100
9103
|
var ATTACK_TYPES = {
|
|
9101
9104
|
"attack-sqli": "sqli",
|
|
9102
9105
|
"attack-xss": "xss",
|
|
@@ -9230,18 +9233,31 @@ var RequestContext = class {
|
|
|
9230
9233
|
values(target) {
|
|
9231
9234
|
let slots = this.slots.get(target);
|
|
9232
9235
|
if (!slots) {
|
|
9233
|
-
slots = this.derive(target).map((value) => ({ value, cache: /* @__PURE__ */ new Map() }));
|
|
9236
|
+
slots = target === "ARGS" ? this.args() : this.derive(target).map((value) => ({ value, cache: /* @__PURE__ */ new Map() }));
|
|
9234
9237
|
this.slots.set(target, slots);
|
|
9235
9238
|
}
|
|
9236
9239
|
return slots;
|
|
9237
9240
|
}
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
const relative4 = uri.replace(ABSOLUTE_FORM, "");
|
|
9241
|
+
/** apr_uri_parse: path up to ? or #, query up to #, authority dropped. */
|
|
9242
|
+
split() {
|
|
9243
|
+
const relative4 = this.req.uri.replace(ABSOLUTE_FORM, "");
|
|
9241
9244
|
const q = relative4.search(/[?#]/);
|
|
9242
9245
|
const path = q === -1 ? relative4 : relative4.slice(0, q);
|
|
9243
9246
|
const hasQuery = q !== -1 && relative4[q] === "?";
|
|
9244
|
-
|
|
9247
|
+
return { path, query: hasQuery ? relative4.slice(q + 1).split("#")[0] : void 0 };
|
|
9248
|
+
}
|
|
9249
|
+
args() {
|
|
9250
|
+
const { path, query } = this.split();
|
|
9251
|
+
if (query === void 0) return [];
|
|
9252
|
+
const exclusions = ARGUMENT_EXCLUSIONS.filter((e) => e.path.test(path));
|
|
9253
|
+
return parseArguments(query).map(({ name, value }) => {
|
|
9254
|
+
const ids = exclusions.filter((e) => e.arg === name && e.value.test(value)).flatMap((e) => e.ruleIds);
|
|
9255
|
+
return { value, cache: /* @__PURE__ */ new Map(), ...ids.length ? { excluded: new Set(ids) } : {} };
|
|
9256
|
+
});
|
|
9257
|
+
}
|
|
9258
|
+
derive(target) {
|
|
9259
|
+
const { uri } = this.req;
|
|
9260
|
+
const { path, query } = this.split();
|
|
9245
9261
|
switch (target) {
|
|
9246
9262
|
case "REQUEST_LINE":
|
|
9247
9263
|
return this.req.method && this.req.protocol ? [`${this.req.method} ${uri} ${this.req.protocol}`] : [];
|
|
@@ -9393,7 +9409,9 @@ var CrsEngine = class {
|
|
|
9393
9409
|
const hit = new Uint8Array(this.rules.length);
|
|
9394
9410
|
for (const [target, rules] of this.byTarget) {
|
|
9395
9411
|
for (const slot of ctx.values(target)) {
|
|
9396
|
-
for (const index of this.slotMatches(target, rules, slot))
|
|
9412
|
+
for (const index of this.slotMatches(target, rules, slot)) {
|
|
9413
|
+
if (!slot.excluded?.has(this.rules[index].rule.id)) hit[index] = 1;
|
|
9414
|
+
}
|
|
9397
9415
|
}
|
|
9398
9416
|
}
|
|
9399
9417
|
for (const compiled of this.chained) {
|