@contrast/common 1.36.0 → 1.38.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.
@@ -6,11 +6,11 @@ export declare enum Event {
6
6
  ASSESS_DATAFLOW_FINDING = "assess-dataflow-findings",
7
7
  ASSESS_DATAFLOW_SAFE_POSITIVE = "assess-dataflow-safe-positive",
8
8
  ASSESS_RESPONSE_SCANNING_FINDING = "assess-response-scanning-findings",
9
- ASSESS_SESSION_CONFIGURATION_FINDING = "assess-session-configuration-findings",
9
+ ASSESS_CONFIGURATION_FINDING = "assess-configuration-findings",
10
10
  ASSESS_CRYPTO_ANALYSIS_FINDING = "assess-crypto-analysis-finding",
11
11
  LIBRARY = "library",
12
12
  LIBRARY_USAGE = "library-usage",
13
- PROTECT = "protect",
13
+ PROTECT_FINDING = "protect-finding",
14
14
  ROUTE_COVERAGE_OBSERVATION = "route-coverage-observation",
15
15
  SERVER_SETTINGS_UPDATE = "server-settings-update",// UI remote settings updates
16
16
  UNINSTALL = "uninstall",// disable all components/features
@@ -60,9 +60,10 @@ export declare enum ResponseScanningRule {
60
60
  XCONTENTTYPE_HEADER_MISSING = "xcontenttype-header-missing",
61
61
  XXSPROTECTION_HEADER_DISABLED = "xxssprotection-header-disabled"
62
62
  }
63
- export declare enum SessionConfigurationRule {
63
+ export declare enum ConfigurationRule {
64
64
  HTTPONLY = "httponly",
65
- SECURE_FLAG_MISSING = "secure-flag-missing"
65
+ SECURE_FLAG_MISSING = "secure-flag-missing",
66
+ GRAPHQL_INTROSPECTION = "graphql-introspection"
66
67
  }
67
68
  export declare enum InputType {
68
69
  UNDEFINED_TYPE = "UNDEFINED_TYPE",
@@ -86,7 +87,8 @@ export declare enum InputType {
86
87
  METHOD = "METHOD",
87
88
  REQUEST = "REQUEST",
88
89
  URL_PARAMETER = "URL_PARAMETER",
89
- UNKNOWN = "UNKNOWN"
90
+ UNKNOWN = "UNKNOWN",
91
+ WEBSOCKET = "WEBSOCKET"
90
92
  }
91
93
  export declare enum ExclusionType {
92
94
  BODY = "BODY",
@@ -96,6 +98,12 @@ export declare enum ExclusionType {
96
98
  QUERYSTRING = "QUERYSTRING",
97
99
  URL = "URL"
98
100
  }
101
+ export declare enum RouteType {
102
+ HTTP = "HTTP",
103
+ MESSAGE_BROKER = "MESSAGE_BROKER",
104
+ MIDDLEWARE = "MIDDLEWARE",
105
+ RPC = "RPC"
106
+ }
99
107
  export declare enum DataflowTag {
100
108
  XML_ENCODED = "XML_ENCODED",
101
109
  XML_DECODED = "XML_DECODED",
package/lib/constants.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * way not consistent with the End User License Agreement.
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.URI_REGEXES = exports.symbols = exports.agentLibIDListTypes = exports.FS_METHODS = exports.BLOCKING_MODES = exports.ServerEnvironment = exports.DataflowTag = exports.ExclusionType = exports.InputType = exports.SessionConfigurationRule = exports.ResponseScanningRule = exports.Rule = exports.ProtectRuleMode = exports.Event = void 0;
17
+ exports.URI_REGEXES = exports.symbols = exports.agentLibIDListTypes = exports.FS_METHODS = exports.BLOCKING_MODES = exports.ServerEnvironment = exports.DataflowTag = exports.RouteType = exports.ExclusionType = exports.InputType = exports.ConfigurationRule = exports.ResponseScanningRule = exports.Rule = exports.ProtectRuleMode = exports.Event = void 0;
18
18
  var Event;
19
19
  (function (Event) {
20
20
  // lifecycle
@@ -26,11 +26,11 @@ var Event;
26
26
  Event["ASSESS_DATAFLOW_FINDING"] = "assess-dataflow-findings";
27
27
  Event["ASSESS_DATAFLOW_SAFE_POSITIVE"] = "assess-dataflow-safe-positive";
28
28
  Event["ASSESS_RESPONSE_SCANNING_FINDING"] = "assess-response-scanning-findings";
29
- Event["ASSESS_SESSION_CONFIGURATION_FINDING"] = "assess-session-configuration-findings";
29
+ Event["ASSESS_CONFIGURATION_FINDING"] = "assess-configuration-findings";
30
30
  Event["ASSESS_CRYPTO_ANALYSIS_FINDING"] = "assess-crypto-analysis-finding";
31
31
  Event["LIBRARY"] = "library";
32
32
  Event["LIBRARY_USAGE"] = "library-usage";
33
- Event["PROTECT"] = "protect";
33
+ Event["PROTECT_FINDING"] = "protect-finding";
34
34
  Event["ROUTE_COVERAGE_OBSERVATION"] = "route-coverage-observation";
35
35
  // state changes
36
36
  Event["SERVER_SETTINGS_UPDATE"] = "server-settings-update";
@@ -85,11 +85,12 @@ var ResponseScanningRule;
85
85
  ResponseScanningRule["XCONTENTTYPE_HEADER_MISSING"] = "xcontenttype-header-missing";
86
86
  ResponseScanningRule["XXSPROTECTION_HEADER_DISABLED"] = "xxssprotection-header-disabled";
87
87
  })(ResponseScanningRule || (exports.ResponseScanningRule = ResponseScanningRule = {}));
88
- var SessionConfigurationRule;
89
- (function (SessionConfigurationRule) {
90
- SessionConfigurationRule["HTTPONLY"] = "httponly";
91
- SessionConfigurationRule["SECURE_FLAG_MISSING"] = "secure-flag-missing";
92
- })(SessionConfigurationRule || (exports.SessionConfigurationRule = SessionConfigurationRule = {}));
88
+ var ConfigurationRule;
89
+ (function (ConfigurationRule) {
90
+ ConfigurationRule["HTTPONLY"] = "httponly";
91
+ ConfigurationRule["SECURE_FLAG_MISSING"] = "secure-flag-missing";
92
+ ConfigurationRule["GRAPHQL_INTROSPECTION"] = "graphql-introspection";
93
+ })(ConfigurationRule || (exports.ConfigurationRule = ConfigurationRule = {}));
93
94
  var InputType;
94
95
  (function (InputType) {
95
96
  InputType["UNDEFINED_TYPE"] = "UNDEFINED_TYPE";
@@ -114,6 +115,7 @@ var InputType;
114
115
  InputType["REQUEST"] = "REQUEST";
115
116
  InputType["URL_PARAMETER"] = "URL_PARAMETER";
116
117
  InputType["UNKNOWN"] = "UNKNOWN";
118
+ InputType["WEBSOCKET"] = "WEBSOCKET";
117
119
  })(InputType || (exports.InputType = InputType = {}));
118
120
  var ExclusionType;
119
121
  (function (ExclusionType) {
@@ -124,6 +126,13 @@ var ExclusionType;
124
126
  ExclusionType["QUERYSTRING"] = "QUERYSTRING";
125
127
  ExclusionType["URL"] = "URL";
126
128
  })(ExclusionType || (exports.ExclusionType = ExclusionType = {}));
129
+ var RouteType;
130
+ (function (RouteType) {
131
+ RouteType["HTTP"] = "HTTP";
132
+ RouteType["MESSAGE_BROKER"] = "MESSAGE_BROKER";
133
+ RouteType["MIDDLEWARE"] = "MIDDLEWARE";
134
+ RouteType["RPC"] = "RPC";
135
+ })(RouteType || (exports.RouteType = RouteType = {}));
127
136
  var DataflowTag;
128
137
  (function (DataflowTag) {
129
138
  DataflowTag["XML_ENCODED"] = "XML_ENCODED";
package/lib/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { ServerResponse } from 'node:http';
3
- import { Event, ProtectRuleMode, Rule } from './constants';
3
+ import { Event, ProtectRuleMode, RouteType, Rule } from './constants';
4
4
  export interface Installable {
5
5
  install(...args: any[]): void | Promise<void>;
6
6
  uninstall?(): void | Promise<void>;
@@ -150,9 +150,8 @@ export interface Result {
150
150
  mongoExpansionResult?: boolean;
151
151
  path?: string[];
152
152
  ruleId: Rule;
153
- score: number;
153
+ score?: number;
154
154
  value: string;
155
- sinkContext?: any;
156
155
  }
157
156
  export interface SemanticAnalysisResult extends Result {
158
157
  ruleId: SemanticAnalysisRules;
@@ -230,6 +229,7 @@ export interface SourceInfo {
230
229
  contentType?: string;
231
230
  ip: string;
232
231
  httpVersion: string;
232
+ getHeader(name: string): string | null;
233
233
  }
234
234
  /**
235
235
  * this is known as RequestStore even though, in the future, instrumentation
@@ -335,6 +335,10 @@ export interface RouteInfo {
335
335
  * @example "get"
336
336
  */
337
337
  method?: string;
338
+ /**
339
+ * The type of route that is being reported. Default should be RouteType.HTTP.
340
+ */
341
+ type: RouteType;
338
342
  /**
339
343
  * URL for a route.
340
344
  * @example "prefix/route/path"
@@ -346,6 +350,20 @@ export interface RouteInfo {
346
350
  */
347
351
  normalizedUrl: string;
348
352
  }
353
+ export interface ProtectFindingEventArg {
354
+ store: RequestStore;
355
+ result: Result;
356
+ sinkContext?: {
357
+ name: string;
358
+ value: any;
359
+ stacktraceOpts?: {
360
+ constructorOpt: any;
361
+ prependFrames: any[];
362
+ };
363
+ stack?: any[];
364
+ };
365
+ findings?: any;
366
+ }
349
367
  /**
350
368
  * Agent event emitter for messaging to/from external systems. Use cases are
351
369
  * reporting agent findings and broadcasting settings updates.
@@ -358,7 +376,7 @@ export interface Messages extends EventEmitter {
358
376
  emit(event: Event.ASSESS_DATAFLOW_FINDING, msg: any): boolean;
359
377
  emit(event: Event.LIBRARY, msg: Library): boolean;
360
378
  emit(event: Event.LIBRARY_USAGE, msg: LibraryUsage): boolean;
361
- emit(event: Event.PROTECT, msg: RequestStore): boolean;
379
+ emit(event: Event.PROTECT_FINDING, msg: ProtectFindingEventArg): boolean;
362
380
  emit(event: Event.ROUTE_COVERAGE_DISCOVERY_FINISHED, routes: RouteInfo[]): boolean;
363
381
  emit(event: Event.ROUTE_COVERAGE_OBSERVATION, route: RouteInfo): boolean;
364
382
  emit(event: Event.SERVER_SETTINGS_UPDATE, msg: Record<string, any>): boolean;
@@ -369,7 +387,7 @@ export interface Messages extends EventEmitter {
369
387
  on(event: Event.ASSESS_DATAFLOW_FINDING, listenter: (msg: any) => void): this;
370
388
  on(event: Event.LIBRARY, listener: (msg: Library) => void): this;
371
389
  on(event: Event.LIBRARY_USAGE, listener: (msg: LibraryUsage) => void): this;
372
- on(event: Event.PROTECT, listener: (msg: RequestStore) => void): this;
390
+ on(event: Event.PROTECT_FINDING, listener: (msg: ProtectFindingEventArg) => void): this;
373
391
  on(event: Event.ROUTE_COVERAGE_DISCOVERY_FINISHED, listener: (routes: RouteInfo[]) => void): this;
374
392
  on(event: Event.ROUTE_COVERAGE_OBSERVATION, listener: (route: RouteInfo) => void): this;
375
393
  on(event: Event.SERVER_SETTINGS_UPDATE, listener: (msg: Record<string, any>) => void): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/common",
3
- "version": "1.36.0",
3
+ "version": "1.38.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)",