@contrast/common 1.39.0 → 1.40.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright: 2025 Contrast Security, Inc
1
+ Copyright: 2026 Contrast Security, Inc
2
2
  Contact: support@contrastsecurity.com
3
3
  License: Commercial
4
4
 
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright: 2025 Contrast Security, Inc
3
+ * Copyright: 2026 Contrast Security, Inc
4
4
  * Contact: support@contrastsecurity.com
5
5
  * License: Commercial
6
6
 
package/lib/index.d.ts CHANGED
@@ -38,4 +38,11 @@ export declare function safeConsoleError(...args: Parameters<typeof console.erro
38
38
  /** Suppresses output to stderr when installed by the universal agent */
39
39
  export declare function safeConsoleWarn(...args: Parameters<typeof console.warn>): void;
40
40
  export declare function normalizeURI(uri: string): string;
41
+ export interface FrameInfo {
42
+ file: string;
43
+ lineNumber: number;
44
+ method: string;
45
+ type: string | null;
46
+ }
47
+ export declare function parseStackTraceLines(lines: string[]): null | FrameInfo[];
41
48
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright: 2025 Contrast Security, Inc
3
+ * Copyright: 2026 Contrast Security, Inc
4
4
  * Contact: support@contrastsecurity.com
5
5
  * License: Commercial
6
6
 
@@ -43,6 +43,7 @@ exports.set = set;
43
43
  exports.safeConsoleError = safeConsoleError;
44
44
  exports.safeConsoleWarn = safeConsoleWarn;
45
45
  exports.normalizeURI = normalizeURI;
46
+ exports.parseStackTraceLines = parseStackTraceLines;
46
47
  const constants_1 = require("./constants");
47
48
  const primordials_1 = require("./primordials");
48
49
  __exportStar(require("./constants"), exports);
@@ -192,8 +193,7 @@ function groupResultsMap(resultsMap) {
192
193
  }
193
194
  function get(obj, name) {
194
195
  let target = obj;
195
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
196
- // @ts-ignore
196
+ // @ts-expect-error ts does not handle method overloads well
197
197
  const props = StringPrototypeSplit.call(name, '.');
198
198
  for (const prop of props) {
199
199
  target = target?.[prop];
@@ -203,8 +203,7 @@ function get(obj, name) {
203
203
  return target;
204
204
  }
205
205
  function set(obj, name, value) {
206
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
207
- // @ts-ignore
206
+ // @ts-expect-error ts does not handle method overloads well
208
207
  const props = StringPrototypeSplit.call(name, '.');
209
208
  const lastProp = props.pop();
210
209
  for (const p of props) {
@@ -229,10 +228,37 @@ function safeConsoleWarn(...args) {
229
228
  function normalizeURI(uri) {
230
229
  let normalizedUri = uri;
231
230
  constants_1.URI_REGEXES.forEach(({ rx, rp }) => {
232
- //@ts-ignore
231
+ // @ts-expect-error ts does not handle method overloads well
233
232
  normalizedUri = StringPrototypeReplaceAll.call(normalizedUri, rx, rp);
234
233
  });
235
234
  return normalizedUri;
236
235
  }
237
- ;
236
+ const STACK_FRAME_LINE_PARSER = /^\s*at\s+(?:(?<async>async\s+)?(?<caller>.+?)\s+\()?(?<file>.+?):(?<line>\d+):(?<column>\d+)\)?$/;
237
+ function parseStackTraceLines(lines) {
238
+ const ret = [];
239
+ for (const line of lines) {
240
+ const match = line.match(STACK_FRAME_LINE_PARSER);
241
+ // don't include if we can't parse
242
+ if (!match?.groups)
243
+ continue;
244
+ const { caller, file, line: lineNumber } = match.groups;
245
+ let method = caller;
246
+ let typeName = null;
247
+ if (!method) {
248
+ method = '<anonymous>';
249
+ }
250
+ else if (method.indexOf('.') > 0) {
251
+ const methodIdx = method.lastIndexOf('.');
252
+ typeName = primordials_1.primordials.StringPrototypeSubstring.call(method, 0, methodIdx);
253
+ method = primordials_1.primordials.StringPrototypeSubstring.call(method, methodIdx + 1);
254
+ }
255
+ ret.push({
256
+ method: method || '<anonymous>',
257
+ file,
258
+ lineNumber: Number(lineNumber),
259
+ type: typeName
260
+ });
261
+ }
262
+ return ret;
263
+ }
238
264
  //# sourceMappingURL=index.js.map
@@ -57,6 +57,8 @@ export declare const primordials: {
57
57
  };
58
58
  UtilInspect: typeof inspect;
59
59
  PathBasename: (path: string, ext?: string) => string;
60
+ PathResolve: (...paths: string[]) => string;
61
+ PathJoin: (...paths: string[]) => string;
60
62
  FsOpen: typeof fs.open;
61
63
  FsOpenSync: typeof fs.openSync;
62
64
  FsReadFile: typeof fs.readFile;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright: 2025 Contrast Security, Inc
3
+ * Copyright: 2026 Contrast Security, Inc
4
4
  * Contact: support@contrastsecurity.com
5
5
  * License: Commercial
6
6
 
@@ -19,17 +19,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.primordials = void 0;
21
21
  const util_1 = require("util");
22
- const path_1 = require("path");
22
+ const path_1 = __importDefault(require("path"));
23
23
  const fs_1 = __importDefault(require("fs"));
24
24
  const promises_1 = __importDefault(require("fs/promises"));
25
25
  exports.primordials = {
26
- // arrays
26
+ // Array
27
27
  ArrayPrototypeJoin: Array.prototype.join,
28
28
  ArrayPrototypeSlice: Array.prototype.slice,
29
- //buffers,
29
+ // Buffer
30
30
  BufferFrom: Buffer.from,
31
31
  BufferPrototypeToString: Buffer.prototype.toString,
32
- //strings
32
+ // String
33
33
  StringPrototypeConcat: String.prototype.concat,
34
34
  StringPrototypeMatch: String.prototype.match,
35
35
  StringPrototypeMatchAll: String.prototype.matchAll,
@@ -44,16 +44,20 @@ exports.primordials = {
44
44
  StringPrototypeToLocaleLowerCase: String.prototype.toLocaleLowerCase,
45
45
  StringPrototypeToLocaleUpperCase: String.prototype.toLocaleUpperCase,
46
46
  StringPrototypeTrim: String.prototype.trim,
47
- //regex,
47
+ // RegExp
48
48
  RegExpPrototypeTest: RegExp.prototype.test,
49
49
  RegExpPrototypeExec: RegExp.prototype.exec,
50
- //function
50
+ // Function
51
51
  FunctionPrototypeToString: Function.prototype.toString,
52
- // misc
52
+ // JSON
53
53
  JSONParse: JSON.parse,
54
54
  JSONStringify: JSON.stringify,
55
+ // util
55
56
  UtilInspect: util_1.inspect,
56
- PathBasename: path_1.basename,
57
+ // path
58
+ PathBasename: path_1.default.basename,
59
+ PathResolve: path_1.default.resolve,
60
+ PathJoin: path_1.default.join,
57
61
  // fs
58
62
  FsOpen: fs_1.default.open,
59
63
  FsOpenSync: fs_1.default.openSync,
package/lib/types.d.ts CHANGED
@@ -143,6 +143,7 @@ export type HardeningRules = Rule.UNTRUSTED_DESERIALIZATION;
143
143
  export interface Result {
144
144
  blocked: boolean;
145
145
  exploitMetadata?: any[] | any;
146
+ exploited?: boolean;
146
147
  idsList?: string[];
147
148
  inputType: string;
148
149
  key?: string;
package/lib/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright: 2025 Contrast Security, Inc
3
+ * Copyright: 2026 Contrast Security, Inc
4
4
  * Contact: support@contrastsecurity.com
5
5
  * License: Commercial
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/common",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "Shared constants and utilities for all Contrast Agent modules",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",