@contrast/assess 1.14.0 → 1.15.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/lib/dataflow/propagation/install/JSON/parse-fn.js +2 -2
- package/lib/dataflow/propagation/install/escape-html.js +1 -1
- package/lib/dataflow/propagation/install/validator/hooks.js +8 -6
- package/lib/session-configuration/handlers.js +1 -1
- package/lib/session-configuration/index.js +1 -0
- package/lib/session-configuration/install/hapi.js +108 -0
- package/package.json +1 -1
|
@@ -217,7 +217,7 @@ function processInput(input) {
|
|
|
217
217
|
return number(input, 0);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
if (firstElement === '"') {
|
|
220
|
+
if (firstElement === '"' && lastElement === '"') {
|
|
221
221
|
return string(input, 1);
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -228,7 +228,7 @@ function processInput(input) {
|
|
|
228
228
|
case 'null':
|
|
229
229
|
return nully();
|
|
230
230
|
default:
|
|
231
|
-
|
|
231
|
+
return string(input, 0);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
@@ -51,7 +51,7 @@ module.exports = function(core) {
|
|
|
51
51
|
if (!argInfo) return;
|
|
52
52
|
|
|
53
53
|
const resultInfo = tracker.getData(result);
|
|
54
|
-
const history = [argInfo];
|
|
54
|
+
const history = [{ ...argInfo }];
|
|
55
55
|
const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
|
|
56
56
|
|
|
57
57
|
newTags[HTML_ENCODED] = [0, result.length - 1];
|
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
const { validators, untrackers, sanitizers, custom } = require('./methods');
|
|
18
18
|
const { patchType } = require('../../common');
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
function getPatcherArgs(obj) {
|
|
21
|
+
return typeof obj === 'object' ? [obj, 'default'] : [obj];
|
|
22
|
+
}
|
|
21
23
|
|
|
24
|
+
module.exports = function (core) {
|
|
22
25
|
const {
|
|
23
26
|
depHooks,
|
|
24
27
|
patcher,
|
|
@@ -62,9 +65,8 @@ module.exports = function(core) {
|
|
|
62
65
|
depHooks.resolve(
|
|
63
66
|
{ name: 'validator', file: `lib/${validator}` },
|
|
64
67
|
(index) => {
|
|
65
|
-
const patchFn = typeof index === 'object' ? index.default : index;
|
|
66
68
|
const name = `validator.${validator}`;
|
|
67
|
-
return patcher.patch(
|
|
69
|
+
return patcher.patch(...getPatcherArgs(index), {
|
|
68
70
|
name,
|
|
69
71
|
patchType,
|
|
70
72
|
post(data) {
|
|
@@ -98,7 +100,7 @@ module.exports = function(core) {
|
|
|
98
100
|
untrackers.forEach((untracker) => {
|
|
99
101
|
depHooks.resolve(
|
|
100
102
|
{ name: 'validator', file: `lib/${untracker}` },
|
|
101
|
-
(index) => patcher.patch(index
|
|
103
|
+
(index) => patcher.patch(...getPatcherArgs(index), {
|
|
102
104
|
name: `validator.${untracker}`,
|
|
103
105
|
patchType,
|
|
104
106
|
post(data) {
|
|
@@ -115,7 +117,7 @@ module.exports = function(core) {
|
|
|
115
117
|
for (const sanitizer in sanitizers) {
|
|
116
118
|
depHooks.resolve(
|
|
117
119
|
{ name: 'validator', file: `lib/${sanitizer}` },
|
|
118
|
-
(index) => patcher.patch(index
|
|
120
|
+
(index) => patcher.patch(...getPatcherArgs(index), {
|
|
119
121
|
name: `validator.${sanitizer}`,
|
|
120
122
|
patchType,
|
|
121
123
|
post(data) {
|
|
@@ -147,7 +149,7 @@ module.exports = function(core) {
|
|
|
147
149
|
for (const method in custom) {
|
|
148
150
|
depHooks.resolve(
|
|
149
151
|
{ name: 'validator', file: `lib/${method}` },
|
|
150
|
-
(index) => patcher.patch(index
|
|
152
|
+
(index) => patcher.patch(...getPatcherArgs(index), {
|
|
151
153
|
name: `validator.${method}`,
|
|
152
154
|
patchType,
|
|
153
155
|
post(data) {
|
|
@@ -22,6 +22,7 @@ module.exports = function(core) {
|
|
|
22
22
|
|
|
23
23
|
require('./handlers')(core);
|
|
24
24
|
require('./install/express-session')(core);
|
|
25
|
+
require('./install/hapi')(core);
|
|
25
26
|
|
|
26
27
|
sessionConfiguration.install = function() {
|
|
27
28
|
callChildComponentMethodsSync(sessionConfiguration, 'install');
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2023 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
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const util = require('util');
|
|
18
|
+
const { patchType } = require('../common');
|
|
19
|
+
|
|
20
|
+
module.exports = function (core) {
|
|
21
|
+
const {
|
|
22
|
+
assess: {
|
|
23
|
+
eventFactory: { createSessionEvent },
|
|
24
|
+
sessionConfiguration: {
|
|
25
|
+
handleHttpOnly,
|
|
26
|
+
handleSecure,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
depHooks,
|
|
30
|
+
patcher,
|
|
31
|
+
scopes: { sources },
|
|
32
|
+
} = core;
|
|
33
|
+
|
|
34
|
+
const hapiSession = core.assess.sessionConfiguration.hapiSession = {};
|
|
35
|
+
|
|
36
|
+
const inspect = patcher.unwrap(util.inspect);
|
|
37
|
+
|
|
38
|
+
hapiSession.install = function () {
|
|
39
|
+
|
|
40
|
+
return depHooks.resolve({ name: '@hapi/hapi', version: '>=18 <21' }, (hapi) => {
|
|
41
|
+
['server', 'Server'].forEach((server) => {
|
|
42
|
+
patcher.patch(hapi, server, {
|
|
43
|
+
name: `hapi.${server}`,
|
|
44
|
+
patchType,
|
|
45
|
+
post(data) {
|
|
46
|
+
patcher.patch(data.result, 'state', {
|
|
47
|
+
name: 'state',
|
|
48
|
+
patchType,
|
|
49
|
+
post(data) {
|
|
50
|
+
|
|
51
|
+
const options = data.args[1];
|
|
52
|
+
|
|
53
|
+
const httpOnly = Object.prototype.hasOwnProperty.call(options, 'isHttpOnly') ? options.isHttpOnly : true;
|
|
54
|
+
const isSecure = Object.prototype.hasOwnProperty.call(options, 'isSecure') ? options.isSecure : true;
|
|
55
|
+
|
|
56
|
+
if (httpOnly && isSecure) return;
|
|
57
|
+
|
|
58
|
+
const sessionEvent = createSessionEvent({
|
|
59
|
+
args: [{
|
|
60
|
+
tracked: false,
|
|
61
|
+
value: inspect(options),
|
|
62
|
+
}],
|
|
63
|
+
context: `state(${inspect(data.args)})`,
|
|
64
|
+
history: [],
|
|
65
|
+
name: `hapi.${server}.state`,
|
|
66
|
+
moduleName: 'hapi',
|
|
67
|
+
methodName: '',
|
|
68
|
+
object: {
|
|
69
|
+
tracked: false,
|
|
70
|
+
value: `hapi.${server}`,
|
|
71
|
+
},
|
|
72
|
+
result: {
|
|
73
|
+
tracked: false,
|
|
74
|
+
value: undefined,
|
|
75
|
+
},
|
|
76
|
+
source: 'P1',
|
|
77
|
+
stacktraceOpts: {
|
|
78
|
+
constructorOpt: data.hooked,
|
|
79
|
+
},
|
|
80
|
+
framework: 'hapi',
|
|
81
|
+
options
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
data.obj.ext('onPostResponse', ({ response: { headers } }) => {
|
|
85
|
+
const value = headers?.['set-cookie']?.[0];
|
|
86
|
+
if (!value) return;
|
|
87
|
+
|
|
88
|
+
const sourceContext = sources.getStore()?.assess;
|
|
89
|
+
if (!sourceContext) return;
|
|
90
|
+
|
|
91
|
+
if (!httpOnly) {
|
|
92
|
+
handleHttpOnly(sourceContext, `set-cookie: ${value}`, sessionEvent);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!isSecure) {
|
|
96
|
+
handleSecure(sourceContext, `set-cookie: ${value}`, sessionEvent);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return hapiSession;
|
|
108
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/assess",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Contrast service providing framework-agnostic Assess support",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|