@contrast/agent 4.10.4 → 4.11.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/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/esm.mjs +45 -3
- package/lib/assess/propagators/joi/any.js +8 -9
- package/lib/assess/propagators/joi/object.js +9 -10
- package/lib/assess/propagators/joi/string-base.js +22 -19
- package/lib/assess/sinks/rethinkdb-nosql-injection.js +1 -1
- package/lib/core/arch-components/dynamodb.js +7 -3
- package/lib/core/arch-components/dynamodbv3.js +7 -3
- package/lib/core/arch-components/index.js +2 -0
- package/lib/core/arch-components/mongodb.js +6 -6
- package/lib/core/arch-components/mysql.js +9 -6
- package/lib/core/arch-components/postgres.js +10 -11
- package/lib/core/arch-components/rethinkdb.js +4 -4
- package/lib/core/arch-components/sqlite3.js +6 -3
- package/lib/core/arch-components/util.js +4 -2
- package/lib/core/config/options.js +136 -238
- package/lib/util/traverse.js +40 -9
- package/package.json +1 -1
package/lib/util/traverse.js
CHANGED
|
@@ -59,7 +59,7 @@ class Path extends Stack {
|
|
|
59
59
|
|
|
60
60
|
super.push({
|
|
61
61
|
key,
|
|
62
|
-
array
|
|
62
|
+
array,
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -74,7 +74,16 @@ class Visitor {
|
|
|
74
74
|
this.cache = new WeakSet();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
visit(key, value) {
|
|
77
|
+
visit(key, value, isMaxDepthReached) {
|
|
78
|
+
if (isMaxDepthReached) {
|
|
79
|
+
this.updateStacks(
|
|
80
|
+
{ counter: this.counter, path: this.path },
|
|
81
|
+
null,
|
|
82
|
+
null,
|
|
83
|
+
isMaxDepthReached,
|
|
84
|
+
);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
78
87
|
// skip circular objects
|
|
79
88
|
if (typeof value === 'object' && value !== null) {
|
|
80
89
|
if (this.cache.has(value)) {
|
|
@@ -96,7 +105,11 @@ class Visitor {
|
|
|
96
105
|
return newVal || value;
|
|
97
106
|
}
|
|
98
107
|
|
|
99
|
-
updateStacks(stacks, key, value) {
|
|
108
|
+
updateStacks(stacks, key, value, isMaxDepthReached) {
|
|
109
|
+
if (isMaxDepthReached) {
|
|
110
|
+
stacks.counter.pop();
|
|
111
|
+
stacks.path.pop();
|
|
112
|
+
}
|
|
100
113
|
// We're decending into the object, so here we're
|
|
101
114
|
// just building up the stacks.
|
|
102
115
|
|
|
@@ -123,7 +136,7 @@ class Visitor {
|
|
|
123
136
|
return this.updateStacks(
|
|
124
137
|
{ counter: this.counter, path: this.path },
|
|
125
138
|
key,
|
|
126
|
-
value
|
|
139
|
+
value,
|
|
127
140
|
);
|
|
128
141
|
}
|
|
129
142
|
return;
|
|
@@ -136,16 +149,34 @@ function traverse(obj, fn, visitor, maxDepth) {
|
|
|
136
149
|
maxDepth = visitor;
|
|
137
150
|
visitor = undefined;
|
|
138
151
|
}
|
|
139
|
-
|
|
140
152
|
visitor =
|
|
141
153
|
visitor ||
|
|
142
|
-
new Visitor(function(key, value, depth, paths) {
|
|
154
|
+
new Visitor(function (key, value, depth, paths) {
|
|
143
155
|
fn(key, value, depth, paths);
|
|
144
156
|
}, maxDepth);
|
|
145
157
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
traverseObject(obj, visitor, maxDepth);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function traverseObject(obj, visitor, remainingDepth = Infinity) {
|
|
162
|
+
if (!obj) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (visitor.path.length() < 1) {
|
|
166
|
+
visitor.visit('', obj);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// This is done just to reset the stack, without changing the current impletion
|
|
170
|
+
if (remainingDepth == 0) {
|
|
171
|
+
visitor.visit(null, null, true);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
176
|
+
visitor.visit(key, value);
|
|
177
|
+
if (value && typeof value === 'object') {
|
|
178
|
+
traverseObject(value, visitor, remainingDepth - 1);
|
|
179
|
+
}
|
|
149
180
|
});
|
|
150
181
|
}
|
|
151
182
|
|