@contrast/assess 1.10.0 → 1.12.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.
Files changed (119) hide show
  1. package/lib/dataflow/index.js +1 -2
  2. package/lib/dataflow/propagation/common.js +1 -1
  3. package/lib/dataflow/propagation/index.js +2 -1
  4. package/lib/dataflow/propagation/install/JSON/index.js +1 -1
  5. package/lib/dataflow/propagation/install/JSON/parse-fn.js +1 -1
  6. package/lib/dataflow/propagation/install/JSON/parse.js +3 -5
  7. package/lib/dataflow/propagation/install/JSON/stringify.js +3 -2
  8. package/lib/dataflow/propagation/install/array-prototype-join.js +3 -2
  9. package/lib/dataflow/propagation/install/buffer.js +3 -5
  10. package/lib/dataflow/propagation/install/contrast-methods/add.js +3 -2
  11. package/lib/dataflow/propagation/install/contrast-methods/index.js +1 -1
  12. package/lib/dataflow/propagation/install/contrast-methods/number.js +1 -1
  13. package/lib/dataflow/propagation/install/contrast-methods/string.js +3 -5
  14. package/lib/dataflow/propagation/install/contrast-methods/tag.js +3 -5
  15. package/lib/dataflow/propagation/install/decode-uri-component.js +3 -2
  16. package/lib/dataflow/propagation/install/ejs/escape-xml.js +3 -2
  17. package/lib/dataflow/propagation/install/ejs/index.js +1 -1
  18. package/lib/dataflow/propagation/install/encode-uri-component.js +3 -2
  19. package/lib/dataflow/propagation/install/escape-html.js +3 -2
  20. package/lib/dataflow/propagation/install/escape.js +3 -2
  21. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +3 -2
  22. package/lib/dataflow/propagation/install/isnumeric-0.js +1 -1
  23. package/lib/dataflow/propagation/install/mongoose/common.js +20 -0
  24. package/lib/dataflow/propagation/install/mongoose/index.js +5 -9
  25. package/lib/dataflow/propagation/install/mongoose/schema-map.js +149 -0
  26. package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +162 -0
  27. package/lib/dataflow/propagation/install/mongoose/schema-string.js +91 -39
  28. package/lib/dataflow/propagation/install/mysql-connection-escape.js +3 -2
  29. package/lib/dataflow/propagation/install/parse-int.js +1 -1
  30. package/lib/dataflow/propagation/install/path/basename.js +3 -5
  31. package/lib/dataflow/propagation/install/path/common.js +1 -1
  32. package/lib/dataflow/propagation/install/path/index.js +1 -1
  33. package/lib/dataflow/propagation/install/path/join-and-resolve.js +3 -5
  34. package/lib/dataflow/propagation/install/path/normalize.js +3 -5
  35. package/lib/dataflow/propagation/install/pug/index.js +1 -1
  36. package/lib/dataflow/propagation/install/pug-runtime-escape.js +3 -2
  37. package/lib/dataflow/propagation/install/querystring/index.js +1 -1
  38. package/lib/dataflow/propagation/install/querystring/parse.js +3 -2
  39. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +180 -0
  40. package/lib/dataflow/propagation/install/sequelize.js +3 -5
  41. package/lib/dataflow/propagation/install/sql-template-strings.js +3 -2
  42. package/lib/dataflow/propagation/install/string/concat.js +3 -2
  43. package/lib/dataflow/propagation/install/string/format-methods.js +3 -2
  44. package/lib/dataflow/propagation/install/string/html-methods.js +3 -2
  45. package/lib/dataflow/propagation/install/string/index.js +66 -1
  46. package/lib/dataflow/propagation/install/string/match-all.js +236 -0
  47. package/lib/dataflow/propagation/install/string/match.js +83 -37
  48. package/lib/dataflow/propagation/install/string/replace.js +4 -3
  49. package/lib/dataflow/propagation/install/string/slice.js +3 -2
  50. package/lib/dataflow/propagation/install/string/split.js +3 -2
  51. package/lib/dataflow/propagation/install/string/substring.js +3 -2
  52. package/lib/dataflow/propagation/install/string/trim.js +3 -2
  53. package/lib/dataflow/propagation/install/unescape.js +3 -2
  54. package/lib/dataflow/propagation/install/url/domain-parsers.js +3 -2
  55. package/lib/dataflow/propagation/install/url/index.js +3 -1
  56. package/lib/dataflow/propagation/install/url/parse.js +132 -0
  57. package/lib/dataflow/propagation/install/url/searchParams.js +140 -0
  58. package/lib/dataflow/propagation/install/url/url.js +11 -53
  59. package/lib/dataflow/propagation/install/validator/hooks.js +3 -2
  60. package/lib/dataflow/propagation/install/validator/index.js +1 -1
  61. package/lib/dataflow/propagation/install/validator/methods.js +1 -1
  62. package/lib/dataflow/sinks/common.js +1 -1
  63. package/lib/dataflow/sinks/index.js +1 -1
  64. package/lib/dataflow/sinks/install/child-process.js +2 -2
  65. package/lib/dataflow/sinks/install/eval.js +2 -2
  66. package/lib/dataflow/sinks/install/express/index.js +1 -1
  67. package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +3 -3
  68. package/lib/dataflow/sinks/install/fastify/index.js +1 -1
  69. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +2 -2
  70. package/lib/dataflow/sinks/install/fs.js +2 -2
  71. package/lib/dataflow/sinks/install/function.js +2 -2
  72. package/lib/dataflow/sinks/install/http/index.js +1 -1
  73. package/lib/dataflow/sinks/install/http/request.js +2 -2
  74. package/lib/dataflow/sinks/install/http/server-response.js +2 -2
  75. package/lib/dataflow/sinks/install/koa/index.js +1 -1
  76. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +2 -2
  77. package/lib/dataflow/sinks/install/marsdb.js +2 -2
  78. package/lib/dataflow/sinks/install/mongodb.js +33 -26
  79. package/lib/dataflow/sinks/install/mssql.js +2 -2
  80. package/lib/dataflow/sinks/install/mysql.js +3 -3
  81. package/lib/dataflow/sinks/install/postgres.js +2 -2
  82. package/lib/dataflow/sinks/install/sequelize.js +2 -2
  83. package/lib/dataflow/sinks/install/sqlite3.js +2 -2
  84. package/lib/dataflow/sinks/install/vm.js +2 -2
  85. package/lib/dataflow/sources/common.js +1 -1
  86. package/lib/dataflow/sources/handler.js +3 -3
  87. package/lib/dataflow/sources/index.js +1 -1
  88. package/lib/dataflow/sources/install/body-parser1.js +1 -1
  89. package/lib/dataflow/sources/install/busboy1.js +1 -1
  90. package/lib/dataflow/sources/install/cookie-parser1.js +1 -1
  91. package/lib/dataflow/sources/install/express/index.js +1 -1
  92. package/lib/dataflow/sources/install/express/params.js +1 -1
  93. package/lib/dataflow/sources/install/express/parsedUrl.js +1 -1
  94. package/lib/dataflow/sources/install/fastify/fastify.js +1 -1
  95. package/lib/dataflow/sources/install/fastify/index.js +1 -1
  96. package/lib/dataflow/sources/install/formidable1.js +1 -1
  97. package/lib/dataflow/sources/install/http.js +2 -2
  98. package/lib/dataflow/sources/install/koa/index.js +1 -1
  99. package/lib/dataflow/sources/install/koa/koa-bodyparsers.js +1 -1
  100. package/lib/dataflow/sources/install/koa/koa-routers.js +1 -1
  101. package/lib/dataflow/sources/install/koa/koa2.js +1 -1
  102. package/lib/dataflow/sources/install/qs6.js +1 -1
  103. package/lib/dataflow/sources/install/querystring.js +1 -1
  104. package/lib/dataflow/tag-utils.js +1 -1
  105. package/lib/dataflow/tracker.js +2 -6
  106. package/lib/dataflow/utils/is-safe-content-type.js +1 -1
  107. package/lib/dataflow/utils/is-vulnerable.js +1 -1
  108. package/lib/{dataflow/event-factory.js → event-factory.js} +58 -2
  109. package/lib/index.js +4 -2
  110. package/lib/response-scanning/handlers/index.js +36 -30
  111. package/lib/response-scanning/handlers/utils.js +1 -1
  112. package/lib/response-scanning/index.js +1 -1
  113. package/lib/response-scanning/install/http.js +3 -3
  114. package/lib/session-configuration/common.js +19 -0
  115. package/lib/session-configuration/handlers.js +86 -0
  116. package/lib/session-configuration/index.js +6 -9
  117. package/lib/session-configuration/install/express-session.js +131 -0
  118. package/package.json +3 -3
  119. package/lib/session-configuration/install/http.js +0 -79
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -40,6 +40,7 @@ module.exports = function(core) {
40
40
  patcher,
41
41
  scopes: { sources },
42
42
  assess: {
43
+ eventFactory: { createSinkEvent },
43
44
  dataflow: {
44
45
  tracker,
45
46
  sinks: {
@@ -48,7 +49,6 @@ module.exports = function(core) {
48
49
  reportSafePositive,
49
50
  isSafeContentType
50
51
  },
51
- eventFactory: { createSinkEvent },
52
52
  },
53
53
  },
54
54
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -39,10 +39,10 @@ module.exports = function(core) {
39
39
  config,
40
40
  scopes: { sources },
41
41
  assess: {
42
+ eventFactory: { createSinkEvent },
42
43
  dataflow: {
43
44
  tracker,
44
45
  sinks: { isVulnerable, reportFindings, reportSafePositive },
45
- eventFactory: { createSinkEvent },
46
46
  },
47
47
  },
48
48
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -43,10 +43,10 @@ module.exports = function(core) {
43
43
  patcher,
44
44
  scopes: { sources, instrumentation },
45
45
  assess: {
46
+ eventFactory: { createSinkEvent },
46
47
  dataflow: {
47
48
  tracker,
48
49
  sinks: { isVulnerable, reportFindings },
49
- eventFactory: { createSinkEvent },
50
50
  },
51
51
  },
52
52
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -74,10 +74,10 @@ module.exports = function(core) {
74
74
  patcher,
75
75
  scopes: { sources, instrumentation },
76
76
  assess: {
77
+ eventFactory: { createSinkEvent },
77
78
  dataflow: {
78
79
  tracker,
79
- sinks: { isVulnerable, runInActiveSink, isLocked, reportFindings, reportSafePositive },
80
- eventFactory: { createSinkEvent }
80
+ sinks: { isVulnerable, runInActiveSink, isLocked, reportFindings, reportSafePositive }
81
81
  }
82
82
  }
83
83
  } = core;
@@ -85,16 +85,16 @@ module.exports = function(core) {
85
85
  const instr = core.assess.dataflow.sinks.mongodb = {};
86
86
 
87
87
  instr.getQueryVulnerabilityInfo = function getQueryVulnerabilityInfo(query) {
88
+ const reportSafe = [];
88
89
  let vulnInfo = null;
89
- let reportSafe = null;
90
90
 
91
91
  if (isString(query)) {
92
92
  const strInfo = tracker.getData(query);
93
93
  if (strInfo) {
94
94
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
95
95
  vulnInfo = { strInfo };
96
- } else {
97
- reportSafe = { strInfo };
96
+ } else if (config.assess.safe_positives.enable) {
97
+ reportSafe.push({ strInfo });
98
98
  }
99
99
  }
100
100
 
@@ -109,8 +109,8 @@ module.exports = function(core) {
109
109
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
110
110
  vulnInfo = { path: [...path], strInfo };
111
111
  return true; // halts traversal
112
- } else {
113
- reportSafe = { path: [...path], strInfo };
112
+ } else if (config.assess.safe_positives.enable) {
113
+ reportSafe.push({ path: [...path], strInfo });
114
114
  }
115
115
  }
116
116
  });
@@ -119,8 +119,8 @@ module.exports = function(core) {
119
119
  };
120
120
 
121
121
  instr.getAggregateVulnerabilityInfo = function getAggregateVulnerabilityInfo(aggregation) {
122
+ const reportSafe = [];
122
123
  let vulnInfo = null;
123
- let reportSafe = null;
124
124
 
125
125
  if (!isNonEmptyObject(aggregation)) return { vulnInfo, reportSafe };
126
126
 
@@ -141,8 +141,8 @@ module.exports = function(core) {
141
141
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
142
142
  vulnInfo = { path: [...path], strInfo };
143
143
  return true; // halts traversal
144
- } else {
145
- reportSafe = { path: [...path], strInfo };
144
+ } else if (config.assess.safe_positives.enable) {
145
+ reportSafe.push({ path: [...path], strInfo });
146
146
  }
147
147
  }
148
148
  }
@@ -152,16 +152,16 @@ module.exports = function(core) {
152
152
  };
153
153
 
154
154
  instr.getMapReduceVulnerabilityInfo = function getMapReduceVulnerabilityInfo(argToCheck, argIdx) {
155
+ const reportSafe = [];
155
156
  let vulnInfo = null;
156
- let reportSafe = null;
157
157
 
158
158
  if (argIdx !== 2 && isString(argToCheck)) {
159
159
  const strInfo = tracker.getData(argToCheck);
160
160
  if (strInfo) {
161
161
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
162
162
  vulnInfo = { strInfo };
163
- } else {
164
- reportSafe = { strInfo };
163
+ } else if (config.assess.safe_positives.enable) {
164
+ reportSafe.push({ strInfo });
165
165
  }
166
166
  }
167
167
 
@@ -181,8 +181,8 @@ module.exports = function(core) {
181
181
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
182
182
  vulnInfo = { path: [...path], strInfo };
183
183
  return true; // halts traversal
184
- } else {
185
- reportSafe = { path: [...path], strInfo };
184
+ } else if (config.assess.safe_positives.enable) {
185
+ reportSafe.push({ path: [...path], strInfo });
186
186
  }
187
187
  }
188
188
  }
@@ -192,16 +192,16 @@ module.exports = function(core) {
192
192
  };
193
193
 
194
194
  instr.getGroupVulnerabilityInfo = function getGroupVulnerabilityInfo(argToCheck, argIdx) {
195
+ const reportSafe = [];
195
196
  let vulnInfo = null;
196
- let reportSafe = null;
197
197
 
198
198
  if (argIdx !== 1 && isString(argToCheck)) {
199
199
  const strInfo = tracker.getData(argToCheck);
200
200
  if (strInfo) {
201
201
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
202
202
  vulnInfo = { strInfo };
203
- } else {
204
- reportSafe = { strInfo };
203
+ } else if (config.assess.safe_positives.enable) {
204
+ reportSafe.push({ strInfo });
205
205
  }
206
206
  }
207
207
 
@@ -216,8 +216,8 @@ module.exports = function(core) {
216
216
  if (isVulnerable(UNTRUSTED, querySafeTags, strInfo.tags)) {
217
217
  vulnInfo = { path: [...path], strInfo };
218
218
  return true; // halts traversal
219
- } else {
220
- reportSafe = { path: [...path], strInfo };
219
+ } else if (config.assess.safe_positives.enable) {
220
+ reportSafe.push({ path: [...path], strInfo });
221
221
  }
222
222
  }
223
223
  });
