@contrast/common 1.0.0 → 1.0.3
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/lib/constants.js +14 -0
- package/lib/constants.js.map +1 -1
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +32 -23
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +15 -0
- package/src/index.ts +15 -0
- package/src/types/index.ts +49 -24
package/lib/constants.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
4
|
+
* Contact: support@contrastsecurity.com
|
|
5
|
+
* License: Commercial
|
|
6
|
+
|
|
7
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
8
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
9
|
+
* made available through public repositories, use of this Software is subject to
|
|
10
|
+
* the applicable End User Licensing Agreement found at
|
|
11
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
12
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
13
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
14
|
+
* way not consistent with the End User License Agreement.
|
|
15
|
+
*/
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.Rule = exports.Event = void 0;
|
|
4
18
|
var Event;
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,0BAAiB,CAAA;IACjB,4BAAmB,CAAA;AACrB,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB;AAED,IAAY,IAkBX;AAlBD,WAAY,IAAI;IACd,mCAA2B,CAAA;IAC3B,uCAA+B,CAAA;IAC/B,2EAAmE,CAAA;IACnE,2FAAmF,CAAA;IACnF,yFAAiF,CAAA;IACjF,mCAA2B,CAAA;IAC3B,6CAAqC,CAAA;IACrC,2CAAmC,CAAA;IACnC,uDAA+C,CAAA;IAC/C,yCAAiC,CAAA;IACjC,uCAA+B,CAAA;IAC/B,uCAA+B,CAAA;IAC/B,yCAAiC,CAAA;IACjC,uCAA+B,CAAA;IAC/B,+DAAuD,CAAA;IACvD,iDAAyC,CAAA;IACzC,mBAAW,CAAA;AACb,CAAC,EAlBW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAkBf"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
4
|
+
* Contact: support@contrastsecurity.com
|
|
5
|
+
* License: Commercial
|
|
6
|
+
|
|
7
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
8
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
9
|
+
* made available through public repositories, use of this Software is subject to
|
|
10
|
+
* the applicable End User Licensing Agreement found at
|
|
11
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
12
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
13
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
14
|
+
* way not consistent with the End User License Agreement.
|
|
15
|
+
*/
|
|
2
16
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
17
|
if (k2 === undefined) k2 = k;
|
|
4
18
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,0CAAwB;AAExB;;;GAGG;AACH,wDAAwD;AACxD,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC;AAC9D,CAAC;AAFD,4BAEC;AAED,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAFD,oCAEC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface RuleConfig {
|
|
|
7
7
|
export interface RulesConfig extends Record<Rule, RuleConfig> {
|
|
8
8
|
}
|
|
9
9
|
export interface Result {
|
|
10
|
+
blocked: boolean;
|
|
10
11
|
ruleId: Rule;
|
|
11
12
|
inputType: string;
|
|
12
13
|
path: string[];
|
|
@@ -14,31 +15,39 @@ export interface Result {
|
|
|
14
15
|
value: string;
|
|
15
16
|
details?: any[];
|
|
16
17
|
}
|
|
18
|
+
export interface ReqData {
|
|
19
|
+
method: string;
|
|
20
|
+
headers: string[];
|
|
21
|
+
uriPath: string;
|
|
22
|
+
queries: string;
|
|
23
|
+
contentType?: string;
|
|
24
|
+
standardUrlParsing: boolean;
|
|
25
|
+
ip: string;
|
|
26
|
+
httpVersion: string;
|
|
27
|
+
headers2: {
|
|
28
|
+
[key: string]: Array<string>;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface Findings {
|
|
32
|
+
trackRequest: boolean;
|
|
33
|
+
securityException?: [mode: string, ruleId: string];
|
|
34
|
+
bodyType?: 'json' | 'urlencoded';
|
|
35
|
+
resultsMap: Record<Rule, Result[]>;
|
|
36
|
+
}
|
|
17
37
|
export interface RequestStore {
|
|
18
|
-
protect?:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
block: (mode: string, ruleId: string) => void;
|
|
28
|
-
rules: {
|
|
29
|
-
agentLibRules: RulesConfig;
|
|
30
|
-
agentLibRulesMask: number;
|
|
31
|
-
agentRules: RulesConfig;
|
|
32
|
-
};
|
|
33
|
-
exclusions: any[];
|
|
34
|
-
virtualPatches: any[];
|
|
35
|
-
findings: {
|
|
36
|
-
trackRequest: boolean;
|
|
37
|
-
securityException?: [mode: string, ruleId: string];
|
|
38
|
-
bodyType?: 'json' | 'urlencoded';
|
|
39
|
-
resultsMap: Record<Rule, Result[]>;
|
|
40
|
-
};
|
|
38
|
+
protect?: ProtectMessage;
|
|
39
|
+
}
|
|
40
|
+
export interface ProtectMessage {
|
|
41
|
+
reqData: ReqData;
|
|
42
|
+
block: (mode: string, ruleId: string) => void;
|
|
43
|
+
rules: {
|
|
44
|
+
agentLibRules: RulesConfig;
|
|
45
|
+
agentLibRulesMask: number;
|
|
46
|
+
agentRules: RulesConfig;
|
|
41
47
|
};
|
|
48
|
+
exclusions: any[];
|
|
49
|
+
virtualPatches: any[];
|
|
50
|
+
findings: Findings;
|
|
42
51
|
}
|
|
43
52
|
export interface Messages extends EventEmitter {
|
|
44
53
|
addListener(event: Event.PROTECT, listener: (msg: RequestStore) => void): this;
|
package/lib/types/index.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
4
|
+
* Contact: support@contrastsecurity.com
|
|
5
|
+
* License: Commercial
|
|
6
|
+
|
|
7
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
8
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
9
|
+
* made available through public repositories, use of this Software is subject to
|
|
10
|
+
* the applicable End User Licensing Agreement found at
|
|
11
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
12
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
13
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
14
|
+
* way not consistent with the End User License Agreement.
|
|
15
|
+
*/
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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)",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
9
|
"engines": {
|
|
10
|
-
"npm": ">= 8.
|
|
10
|
+
"npm": ">=6.13.7 <7 || >= 8.3.1",
|
|
11
11
|
"node": ">= 14.15.0"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
export enum Event {
|
|
2
17
|
ASSESS = 'assess',
|
|
3
18
|
PROTECT = 'protect',
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
export * from './constants';
|
|
2
17
|
export * from './types';
|
|
3
18
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
import { Event, Rule } from '../constants';
|
|
2
17
|
import { EventEmitter } from 'events';
|
|
3
18
|
|
|
@@ -8,12 +23,32 @@ export interface RuleConfig {
|
|
|
8
23
|
export interface RulesConfig extends Record<Rule, RuleConfig> {}
|
|
9
24
|
|
|
10
25
|
export interface Result {
|
|
26
|
+
blocked: boolean;
|
|
11
27
|
ruleId: Rule,
|
|
12
28
|
inputType: string, // TODO
|
|
13
29
|
path: string[],
|
|
14
30
|
key: string,
|
|
15
31
|
value: string,
|
|
16
|
-
details?: any[],
|
|
32
|
+
details?: any[], // TODO
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ReqData {
|
|
36
|
+
method: string;
|
|
37
|
+
headers: string[];
|
|
38
|
+
uriPath: string;
|
|
39
|
+
queries: string;
|
|
40
|
+
contentType?: string;
|
|
41
|
+
standardUrlParsing: boolean;
|
|
42
|
+
ip: string;
|
|
43
|
+
httpVersion: string,
|
|
44
|
+
headers2: { [key: string]: Array<string> };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Findings {
|
|
48
|
+
trackRequest: boolean;
|
|
49
|
+
securityException?: [mode: string, ruleId: string];
|
|
50
|
+
bodyType?: 'json' | 'urlencoded';
|
|
51
|
+
resultsMap: Record<Rule, Result[]>
|
|
17
52
|
}
|
|
18
53
|
|
|
19
54
|
//
|
|
@@ -28,30 +63,20 @@ export interface Result {
|
|
|
28
63
|
//
|
|
29
64
|
export interface RequestStore {
|
|
30
65
|
// TODO: from protect/lib/make-source-context
|
|
31
|
-
protect?:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rules: {
|
|
42
|
-
agentLibRules: RulesConfig;
|
|
43
|
-
agentLibRulesMask: number;
|
|
44
|
-
agentRules: RulesConfig;
|
|
45
|
-
};
|
|
46
|
-
exclusions: any[]; // TODO
|
|
47
|
-
virtualPatches: any[]; // TODO
|
|
48
|
-
findings: {
|
|
49
|
-
trackRequest: boolean;
|
|
50
|
-
securityException?: [mode: string, ruleId: string];
|
|
51
|
-
bodyType?: 'json' | 'urlencoded';
|
|
52
|
-
resultsMap: Record<Rule, Result[]>
|
|
53
|
-
};
|
|
66
|
+
protect?: ProtectMessage;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ProtectMessage {
|
|
70
|
+
reqData: ReqData;
|
|
71
|
+
block: (mode: string, ruleId: string) => void;
|
|
72
|
+
rules: {
|
|
73
|
+
agentLibRules: RulesConfig;
|
|
74
|
+
agentLibRulesMask: number;
|
|
75
|
+
agentRules: RulesConfig;
|
|
54
76
|
};
|
|
77
|
+
exclusions: any[]; // TODO
|
|
78
|
+
virtualPatches: any[]; // TODO
|
|
79
|
+
findings: Findings;
|
|
55
80
|
}
|
|
56
81
|
|
|
57
82
|
export interface Messages extends EventEmitter {
|