@contrast/assess 1.19.0 → 1.20.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 (160) hide show
  1. package/LICENSE +1 -1
  2. package/lib/constants.js +1 -1
  3. package/lib/crypto-analysis/common.js +1 -1
  4. package/lib/crypto-analysis/index.js +1 -1
  5. package/lib/crypto-analysis/install/crypto.js +8 -3
  6. package/lib/crypto-analysis/install/math.js +8 -3
  7. package/lib/dataflow/index.js +1 -1
  8. package/lib/dataflow/propagation/common.js +1 -1
  9. package/lib/dataflow/propagation/index.js +1 -1
  10. package/lib/dataflow/propagation/install/JSON/index.js +1 -1
  11. package/lib/dataflow/propagation/install/JSON/parse-fn.js +1 -1
  12. package/lib/dataflow/propagation/install/JSON/parse.js +3 -3
  13. package/lib/dataflow/propagation/install/JSON/stringify.js +1 -1
  14. package/lib/dataflow/propagation/install/array-prototype-join.js +1 -1
  15. package/lib/dataflow/propagation/install/buffer.js +1 -1
  16. package/lib/dataflow/propagation/install/contrast-methods/add.js +1 -1
  17. package/lib/dataflow/propagation/install/contrast-methods/index.js +1 -1
  18. package/lib/dataflow/propagation/install/contrast-methods/number.js +4 -3
  19. package/lib/dataflow/propagation/install/contrast-methods/string.js +1 -1
  20. package/lib/dataflow/propagation/install/contrast-methods/tag.js +1 -1
  21. package/lib/dataflow/propagation/install/decode-uri-component.js +1 -1
  22. package/lib/dataflow/propagation/install/ejs/escape-xml.js +1 -1
  23. package/lib/dataflow/propagation/install/ejs/index.js +1 -1
  24. package/lib/dataflow/propagation/install/ejs/template.js +7 -5
  25. package/lib/dataflow/propagation/install/encode-uri.js +1 -1
  26. package/lib/dataflow/propagation/install/escape-html.js +1 -1
  27. package/lib/dataflow/propagation/install/escape.js +1 -1
  28. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +1 -1
  29. package/lib/dataflow/propagation/install/isnumeric-0.js +3 -3
  30. package/lib/dataflow/propagation/install/joi/any.js +1 -1
  31. package/lib/dataflow/propagation/install/joi/boolean.js +1 -1
  32. package/lib/dataflow/propagation/install/joi/expression.js +1 -1
  33. package/lib/dataflow/propagation/install/joi/index.js +1 -1
  34. package/lib/dataflow/propagation/install/joi/keys.js +1 -1
  35. package/lib/dataflow/propagation/install/joi/number.js +1 -1
  36. package/lib/dataflow/propagation/install/joi/object.js +1 -1
  37. package/lib/dataflow/propagation/install/joi/string-schema.js +1 -1
  38. package/lib/dataflow/propagation/install/joi/utils.js +1 -1
  39. package/lib/dataflow/propagation/install/joi/values.js +1 -1
  40. package/lib/dataflow/propagation/install/mongoose/common.js +1 -1
  41. package/lib/dataflow/propagation/install/mongoose/index.js +1 -1
  42. package/lib/dataflow/propagation/install/mongoose/schema-map.js +1 -1
  43. package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +1 -1
  44. package/lib/dataflow/propagation/install/mongoose/schema-string.js +1 -1
  45. package/lib/dataflow/propagation/install/mustache-escape.js +1 -1
  46. package/lib/dataflow/propagation/install/mysql-connection-escape.js +1 -1
  47. package/lib/dataflow/propagation/install/parse-int.js +3 -3
  48. package/lib/dataflow/propagation/install/path/basename.js +1 -1
  49. package/lib/dataflow/propagation/install/path/common.js +1 -1
  50. package/lib/dataflow/propagation/install/path/dirname.js +1 -1
  51. package/lib/dataflow/propagation/install/path/extname.js +1 -1
  52. package/lib/dataflow/propagation/install/path/format.js +1 -1
  53. package/lib/dataflow/propagation/install/path/index.js +1 -1
  54. package/lib/dataflow/propagation/install/path/join-and-resolve.js +1 -1
  55. package/lib/dataflow/propagation/install/path/normalize.js +1 -1
  56. package/lib/dataflow/propagation/install/path/parse.js +1 -1
  57. package/lib/dataflow/propagation/install/path/relative.js +1 -1
  58. package/lib/dataflow/propagation/install/path/toNamespacedPath.js +1 -1
  59. package/lib/dataflow/propagation/install/pug/index.js +3 -3
  60. package/lib/dataflow/propagation/install/pug-runtime-escape.js +1 -1
  61. package/lib/dataflow/propagation/install/querystring/escape.js +1 -1
  62. package/lib/dataflow/propagation/install/querystring/index.js +1 -1
  63. package/lib/dataflow/propagation/install/querystring/parse.js +1 -1
  64. package/lib/dataflow/propagation/install/querystring/stringify.js +1 -1
  65. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +1 -1
  66. package/lib/dataflow/propagation/install/send.js +1 -1
  67. package/lib/dataflow/propagation/install/sequelize/index.js +1 -1
  68. package/lib/dataflow/propagation/install/sequelize/query-generator.js +1 -1
  69. package/lib/dataflow/propagation/install/sequelize/sql-string.js +1 -1
  70. package/lib/dataflow/propagation/install/sql-template-strings.js +1 -1
  71. package/lib/dataflow/propagation/install/string/concat.js +1 -1
  72. package/lib/dataflow/propagation/install/string/format-methods.js +1 -1
  73. package/lib/dataflow/propagation/install/string/html-methods.js +1 -1
  74. package/lib/dataflow/propagation/install/string/index.js +1 -1
  75. package/lib/dataflow/propagation/install/string/match-all.js +1 -1
  76. package/lib/dataflow/propagation/install/string/match.js +1 -1
  77. package/lib/dataflow/propagation/install/string/replace.js +1 -1
  78. package/lib/dataflow/propagation/install/string/slice.js +1 -1
  79. package/lib/dataflow/propagation/install/string/split.js +1 -1
  80. package/lib/dataflow/propagation/install/string/substring.js +1 -1
  81. package/lib/dataflow/propagation/install/string/trim.js +1 -1
  82. package/lib/dataflow/propagation/install/unescape.js +1 -1
  83. package/lib/dataflow/propagation/install/url/domain-parsers.js +1 -1
  84. package/lib/dataflow/propagation/install/url/index.js +1 -1
  85. package/lib/dataflow/propagation/install/url/parse.js +1 -1
  86. package/lib/dataflow/propagation/install/url/searchParams.js +1 -1
  87. package/lib/dataflow/propagation/install/url/url.js +1 -1
  88. package/lib/dataflow/propagation/install/util-format.js +1 -1
  89. package/lib/dataflow/propagation/install/validator/hooks.js +1 -1
  90. package/lib/dataflow/propagation/install/validator/index.js +1 -1
  91. package/lib/dataflow/propagation/install/validator/methods.js +1 -1
  92. package/lib/dataflow/sinks/common.js +1 -1
  93. package/lib/dataflow/sinks/index.js +1 -1
  94. package/lib/dataflow/sinks/install/child-process.js +1 -1
  95. package/lib/dataflow/sinks/install/eval.js +1 -1
  96. package/lib/dataflow/sinks/install/express/index.js +1 -1
  97. package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +1 -1
  98. package/lib/dataflow/sinks/install/fastify/index.js +1 -1
  99. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -1
  100. package/lib/dataflow/sinks/install/fs.js +1 -1
  101. package/lib/dataflow/sinks/install/function.js +1 -1
  102. package/lib/dataflow/sinks/install/http/index.js +1 -1
  103. package/lib/dataflow/sinks/install/http/request.js +1 -1
  104. package/lib/dataflow/sinks/install/http/server-response.js +1 -1
  105. package/lib/dataflow/sinks/install/koa/index.js +1 -1
  106. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +1 -1
  107. package/lib/dataflow/sinks/install/libxmljs.js +1 -1
  108. package/lib/dataflow/sinks/install/marsdb.js +4 -4
  109. package/lib/dataflow/sinks/install/mongodb.js +7 -7
  110. package/lib/dataflow/sinks/install/mssql.js +1 -1
  111. package/lib/dataflow/sinks/install/mysql.js +1 -1
  112. package/lib/dataflow/sinks/install/node-serialize.js +1 -1
  113. package/lib/dataflow/sinks/install/postgres.js +1 -1
  114. package/lib/dataflow/sinks/install/sequelize.js +7 -8
  115. package/lib/dataflow/sinks/install/sqlite3.js +1 -1
  116. package/lib/dataflow/sinks/install/vm.js +1 -1
  117. package/lib/dataflow/sources/common.js +1 -1
  118. package/lib/dataflow/sources/handler.js +11 -10
  119. package/lib/dataflow/sources/index.js +2 -2
  120. package/lib/dataflow/sources/install/body-parser1.js +11 -13
  121. package/lib/dataflow/sources/install/{busboy1.js → busboy.js} +15 -15
  122. package/lib/dataflow/sources/install/cookie-parser1.js +7 -6
  123. package/lib/dataflow/sources/install/express/index.js +1 -1
  124. package/lib/dataflow/sources/install/express/params.js +9 -10
  125. package/lib/dataflow/sources/install/express/parsedUrl.js +1 -1
  126. package/lib/dataflow/sources/install/fastify/fastify.js +6 -7
  127. package/lib/dataflow/sources/install/fastify/index.js +1 -1
  128. package/lib/dataflow/sources/install/formidable1.js +8 -6
  129. package/lib/dataflow/sources/install/http.js +4 -4
  130. package/lib/dataflow/sources/install/koa/index.js +1 -1
  131. package/lib/dataflow/sources/install/koa/koa-bodyparsers.js +10 -9
  132. package/lib/dataflow/sources/install/koa/koa-multer.js +1 -1
  133. package/lib/dataflow/sources/install/koa/koa-routers.js +6 -8
  134. package/lib/dataflow/sources/install/koa/koa2.js +42 -38
  135. package/lib/dataflow/sources/install/multer1.js +1 -1
  136. package/lib/dataflow/sources/install/qs6.js +7 -6
  137. package/lib/dataflow/sources/install/querystring.js +4 -4
  138. package/lib/dataflow/tag-utils.js +1 -1
  139. package/lib/dataflow/tracker.js +1 -1
  140. package/lib/dataflow/utils/is-safe-content-type.js +1 -1
  141. package/lib/dataflow/utils/is-vulnerable.js +1 -1
  142. package/lib/event-factory.js +30 -28
  143. package/lib/get-policy.js +1 -1
  144. package/lib/get-source-context.js +1 -1
  145. package/lib/index.d.ts +16 -2
  146. package/lib/index.js +1 -1
  147. package/lib/make-source-context.js +6 -2
  148. package/lib/response-scanning/handlers/index.js +1 -1
  149. package/lib/response-scanning/handlers/utils.js +1 -1
  150. package/lib/response-scanning/index.js +1 -1
  151. package/lib/response-scanning/install/http.js +1 -1
  152. package/lib/rule-scopes.js +1 -1
  153. package/lib/session-configuration/common.js +1 -1
  154. package/lib/session-configuration/handlers.js +67 -49
  155. package/lib/session-configuration/index.js +3 -1
  156. package/lib/session-configuration/install/express-session.js +15 -24
  157. package/lib/session-configuration/install/fastify-cookie.js +110 -0
  158. package/lib/session-configuration/install/hapi.js +8 -11
  159. package/lib/session-configuration/install/koa.js +101 -0
  160. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -18,6 +18,8 @@