@@ -248,12 +248,19 @@ module.exports = function(core) {
248
248
  vulnArgIdx = argIdx;
249
249
  break;
250
250
  }
251
- if (reportSafe) safeReports.push({ ...reportSafe, argIdx });
251
+
252
+ if (config.assess.safe_positives.enable && reportSafe.length) {
253
+ reportSafe.forEach(el => safeReports.push({ ...el, argIdx }));
254
+ }
252
255
  }
253
256
 
254
257
  if (!vulnInfo) {
255
258
  if (safeReports.length && config.assess.safe_positives.enable) {
256
- const safeTags = safeReports.map((report) => filterSafeTags(querySafeTags, report.strInfo));
259
+ const safeTags = safeReports
260
+ .map((report) => filterSafeTags(querySafeTags, report.strInfo))
261
+ .flat()
262
+ .filter((value, index, self) => index === self.indexOf(value));
263
+
257
264
  const strInfo = safeReports.map((report) => {
258
265
  const tags = report.path ? utils.createAdjustedQueryTags(report.path, report.strInfo.tags, report.strInfo.value, inspect(origArgs[report.argIdx], { depth: 4 })) : report.strInfo?.tags;
259
266
 
@@ -266,7 +273,7 @@ module.exports = function(core) {
266
273
  reportSafePositive({
267
274
  name,
268
275
  ruleId: NOSQL_INJECTION_MONGO,
269
- safeTags: safeTags.length === 1 ? safeTags[0] : safeTags,
276
+ safeTags,
270
277
  strInfo: strInfo.length === 1 ? strInfo[0] : strInfo
271
278
  });
272
279
  }
@@ -323,8 +330,6 @@ module.exports = function(core) {
323
330
  });
324
331
  };
325
332
 
326
- return instr;
327
-
328
333
  function patchCollection(mongodb, version) {
329
334
  for (const method of collectionMethods) {
330
335
  const proto = mongodb.Collection.prototype;
@@ -400,4 +405,6 @@ module.exports = function(core) {
400
405
 
401
406
  return name;
402
407
  }
408
+
409
+ return instr;
403
410
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -39,10 +39,10 @@ module.exports = function(core) {
39
39
  config,
40
40
  scopes: { sources },
41
41
  assess: {
42
+ eventFactory: { createSinkEvent },
42
43
  dataflow: {
43
44
  tracker,
44
45
  sinks: { isVulnerable, isLocked, reportFindings, reportSafePositive },
45
- eventFactory: { createSinkEvent },
46
46
  },
47
47
  },
48
48
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -46,10 +46,10 @@ module.exports = function(core) {
46
46
  patcher,
47
47
  scopes: { sources },
48
48
  assess: {
49
+ eventFactory: { createSinkEvent },
49
50
  dataflow: {
50
51
  tracker,
51
- sinks: { isVulnerable, isLocked, reportFindings },
52
- eventFactory: { createSinkEvent },
52
+ sinks: { isVulnerable, isLocked, reportFindings }
53
53
  },
54
54
  },
55
55
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -30,10 +30,10 @@ module.exports = function(core) {
30
30
  patcher,
31
31
  scopes: { sources },
32
32
  assess: {
33
+ eventFactory: { createSinkEvent },
33
34
  dataflow: {
34
35
  tracker,
35
36
  sinks: { isVulnerable, isLocked, reportFindings, reportSafePositive },
36
- eventFactory: { createSinkEvent },
37
37
  },
38
38
  },
39
39
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -35,10 +35,10 @@ module.exports = function(core) {
35
35
  config,
36
36
  scopes: { sources },
37
37
  assess: {
38
+ eventFactory: { createSinkEvent },
38
39
  dataflow: {
39
40
  tracker,
40
41
  sinks: { isVulnerable, runInActiveSink, reportFindings, reportSafePositive },
41
- eventFactory: { createSinkEvent },
42
42
  },
43
43
  },
44
44
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -35,10 +35,10 @@ module.exports = function(core) {
35
35
  patcher,
36
36
  scopes: { sources },
37
37
  assess: {
38
+ eventFactory: { createSinkEvent },
38
39
  dataflow: {
39
40
  tracker,
40
41
  sinks: { isVulnerable, isLocked, reportFindings },
41
- eventFactory: { createSinkEvent },
42
42
  },
43
43
  },
44
44
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -48,6 +48,7 @@ module.exports = function(core) {
48
48
  patcher,
49
49
  scopes: { sources, instrumentation },
50
50
  assess: {
51
+ eventFactory: { createSinkEvent },
51
52
  dataflow: {
52
53
  tracker,
53
54
  sinks: {
@@ -57,7 +58,6 @@ module.exports = function(core) {
57
58
  reportFindings,
58
59
  reportSafePositive,
59
60
  },
60
- eventFactory: { createSinkEvent },
61
61
  },
62
62
  },
63
63
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -25,10 +25,10 @@ const {
25
25
  module.exports = function(core) {
26
26
  const {
27
27
  assess: {
28
+ eventFactory,
28
29
  dataflow: {
29
30
  sources,
30
- tracker,
31
- eventFactory
31
+ tracker
32
32
  }
33
33
  },
34
34
  config,
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -80,7 +80,7 @@ module.exports = function(core) {
80
80
  pre(data) {
81
81
  const [name = '', value] = data.args;
82
82
  if (toLowerCase(name) === 'content-type' && value) {
83
- scopes.sources.getStore().assess.responseData.contentType = value;
83
+ store.assess.responseData.contentType = value;
84
84
  }
85
85
  }
86
86
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -21,11 +21,7 @@ const { isString } = require('@contrast/common');
21
21
  module.exports = function tracker(core) {
22
22
  const {
23
23
  assess: {
24
- dataflow: {
25
- eventFactory: {
26
- createdEvents
27
- }
28
- }
24
+ eventFactory: { createdEvents },
29
25
  },
30
26
  logger
31
27
  } = core;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2022 Contrast Security, Inc
2
+ * Copyright: 2023 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -26,7 +26,7 @@ module.exports = function(core) {
26
26
  scopes: { sources },
27
27
  } = core;
28
28
 
29
- const eventFactory = core.assess.dataflow.eventFactory = {};
29
+ const eventFactory = core.assess.eventFactory = {};
30
30
 
31
31
  eventFactory.createdEvents = new WeakSet();
32
32
 
@@ -214,5 +214,61 @@ module.exports = function(core) {
214
214
  return event;
215
215
  };
216
216
 
217
+ eventFactory.createSessionEvent = function(data) {
218
+ const {
219
+ context,
220
+ name = '',
221
+ moduleName,
222
+ methodName,
223
+ object = { value: null, tracked: false },
224
+ args = [],
225
+ result = { value: null, tracked: false },
226
+ source,
227
+ stacktraceOpts,
228
+ framework,
229
+ options
230
+ } = data;
231
+
232
+ if (!name) {
233
+ logger.debug({ data }, 'no sink event name');
234
+ return null;
235
+ }
236
+
237
+ if (
238
+ (!source || !source.match(annotationRegExp))
239
+ ) {
240
+ logger.debug({ data }, 'malformed or missing sink event source field');
241
+ return null;
242
+ }
243
+
244
+ let stack;
245
+ if (config.assess.stacktraces !== 'NONE') {
246
+ stack = createSnapshot(stacktraceOpts)();
247
+ } else {
248
+ stack = [];
249
+ }
250
+
251
+ const event = {
252
+ args,
253
+ context,
254
+ history: [],
255
+ name,
256
+ moduleName,
257
+ methodName,
258
+ object,
259
+ result,
260
+ source,
261
+ stack,
262
+ tags: {},
263
+ time: Date.now(),
264
+ framework,
265
+ options,
266
+ };
267
+
268
+ eventFactory.createdEvents.add(event);
269
+
270
+ return event;
271
+ };
272
+
217
273
  return eventFactory;
218
274
  };