@contrast/agentify 1.39.0 → 1.41.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/lib/index.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  import { Installable } from '@contrast/common';
17
17
  import { Config } from '@contrast/config';
18
- import { Perf } from '@contrast/perf';
18
+ import Perf from '@contrast/perf';
19
19
  import { Core as _Core } from '@contrast/core';
20
20
  import { Deadzones } from '@contrast/deadzones';
21
21
  import { DepHooks } from '@contrast/dep-hooks';
@@ -54,7 +54,7 @@ declare module 'node:module' {
54
54
 
55
55
  export interface Core extends _Core {
56
56
  config: Config;
57
- Perf: Perf;
57
+ Perf: typeof Perf;
58
58
  logger: Logger;
59
59
  depHooks: DepHooks;
60
60
  patcher: Patcher
package/lib/index.js CHANGED
@@ -83,7 +83,7 @@ module.exports = function init(core = {}) {
83
83
 
84
84
  let _callback;
85
85
  let _opts;
86
- const _perf = new core.Perf('agentify');
86
+ const _perfAgentify = new core.Perf('agentify');
87
87
 
88
88
  core.agentify = async function agentify(callback, opts = {}) {
89
89
  // options are hardcoded, so if this throws it's going to be in testing/dev situation
@@ -165,6 +165,7 @@ module.exports = function init(core = {}) {
165
165
  { name: 'agent-info', spec: '@contrast/core/lib/agent-info' },
166
166
  { name: 'app-info', spec: '@contrast/core/lib/app-info' },
167
167
  { name: 'system-info', spec: '@contrast/core/lib/system-info' },
168
+ { name: 'build-id', spec: '@contrast/core/lib/build-id' },
168
169
  // was check for appInfo errors length and throw if found
169
170
  { name: 'telemetry', spec: '@contrast/telemetry' },
170
171
  { name: 'sensitive-data-masking', spec: '@contrast/core/lib/sensitive-data-masking' },
@@ -217,7 +218,7 @@ module.exports = function init(core = {}) {
217
218
  mod = mod.default;
218
219
  }
219
220
 
220
- _perf.wrapInit(mod, spec)(core);
221
+ _perfAgentify.wrapInit(mod, spec)(core);
221
222
 
222
223
  // perform any validations that can take place now that this module is loaded.
223
224
  if (name === 'logger') {
package/lib/sources.js CHANGED
@@ -16,7 +16,8 @@
16
16
  'use strict';
17
17
 
18
18
  const { EventEmitter } = require('events');
19
- const { Event } = require('@contrast/common');
19
+ const onFinished = require('on-finished');
20
+ const { Event, primordials: { StringPrototypeToLowerCase } } = require('@contrast/common');
20
21
 
21
22
  module.exports = function(core) {
22
23
  const {
@@ -48,6 +49,7 @@ module.exports = function(core) {
48
49
  protocol: serverType === 'http' ? 'http' : 'https',
49
50
  serverType,
50
51
  time: Date.now(),
52
+ method: StringPrototypeToLowerCase.call(req.method),
51
53
  }
52
54
  };
53
55
 
@@ -61,7 +63,7 @@ module.exports = function(core) {
61
63
  });
62
64
  }
63
65
 
64
- res.on('finish', () => {
66
+ onFinished(res, (/* err, req */) => {
65
67
  messages.emit(Event.RESPONSE_FINISH, store);
66
68
  });
67
69
 
@@ -4,6 +4,7 @@ const EventEmitter = require('events');
4
4
  const { expect } = require('chai');
5
5
  const sinon = require('sinon');
6
6
  const { initProtectFixture } = require('@contrast/test/fixtures');
7
+ const proxyquire = require('proxyquire');
7
8
 
8
9
  describe('agentify sources', function () {
9
10
  [
@@ -51,7 +52,7 @@ describe('agentify sources', function () {
51
52
  }
52
53
  ].forEach(({ name, method, expected }) => {
53
54
  describe(`${name} sources using ${method || 'Server'}()`, function () {
54
- let core, api, ServerMock, reqMock, resMock;
55
+ let core, api, ServerMock, reqMock, resMock, onFinishedMock;
55
56
 
56
57
  beforeEach(function () {
57
58
  ({ core } = initProtectFixture());
@@ -83,9 +84,12 @@ describe('agentify sources', function () {
83
84
  url: 'http://localhost',
84
85
  };
85
86
  resMock = new EventEmitter();
87
+ onFinishedMock = sinon.stub();
86
88
 
87
89
  core.depHooks.resolve.withArgs(sinon.match({ name: 'http' })).yields(api);
88
- require('./sources')(core).install();
90
+ proxyquire('./sources', {
91
+ 'on-finished': onFinishedMock,
92
+ })(core).install();
89
93
  });
90
94
 
91
95
  it('"request" events run in scope with correct sourceInfo', function () {
@@ -103,7 +107,8 @@ describe('agentify sources', function () {
103
107
  protocol: 'http',
104
108
  serverType: 'http',
105
109
  });
106
- expect(resMock._events.finish).to.be.a('function');
110
+
111
+ expect(onFinishedMock).to.have.been.calledWith(resMock);
107
112
  });
108
113
 
109
114
  it('non-"request" events do not run in scope', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agentify",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "description": "Configures Contrast agent services and instrumentation within an application",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,21 +17,22 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.27.0",
21
- "@contrast/config": "1.37.0",
22
- "@contrast/core": "1.42.0",
23
- "@contrast/deadzones": "1.14.0",
24
- "@contrast/dep-hooks": "1.11.0",
25
- "@contrast/esm-hooks": "2.16.0",
20
+ "@contrast/common": "1.29.0",
21
+ "@contrast/config": "1.39.0",
22
+ "@contrast/core": "1.44.0",
23
+ "@contrast/deadzones": "1.16.0",
24
+ "@contrast/dep-hooks": "1.13.0",
25
+ "@contrast/esm-hooks": "2.18.0",
26
26
  "@contrast/find-package-json": "^1.1.0",
27
- "@contrast/instrumentation": "1.21.0",
28
- "@contrast/logger": "1.15.0",
29
- "@contrast/metrics": "1.19.0",
30
- "@contrast/patcher": "1.14.0",
31
- "@contrast/perf": "1.2.2",
32
- "@contrast/reporter": "1.38.0",
33
- "@contrast/rewriter": "1.18.0",
34
- "@contrast/scopes": "1.12.0",
27
+ "@contrast/instrumentation": "1.23.0",
28
+ "@contrast/logger": "1.17.0",
29
+ "@contrast/metrics": "1.21.0",
30
+ "@contrast/patcher": "1.16.0",
31
+ "@contrast/perf": "1.3.0",
32
+ "@contrast/reporter": "1.40.0",
33
+ "@contrast/rewriter": "1.20.0",
34
+ "@contrast/scopes": "1.14.0",
35
+ "on-finished": "^2.4.1",
35
36
  "semver": "^7.6.0"
36
37
  }
37
38
  }