@contrast/protect 1.77.1 → 1.78.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.
|
@@ -36,49 +36,55 @@ module.exports = (core) => {
|
|
|
36
36
|
* registers a depHook for fastify module instrumentation
|
|
37
37
|
*/
|
|
38
38
|
function install() {
|
|
39
|
-
depHooks.resolve({ name: 'fastify', version: '>=4 <6' }, (fastify) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
depHooks.resolve({ name: 'fastify', version: '>=4 <6' }, (fastify) => {
|
|
40
|
+
const patched = patcher.patch(fastify, {
|
|
41
|
+
name: 'fastify.build',
|
|
42
|
+
patchType,
|
|
43
|
+
post({ result: server, funcKey }) {
|
|
44
|
+
server.addHook('preValidation', function (request, reply, done) {
|
|
45
|
+
// todo(NODE-3793): support for @fastify/websocket
|
|
46
|
+
if (request.constructor.name == 'WebSocket') return;
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
let securityException;
|
|
49
|
+
const sourceContext = protect.getSourceContext();
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
if (sourceContext) {
|
|
52
|
+
try {
|
|
53
|
+
if (request.params) {
|
|
54
|
+
sourceContext.parsedParams = request.params;
|
|
55
|
+
inputAnalysis.handleUrlParams(sourceContext, request.params);
|
|
56
|
+
}
|
|
57
|
+
if (request.cookies) {
|
|
58
|
+
sourceContext.parsedCookies = request.cookies;
|
|
59
|
+
inputAnalysis.handleCookies(sourceContext, request.cookies);
|
|
60
|
+
}
|
|
61
|
+
if (request.body) {
|
|
62
|
+
sourceContext.parsedBody = request.body;
|
|
63
|
+
inputAnalysis.handleParsedBody(sourceContext, request.body);
|
|
64
|
+
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
if (request.query) {
|
|
67
|
+
sourceContext.parsedQuery = request.query;
|
|
68
|
+
inputAnalysis.handleQueryParams(sourceContext, request.query);
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (isSecurityException(err)) {
|
|
72
|
+
securityException = err;
|
|
73
|
+
} else {
|
|
74
|
+
logger.error({ err, funcKey }, 'Unexpected error during input analysis');
|
|
75
|
+
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
done(securityException);
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
fastify.fastify = patched;
|
|
84
|
+
fastify.default = patched;
|
|
85
|
+
|
|
86
|
+
return patched;
|
|
87
|
+
});
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
return inputAnalysis.fastifyInstrumentation = {
|
|
@@ -158,7 +158,7 @@ module.exports = function(core) {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
instr.install = function() {
|
|
161
|
-
depHooks.resolve({ name: 'mongodb', version: '<
|
|
161
|
+
depHooks.resolve({ name: 'mongodb', version: '<8' }, (mongodb, meta) => {
|
|
162
162
|
if (!mongodb.Collection || !mongodb.Db) {
|
|
163
163
|
meta.rerun();
|
|
164
164
|
return;
|
|
@@ -32,18 +32,25 @@ module.exports = function(core) {
|
|
|
32
32
|
{
|
|
33
33
|
moduleName: 'sqlite3',
|
|
34
34
|
version: '<6',
|
|
35
|
-
methods: ['all', 'run', 'get', 'each', 'exec', 'prepare']
|
|
35
|
+
methods: ['all', 'run', 'get', 'each', 'exec', 'prepare'],
|
|
36
|
+
target: 'Database'
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
moduleName: 'better-sqlite3',
|
|
39
40
|
version: '<13',
|
|
40
|
-
methods: ['exec', 'prepare']
|
|
41
|
+
methods: ['exec', 'prepare'],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
moduleName: 'node:sqlite',
|
|
45
|
+
version: '*',
|
|
46
|
+
methods: ['exec', 'prepare'],
|
|
47
|
+
target: 'DatabaseSync'
|
|
41
48
|
}
|
|
42
|
-
].forEach(({ moduleName, version, methods }) => {
|
|
49
|
+
].forEach(({ moduleName, version, methods, target }) => {
|
|
43
50
|
depHooks.resolve({ name: moduleName, version }, module => {
|
|
44
51
|
methods.forEach((method) => {
|
|
45
|
-
const name = `${moduleName}.
|
|
46
|
-
patcher.patch(
|
|
52
|
+
const name = `${moduleName + (target ? `.${target}` : '')}.prototype.${method}`;
|
|
53
|
+
patcher.patch(target ? module[target].prototype : module.prototype, method, {
|
|
47
54
|
name,
|
|
48
55
|
patchType,
|
|
49
56
|
pre({ args, hooked, name, orig }) {
|
|
@@ -64,9 +71,9 @@ module.exports = function(core) {
|
|
|
64
71
|
inputTracing.handleSqlInjection(sourceContext, sinkContext);
|
|
65
72
|
}
|
|
66
73
|
});
|
|
67
|
-
})
|
|
74
|
+
});
|
|
68
75
|
});
|
|
69
|
-
})
|
|
76
|
+
});
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
const sqlite3Instrumentation = inputTracing.sqlite3Instrumentation = { install };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/protect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.0",
|
|
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)",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@contrast/agent-lib": "9.2.0",
|
|
24
24
|
"@contrast/common": "1.41.1",
|
|
25
|
-
"@contrast/config": "1.
|
|
26
|
-
"@contrast/core": "1.
|
|
27
|
-
"@contrast/dep-hooks": "1.
|
|
28
|
-
"@contrast/esm-hooks": "2.
|
|
29
|
-
"@contrast/instrumentation": "1.
|
|
30
|
-
"@contrast/logger": "1.
|
|
31
|
-
"@contrast/patcher": "1.
|
|
32
|
-
"@contrast/rewriter": "1.
|
|
33
|
-
"@contrast/scopes": "1.
|
|
34
|
-
"@contrast/stack-trace-factory": "1.
|
|
25
|
+
"@contrast/config": "1.59.0",
|
|
26
|
+
"@contrast/core": "1.64.0",
|
|
27
|
+
"@contrast/dep-hooks": "1.33.0",
|
|
28
|
+
"@contrast/esm-hooks": "2.39.0",
|
|
29
|
+
"@contrast/instrumentation": "1.43.0",
|
|
30
|
+
"@contrast/logger": "1.37.0",
|
|
31
|
+
"@contrast/patcher": "1.36.0",
|
|
32
|
+
"@contrast/rewriter": "1.41.0",
|
|
33
|
+
"@contrast/scopes": "1.34.0",
|
|
34
|
+
"@contrast/stack-trace-factory": "1.5.0",
|
|
35
35
|
"async-hook-domain": "4.0.1",
|
|
36
36
|
"ipaddr.js": "2.0.1",
|
|
37
37
|
"on-finished": "2.4.1",
|