18
18
  const { InputType } = require('@contrast/common');
19
19
  const { patchType } = require('../../common');
20
20
 
21
+ const inputType = InputType.QUERYSTRING;
22
+
21
23
  /**
22
24
  * Function that exports an install method to patch Koa framework with our instrumentation
23
25
  * @param {Object} core - the core Contrast object in v5
@@ -36,58 +38,60 @@ module.exports = (core) => {
36
38
  */
37
39
  function install() {
38
40
  depHooks.resolve({ name: 'koa', version: '>=2.3.0' }, (Koa) => {
39
- function contrastStartMiddleware(ctx, next) {
40
- const name = 'Koa.Application';
41
- const sourceContext = core.scopes.sources.getStore()?.assess;
42
- const inputType = InputType.QUERYSTRING;
41
+ const createMiddleware = ({ name, funcKey }) => {
42
+ const contrastStartMiddleware = function contrastStartMiddleware(ctx, next) {
43
+ const sourceContext = core.scopes.sources.getStore()?.assess;
43
44
 
44
- if (!sourceContext) {
45
- logger.error({ name, inputType }, 'unable to handle Koa source. Missing `sourceContext`');
46
- return next();
47
- }
48
-
49
- // We check the contents mainly to trigger the getter for `ctx.query`
50
- // that is eventually set up by `koa-qs`
51
- if (ctx.query) {
52
- if (sourceContext.parsedQuery) {
53
- logger.trace({ name, inputType }, 'values already tracked');
45
+ if (!sourceContext) {
46
+ logger.error({ inputType, funcKey }, 'unable to handle Koa source. Missing `sourceContext`');
54
47
  return next();
55
48
  }
56
49
 
57
- try {
58
- sources.handle({
59
- context: 'ctx.query',
60
- data: ctx.query,
61
- inputType,
62
- name,
63
- stacktraceOpts: {
64
- constructorOpt: contrastStartMiddleware,
65
- },
66
- sourceContext
67
- });
68
-
69
- sourceContext.parsedQuery = true;
70
- } catch (err) {
71
- logger.error({ err, inputType, name }, 'unable to handle Koa source');
50
+ // We check the contents mainly to trigger the getter for `ctx.query`
51
+ // that is eventually set up by `koa-qs`
52
+ if (ctx.query) {
53
+ if (sourceContext.parsedQuery) {
54
+ logger.trace({ inputType, funcKey }, 'values already tracked');
55
+ return next();
56
+ }
57
+
58
+ try {
59
+ sources.handle({
60
+ context: 'ctx.query',
61
+ data: ctx.query,
62
+ inputType,
63
+ name,
64
+ stacktraceOpts: {
65
+ constructorOpt: contrastStartMiddleware,
66
+ },
67
+ sourceContext
68
+ });
69
+
70
+ sourceContext.parsedQuery = true;
71
+ } catch (err) {
72
+ logger.error({ err, inputType, funcKey }, 'unable to handle Koa source');
73
+ }
72
74
  }
73
- }
74
75
 
75
- return next();
76
- }
76
+ return next();
77
+ };
78
+
79
+ // mark these middleware as ours
80
+ contrastStartMiddleware._isContrastStartMiddleware = true;
77
81
 
78
- // mark these middleware as ours
79
- contrastStartMiddleware._isContrastStartMiddleware = true;
82
+ return contrastStartMiddleware;
83
+ };
80
84
 
81
85
  patcher.patch(Koa.prototype, 'use', {
82
86
  name: 'Koa.Application',
83
87
  patchType,
84
- pre({ obj: app }) {
88
+ pre({ obj: app, name, funcKey }) {
85
89
  // if not already inserted, insert the initial middleware.
86
90
  if (
87
91
  app.middleware &&
88
- (!app.middleware[0] || !app.middleware[0]._isContrastStartMiddleware)
92
+ (!app.middleware[0] || !app.middleware[0]._isContrastStartMiddleware)
89
93
  ) {
90
- app.middleware.splice(0, 0, contrastStartMiddleware);
94
+ app.middleware.unshift(createMiddleware({ name, funcKey }));
91
95
  }
92
96
  }
93
97
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -18,6 +18,8 @@
18
18
  const { InputType } = require('@contrast/common');
19
19
  const { patchType } = require('../common');
20
20
 
21
+ const inputType = InputType.QUERYSTRING;
22
+
21
23
  module.exports = (core) => {
22
24
  const {
23
25
  depHooks,
@@ -33,17 +35,16 @@ module.exports = (core) => {
33
35
  (qs) => patcher.patch(qs, 'parse', {
34
36
  name,
35
37
  patchType,
36
- post({ args, hooked, orig, result }) {
38
+ post({ args, hooked, orig, result, funcKey }) {
37
39
  const sourceContext = core.scopes.sources.getStore()?.assess;
38
- const inputType = InputType.QUERYSTRING;
39
40
 
40
41
  if (!sourceContext) {
41
- logger.error({ inputType, name }, 'unable to handle source. Missing `sourceContext`');
42
+ logger.error({ inputType, funcKey }, 'unable to handle source. Missing `sourceContext`');
42
43
  return;
43
44
  }
44
45
 
45
46
  if (sourceContext.parsedQuery) {
46
- logger.trace({ inputType, name }, 'values already tracked');
47
+ logger.trace({ inputType, funcKey }, 'values already tracked');
47
48
  return;
48
49
  }
49
50
 
@@ -67,7 +68,7 @@ module.exports = (core) => {
67
68
 
68
69
  sourceContext.parsedQuery = true;
69
70
  } catch (err) {
70
- logger.error({ err, inputType, name }, 'unable to handle source');
71
+ logger.error({ err, inputType, funcKey }, 'unable to handle source');
71
72
  }
72
73
  }
73
74
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -28,14 +28,14 @@ module.exports = (core) => {
28
28
  (querystring) => patcher.patch(querystring, 'parse', {
29
29
  name,
30
30
  patchType,
31
- post({ args, hooked, orig, result }) {
31
+ post({ args, hooked, orig, result, funcKey }) {
32
32
  const sourceContext = core.scopes.sources.getStore()?.assess;
33
33
  const inputType = InputType.QUERYSTRING;
34
34
 
35
35
  if (!sourceContext) return;
36
36
 
37
37
  if (sourceContext.parsedQuery) {
38
- logger.trace({ name }, 'values already tracked');
38
+ logger.trace({ funcKey }, 'values already tracked');
39
39
  return;
40
40
  }
41
41
 
@@ -58,7 +58,7 @@ module.exports = (core) => {
58
58
  // we do not set the `parsedQuery` value here so that frameworks
59
59
  // may handle queries in their own more specific manner.
60
60
  } catch (err) {
61
- logger.error({ err, name }, 'unable to handle source');
61
+ logger.error({ err, funcKey }, 'unable to handle source');
62
62
  }
63
63
  }
64
64
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -16,9 +16,11 @@
16
16
  'use strict';
17
17
 
18
18
  const { InputType, match } = require('@contrast/common');
19
- const annotationRegExp = /^(A|O|R|P|P\d+)$/;
19
+ const ANNOTATION_REGEX = /^(A|O|R|P|P\d+)$/;
20
+ const SOURCE_EVENT_MSG = 'Source event not created: %s';
21
+ const PROPAGATION_EVENT_MSG = 'Propagation event not created: %s';
20
22
 
21
- module.exports = function(core) {
23
+ module.exports = function (core) {
22
24
  const {
23
25
  createSnapshot,
24
26
  config,
@@ -30,7 +32,7 @@ module.exports = function(core) {
30
32
 
31
33
  eventFactory.createdEvents = new WeakSet();
32
34
 
33
- eventFactory.createSourceEvent = function(data = {}) {
35
+ eventFactory.createSourceEvent = function (data = {}) {
34
36
  const {
35
37
  name,
36
38
  result = { value: null, tracked: false },
@@ -39,31 +41,29 @@ module.exports = function(core) {
39
41
  stack,
40
42
  } = data;
41
43
 
42
- const baseMessage = 'Source event not created: %s';
43
-
44
44
  if (!result.value) {
45
- logger.debug({ result }, baseMessage, 'invalid result');
45
+ logger.debug({ data }, SOURCE_EVENT_MSG, 'invalid result');
46
46
  return null;
47
47
  }
48
48
 
49
49
  if (!name) {
50
- logger.debug({ data }, baseMessage, 'invalid name');
50
+ logger.debug({ data }, SOURCE_EVENT_MSG, 'invalid name');
51
51
  return null;
52
52
  }
53
53
 
54
54
  if (!(inputType in InputType)) {
55
- logger.debug({ inputType }, baseMessage, 'invalid inputType');
55
+ logger.debug({ data }, SOURCE_EVENT_MSG, 'invalid inputType');
56
56
  return null;
57
57
  }
58
58
 
59
59
  if (!tags) {
60
- logger.debug({ data }, baseMessage, 'event has no tags');
60
+ logger.debug({ data }, SOURCE_EVENT_MSG, 'event has no tags');
61
61
  return null;
62
62
  }
63
63
 
64
64
 
65
65
  if (!stack || !Array.isArray(stack)) {
66
- logger.debug({ data }, baseMessage, 'invalid stack');
66
+ logger.debug({ data }, SOURCE_EVENT_MSG, 'invalid stack');
67
67
  return null;
68
68
  }
69
69
 
@@ -73,7 +73,7 @@ module.exports = function(core) {
73
73
  return data;
74
74
  };
75
75
 
76
- eventFactory.createPropagationEvent = function(data) {
76
+ eventFactory.createPropagationEvent = function (data) {
77
77
  const {
78
78
  name = '',
79
79
  moduleName,
@@ -94,30 +94,32 @@ module.exports = function(core) {
94
94
  const sourceContext = sources.getStore()?.assess;
95
95
 
96
96
  if (!sourceContext) {
97
- logger.debug({ name }, 'No sourceContext found during Propagation event creation');
97
+ logger.debug({ data }, 'No sourceContext found during Propagation event creation');
98
98
  return null;
99
99
  }
100
100
 
101
101
  if (sourceContext.propagationEventsCount >= config.assess.max_propagation_events) {
102
- logger.debug({ name }, 'Maximum number of Propagation events reached. Event not created');
102
+ logger.debug({ data }, 'Maximum number of Propagation events reached. Event not created');
103
103
  return null;
104
104
  }
105
105
 
106
106
  if (!name) {
107
- logger.debug({ name }, 'Propagation event not created: invalid name');
107
+ logger.debug({ data }, PROPAGATION_EVENT_MSG, 'invalid name');
108
108
  return null;
109
109
  }
110
110
 
111
111
  if (!history.length) {
112
- logger.debug({ name, history }, 'Propagation event not created: invalid history');
112
+ logger.debug({ data }, PROPAGATION_EVENT_MSG, 'invalid history');
113
113
  return null;
114
114
  }
115
115
 
116
- if (
117
- (!source || !match(source, annotationRegExp)) ||
118
- (!target || !match(target, annotationRegExp))
119
- ) {
120
- logger.debug({ name, source, target }, 'Propagation event not created: %s', 'invalid source/target');
116
+ if (!source || !match(source, ANNOTATION_REGEX)) {
117
+ logger.debug({ data }, PROPAGATION_EVENT_MSG, 'invalid source');
118
+ return null;
119
+ }
120
+
121
+ if (!target || !match(target, ANNOTATION_REGEX)) {
122
+ logger.debug({ data }, PROPAGATION_EVENT_MSG, 'invalid target');
121
123
  return null;
122
124
  }
123
125
 
@@ -152,7 +154,7 @@ module.exports = function(core) {
152
154
  return event;
153
155
  };
154
156
 
155
- eventFactory.createSinkEvent = function(data) {
157
+ eventFactory.createSinkEvent = function (data) {
156
158
  const {
157
159
  context,
158
160
  name = '',
@@ -169,7 +171,7 @@ module.exports = function(core) {
169
171
 
170
172
  const sourceContext = sources.getStore()?.assess;
171
173
  if (!sourceContext) {
172
- logger.debug('no sourceContext found during sink event creation');
174
+ logger.debug({ data }, 'no sourceContext found during sink event creation');
173
175
  return null;
174
176
  }
175
177
  if (!name) {
@@ -181,7 +183,7 @@ module.exports = function(core) {
181
183
  return null;
182
184
  }
183
185
  if (
184
- (!source || !source.match(annotationRegExp))
186
+ (!source || !source.match(ANNOTATION_REGEX))
185
187
  ) {
186
188
  logger.debug({ data }, 'malformed or missing sink event source field');
187
189
  return null;
@@ -214,7 +216,7 @@ module.exports = function(core) {
214
216
  return event;
215
217
  };
216
218
 
217
- eventFactory.createSessionEvent = function(data) {
219
+ eventFactory.createSessionEvent = function (data) {
218
220
  const {
219
221
  context,
220
222
  name = '',
@@ -235,7 +237,7 @@ module.exports = function(core) {
235
237
  }
236
238
 
237
239
  if (
238
- (!source || !source.match(annotationRegExp))
240
+ (!source || !source.match(ANNOTATION_REGEX))
239
241
  ) {
240
242
  logger.debug({ data }, 'malformed or missing sink event source field');
241
243
  return null;
@@ -285,7 +287,7 @@ module.exports = function(core) {
285
287
  * }} data
286
288
  * @returns {any}
287
289
  */
288
- eventFactory.createCryptoAnalysisEvent = function(data) {
290
+ eventFactory.createCryptoAnalysisEvent = function (data) {
289
291
  const {
290
292
  name = '',
291
293
  source,
@@ -297,7 +299,7 @@ module.exports = function(core) {
297
299
  return null;
298
300
  }
299
301
 
300
- if (!source || !source.match(annotationRegExp)) {
302
+ if (!source || !source.match(ANNOTATION_REGEX)) {
301
303
  logger.debug({ data }, 'malformed or missing sink event source field');
302
304
  return null;
303
305
  }
package/lib/get-policy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -13,7 +13,10 @@
13
13
  * way not consistent with the End User License Agreement.
14
14
  */
15
15
  import { IncomingMessage, ServerResponse } from 'node:http';
16
- import { Rule } from '@contrast/common';
16
+ import {
17
+ Rule,
18
+ SessionConfigurationRule,
19
+ } from '@contrast/common';
17
20
 
18
21
  export enum InstrumentationType {
19
22
  SOURCE = 'source',
@@ -40,11 +43,22 @@ export interface RuleScopes {
40
43
  isLocked(ruleId: Rule): boolean;
41
44
  }
42
45
 
46
+ export interface SessionRuleState {
47
+ reported: boolean,
48
+ valuesAnalyzed: Set<string>,
49
+ }
50
+
51
+ export interface RuleState {
52
+ [SessionConfigurationRule.HTTPONLY]?: SessionRuleState,
53
+ [SessionConfigurationRule.SECURE_FLAG_MISSING]?: SessionRuleState,
54
+ }
55
+
43
56
  export interface Assess {
44
57
  getPolicy(): Policy,
45
58
  getSourceContext(instrType?: InstrumentationType, opts?: any): SourceContext,
46
59
  makeSourceContext(req: IncomingMessage, res: ServerResponse): SourceContext,
47
60
  ruleScopes: RuleScopes,
61
+ ruleState: RuleState,
48
62
  }
49
63
 
50
64
  export function getSourceContext(instrType?: InstrumentationType, ops?: any): SourceContext;
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -29,6 +29,9 @@ module.exports = function(core) {
29
29
  logger,
30
30
  } = core;
31
31
 
32
+ /**
33
+ * @returns {import('@contrast/assess').SourceContext}
34
+ */
32
35
  return core.assess.makeSourceContext = function (req, res) {
33
36
  let contentType, queries, uriPath;
34
37
 
@@ -61,7 +64,8 @@ module.exports = function(core) {
61
64
  queries,
62
65
  contentType,
63
66
  },
64
- responseData: {}
67
+ responseData: {},
68
+ ruleState: {},
65
69
  };
66
70
  } catch (err) {
67
71
  logger.error(
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright: 2023 Contrast Security, Inc
2
+ * Copyright: 2024 Contrast Security, Inc
3
3
  * Contact: support@contrastsecurity.com
4
4
  * License: Commercial
5
5