@contrast/assess 1.42.0 → 1.44.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.
@@ -24,7 +24,7 @@ const {
24
24
  UNTRUSTED,
25
25
  },
26
26
  Rule: { SQL_INJECTION: ruleId },
27
- isString
27
+ isString,
28
28
  } = require('@contrast/common');
29
29
  const { createModuleLabel } = require('../../propagation/common');
30
30
  const { patchType, filterSafeTags } = require('../common');
@@ -44,7 +44,7 @@ const safeTags = [
44
44
  * }} core
45
45
  * @returns {import('@contrast/common').Installable}
46
46
  */
47
- module.exports = function(core) {
47
+ module.exports = function (core) {
48
48
  const {
49
49
  depHooks,
50
50
  patcher,
@@ -74,8 +74,8 @@ module.exports = function(core) {
74
74
  const event = createSinkEvent({
75
75
  name,
76
76
  moduleName: 'mssql',
77
- methodName: `PreparedStatement.prototype.${method}`,
78
- context: `mssql.PreparedStatement.${method}('${strInfo.value}')`,
77
+ methodName: `${obj}.prototype.${method}`,
78
+ context: `mssql.${obj}.${method}('${strInfo.value}')`,
79
79
  history: [strInfo],
80
80
  object: {
81
81
  value: `[${createModuleLabel('mssql', version)}].${obj}`,
@@ -91,7 +91,7 @@ module.exports = function(core) {
91
91
  source: 'P0',
92
92
  stacktraceOpts: {
93
93
  contructorOpt: data.hooked,
94
- prependFrames: [data.orig]
94
+ prependFrames: [data.orig],
95
95
  },
96
96
  });
97
97
 
@@ -109,7 +109,7 @@ module.exports = function(core) {
109
109
  strInfo: {
110
110
  tags: strInfo.tags,
111
111
  value: strInfo.value,
112
- }
112
+ },
113
113
  });
114
114
  }
115
115
  };
@@ -117,7 +117,7 @@ module.exports = function(core) {
117
117
  core.assess.dataflow.sinks.mssql = {
118
118
  install() {
119
119
  depHooks.resolve(
120
- { name: 'mssql', version: '<12', file: 'lib/base/prepared-statement.js' },
120
+ { name: 'mssql', version: '>7 <12', file: 'lib/base/prepared-statement.js' },
121
121
  (PreparedStatement, version) => {
122
122
  patcher.patch(PreparedStatement.prototype, 'prepare', {
123
123
  name: 'PreparedStatement.prototype.prepare',
@@ -133,7 +133,7 @@ module.exports = function(core) {
133
133
  );
134
134
 
135
135
  depHooks.resolve(
136
- { name: 'mssql', version: '<12', file: 'lib/base/request.js' },
136
+ { name: 'mssql', version: '>7 <12', file: 'lib/base/request.js' },
137
137
  (Request, version) => {
138
138
  patcher.patch(Request.prototype, 'batch', {
139
139
  name: 'Request.prototype.batch',
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {
4
- DataflowTag: { UNTRUSTED, SQL_ENCODED }
4
+ DataflowTag: { UNTRUSTED, SQL_ENCODED },
5
5
  } = require('@contrast/common');
6
6
  const { expect } = require('chai');
7
7
  const sinon = require('sinon');
@@ -11,12 +11,12 @@ describe('assess dataflow sinks mssql', function () {
11
11
  let core, simulateRequestScope, trackString, tracker, reportFindings, reportSafePositive;
12
12
 
13
13
  class PreparedStatement {
14
- prepare() { }
14
+ prepare() {}
15
15
  }
16
16
 
17
17
  class Request {
18
- batch() { }
19
- query() { }
18
+ batch() {}
19
+ query() {}
20
20
  }
21
21
 
22
22
  beforeEach(function () {
@@ -93,8 +93,8 @@ describe('assess dataflow sinks mssql', function () {
93
93
  sinkEvent: {
94
94
  name,
95
95
  moduleName: 'mssql',
96
- methodName: `PreparedStatement.prototype.${method}`,
97
- context: `mssql.PreparedStatement.${method}('${value}')`,
96
+ methodName: `${subject.name}.prototype.${method}`,
97
+ context: `mssql.${subject.name}.${method}('${value}')`,
98
98
  object: {
99
99
  value: sinon.match(subject.name),
100
100
  tracked: false,
@@ -121,13 +121,11 @@ describe('assess dataflow sinks mssql', function () {
121
121
  expect(reportSafePositive).to.have.been.calledWithMatch({
122
122
  name,
123
123
  ruleId: 'sql-injection',
124
- safeTags: [
125
- SQL_ENCODED,
126
- ],
124
+ safeTags: [SQL_ENCODED],
127
125
  strInfo: {
128
126
  tags: strInfo.tags,
129
127
  value: strInfo.value,
130
- }
128
+ },
131
129
  });
132
130
  });
133
131
  });
@@ -80,7 +80,7 @@ function initMockCore() {
80
80
  assess: {},
81
81
  // mocks
82
82
  messages: new EventEmitter(),
83
- logger: mocks.logger(),
83
+ logger: mocks.logger()
84
84
  };
85
85
  // use actual config so we can get dynamic effective values with TS message
86
86
  // updates (mock doesn't). we can also test new effective config mappings.
@@ -236,7 +236,7 @@ function initMockCore() {
236
236
  assess: {},
237
237
  // mocks
238
238
  messages: new EventEmitter(),
239
- logger: mocks.logger(),
239
+ logger: mocks.logger()
240
240
  };
241
241
  // use actual config so we can get dynamic effective values with TS message
242
242
  // updates (mock doesn't). we can also test new effective config mappings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/assess",
3
- "version": "1.42.0",
3
+ "version": "1.44.0",
4
4
  "description": "Contrast service providing framework-agnostic Assess support",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,17 +17,17 @@
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/dep-hooks": "1.11.0",
20
+ "@contrast/common": "1.29.0",
21
+ "@contrast/config": "1.39.0",
22
+ "@contrast/core": "1.44.0",
23
+ "@contrast/dep-hooks": "1.13.0",
24
24
  "@contrast/distringuish": "^5.1.0",
25
- "@contrast/instrumentation": "1.21.0",
26
- "@contrast/logger": "1.15.0",
27
- "@contrast/patcher": "1.14.0",
28
- "@contrast/rewriter": "1.18.0",
29
- "@contrast/route-coverage": "1.32.0",
30
- "@contrast/scopes": "1.12.0",
25
+ "@contrast/instrumentation": "1.23.0",
26
+ "@contrast/logger": "1.17.0",
27
+ "@contrast/patcher": "1.16.0",
28
+ "@contrast/rewriter": "1.20.0",
29
+ "@contrast/route-coverage": "1.34.0",
30
+ "@contrast/scopes": "1.14.0",
31
31
  "semver": "^7.6.0"
32
32
  }
33
33
  }