@contrast/route-coverage 1.9.0 → 1.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/LICENSE +12 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +6 -3
- package/lib/install/express.js +1 -1
- package/lib/install/fastify.js +3 -3
- package/lib/install/koa.js +1 -1
- package/lib/utils/route-info.js +1 -1
- package/package.json +7 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright: 2023 Contrast Security, Inc
|
|
2
|
+
Contact: support@contrastsecurity.com
|
|
3
|
+
License: Commercial
|
|
4
|
+
|
|
5
|
+
NOTICE: This Software and the patented inventions embodied within may only be
|
|
6
|
+
used as part of Contrast Security’s commercial offerings. Even though it is
|
|
7
|
+
made available through public repositories, use of this Software is subject to
|
|
8
|
+
the applicable End User Licensing Agreement found at
|
|
9
|
+
https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
10
|
+
between Contrast Security and the End User. The Software may not be reverse
|
|
11
|
+
engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
12
|
+
way not consistent with the End User License Agreement.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright:
|
|
2
|
+
* Copyright: 2023 Contrast Security, Inc
|
|
3
3
|
* Contact: support@contrastsecurity.com
|
|
4
4
|
* License: Commercial
|
|
5
5
|
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { Installable, Messages, RouteInfo } from '@contrast/common';
|
|
17
|
+
import { Config } from '@contrast/config';
|
|
17
18
|
import { Logger } from '@contrast/logger';
|
|
18
19
|
import { Patcher } from '@contrast/patcher';
|
|
19
20
|
import RequireHook from '@contrast/require-hook';
|
|
@@ -29,6 +30,7 @@ export interface RouteCoverage extends Installable {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export interface Core {
|
|
33
|
+
readonly config: Config;
|
|
32
34
|
readonly depHooks: RequireHook;
|
|
33
35
|
readonly logger: Logger;
|
|
34
36
|
readonly messages: Messages;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright:
|
|
2
|
+
* Copyright: 2023 Contrast Security, Inc
|
|
3
3
|
* Contact: support@contrastsecurity.com
|
|
4
4
|
* License: Commercial
|
|
5
5
|
|
|
@@ -24,13 +24,16 @@ const { routeIdentifier } = require('./utils/route-info');
|
|
|
24
24
|
* }} core
|
|
25
25
|
*/
|
|
26
26
|
module.exports = function init(core) {
|
|
27
|
-
const { logger, messages, scopes } = core;
|
|
27
|
+
const { config, logger, messages, scopes } = core;
|
|
28
|
+
|
|
29
|
+
if (!config.agent.route_coverage.enable) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
/** @type {Map<string, import('@contrast/common').RouteInfo>} */
|
|
30
34
|
const routeInfo = new Map();
|
|
31
35
|
|
|
32
36
|
core.routeCoverage = {
|
|
33
|
-
|
|
34
37
|
discover(info) {
|
|
35
38
|
routeInfo.set(routeIdentifier(info), info);
|
|
36
39
|
messages.emit(Event.ROUTE_COVERAGE_DISCOVERY, info);
|
package/lib/install/express.js
CHANGED
package/lib/install/fastify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright:
|
|
2
|
+
* Copyright: 2023 Contrast Security, Inc
|
|
3
3
|
* Contact: support@contrastsecurity.com
|
|
4
4
|
* License: Commercial
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
const { createSignature } = require('./../utils/route-info');
|
|
19
19
|
const { toLowerCase } = require('@contrast/common');
|
|
20
20
|
|
|
21
|
-
/** @typedef {Parameters<import('
|
|
21
|
+
/** @typedef {Parameters<import('fastify-3.0.0').onRouteHookHandler>[0]} RouteOptions */
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @param {import('..').Core & {
|
|
@@ -86,7 +86,7 @@ module.exports = function init(core) {
|
|
|
86
86
|
install() {
|
|
87
87
|
depHooks.resolve(
|
|
88
88
|
{ name: 'fastify', version: '>=3.0.0' },
|
|
89
|
-
/** @param {import("
|
|
89
|
+
/** @param {import("fastify-3.0.0").fastify} fastify */
|
|
90
90
|
(fastify) =>
|
|
91
91
|
patcher.patch(fastify, {
|
|
92
92
|
name: 'fastify.build',
|
package/lib/install/koa.js
CHANGED
package/lib/utils/route-info.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/route-coverage",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.11.0",
|
|
4
|
+
"description": "Handles route discovery and observation",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/"
|
|
9
|
+
],
|
|
7
10
|
"main": "lib/index.js",
|
|
8
11
|
"types": "lib/index.d.ts",
|
|
9
12
|
"engines": {
|
|
@@ -14,6 +17,6 @@
|
|
|
14
17
|
"test": "../scripts/test.sh"
|
|
15
18
|
},
|
|
16
19
|
"dependencies": {
|
|
17
|
-
"@contrast/common": "1.
|
|
20
|
+
"@contrast/common": "1.15.0"
|
|
18
21
|
}
|
|
19
|
-
}
|
|
22
|
+
}
|