@contrast/protect 1.35.2 → 1.36.1
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/lib/input-analysis/handlers.js +6 -6
- package/lib/input-analysis/install/http.js +2 -2
- package/lib/input-analysis/ip-analysis.js +2 -2
- package/lib/input-analysis/virtual-patches.js +2 -2
- package/lib/input-tracing/handlers/index.js +2 -2
- package/lib/make-response-blocker.js +2 -2
- package/lib/make-source-context.js +5 -5
- package/lib/policy.js +7 -7
- package/lib/semantic-analysis/handlers.js +2 -2
- package/lib/semantic-analysis/utils/xml-analysis.js +5 -5
- package/package.json +6 -6
|
@@ -24,9 +24,9 @@ const {
|
|
|
24
24
|
traverseKeysAndValues,
|
|
25
25
|
traverseValues,
|
|
26
26
|
InputType,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
ArrayPrototypeJoin,
|
|
28
|
+
StringPrototypeToLowerCase,
|
|
29
|
+
StringPrototypeSplit,
|
|
30
30
|
} = require('@contrast/common');
|
|
31
31
|
|
|
32
32
|
//
|
|
@@ -595,7 +595,7 @@ module.exports = function (core) {
|
|
|
595
595
|
const probe = Object.assign({}, resultByRuleId, result, {
|
|
596
596
|
mappedId: result.ruleId,
|
|
597
597
|
});
|
|
598
|
-
const key =
|
|
598
|
+
const key = ArrayPrototypeJoin.call([
|
|
599
599
|
probe.ruleId,
|
|
600
600
|
probe.inputType,
|
|
601
601
|
...probe.path,
|
|
@@ -725,7 +725,7 @@ module.exports = function (core) {
|
|
|
725
725
|
|
|
726
726
|
for (let i = 0; i < reqHeaders.length; i++) {
|
|
727
727
|
if (reqHeaders[i] === 'x-forwarded-for') {
|
|
728
|
-
const ipsFromHeaders =
|
|
728
|
+
const ipsFromHeaders = StringPrototypeSplit.call(reqHeaders[i + 1], /[,;]+/);
|
|
729
729
|
forwardedIps.push(...ipsFromHeaders);
|
|
730
730
|
}
|
|
731
731
|
}
|
|
@@ -797,7 +797,7 @@ function isResultExcluded(sourceContext, result) {
|
|
|
797
797
|
}
|
|
798
798
|
case 'HeaderKey':
|
|
799
799
|
case 'HeaderValue': {
|
|
800
|
-
if (path[0] &&
|
|
800
|
+
if (path[0] && StringPrototypeToLowerCase.call(path[0]) === 'cookie') {
|
|
801
801
|
inputExclusions = exclusions.cookie;
|
|
802
802
|
checkCookiesInHeader = true;
|
|
803
803
|
} else {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { Event,
|
|
18
|
+
const { Event, StringPrototypeToLowerCase } = require('@contrast/common');
|
|
19
19
|
const { patchType } = require('../constants');
|
|
20
20
|
|
|
21
21
|
module.exports = function (core) {
|
|
@@ -94,7 +94,7 @@ module.exports = function (core) {
|
|
|
94
94
|
const connectInputs = {
|
|
95
95
|
headers: removeCookies(headers),
|
|
96
96
|
uriPath,
|
|
97
|
-
method:
|
|
97
|
+
method:StringPrototypeToLowerCase.call(method),
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
if (inputAnalysis.virtualPatchesEvaluators?.length) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { Event,
|
|
18
|
+
const { Event, StringPrototypeSubstr } = require('@contrast/common');
|
|
19
19
|
const address = require('ipaddr.js');
|
|
20
20
|
|
|
21
21
|
module.exports = (core) => {
|
|
@@ -57,7 +57,7 @@ function ipEntryMap(ipEntry, startTime) {
|
|
|
57
57
|
const slashIdx = ip.indexOf('/');
|
|
58
58
|
const isCIDR = slashIdx >= 0;
|
|
59
59
|
const ipInstance = isCIDR
|
|
60
|
-
? address.process(
|
|
60
|
+
? address.process(StringPrototypeSubstr.call(ip, 0, slashIdx))
|
|
61
61
|
: address.process(ip);
|
|
62
62
|
|
|
63
63
|
const normalizedValue = ipInstance.toNormalizedString();
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { Event,
|
|
18
|
+
const { Event, StringPrototypeToLowerCase } = require('@contrast/common');
|
|
19
19
|
|
|
20
20
|
module.exports = (core) => {
|
|
21
21
|
const {
|
|
@@ -47,7 +47,7 @@ function buildVPEvaluators(virtualPatches, evaluatorsArray) {
|
|
|
47
47
|
acc.push(...entry);
|
|
48
48
|
return acc;
|
|
49
49
|
}, []);
|
|
50
|
-
const keyIndex = headersArray.indexOf(
|
|
50
|
+
const keyIndex = headersArray.indexOf(StringPrototypeToLowerCase.call(name));
|
|
51
51
|
|
|
52
52
|
result = keyIndex !== -1 && evalCheck(headersArray[keyIndex + 1], value);
|
|
53
53
|
if (!result) break;
|
|
@@ -20,7 +20,7 @@ const {
|
|
|
20
20
|
ProtectRuleMode: { OFF },
|
|
21
21
|
BLOCKING_MODES,
|
|
22
22
|
isString,
|
|
23
|
-
|
|
23
|
+
JSONStringify,
|
|
24
24
|
traverseKeys,
|
|
25
25
|
traverseKeysAndValues,
|
|
26
26
|
agentLibIDListTypes,
|
|
@@ -351,7 +351,7 @@ function handleObjectValue(result, object) {
|
|
|
351
351
|
obj = obj[value];
|
|
352
352
|
// does the found object in the query equal the saved object?
|
|
353
353
|
if (util.isDeepStrictEqual(obj, result.mongoContext.inputToCheck)) {
|
|
354
|
-
const start =
|
|
354
|
+
const start = JSONStringify(object).indexOf(value);
|
|
355
355
|
const end = start + value.length;
|
|
356
356
|
const inputBoundaryIndex = 0;
|
|
357
357
|
findings = { start, end, boundaryOverrunIndex: start, inputBoundaryIndex };
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { StringPrototypeToUpperCase } = require('@contrast/common');
|
|
19
19
|
|
|
20
20
|
module.exports = function(core) {
|
|
21
21
|
// i think this should be a weakset. we don't want to accumulate
|
|
@@ -29,7 +29,7 @@ module.exports = function(core) {
|
|
|
29
29
|
if (blocked.has(res)) return;
|
|
30
30
|
|
|
31
31
|
blocked.add(res);
|
|
32
|
-
mode =
|
|
32
|
+
mode = StringPrototypeToUpperCase.call(mode);
|
|
33
33
|
const end = patcher.unwrap(res.end);
|
|
34
34
|
const writeHead = patcher.unwrap(res.writeHead);
|
|
35
35
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { StringPrototypeToLowerCase, StringPrototypeSlice } = require('@contrast/common');
|
|
19
19
|
|
|
20
20
|
module.exports = function(core) {
|
|
21
21
|
const {
|
|
@@ -36,8 +36,8 @@ module.exports = function(core) {
|
|
|
36
36
|
const ix = req.url.indexOf('?');
|
|
37
37
|
|
|
38
38
|
if (ix >= 0) {
|
|
39
|
-
uriPath =
|
|
40
|
-
queries =
|
|
39
|
+
uriPath = StringPrototypeSlice.call(req.url, 0, ix);
|
|
40
|
+
queries = StringPrototypeSlice.call(req.url, ix + 1);
|
|
41
41
|
} else {
|
|
42
42
|
uriPath = req.url;
|
|
43
43
|
queries = '';
|
|
@@ -55,10 +55,10 @@ module.exports = function(core) {
|
|
|
55
55
|
const headers = Array(req.rawHeaders.length);
|
|
56
56
|
|
|
57
57
|
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
58
|
-
headers[i] =
|
|
58
|
+
headers[i] = StringPrototypeToLowerCase.call(req.rawHeaders[i]);
|
|
59
59
|
headers[i + 1] = req.rawHeaders[i + 1];
|
|
60
60
|
if (headers[i] === 'content-type') {
|
|
61
|
-
contentType =
|
|
61
|
+
contentType = StringPrototypeToLowerCase.call(headers[i + 1]);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
package/lib/policy.js
CHANGED
|
@@ -19,9 +19,9 @@ const {
|
|
|
19
19
|
Rule,
|
|
20
20
|
ProtectRuleMode,
|
|
21
21
|
Event,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
ArrayPrototypeJoin,
|
|
23
|
+
StringPrototypeToLowerCase,
|
|
24
|
+
StringPrototypeSplit,
|
|
25
25
|
} = require('@contrast/common');
|
|
26
26
|
const { ConfigSource } = require('@contrast/config');
|
|
27
27
|
|
|
@@ -88,7 +88,7 @@ module.exports = function (core) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
if (regExpNeeded) {
|
|
91
|
-
const rx = new RegExp(`^${
|
|
91
|
+
const rx = new RegExp(`^${ArrayPrototypeJoin.call(urls, '|')}$`);
|
|
92
92
|
|
|
93
93
|
return (uriPath) => rx ? rx.test(uriPath) : false;
|
|
94
94
|
}
|
|
@@ -305,7 +305,7 @@ module.exports = function (core) {
|
|
|
305
305
|
exclusionDtm.type = exclusionDtm.type || 'URL';
|
|
306
306
|
|
|
307
307
|
const { name, protect_rules, urls, type } = exclusionDtm;
|
|
308
|
-
const key =
|
|
308
|
+
const key = StringPrototypeToLowerCase.call(type);
|
|
309
309
|
|
|
310
310
|
if (!compiled[key]) continue;
|
|
311
311
|
|
|
@@ -340,8 +340,8 @@ module.exports = function (core) {
|
|
|
340
340
|
}
|
|
341
341
|
if (key === 'cookie') {
|
|
342
342
|
e.checkCookieInHeader = (cookieHeader) => {
|
|
343
|
-
for (const cookiePair of
|
|
344
|
-
const cookieKey =
|
|
343
|
+
for (const cookiePair of StringPrototypeSplit.call(cookieHeader, ';')) {
|
|
344
|
+
const cookieKey = StringPrototypeSplit.call(cookiePair, '=')[0];
|
|
345
345
|
if (e.matchesInputName(cookieKey)) {
|
|
346
346
|
return true;
|
|
347
347
|
}
|
|
@@ -21,7 +21,7 @@ const {
|
|
|
21
21
|
ProtectRuleMode: { OFF },
|
|
22
22
|
InputType,
|
|
23
23
|
traverseValues,
|
|
24
|
-
|
|
24
|
+
StringPrototypeReplace,
|
|
25
25
|
} = require('@contrast/common');
|
|
26
26
|
|
|
27
27
|
const {
|
|
@@ -29,7 +29,7 @@ const {
|
|
|
29
29
|
} = require('./utils/xml-analysis');
|
|
30
30
|
|
|
31
31
|
const SINK_EXPLOIT_PATTERN_START = /(?:^|\\|\/)(?:sh|bash|zsh|ksh|tcsh|csh|fish|cmd)/;
|
|
32
|
-
const stripWhiteSpace = (str) =>
|
|
32
|
+
const stripWhiteSpace = (str) => StringPrototypeReplace.call(str, /\s/g, '');
|
|
33
33
|
|
|
34
34
|
const getRuleResults = function(obj, prop) {
|
|
35
35
|
return obj[prop] || (obj[prop] = []);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const {
|
|
17
|
+
const { StringPrototypeSubstr, StringPrototypeToLowerCase } = require('@contrast/common');
|
|
18
18
|
|
|
19
19
|
const PROTOCOLS = {
|
|
20
20
|
FTP: 'FTP',
|
|
@@ -23,9 +23,9 @@ const PROTOCOLS = {
|
|
|
23
23
|
TCP: 'TCP'
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const FTP = `${
|
|
27
|
-
const HTTP = `${
|
|
28
|
-
const HTTPS = `${
|
|
26
|
+
const FTP = `${StringPrototypeToLowerCase.call(PROTOCOLS.FTP)}:`;
|
|
27
|
+
const HTTP = `${StringPrototypeToLowerCase.call(PROTOCOLS.HTTP)}:`;
|
|
28
|
+
const HTTPS = `${StringPrototypeToLowerCase.call(PROTOCOLS.HTTPS)}:`;
|
|
29
29
|
const DTD_EXTENSION = '.dtd';
|
|
30
30
|
const FILE_START = 'file:';
|
|
31
31
|
const GOPHER_START = 'gopher:';
|
|
@@ -101,7 +101,7 @@ module.exports.findExternalEntities = function(xml = '') {
|
|
|
101
101
|
|
|
102
102
|
return {
|
|
103
103
|
entities,
|
|
104
|
-
prolog: len &&
|
|
104
|
+
prolog: len && StringPrototypeSubstr.call(xml, 0, entities[len - 1].finish) || null
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/protect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.1",
|
|
4
4
|
"description": "Contrast service providing framework-agnostic Protect support",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"types": "lib/index.d.ts",
|
|
12
12
|
"engines": {
|
|
13
13
|
"npm": ">=6.13.7 <7 || >= 8.3.1",
|
|
14
|
-
"node": ">=
|
|
14
|
+
"node": ">= 16.9.1"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "../scripts/test.sh"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@contrast/agent-lib": "^7.0.1",
|
|
21
|
-
"@contrast/common": "1.
|
|
22
|
-
"@contrast/config": "1.
|
|
23
|
-
"@contrast/core": "1.
|
|
24
|
-
"@contrast/esm-hooks": "2.
|
|
21
|
+
"@contrast/common": "1.21.1",
|
|
22
|
+
"@contrast/config": "1.28.1",
|
|
23
|
+
"@contrast/core": "1.32.1",
|
|
24
|
+
"@contrast/esm-hooks": "2.6.1",
|
|
25
25
|
"@contrast/scopes": "1.4.1",
|
|
26
26
|
"ipaddr.js": "^2.0.1",
|
|
27
27
|
"semver": "^7.3.7"
|