@contrast/route-coverage 1.35.0 → 1.35.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright: 2024 Contrast Security, Inc
1
+ Copyright: 2025 Contrast Security, Inc
2
2
  Contact: support@contrastsecurity.com
3
3
  License: Commercial
4
4
 
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2024 Contrast Security, Inc
2
+ * Copyright: 2025 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@contrast/route-coverage",
3
- "version": "1.35.0",
3
+ "version": "1.35.2",
4
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
7
  "files": [
8
- "lib/"
8
+ "lib/",
9
+ "!*.test.*",
10
+ "!tsconfig.*",
11
+ "!*.map"
9
12
  ],
10
13
  "main": "lib/index.js",
11
14
  "types": "lib/index.d.ts",
@@ -17,13 +20,13 @@
17
20
  "test": "../scripts/test.sh"
18
21
  },
19
22
  "dependencies": {
20
- "@contrast/common": "1.29.0",
21
- "@contrast/config": "1.40.0",
22
- "@contrast/dep-hooks": "1.14.0",
23
+ "@contrast/common": "1.29.1",
24
+ "@contrast/config": "1.40.2",
25
+ "@contrast/dep-hooks": "1.14.2",
23
26
  "@contrast/fn-inspect": "^4.3.0",
24
- "@contrast/logger": "1.18.0",
25
- "@contrast/patcher": "1.17.0",
26
- "@contrast/scopes": "1.15.0",
27
+ "@contrast/logger": "1.18.2",
28
+ "@contrast/patcher": "1.17.2",
29
+ "@contrast/scopes": "1.15.2",
27
30
  "semver": "^7.6.0",
28
31
  "path-to-regexp": "^8.2.0"
29
32
  }
package/lib/index.test.js DELETED
@@ -1,136 +0,0 @@
1
- 'use strict';
2
-
3
- const { expect } = require('chai');
4
- const sinon = require('sinon');
5
- const proxyquire = require('proxyquire');
6
- const { Event } = require('@contrast/common');
7
- const mocks = require('@contrast/test/mocks');
8
- const { initAssessFixture } = require('@contrast/test/fixtures');
9
- const { installsComponents } = require('@contrast/test/utils');
10
-
11
- const MODULES = ['express', 'fastify', 'hapi', 'koa'];
12
-
13
- describe('route coverage', function () {
14
- let core, simulateRequestScope, routeCoverage, clock;
15
-
16
- beforeEach(function () {
17
- ({ core, simulateRequestScope } = initAssessFixture());
18
-
19
- clock = sinon.useFakeTimers();
20
- sinon.spy(core.messages, 'emit');
21
-
22
- const moduleMock = (moduleName) => (deps) => {
23
- deps.routeCoverage[moduleName] = mocks.installable();
24
- };
25
-
26
- routeCoverage = proxyquire('.', {
27
- './install/express': moduleMock('express'),
28
- './install/fastify': moduleMock('fastify'),
29
- './install/hapi': moduleMock('hapi'),
30
- './install/koa': moduleMock('koa'),
31
- });
32
- });
33
-
34
- it('installs its components', function () {
35
- routeCoverage(core).install();
36
- installsComponents(core.routeCoverage, MODULES);
37
- });
38
-
39
- it('does not install when not enabled', function () {
40
- core.config.agent.route_coverage.enable = false;
41
- routeCoverage(core);
42
- expect(core).not.to.have.property('routeCoverage');
43
- });
44
-
45
- describe('.discoveryFinished()', function () {
46
- beforeEach(function () {
47
- routeCoverage(core).install();
48
- });
49
-
50
- it('emits an event when discovery is finished', function () {
51
- const eventA = { signature: 'url.get', url: 'url', method: 'get' };
52
- const eventB = { signature: 'url.post', url: 'url', method: 'post' };
53
- core.routeCoverage.discover(eventA);
54
- core.routeCoverage.discover(eventA); // check that we dedupe discovery.
55
- core.routeCoverage.discover(eventB);
56
- core.routeCoverage.discoveryFinished();
57
-
58
- expect(core.messages.emit).to.have.been.calledWith(
59
- Event.ROUTE_COVERAGE_DISCOVERY_FINISHED,
60
- [eventA, eventB],
61
- );
62
- });
63
-
64
- it('queues new events after initial discovery is finished', function () {
65
- const eventA = { signature: 'url.get', url: 'url', method: 'get' };
66
- core.routeCoverage.discover(eventA);
67
- core.routeCoverage.discoveryFinished();
68
- expect(core.messages.emit).to.have.been.calledWith(
69
- Event.ROUTE_COVERAGE_DISCOVERY_FINISHED,
70
- [eventA],
71
- );
72
-
73
- const eventB = { signature: 'url.post', url: 'url', method: 'post' };
74
- core.routeCoverage.discover(eventA); // check that we dedupe routes discoverd on startup
75
- core.routeCoverage.discover(eventB);
76
- core.routeCoverage.discover(eventB); // check that we dedupe routes defined lazily
77
- clock.tick(10000); //queuingFinished
78
-
79
- expect(core.messages.emit).to.have.been.calledWith(
80
- Event.ROUTE_COVERAGE_DISCOVERY_FINISHED,
81
- [eventB],
82
- );
83
- });
84
- });
85
-
86
- describe('.observe()', function () {
87
- beforeEach(function () {
88
- routeCoverage(core).install();
89
- });
90
-
91
- it('logs debug messages when a route is missing on observation', function () {
92
- const info = { url: 'url', method: 'get' };
93
- core.routeCoverage.observe(info);
94
- expect(core.logger.debug).to.have.been.calledOnceWithExactly(
95
- info,
96
- 'unable to observe undiscovered route',
97
- );
98
- });
99
-
100
- it('emits an event on route observation', function () {
101
- const event = {
102
- signature: 'hello',
103
- url: 'url',
104
- method: 'get',
105
- sourceInfo: undefined
106
- };
107
- core.routeCoverage.discover(event);
108
- core.routeCoverage.observe(event);
109
-
110
- expect(core.messages.emit).to.have.been.calledWith(
111
- Event.ROUTE_COVERAGE_OBSERVATION,
112
- event,
113
- );
114
- });
115
-
116
- it('emits an event on route observation and appends sourceInfo when in request scope', function () {
117
- const event = {
118
- signature: 'hello',
119
- url: 'url',
120
- method: 'get',
121
- };
122
- core.routeCoverage.discover(event);
123
-
124
- simulateRequestScope(() => {
125
- core.routeCoverage.observe(event);
126
- const { sourceInfo, route } = core.scopes.sources.getStore();
127
- expect(sourceInfo).to.be.ok;
128
- expect(route).to.eql({ method: 'get', signature: 'hello', url: 'url' });
129
- expect(core.messages.emit).to.have.been.calledWith(
130
- Event.ROUTE_COVERAGE_OBSERVATION,
131
- sinon.match({ ...event, sourceInfo })
132
- );
133
- });
134
- });
135
- });
136
- });