@contrast/agent 4.16.1 → 4.17.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/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 +21 -11
- package/lib/assess/policy/propagators.json +4 -0
- package/lib/assess/policy/signatures.json +5 -0
- package/lib/assess/propagators/fastify-static/allowed-path.js +85 -0
- package/lib/cli-rewriter/index.js +1 -1
- package/lib/contrast.js +1 -1
- package/lib/core/rewrite/index.js +2 -2
- package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
- package/lib/protect/service.js +2 -0
- package/lib/util/trace-util.js +5 -4
- package/node_modules/@colors/colors/LICENSE +26 -0
- package/node_modules/@colors/colors/README.md +219 -0
- package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
- package/node_modules/@colors/colors/examples/safe-string.js +80 -0
- package/node_modules/@colors/colors/index.d.ts +136 -0
- package/node_modules/@colors/colors/lib/colors.js +211 -0
- package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
- package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
- package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
- package/node_modules/@colors/colors/lib/index.js +13 -0
- package/node_modules/@colors/colors/lib/maps/america.js +10 -0
- package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
- package/node_modules/@colors/colors/lib/maps/random.js +11 -0
- package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
- package/node_modules/@colors/colors/lib/styles.js +95 -0
- package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
- package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
- package/node_modules/@colors/colors/package.json +49 -0
- package/node_modules/@colors/colors/safe.d.ts +48 -0
- package/node_modules/@colors/colors/safe.js +10 -0
- package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
- package/node_modules/@dabh/diagnostics/README.md +16 -16
- package/node_modules/@dabh/diagnostics/package.json +9 -9
- package/node_modules/async/CHANGELOG.md +13 -0
- package/node_modules/async/all.js +74 -9
- package/node_modules/async/allLimit.js +3 -3
- package/node_modules/async/allSeries.js +3 -3
- package/node_modules/async/any.js +75 -9
- package/node_modules/async/anyLimit.js +3 -3
- package/node_modules/async/anySeries.js +3 -3
- package/node_modules/async/applyEach.js +2 -2
- package/node_modules/async/applyEachSeries.js +2 -2
- package/node_modules/async/asyncify.js +3 -3
- package/node_modules/async/auto.js +81 -15
- package/node_modules/async/autoInject.js +30 -4
- package/node_modules/async/cargo.js +1 -1
- package/node_modules/async/cargoQueue.js +1 -1
- package/node_modules/async/compose.js +1 -1
- package/node_modules/async/concat.js +72 -4
- package/node_modules/async/concatLimit.js +3 -3
- package/node_modules/async/concatSeries.js +2 -2
- package/node_modules/async/detect.js +43 -8
- package/node_modules/async/detectLimit.js +3 -3
- package/node_modules/async/detectSeries.js +3 -3
- package/node_modules/async/dir.js +1 -1
- package/node_modules/async/dist/async.js +1379 -168
- package/node_modules/async/dist/async.min.js +1 -1
- package/node_modules/async/dist/async.mjs +1372 -161
- package/node_modules/async/doDuring.js +3 -3
- package/node_modules/async/doUntil.js +2 -2
- package/node_modules/async/doWhilst.js +3 -3
- package/node_modules/async/during.js +3 -3
- package/node_modules/async/each.js +69 -28
- package/node_modules/async/eachLimit.js +4 -4
- package/node_modules/async/eachOf.js +85 -16
- package/node_modules/async/eachOfLimit.js +3 -3
- package/node_modules/async/eachOfSeries.js +2 -2
- package/node_modules/async/eachSeries.js +2 -2
- package/node_modules/async/ensureAsync.js +2 -2
- package/node_modules/async/every.js +74 -9
- package/node_modules/async/everyLimit.js +3 -3
- package/node_modules/async/everySeries.js +3 -3
- package/node_modules/async/filter.js +49 -9
- package/node_modules/async/filterLimit.js +3 -3
- package/node_modules/async/filterSeries.js +3 -3
- package/node_modules/async/find.js +43 -8
- package/node_modules/async/findLimit.js +3 -3
- package/node_modules/async/findSeries.js +3 -3
- package/node_modules/async/flatMap.js +72 -4
- package/node_modules/async/flatMapLimit.js +3 -3
- package/node_modules/async/flatMapSeries.js +2 -2
- package/node_modules/async/foldl.js +87 -11
- package/node_modules/async/foldr.js +2 -2
- package/node_modules/async/forEach.js +69 -28
- package/node_modules/async/forEachLimit.js +4 -4
- package/node_modules/async/forEachOf.js +85 -16
- package/node_modules/async/forEachOfLimit.js +3 -3
- package/node_modules/async/forEachOfSeries.js +2 -2
- package/node_modules/async/forEachSeries.js +2 -2
- package/node_modules/async/forever.js +4 -4
- package/node_modules/async/groupBy.js +62 -8
- package/node_modules/async/groupByLimit.js +3 -3
- package/node_modules/async/groupBySeries.js +2 -2
- package/node_modules/async/inject.js +87 -11
- package/node_modules/async/internal/applyEach.js +2 -2
- package/node_modules/async/internal/asyncEachOfLimit.js +1 -1
- package/node_modules/async/internal/consoleFunc.js +5 -1
- package/node_modules/async/internal/createTester.js +2 -2
- package/node_modules/async/internal/eachOfLimit.js +6 -6
- package/node_modules/async/internal/filter.js +2 -2
- package/node_modules/async/internal/iterator.js +5 -2
- package/node_modules/async/internal/map.js +1 -1
- package/node_modules/async/internal/parallel.js +3 -3
- package/node_modules/async/internal/queue.js +4 -4
- package/node_modules/async/internal/reject.js +2 -2
- package/node_modules/async/internal/setImmediate.js +6 -2
- package/node_modules/async/internal/wrapAsync.js +1 -1
- package/node_modules/async/log.js +1 -1
- package/node_modules/async/map.js +86 -6
- package/node_modules/async/mapLimit.js +3 -3
- package/node_modules/async/mapSeries.js +3 -3
- package/node_modules/async/mapValues.js +102 -12
- package/node_modules/async/mapValuesLimit.js +4 -4
- package/node_modules/async/mapValuesSeries.js +1 -1
- package/node_modules/async/memoize.js +3 -3
- package/node_modules/async/nextTick.js +3 -3
- package/node_modules/async/package.json +4 -6
- package/node_modules/async/parallel.js +96 -7
- package/node_modules/async/parallelLimit.js +2 -2
- package/node_modules/async/priorityQueue.js +11 -4
- package/node_modules/async/queue.js +4 -4
- package/node_modules/async/race.js +3 -3
- package/node_modules/async/reduce.js +87 -11
- package/node_modules/async/reduceRight.js +2 -2
- package/node_modules/async/reflect.js +2 -2
- package/node_modules/async/reflectAll.js +1 -1
- package/node_modules/async/reject.js +44 -10
- package/node_modules/async/rejectLimit.js +3 -3
- package/node_modules/async/rejectSeries.js +3 -3
- package/node_modules/async/retry.js +2 -2
- package/node_modules/async/retryable.js +4 -4
- package/node_modules/async/select.js +49 -9
- package/node_modules/async/selectLimit.js +3 -3
- package/node_modules/async/selectSeries.js +3 -3
- package/node_modules/async/seq.js +4 -4
- package/node_modules/async/series.js +112 -12
- package/node_modules/async/setImmediate.js +1 -1
- package/node_modules/async/some.js +75 -9
- package/node_modules/async/someLimit.js +3 -3
- package/node_modules/async/someSeries.js +3 -3
- package/node_modules/async/sortBy.js +121 -19
- package/node_modules/async/timeout.js +2 -2
- package/node_modules/async/times.js +1 -1
- package/node_modules/async/timesLimit.js +3 -3
- package/node_modules/async/timesSeries.js +1 -1
- package/node_modules/async/transform.js +111 -19
- package/node_modules/async/tryEach.js +3 -3
- package/node_modules/async/until.js +3 -3
- package/node_modules/async/waterfall.js +4 -4
- package/node_modules/async/whilst.js +3 -3
- package/node_modules/async/wrapSync.js +3 -3
- package/node_modules/color/README.md +9 -0
- package/node_modules/color/index.js +4 -1
- package/node_modules/color/package.json +8 -8
- package/node_modules/color-string/README.md +6 -2
- package/node_modules/color-string/index.js +21 -13
- package/node_modules/color-string/package.json +4 -4
- package/node_modules/colorspace/package.json +5 -5
- package/node_modules/fecha/dist/fecha.min.js +1 -1
- package/node_modules/fecha/dist/fecha.min.js.map +1 -0
- package/node_modules/fecha/lib/fecha.d.ts +2 -2
- package/node_modules/fecha/lib/fecha.js +35 -18
- package/node_modules/fecha/lib/fecha.js.map +1 -0
- package/node_modules/fecha/lib/fecha.umd.js +35 -18
- package/node_modules/fecha/lib/fecha.umd.js.map +1 -0
- package/node_modules/fecha/package.json +9 -10
- package/node_modules/fecha/src/fecha.ts +524 -0
- package/node_modules/logform/.eslintrc +1 -1
- package/node_modules/logform/CHANGELOG.md +24 -0
- package/node_modules/logform/README.md +15 -17
- package/node_modules/logform/browser.js +3 -1
- package/node_modules/logform/cli.js +1 -1
- package/node_modules/logform/colorize.js +2 -2
- package/node_modules/logform/dist/browser.js +8 -2
- package/node_modules/logform/dist/cli.js +2 -2
- package/node_modules/logform/dist/colorize.js +5 -5
- package/node_modules/logform/dist/errors.js +1 -1
- package/node_modules/logform/dist/format.js +9 -5
- package/node_modules/logform/dist/index.js +53 -20
- package/node_modules/logform/dist/json.js +7 -6
- package/node_modules/logform/dist/logstash.js +1 -1
- package/node_modules/logform/dist/pad-levels.js +4 -4
- package/node_modules/logform/dist/printf.js +1 -1
- package/node_modules/logform/dist/simple.js +1 -1
- package/node_modules/logform/dist/splat.js +2 -2
- package/node_modules/logform/dist/uncolorize.js +1 -1
- package/node_modules/logform/errors.js +1 -1
- package/node_modules/logform/index.d.ts +36 -0
- package/node_modules/logform/index.js +19 -20
- package/node_modules/logform/json.js +7 -7
- package/node_modules/logform/logstash.js +1 -1
- package/node_modules/logform/package.json +10 -9
- package/node_modules/logform/simple.js +1 -1
- package/node_modules/logform/uncolorize.js +1 -1
- package/node_modules/safe-stable-stringify/CHANGELOG.md +75 -0
- package/node_modules/safe-stable-stringify/LICENSE +21 -0
- package/node_modules/safe-stable-stringify/esm/package.json +4 -0
- package/node_modules/safe-stable-stringify/esm/wrapper.js +6 -0
- package/node_modules/safe-stable-stringify/index.d.ts +18 -0
- package/node_modules/safe-stable-stringify/index.js +618 -0
- package/node_modules/safe-stable-stringify/package.json +69 -0
- package/node_modules/safe-stable-stringify/readme.md +170 -0
- package/node_modules/safe-stable-stringify/tsconfig.json +22 -0
- package/node_modules/winston/LICENSE +18 -18
- package/node_modules/winston/README.md +1231 -1230
- package/node_modules/winston/dist/winston/common.js +10 -10
- package/node_modules/winston/dist/winston/config/index.js +17 -17
- package/node_modules/winston/dist/winston/container.js +46 -46
- package/node_modules/winston/dist/winston/create-logger.js +28 -24
- package/node_modules/winston/dist/winston/exception-handler.js +49 -49
- package/node_modules/winston/dist/winston/exception-stream.js +27 -27
- package/node_modules/winston/dist/winston/logger.js +152 -138
- package/node_modules/winston/dist/winston/profiler.js +22 -22
- package/node_modules/winston/dist/winston/rejection-handler.js +54 -54
- package/node_modules/winston/dist/winston/tail-file.js +14 -14
- package/node_modules/winston/dist/winston/transports/console.js +31 -31
- package/node_modules/winston/dist/winston/transports/file.js +101 -101
- package/node_modules/winston/dist/winston/transports/http.js +119 -41
- package/node_modules/winston/dist/winston/transports/index.js +17 -17
- package/node_modules/winston/dist/winston/transports/stream.js +24 -24
- package/node_modules/winston/dist/winston.js +91 -97
- package/node_modules/winston/index.d.ts +213 -193
- package/node_modules/winston/lib/winston/common.js +61 -61
- package/node_modules/winston/lib/winston/config/index.d.ts +99 -98
- package/node_modules/winston/lib/winston/config/index.js +35 -35
- package/node_modules/winston/lib/winston/container.js +114 -114
- package/node_modules/winston/lib/winston/create-logger.js +104 -104
- package/node_modules/winston/lib/winston/exception-handler.js +245 -245
- package/node_modules/winston/lib/winston/exception-stream.js +54 -54
- package/node_modules/winston/lib/winston/logger.js +676 -667
- package/node_modules/winston/lib/winston/profiler.js +51 -51
- package/node_modules/winston/lib/winston/rejection-handler.js +251 -251
- package/node_modules/winston/lib/winston/tail-file.js +124 -124
- package/node_modules/winston/lib/winston/transports/console.js +117 -117
- package/node_modules/winston/lib/winston/transports/file.js +695 -695
- package/node_modules/winston/lib/winston/transports/http.js +267 -202
- package/node_modules/winston/lib/winston/transports/index.d.ts +103 -100
- package/node_modules/winston/lib/winston/transports/index.js +56 -56
- package/node_modules/winston/lib/winston/transports/stream.js +63 -63
- package/node_modules/winston/lib/winston.js +176 -182
- package/node_modules/winston/node_modules/winston-transport/.babelrc +3 -0
- package/node_modules/winston/node_modules/winston-transport/.eslintrc +7 -0
- package/node_modules/winston/node_modules/winston-transport/.gitattributes +1 -0
- package/node_modules/winston/node_modules/winston-transport/.nyc_output/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
- package/node_modules/winston/node_modules/winston-transport/.nyc_output/processinfo/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
- package/node_modules/winston/node_modules/winston-transport/.nyc_output/processinfo/index.json +1 -0
- package/node_modules/winston/node_modules/winston-transport/CHANGELOG.md +126 -0
- package/node_modules/winston/node_modules/winston-transport/LICENSE +22 -0
- package/node_modules/winston/node_modules/winston-transport/README.md +50 -0
- package/node_modules/winston/node_modules/winston-transport/dist/index.js +215 -0
- package/node_modules/winston/node_modules/winston-transport/dist/legacy.js +116 -0
- package/node_modules/winston/node_modules/winston-transport/index.d.ts +39 -0
- package/node_modules/winston/node_modules/winston-transport/index.js +215 -0
- package/node_modules/winston/node_modules/winston-transport/legacy.js +119 -0
- package/node_modules/winston/node_modules/winston-transport/package.json +56 -0
- package/node_modules/winston/package.json +76 -75
- package/package.json +8 -6
- package/node_modules/@dabh/diagnostics/example.png +0 -0
- package/node_modules/color-string/CHANGELOG.md +0 -18
- package/node_modules/colorspace/test.js +0 -14
- package/node_modules/fecha/CHANGELOG.md +0 -67
- package/node_modules/logform/.travis.yml +0 -17
- package/node_modules/winston/CHANGELOG.md +0 -560
package/bin/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.28.
|
|
1
|
+
2.28.20
|
|
Binary file
|
package/bin/mac/contrast-service
CHANGED
|
Binary file
|
|
Binary file
|
package/esm.mjs
CHANGED
|
@@ -14,21 +14,22 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
14
14
|
*/
|
|
15
15
|
import { fileURLToPath } from 'url';
|
|
16
16
|
import { createRequire } from 'module';
|
|
17
|
-
|
|
17
|
+
import { promises as fs } from 'fs';
|
|
18
18
|
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
19
20
|
const loader = require('./agent-loader.js');
|
|
21
|
+
|
|
20
22
|
const { enabled } = await loader.init(process.argv);
|
|
21
23
|
if (enabled) {
|
|
22
24
|
await loader.bootstrap(process.argv);
|
|
23
25
|
}
|
|
24
26
|
await loader.resetArgs(process.argv[0], process.argv[1]);
|
|
25
|
-
const { readFile } = require('fs').promises;
|
|
26
27
|
|
|
27
|
-
const agent = require(
|
|
28
|
-
const logger = require(
|
|
29
|
-
const rewriter = require(
|
|
30
|
-
const helpers = require(
|
|
31
|
-
const getType = require(
|
|
28
|
+
const agent = require('./lib/agent.js');
|
|
29
|
+
const logger = require('./lib/core/logger/index.js')('contrast:esm-loaders');
|
|
30
|
+
const rewriter = require('./lib/core/rewrite/index.js')(agent);
|
|
31
|
+
const helpers = require('./lib/hooks/module/helpers.js');
|
|
32
|
+
const getType = require('./lib/util/get-file-type.js');
|
|
32
33
|
|
|
33
34
|
const loadedFromCache = new Set();
|
|
34
35
|
|
|
@@ -46,6 +47,8 @@ const loadedFromCache = new Set();
|
|
|
46
47
|
* @returns {Promise<{ source: string | SharedArrayBuffer | Uint8Array }>}
|
|
47
48
|
*/
|
|
48
49
|
export async function getSource(url, context, defaultGetSource) {
|
|
50
|
+
if (!enabled) return defaultGetSource(url, context, defaultGetSource);
|
|
51
|
+
|
|
49
52
|
const filename = fileURLToPath(url);
|
|
50
53
|
logger.debug('getSource %s', filename);
|
|
51
54
|
try {
|
|
@@ -78,6 +81,9 @@ export async function getSource(url, context, defaultGetSource) {
|
|
|
78
81
|
* @returns {Promise<{ source: string | SharedArrayBuffer | Uint8Array }>}
|
|
79
82
|
*/
|
|
80
83
|
export async function transformSource(source, context, defaultTransformSource) {
|
|
84
|
+
if (!enabled)
|
|
85
|
+
return defaultTransformSource(source, context, defaultTransformSource);
|
|
86
|
+
|
|
81
87
|
const filename = fileURLToPath(context.url);
|
|
82
88
|
logger.debug('transformSource %s', filename);
|
|
83
89
|
let result;
|
|
@@ -99,11 +105,11 @@ export async function transformSource(source, context, defaultTransformSource) {
|
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
/**
|
|
102
|
-
* For Node 16 and above, the 'getFormat', 'getSource' and 'transformSource' have been
|
|
108
|
+
* For Node 16 and above, the 'getFormat', 'getSource' and 'transformSource' have been
|
|
103
109
|
* consolidated into one 'load' hook. The logic is similar to that of transformSource
|
|
104
110
|
* except that the source is not provided and must be either read in from the file provided
|
|
105
111
|
* or accessed from the cache.
|
|
106
|
-
*
|
|
112
|
+
*
|
|
107
113
|
* @see https://nodejs.org/dist/latest-v16.x/docs/api/esm.html#loadurl-context-defaultload
|
|
108
114
|
* @param {string} url
|
|
109
115
|
* @param {{ format: string, url: string }} context
|
|
@@ -111,6 +117,8 @@ export async function transformSource(source, context, defaultTransformSource) {
|
|
|
111
117
|
* @returns {Promise<{ format: string, source: string | SharedArrayBuffer | Uint8Array }>}
|
|
112
118
|
*/
|
|
113
119
|
export async function load(url, context, defaultLoad) {
|
|
120
|
+
if (!enabled) return defaultLoad(url, context, defaultLoad);
|
|
121
|
+
|
|
114
122
|
const type = getType(url);
|
|
115
123
|
|
|
116
124
|
if (type === 'builtin' || type === 'unknown') {
|
|
@@ -130,8 +138,10 @@ export async function load(url, context, defaultLoad) {
|
|
|
130
138
|
if (cached) {
|
|
131
139
|
result = { code: cached };
|
|
132
140
|
} else {
|
|
133
|
-
const source = await readFile(filename, 'utf8');
|
|
134
|
-
result = rewriter.rewriteFile(source, filename, {
|
|
141
|
+
const source = await fs.readFile(filename, 'utf8');
|
|
142
|
+
result = rewriter.rewriteFile(source, filename, {
|
|
143
|
+
sourceType: type === 'commonjs' ? 'script' : 'module',
|
|
144
|
+
});
|
|
135
145
|
helpers.cacheWithSourceMap(agent, filename, result);
|
|
136
146
|
}
|
|
137
147
|
return { format: type, source: result.code };
|
|
@@ -1367,6 +1367,11 @@
|
|
|
1367
1367
|
"moduleName": "Number",
|
|
1368
1368
|
"methodName": "isNaN",
|
|
1369
1369
|
"isModule": false
|
|
1370
|
+
},
|
|
1371
|
+
"fastify-static.allowedPath": {
|
|
1372
|
+
"moduleName": "fastify-static",
|
|
1373
|
+
"methodName": "allowedPath",
|
|
1374
|
+
"isModule": false
|
|
1370
1375
|
}
|
|
1371
1376
|
}
|
|
1372
1377
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const logger = require('../../../core/logger')('contrast:validator:propagator');
|
|
18
|
+
const patcher = require('../../../hooks/patcher');
|
|
19
|
+
const requireHook = require('../../../hooks/require');
|
|
20
|
+
const { PATCH_TYPES } = require('../../../constants');
|
|
21
|
+
const agent = require('../../../agent');
|
|
22
|
+
const tracker = require('../../../tracker');
|
|
23
|
+
const tagRangeUtil = require('../../models/tag-range/util');
|
|
24
|
+
const TagRange = require('../../models/tag-range');
|
|
25
|
+
const { CallContext, PropagationEvent, Signature } = require('../../models');
|
|
26
|
+
|
|
27
|
+
module.exports.handle = function handle() {
|
|
28
|
+
requireHook.resolve(
|
|
29
|
+
{ name: 'fastify-plugin', file: 'plugin' },
|
|
30
|
+
(fastifyPlugin) => (patcher.patch(fastifyPlugin, {
|
|
31
|
+
name: 'fastify-plugin',
|
|
32
|
+
patchType: PATCH_TYPES.ASSESS_PROPAGATOR,
|
|
33
|
+
alwaysRun: true,
|
|
34
|
+
pre: ({ args }) => {
|
|
35
|
+
if ((typeof args[0] == 'function') && args[1] && (args[1].name === 'fastify-static')) {
|
|
36
|
+
const fastifyStatic = args[0];
|
|
37
|
+
|
|
38
|
+
args[0] = patcher.patch(fastifyStatic, {
|
|
39
|
+
name: 'fastify-static',
|
|
40
|
+
patchType: PATCH_TYPES.ASSESS_PROPAGATOR,
|
|
41
|
+
alwaysRun: true,
|
|
42
|
+
pre: ({ args: preArgs }) => {
|
|
43
|
+
if (preArgs[1] && preArgs[1].allowedPath) {
|
|
44
|
+
const { allowedPath } = preArgs[1];
|
|
45
|
+
|
|
46
|
+
preArgs[1].allowedPath = patcher.patch(allowedPath, {
|
|
47
|
+
name: 'allowed-path',
|
|
48
|
+
patchType: PATCH_TYPES.ASSESS_PROPAGATOR,
|
|
49
|
+
alwaysRun: true,
|
|
50
|
+
post: (data) => {
|
|
51
|
+
if (data.result && agent.config.assess.trust_custom_validators) {
|
|
52
|
+
const trackingData = tracker.getData(data.args[0]);
|
|
53
|
+
|
|
54
|
+
if (trackingData) {
|
|
55
|
+
logger.trace('hooking fastify-static/index');
|
|
56
|
+
tagRangeUtil.addInPlace(
|
|
57
|
+
trackingData.tagRanges,
|
|
58
|
+
new TagRange(0, data.args[0].length - 1, 'exclusion:path-traversal')
|
|
59
|
+
);
|
|
60
|
+
tagRangeUtil.removeInPlace(trackingData.tagRanges, ['untrusted']);
|
|
61
|
+
|
|
62
|
+
const context = new CallContext(data);
|
|
63
|
+
const event = new PropagationEvent({
|
|
64
|
+
context,
|
|
65
|
+
signature: new Signature('fastify-static.allowedPath'),
|
|
66
|
+
tagRanges: trackingData.tagRanges,
|
|
67
|
+
source: 'O',
|
|
68
|
+
target: 'R'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
event.parents.push(trackingData.event);
|
|
72
|
+
trackingData.event = event;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
}))
|
|
83
|
+
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -215,7 +215,7 @@ class CLIRewriter {
|
|
|
215
215
|
|
|
216
216
|
const content = await readFile(filename, 'utf8');
|
|
217
217
|
const rewriteData = this.rewriter.rewriteFile(content, filename, {
|
|
218
|
-
sourceType: type
|
|
218
|
+
sourceType: type === 'commonjs' ? 'script' : 'module'
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
if (rewriteData.code) {
|
package/lib/contrast.js
CHANGED
|
@@ -223,7 +223,7 @@ contrastAgent.prepare = function(...args) {
|
|
|
223
223
|
// optionally enable metric collection
|
|
224
224
|
require('./core/metrics').configure(config);
|
|
225
225
|
|
|
226
|
-
if (agent.cluster.isPrimary) {
|
|
226
|
+
if (config.enable && agent.cluster.isPrimary) {
|
|
227
227
|
contrastAgent.showBanner();
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -27,7 +27,7 @@ const BinaryExpression = require('./binary-expression');
|
|
|
27
27
|
const CallExpression = require('./call-expression');
|
|
28
28
|
const CatchClause = require('./catch-clause');
|
|
29
29
|
const functionWrap = require('./function-wrap');
|
|
30
|
-
const ImportDeclaration = require('./import-declaration');
|
|
30
|
+
// const ImportDeclaration = require('./import-declaration');
|
|
31
31
|
const isContrastMethod = require('./is-contrast-method');
|
|
32
32
|
const logRewrite = require('./log');
|
|
33
33
|
const MemberExpression = require('./member-expression');
|
|
@@ -106,7 +106,7 @@ class Rewriter {
|
|
|
106
106
|
BinaryExpression,
|
|
107
107
|
CallExpression,
|
|
108
108
|
CatchClause,
|
|
109
|
-
ImportDeclaration,
|
|
109
|
+
// ImportDeclaration, disabled since we're not yet utilizing this.
|
|
110
110
|
MemberExpression,
|
|
111
111
|
ObjectProperty,
|
|
112
112
|
SwitchStatement,
|
package/lib/protect/service.js
CHANGED
|
@@ -202,9 +202,11 @@ class ProtectService {
|
|
|
202
202
|
headers: req.rawHeaders.map((h, ix) => (ix & 1 ? h : h.toLowerCase()))
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
+
arg.uriPath = req.url;
|
|
205
206
|
const questionMark = req.url.indexOf('?');
|
|
206
207
|
if (questionMark >= 0) {
|
|
207
208
|
arg.queries = req.url.slice(questionMark + 1);
|
|
209
|
+
arg.uriPath = req.url.slice(0, questionMark);
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
const findings = this.agentLib.scoreRequestConnect(rules, arg, evalOptions);
|
package/lib/util/trace-util.js
CHANGED
|
@@ -46,12 +46,13 @@ function getRequest(agent, ruleId) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const ruleCount = context.rules[ruleId];
|
|
49
|
-
|
|
50
49
|
const { sampling } = agent.config.assess;
|
|
51
|
-
if (sampling && sampling.enable && ruleCount
|
|
52
|
-
|
|
53
|
-
return request;
|
|
50
|
+
if (sampling && sampling.enable && ruleCount >= sampling.baseline) {
|
|
51
|
+
return;
|
|
54
52
|
}
|
|
53
|
+
|
|
54
|
+
context.rules[ruleId]++;
|
|
55
|
+
return request;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Original Library
|
|
4
|
+
- Copyright (c) Marak Squires
|
|
5
|
+
|
|
6
|
+
Additional Functionality
|
|
7
|
+
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
8
|
+
- Copyright (c) DABH (https://github.com/DABH)
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# @colors/colors ("colors.js")
|
|
2
|
+
[](https://github.com/DABH/colors.js/actions/workflows/ci.yml)
|
|
3
|
+
[](https://www.npmjs.org/package/@colors/colors)
|
|
4
|
+
|
|
5
|
+
Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback.
|
|
6
|
+
|
|
7
|
+
## get color and style in your node.js console
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
npm install @colors/colors
|
|
14
|
+
|
|
15
|
+
## colors and styles!
|
|
16
|
+
|
|
17
|
+
### text colors
|
|
18
|
+
|
|
19
|
+
- black
|
|
20
|
+
- red
|
|
21
|
+
- green
|
|
22
|
+
- yellow
|
|
23
|
+
- blue
|
|
24
|
+
- magenta
|
|
25
|
+
- cyan
|
|
26
|
+
- white
|
|
27
|
+
- gray
|
|
28
|
+
- grey
|
|
29
|
+
|
|
30
|
+
### bright text colors
|
|
31
|
+
|
|
32
|
+
- brightRed
|
|
33
|
+
- brightGreen
|
|
34
|
+
- brightYellow
|
|
35
|
+
- brightBlue
|
|
36
|
+
- brightMagenta
|
|
37
|
+
- brightCyan
|
|
38
|
+
- brightWhite
|
|
39
|
+
|
|
40
|
+
### background colors
|
|
41
|
+
|
|
42
|
+
- bgBlack
|
|
43
|
+
- bgRed
|
|
44
|
+
- bgGreen
|
|
45
|
+
- bgYellow
|
|
46
|
+
- bgBlue
|
|
47
|
+
- bgMagenta
|
|
48
|
+
- bgCyan
|
|
49
|
+
- bgWhite
|
|
50
|
+
- bgGray
|
|
51
|
+
- bgGrey
|
|
52
|
+
|
|
53
|
+
### bright background colors
|
|
54
|
+
|
|
55
|
+
- bgBrightRed
|
|
56
|
+
- bgBrightGreen
|
|
57
|
+
- bgBrightYellow
|
|
58
|
+
- bgBrightBlue
|
|
59
|
+
- bgBrightMagenta
|
|
60
|
+
- bgBrightCyan
|
|
61
|
+
- bgBrightWhite
|
|
62
|
+
|
|
63
|
+
### styles
|
|
64
|
+
|
|
65
|
+
- reset
|
|
66
|
+
- bold
|
|
67
|
+
- dim
|
|
68
|
+
- italic
|
|
69
|
+
- underline
|
|
70
|
+
- inverse
|
|
71
|
+
- hidden
|
|
72
|
+
- strikethrough
|
|
73
|
+
|
|
74
|
+
### extras
|
|
75
|
+
|
|
76
|
+
- rainbow
|
|
77
|
+
- zebra
|
|
78
|
+
- america
|
|
79
|
+
- trap
|
|
80
|
+
- random
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
By popular demand, `@colors/colors` now ships with two types of usages!
|
|
86
|
+
|
|
87
|
+
The super nifty way
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
var colors = require('@colors/colors');
|
|
91
|
+
|
|
92
|
+
console.log('hello'.green); // outputs green text
|
|
93
|
+
console.log('i like cake and pies'.underline.red); // outputs red underlined text
|
|
94
|
+
console.log('inverse the color'.inverse); // inverses the color
|
|
95
|
+
console.log('OMG Rainbows!'.rainbow); // rainbow
|
|
96
|
+
console.log('Run the trap'.trap); // Drops the bass
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
or a slightly less nifty way which doesn't extend `String.prototype`
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
var colors = require('@colors/colors/safe');
|
|
104
|
+
|
|
105
|
+
console.log(colors.green('hello')); // outputs green text
|
|
106
|
+
console.log(colors.red.underline('i like cake and pies')); // outputs red underlined text
|
|
107
|
+
console.log(colors.inverse('inverse the color')); // inverses the color
|
|
108
|
+
console.log(colors.rainbow('OMG Rainbows!')); // rainbow
|
|
109
|
+
console.log(colors.trap('Run the trap')); // Drops the bass
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
|
|
114
|
+
|
|
115
|
+
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
|
|
116
|
+
|
|
117
|
+
## Enabling/Disabling Colors
|
|
118
|
+
|
|
119
|
+
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
node myapp.js --no-color
|
|
123
|
+
node myapp.js --color=false
|
|
124
|
+
|
|
125
|
+
node myapp.js --color
|
|
126
|
+
node myapp.js --color=true
|
|
127
|
+
node myapp.js --color=always
|
|
128
|
+
|
|
129
|
+
FORCE_COLOR=1 node myapp.js
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Or in code:
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
var colors = require('@colors/colors');
|
|
136
|
+
colors.enable();
|
|
137
|
+
colors.disable();
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
var name = 'Beowulf';
|
|
144
|
+
console.log(colors.green('Hello %s'), name);
|
|
145
|
+
// outputs -> 'Hello Beowulf'
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Custom themes
|
|
149
|
+
|
|
150
|
+
### Using standard API
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
|
|
154
|
+
var colors = require('@colors/colors');
|
|
155
|
+
|
|
156
|
+
colors.setTheme({
|
|
157
|
+
silly: 'rainbow',
|
|
158
|
+
input: 'grey',
|
|
159
|
+
verbose: 'cyan',
|
|
160
|
+
prompt: 'grey',
|
|
161
|
+
info: 'green',
|
|
162
|
+
data: 'grey',
|
|
163
|
+
help: 'cyan',
|
|
164
|
+
warn: 'yellow',
|
|
165
|
+
debug: 'blue',
|
|
166
|
+
error: 'red'
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// outputs red text
|
|
170
|
+
console.log("this is an error".error);
|
|
171
|
+
|
|
172
|
+
// outputs yellow text
|
|
173
|
+
console.log("this is a warning".warn);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Using string safe API
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
var colors = require('@colors/colors/safe');
|
|
180
|
+
|
|
181
|
+
// set single property
|
|
182
|
+
var error = colors.red;
|
|
183
|
+
error('this is red');
|
|
184
|
+
|
|
185
|
+
// set theme
|
|
186
|
+
colors.setTheme({
|
|
187
|
+
silly: 'rainbow',
|
|
188
|
+
input: 'grey',
|
|
189
|
+
verbose: 'cyan',
|
|
190
|
+
prompt: 'grey',
|
|
191
|
+
info: 'green',
|
|
192
|
+
data: 'grey',
|
|
193
|
+
help: 'cyan',
|
|
194
|
+
warn: 'yellow',
|
|
195
|
+
debug: 'blue',
|
|
196
|
+
error: 'red'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// outputs red text
|
|
200
|
+
console.log(colors.error("this is an error"));
|
|
201
|
+
|
|
202
|
+
// outputs yellow text
|
|
203
|
+
console.log(colors.warn("this is a warning"));
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Combining Colors
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
var colors = require('@colors/colors');
|
|
211
|
+
|
|
212
|
+
colors.setTheme({
|
|
213
|
+
custom: ['red', 'underline']
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
console.log('test'.custom);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var colors = require('../lib/index');
|
|
2
|
+
|
|
3
|
+
console.log('First some yellow text'.yellow);
|
|
4
|
+
|
|
5
|
+
console.log('Underline that text'.yellow.underline);
|
|
6
|
+
|
|
7
|
+
console.log('Make it bold and red'.red.bold);
|
|
8
|
+
|
|
9
|
+
console.log(('Double Raindows All Day Long').rainbow);
|
|
10
|
+
|
|
11
|
+
console.log('Drop the bass'.trap);
|
|
12
|
+
|
|
13
|
+
console.log('DROP THE RAINBOW BASS'.trap.rainbow);
|
|
14
|
+
|
|
15
|
+
// styles not widely supported
|
|
16
|
+
console.log('Chains are also cool.'.bold.italic.underline.red);
|
|
17
|
+
|
|
18
|
+
// styles not widely supported
|
|
19
|
+
console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
|
|
20
|
+
+ ' styles! '.yellow.bold);
|
|
21
|
+
console.log('Zebras are so fun!'.zebra);
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
// Remark: .strikethrough may not work with Mac OS Terminal App
|
|
25
|
+
//
|
|
26
|
+
console.log('This is ' + 'not'.strikethrough + ' fun.');
|
|
27
|
+
|
|
28
|
+
console.log('Background color attack!'.black.bgWhite);
|
|
29
|
+
console.log('Use random styles on everything!'.random);
|
|
30
|
+
console.log('America, Heck Yeah!'.america);
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line max-len
|
|
33
|
+
console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
|
|
34
|
+
|
|
35
|
+
console.log('Setting themes is useful');
|
|
36
|
+
|
|
37
|
+
//
|
|
38
|
+
// Custom themes
|
|
39
|
+
//
|
|
40
|
+
console.log('Generic logging theme as JSON'.green.bold.underline);
|
|
41
|
+
// Load theme with JSON literal
|
|
42
|
+
colors.setTheme({
|
|
43
|
+
silly: 'rainbow',
|
|
44
|
+
input: 'grey',
|
|
45
|
+
verbose: 'cyan',
|
|
46
|
+
prompt: 'grey',
|
|
47
|
+
info: 'green',
|
|
48
|
+
data: 'grey',
|
|
49
|
+
help: 'cyan',
|
|
50
|
+
warn: 'yellow',
|
|
51
|
+
debug: 'blue',
|
|
52
|
+
error: 'red',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// outputs red text
|
|
56
|
+
console.log('this is an error'.error);
|
|
57
|
+
|
|
58
|
+
// outputs yellow text
|
|
59
|
+
console.log('this is a warning'.warn);
|
|
60
|
+
|
|
61
|
+
// outputs grey text
|
|
62
|
+
console.log('this is an input'.input);
|
|
63
|
+
|
|
64
|
+
console.log('Generic logging theme as file'.green.bold.underline);
|
|
65
|
+
|
|
66
|
+
// Load a theme from file
|
|
67
|
+
try {
|
|
68
|
+
colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.log(err);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// outputs red text
|
|
74
|
+
console.log('this is an error'.error);
|
|
75
|
+
|
|
76
|
+
// outputs yellow text
|
|
77
|
+
console.log('this is a warning'.warn);
|
|
78
|
+
|
|
79
|
+
// outputs grey text
|
|
80
|
+
console.log('this is an input'.input);
|
|
81
|
+
|
|
82
|
+
// console.log("Don't summon".zalgo)
|
|
83
|
+
|