@contrast/assess 1.1.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/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +266 -0
- package/coverage/lcov-report/lib/dataflow/common.js.html +154 -0
- package/coverage/lcov-report/lib/dataflow/event-factory.js.html +598 -0
- package/coverage/lcov-report/lib/dataflow/index.html +191 -0
- package/coverage/lcov-report/lib/dataflow/index.js.html +190 -0
- package/coverage/lcov-report/lib/dataflow/propagation/common.js.html +145 -0
- package/coverage/lcov-report/lib/dataflow/propagation/index.html +131 -0
- package/coverage/lcov-report/lib/dataflow/propagation/index.js.html +190 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/contrast-methods/index.html +131 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/contrast-methods/index.js.html +184 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/contrast-methods/plus.js.html +397 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/concat.js.html +478 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/index.html +176 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/index.js.html +202 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/replace.js.html +496 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/substring.js.html +415 -0
- package/coverage/lcov-report/lib/dataflow/propagation/install/string/trim.js.html +403 -0
- package/coverage/lcov-report/lib/dataflow/signatures.js.html +5923 -0
- package/coverage/lcov-report/lib/dataflow/sinks/common.js.html +145 -0
- package/coverage/lcov-report/lib/dataflow/sinks/index.html +131 -0
- package/coverage/lcov-report/lib/dataflow/sinks/index.js.html +211 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/fastify/index.html +146 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/fastify/index.js.html +172 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js.html +319 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/fastify/xss.js.html +721 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/http.js.html +340 -0
- package/coverage/lcov-report/lib/dataflow/sinks/install/index.html +116 -0
- package/coverage/lcov-report/lib/dataflow/sources/common.js.html +145 -0
- package/coverage/lcov-report/lib/dataflow/sources/index.html +131 -0
- package/coverage/lcov-report/lib/dataflow/sources/index.js.html +226 -0
- package/coverage/lcov-report/lib/dataflow/sources/install/fastify.js.html +379 -0
- package/coverage/lcov-report/lib/dataflow/sources/install/http.js.html +502 -0
- package/coverage/lcov-report/lib/dataflow/sources/install/index.html +146 -0
- package/coverage/lcov-report/lib/dataflow/sources/install/qs.js.html +322 -0
- package/coverage/lcov-report/lib/dataflow/tag-utils.js.html +418 -0
- package/coverage/lcov-report/lib/dataflow/tracker.js.html +466 -0
- package/coverage/lcov-report/lib/dataflow/utils/index.html +116 -0
- package/coverage/lcov-report/lib/dataflow/utils/is-vulnerable.js.html +424 -0
- package/coverage/lcov-report/lib/index.html +116 -0
- package/coverage/lcov-report/lib/index.js.html +193 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +4856 -0
- package/coverage/tmp/coverage-9548-1675168551025-0.json +1 -0
- package/coverage/tmp/coverage-9551-1675168550963-0.json +1 -0
- package/coverage/tmp/coverage-9552-1675168550969-0.json +1 -0
- package/coverage/tmp/coverage-9553-1675168550970-0.json +1 -0
- package/coverage/tmp/coverage-9554-1675168550962-0.json +1 -0
- package/coverage/tmp/coverage-9555-1675168550965-0.json +1 -0
- package/coverage/tmp/coverage-9556-1675168550964-0.json +1 -0
- package/coverage/tmp/coverage-9557-1675168550969-0.json +1 -0
- package/coverage/tmp/coverage-9558-1675168550964-0.json +1 -0
- package/coverage/tmp/coverage-9559-1675168550971-0.json +1 -0
- package/lib/dataflow/event-factory.js +256 -0
- package/lib/dataflow/index.js +35 -0
- package/lib/dataflow/propagation/common.js +26 -0
- package/lib/dataflow/propagation/index.js +50 -0
- package/lib/dataflow/propagation/install/array-prototype-join.js +125 -0
- package/lib/dataflow/propagation/install/contrast-methods/add.js +104 -0
- package/lib/dataflow/propagation/install/contrast-methods/index.js +34 -0
- package/lib/dataflow/propagation/install/contrast-methods/tag.js +102 -0
- package/lib/dataflow/propagation/install/decode-uri-component.js +88 -0
- package/lib/dataflow/propagation/install/ejs/escape-xml.js +89 -0
- package/lib/dataflow/propagation/install/ejs/index.js +30 -0
- package/lib/dataflow/propagation/install/encode-uri-component.js +87 -0
- package/lib/dataflow/propagation/install/escape-html.js +89 -0
- package/lib/dataflow/propagation/install/escape.js +89 -0
- package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +89 -0
- package/lib/dataflow/propagation/install/mysql-connection-escape.js +111 -0
- package/lib/dataflow/propagation/install/pug/index.js +64 -0
- package/lib/dataflow/propagation/install/pug-runtime-escape.js +89 -0
- package/lib/dataflow/propagation/install/sql-template-strings.js +103 -0
- package/lib/dataflow/propagation/install/string/concat.js +108 -0
- package/lib/dataflow/propagation/install/string/format-methods.js +83 -0
- package/lib/dataflow/propagation/install/string/html-methods.js +163 -0
- package/lib/dataflow/propagation/install/string/index.js +38 -0
- package/lib/dataflow/propagation/install/string/replace.js +197 -0
- package/lib/dataflow/propagation/install/string/substring.js +117 -0
- package/lib/dataflow/propagation/install/string/trim.js +115 -0
- package/lib/dataflow/propagation/install/unescape.js +90 -0
- package/lib/dataflow/propagation/install/url/domain-parsers.js +89 -0
- package/lib/dataflow/propagation/install/url/index.js +33 -0
- package/lib/dataflow/propagation/install/validator/hooks.js +172 -0
- package/lib/dataflow/propagation/install/validator/index.js +28 -0
- package/lib/dataflow/propagation/install/validator/methods.js +82 -0
- package/lib/dataflow/signatures.js +2022 -0
- package/lib/dataflow/sinks/common.js +20 -0
- package/lib/dataflow/sinks/index.js +44 -0
- package/lib/dataflow/sinks/install/fastify/index.js +30 -0
- package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +107 -0
- package/lib/dataflow/sinks/install/http.js +119 -0
- package/lib/dataflow/sinks/install/postgres/index.js +129 -0
- package/lib/dataflow/sources/common.js +20 -0
- package/lib/dataflow/sources/handler.js +114 -0
- package/lib/dataflow/sources/index.js +35 -0
- package/lib/dataflow/sources/install/fastify/cookie.js +61 -0
- package/lib/dataflow/sources/install/fastify/fastify.js +89 -0
- package/lib/dataflow/sources/install/fastify/index.js +31 -0
- package/lib/dataflow/sources/install/http.js +181 -0
- package/lib/dataflow/sources/install/qs.js +88 -0
- package/lib/dataflow/tag-utils.js +122 -0
- package/lib/dataflow/tracker.js +127 -0
- package/lib/dataflow/utils/is-safe-content-type.js +30 -0
- package/lib/dataflow/utils/is-vulnerable.js +113 -0
- package/lib/index.js +36 -0
- package/package.json +21 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
createFullLengthCopyTags
|
|
20
|
+
} = require('../../tag-utils');
|
|
21
|
+
const { patchType, createObjectLabel } = require('../common');
|
|
22
|
+
|
|
23
|
+
module.exports = function(core) {
|
|
24
|
+
const {
|
|
25
|
+
scopes: { sources, instrumentation },
|
|
26
|
+
patcher,
|
|
27
|
+
assess: {
|
|
28
|
+
dataflow: { tracker, eventFactory: { createPropagationEvent } }
|
|
29
|
+
}
|
|
30
|
+
} = core;
|
|
31
|
+
|
|
32
|
+
return core.assess.dataflow.propagation.unescape = {
|
|
33
|
+
install() {
|
|
34
|
+
patcher.patch(global, 'unescape', {
|
|
35
|
+
name: 'global.unescape',
|
|
36
|
+
patchType,
|
|
37
|
+
post(data) {
|
|
38
|
+
const { args, result, hooked, orig } = data;
|
|
39
|
+
if (!result || !args[0] || !sources.getStore()?.assess || instrumentation.isLocked()) return;
|
|
40
|
+
|
|
41
|
+
const argInfo = tracker.getData(args[0]);
|
|
42
|
+
|
|
43
|
+
if (!argInfo) return;
|
|
44
|
+
|
|
45
|
+
const resultInfo = tracker.getData(result);
|
|
46
|
+
const history = [argInfo];
|
|
47
|
+
const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
|
|
48
|
+
delete newTags['weak-url-encoded'];
|
|
49
|
+
|
|
50
|
+
if (!Object.keys(newTags).length) return;
|
|
51
|
+
|
|
52
|
+
const event = createPropagationEvent({
|
|
53
|
+
name: 'global.unescape',
|
|
54
|
+
object: {
|
|
55
|
+
value: createObjectLabel('global'),
|
|
56
|
+
isTracked: false
|
|
57
|
+
},
|
|
58
|
+
result: {
|
|
59
|
+
value: resultInfo ? resultInfo.value : result,
|
|
60
|
+
isTracked: true
|
|
61
|
+
},
|
|
62
|
+
args: [{ value: argInfo.value, isTracked: true }],
|
|
63
|
+
tags: newTags,
|
|
64
|
+
history,
|
|
65
|
+
removedTags: ['weak-url-encoded'],
|
|
66
|
+
stacktraceOpts: {
|
|
67
|
+
constructorOpt: hooked,
|
|
68
|
+
prependFrames: [orig]
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (!event) return;
|
|
73
|
+
|
|
74
|
+
if (resultInfo) {
|
|
75
|
+
Object.assign(resultInfo, event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { extern } = tracker.track(result, event);
|
|
79
|
+
|
|
80
|
+
if (extern) {
|
|
81
|
+
data.result = extern;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
uninstall() {
|
|
87
|
+
global.unescape = patcher.unwrap(global.unescape);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
createFullLengthCopyTags
|
|
20
|
+
} = require('../../../tag-utils');
|
|
21
|
+
const { patchType, createModuleLabel } = require('../../common');
|
|
22
|
+
|
|
23
|
+
module.exports = function(core) {
|
|
24
|
+
const {
|
|
25
|
+
scopes: { sources, instrumentation },
|
|
26
|
+
patcher,
|
|
27
|
+
depHooks,
|
|
28
|
+
assess: {
|
|
29
|
+
dataflow: { tracker, eventFactory: { createPropagationEvent } }
|
|
30
|
+
}
|
|
31
|
+
} = core;
|
|
32
|
+
|
|
33
|
+
return core.assess.dataflow.propagation.urlInstrumentation.domainParsers = {
|
|
34
|
+
install() {
|
|
35
|
+
depHooks.resolve({ name: 'url' }, (url, version) => {
|
|
36
|
+
['domainToASCII', 'domainToUnicode'].forEach((method) => {
|
|
37
|
+
patcher.patch(url, method, {
|
|
38
|
+
name: `url.${method}`,
|
|
39
|
+
patchType,
|
|
40
|
+
post(data) {
|
|
41
|
+
const { args, result, hooked, orig } = data;
|
|
42
|
+
if (!result || !args[0] || !sources.getStore()?.assess || instrumentation.isLocked()) return;
|
|
43
|
+
|
|
44
|
+
const argInfo = tracker.getData(args[0]);
|
|
45
|
+
|
|
46
|
+
if (!argInfo) return;
|
|
47
|
+
|
|
48
|
+
const resultInfo = tracker.getData(result);
|
|
49
|
+
const history = [argInfo];
|
|
50
|
+
|
|
51
|
+
const event = createPropagationEvent({
|
|
52
|
+
name: `url.${method}`,
|
|
53
|
+
object: {
|
|
54
|
+
value: createModuleLabel('url', version),
|
|
55
|
+
isTracked: false
|
|
56
|
+
},
|
|
57
|
+
result: {
|
|
58
|
+
value: resultInfo ? resultInfo.value : result,
|
|
59
|
+
isTracked: true
|
|
60
|
+
},
|
|
61
|
+
args: [{ value: argInfo.value, isTracked: true }],
|
|
62
|
+
tags: createFullLengthCopyTags(argInfo.tags, result.length) || [],
|
|
63
|
+
history,
|
|
64
|
+
source: 'P',
|
|
65
|
+
target: 'R',
|
|
66
|
+
stacktraceOpts: {
|
|
67
|
+
constructorOpt: hooked,
|
|
68
|
+
prependFrames: [orig]
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (!event) return;
|
|
73
|
+
|
|
74
|
+
if (resultInfo) {
|
|
75
|
+
Object.assign(resultInfo, event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { extern } = resultInfo || tracker.track(result, event);
|
|
79
|
+
|
|
80
|
+
if (extern) {
|
|
81
|
+
data.result = extern;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { callChildComponentMethodsSync } = require('@contrast/common');
|
|
19
|
+
|
|
20
|
+
module.exports = function(core) {
|
|
21
|
+
const urlInstrumentation = core.assess.dataflow.propagation.urlInstrumentation = {
|
|
22
|
+
install() {
|
|
23
|
+
callChildComponentMethodsSync(urlInstrumentation, 'install');
|
|
24
|
+
},
|
|
25
|
+
uninstall() {
|
|
26
|
+
callChildComponentMethodsSync(urlInstrumentation, 'uninstall');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
require('./domain-parsers')(core);
|
|
31
|
+
|
|
32
|
+
return urlInstrumentation;
|
|
33
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
const { validators, untrackers, sanitizers, custom } = require('./methods');
|
|
18
|
+
const { patchType } = require('../../common');
|
|
19
|
+
|
|
20
|
+
module.exports = function(core) {
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
depHooks,
|
|
24
|
+
patcher,
|
|
25
|
+
assess: {
|
|
26
|
+
dataflow: { tracker, eventFactory: { createPropagationEvent } }
|
|
27
|
+
}
|
|
28
|
+
} = core;
|
|
29
|
+
|
|
30
|
+
function createValidatorPropagationEvent(method, data, trackingData, newTags, target) {
|
|
31
|
+
return createPropagationEvent({
|
|
32
|
+
name: `validator.${method}`,
|
|
33
|
+
history: [{ ...trackingData }],
|
|
34
|
+
args: [{
|
|
35
|
+
value: data.args[0],
|
|
36
|
+
isTracked: true
|
|
37
|
+
}],
|
|
38
|
+
result: {
|
|
39
|
+
value: data.result,
|
|
40
|
+
isTracked: !!tracker.getData(data.result)
|
|
41
|
+
},
|
|
42
|
+
tags: {
|
|
43
|
+
...trackingData.tags,
|
|
44
|
+
...newTags
|
|
45
|
+
},
|
|
46
|
+
stacktraceData: {
|
|
47
|
+
constructorOpt: data.hooked,
|
|
48
|
+
prependFrames: [data.orig]
|
|
49
|
+
},
|
|
50
|
+
source: 'P1',
|
|
51
|
+
target
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
install() {
|
|
57
|
+
for (const validator in validators) {
|
|
58
|
+
depHooks.resolve(
|
|
59
|
+
{ name: 'validator', file: `lib/${validator}` },
|
|
60
|
+
(index) => {
|
|
61
|
+
const patchFn = typeof index === 'object' ? index.default : index;
|
|
62
|
+
return patcher.patch(patchFn, {
|
|
63
|
+
name: `validator.${validator}`,
|
|
64
|
+
patchType,
|
|
65
|
+
post(data) {
|
|
66
|
+
const matches = validator === 'matches';
|
|
67
|
+
if (
|
|
68
|
+
data.result &&
|
|
69
|
+
(!matches || (matches && core.config.assess.trust_custom_validators))
|
|
70
|
+
) {
|
|
71
|
+
const trackingData = tracker.getData(data.args[0]);
|
|
72
|
+
if (trackingData) {
|
|
73
|
+
const newTags = {};
|
|
74
|
+
const tagName = validators[validator];
|
|
75
|
+
newTags[tagName] = [0, data.args[0].length - 1];
|
|
76
|
+
const event = createValidatorPropagationEvent(
|
|
77
|
+
validator,
|
|
78
|
+
data,
|
|
79
|
+
trackingData,
|
|
80
|
+
newTags,
|
|
81
|
+
'P'
|
|
82
|
+
);
|
|
83
|
+
if (event) {
|
|
84
|
+
Object.assign(trackingData, event);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
untrackers.forEach((untracker) => {
|
|
94
|
+
depHooks.resolve(
|
|
95
|
+
{ name: 'validator', file: `lib/${untracker}` },
|
|
96
|
+
(index) => patcher.patch(index.default, {
|
|
97
|
+
name: `validator.${untracker}`,
|
|
98
|
+
patchType,
|
|
99
|
+
post(data) {
|
|
100
|
+
if (data.result) {
|
|
101
|
+
const trackingData = tracker.getData(data.args[0]);
|
|
102
|
+
if (trackingData) {
|
|
103
|
+
tracker.untrack(data.args[0]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
for (const sanitizer in sanitizers) {
|
|
111
|
+
depHooks.resolve(
|
|
112
|
+
{ name: 'validator', file: `lib/${sanitizer}` },
|
|
113
|
+
(index) => patcher.patch(index.default, {
|
|
114
|
+
name: `validator.${sanitizer}`,
|
|
115
|
+
patchType,
|
|
116
|
+
post(data) {
|
|
117
|
+
const trackingData = tracker.getData(data.args[0]);
|
|
118
|
+
if (trackingData) {
|
|
119
|
+
const newTags = {};
|
|
120
|
+
const tagName = sanitizers[sanitizer];
|
|
121
|
+
newTags[tagName] = [0, data.result.length - 1];
|
|
122
|
+
const event = createValidatorPropagationEvent(
|
|
123
|
+
sanitizer,
|
|
124
|
+
data,
|
|
125
|
+
trackingData,
|
|
126
|
+
newTags,
|
|
127
|
+
'R'
|
|
128
|
+
);
|
|
129
|
+
let resultTracked = tracker.getData(data.result);
|
|
130
|
+
if (!resultTracked) {
|
|
131
|
+
resultTracked = tracker.track(data.result, event);
|
|
132
|
+
if (resultTracked.extern) data.result = resultTracked.extern;
|
|
133
|
+
}
|
|
134
|
+
if (event) {
|
|
135
|
+
Object.assign(resultTracked, event);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (const method in custom) {
|
|
143
|
+
depHooks.resolve(
|
|
144
|
+
{ name: 'validator', file: `lib/${method}` },
|
|
145
|
+
(index) => patcher.patch(index.default, {
|
|
146
|
+
name: `validator.${method}`,
|
|
147
|
+
patchType,
|
|
148
|
+
post(data) {
|
|
149
|
+
const options = data.args[1];
|
|
150
|
+
const trackingData = tracker.getData(data.args[0]);
|
|
151
|
+
|
|
152
|
+
if (data.result && trackingData && !options?.allow_display_name && !options?.require_display_name) {
|
|
153
|
+
const newTags = {};
|
|
154
|
+
const tagName = custom[method];
|
|
155
|
+
newTags[tagName] = [0, data.args[0].length - 1];
|
|
156
|
+
const event = createValidatorPropagationEvent(
|
|
157
|
+
method,
|
|
158
|
+
data,
|
|
159
|
+
trackingData,
|
|
160
|
+
newTags,
|
|
161
|
+
'P'
|
|
162
|
+
);
|
|
163
|
+
if (event) {
|
|
164
|
+
Object.assign(trackingData, event);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
module.exports = function(core) {
|
|
19
|
+
const validatorInstr = require('./hooks')(core);
|
|
20
|
+
|
|
21
|
+
const validatorInstrumentation = core.assess.dataflow.propagation.validatorInstrumentation = {
|
|
22
|
+
install() {
|
|
23
|
+
validatorInstr.install();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return validatorInstrumentation;
|
|
28
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
validators: {
|
|
20
|
+
isAfter: 'alphanum-space-hyphen',
|
|
21
|
+
isAlpha: 'alphanum-space-hyphen',
|
|
22
|
+
isAlphanumeric: 'alphanum-space-hyphen',
|
|
23
|
+
isBase32: 'alphanum-space-hyphen',
|
|
24
|
+
isBase58: 'alphanum-space-hyphen',
|
|
25
|
+
isBase64: 'alphanum-space-hyphen',
|
|
26
|
+
isBefore: 'alphanum-space-hyphen',
|
|
27
|
+
isBIC: 'alphanum-space-hyphen',
|
|
28
|
+
isBoolean: 'limited-chars',
|
|
29
|
+
isBtcAddress: 'alphanum-space-hyphen',
|
|
30
|
+
isCreditCard: 'limited-chars',
|
|
31
|
+
isDate: 'limited-chars',
|
|
32
|
+
isDecimal: 'limited-chars',
|
|
33
|
+
isEAN: 'limited-chars',
|
|
34
|
+
isEthereumAddress: 'alphanum-space-hyphen',
|
|
35
|
+
isFloat: 'limited-chars',
|
|
36
|
+
isHash: 'alphanum-space-hyphen',
|
|
37
|
+
isHexadecimal: 'alphanum-space-hyphen',
|
|
38
|
+
isHexColor: 'alphanum-space-hyphen',
|
|
39
|
+
isHSL: 'alphanum-space-hyphen',
|
|
40
|
+
isIBAN: 'limited-chars',
|
|
41
|
+
isIdentityCard: 'alphanum-space-hyphen',
|
|
42
|
+
isIMEI: 'limited-chars',
|
|
43
|
+
isInt: 'limited-chars',
|
|
44
|
+
isIP: 'limited-chars',
|
|
45
|
+
isIPRange: 'limited-chars',
|
|
46
|
+
isISBN: 'limited-chars',
|
|
47
|
+
isISIN: 'limited-chars',
|
|
48
|
+
isISO8601: 'alphanum-space-hyphen',
|
|
49
|
+
isISO31661Alpha2: 'alphanum-space-hyphen',
|
|
50
|
+
isISO31661Alpha3: 'alphanum-space-hyphen',
|
|
51
|
+
isISRC: 'alphanum-space-hyphen',
|
|
52
|
+
isISSN: 'limited-chars',
|
|
53
|
+
isJWT: 'alphanum-space-hyphen',
|
|
54
|
+
isLatLong: 'limited-chars',
|
|
55
|
+
isLicensePlate: 'alphanum-space-hyphen',
|
|
56
|
+
isMACAddress: 'alphanum-space-hyphen',
|
|
57
|
+
isMagnetURI: 'alphanum-space-hyphen',
|
|
58
|
+
isMD5: 'alphanum-space-hyphen',
|
|
59
|
+
isMobilePhone: 'limited-chars',
|
|
60
|
+
isNumeric: 'limited-chars',
|
|
61
|
+
isOctal: 'alphanum-space-hyphen',
|
|
62
|
+
isPassportNumber: 'limited-chars',
|
|
63
|
+
isPostalCode: 'limited-chars',
|
|
64
|
+
isSemVer: 'limited-chars',
|
|
65
|
+
isTaxID: 'limited-chars',
|
|
66
|
+
isUUID: 'alphanum-space-hyphen',
|
|
67
|
+
isVAT: 'alphanum-space-hyphen',
|
|
68
|
+
matches: 'custom-validated'
|
|
69
|
+
},
|
|
70
|
+
untrackers: [
|
|
71
|
+
'equals',
|
|
72
|
+
'isIn',
|
|
73
|
+
'isMimeType',
|
|
74
|
+
'isRFC3339'
|
|
75
|
+
],
|
|
76
|
+
sanitizers: {
|
|
77
|
+
escape: 'html-encoded'
|
|
78
|
+
},
|
|
79
|
+
custom: {
|
|
80
|
+
isEmail: 'limited-chars'
|
|
81
|
+
}
|
|
82
|
+
};
|