@contrast/common 1.1.3 → 1.1.4
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/index.d.ts +4 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +3 -1
- package/package.json +2 -3
- package/src/index.ts +5 -2
- package/src/types.ts +9 -21
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './constants';
|
|
2
2
|
export * from './types';
|
|
3
|
+
interface TraverseCallback {
|
|
4
|
+
(path: any[], type: 'Key' | 'Value', value: any, obj: any): unknown;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Returns true if the value passed is either a primitive string or a
|
|
5
8
|
* String object.
|
|
@@ -7,5 +10,5 @@ export * from './types';
|
|
|
7
10
|
export declare function isString(value: unknown): value is string | String;
|
|
8
11
|
export declare function isNonEmptyObject(value: unknown): value is object;
|
|
9
12
|
export declare function encodeString(str: string): string;
|
|
10
|
-
export declare function simpleTraverse(obj: any, cb:
|
|
13
|
+
export declare function simpleTraverse(obj: any, cb: TraverseCallback): void;
|
|
11
14
|
export declare function installChildComponentsSync(parent: any, order: string[]): void;
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,0CAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,0CAAwB;AAMxB;;;GAGG;AACH,wDAAwD;AACxD,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY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;
|
|
10
10
|
};
|
|
11
11
|
hostname: string;
|
|
12
|
-
version: string;
|
|
13
12
|
name: string;
|
|
14
13
|
pkg: object;
|
|
15
14
|
agentVersion: string;
|
|
@@ -20,6 +19,7 @@ export interface AppInfo {
|
|
|
20
19
|
indexFile: string;
|
|
21
20
|
serverName: string;
|
|
22
21
|
serverEnvironment: string;
|
|
22
|
+
version: string;
|
|
23
23
|
}
|
|
24
24
|
export declare type SemanticAnalysisRules = Rule.CMD_INJECTION_SEMANTIC_CHAINED_COMMANDS | Rule.CMD_INJECTION_COMMAND_BACKDOORS | Rule.CMD_INJECTION_SEMANTIC_DANGEROUS_PATHS;
|
|
25
25
|
export interface Result {
|
|
@@ -38,6 +38,8 @@ export interface Result {
|
|
|
38
38
|
export interface SemanticAnalysisResult extends Result {
|
|
39
39
|
findings?: {
|
|
40
40
|
command?: string;
|
|
41
|
+
prolog?: string;
|
|
42
|
+
xml?: string;
|
|
41
43
|
};
|
|
42
44
|
sinkContext?: any;
|
|
43
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
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)",
|
|
@@ -13,6 +13,5 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc --build src/",
|
|
15
15
|
"test": "../scripts/test.sh"
|
|
16
|
-
}
|
|
17
|
-
"dependencies": {}
|
|
16
|
+
}
|
|
18
17
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
export * from './constants';
|
|
17
17
|
export * from './types';
|
|
18
18
|
|
|
19
|
+
interface TraverseCallback {
|
|
20
|
+
(path: any[], type: 'Key' | 'Value', value: any, obj: any): unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
* Returns true if the value passed is either a primitive string or a
|
|
21
25
|
* String object.
|
|
@@ -34,12 +38,11 @@ export function encodeString(str: string): string {
|
|
|
34
38
|
return Buffer.from(str).toString('base64');
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
export function simpleTraverse(obj: any, cb:
|
|
41
|
+
export function simpleTraverse(obj: any, cb: TraverseCallback) {
|
|
38
42
|
if (typeof obj !== 'object' || obj === null) {
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
41
45
|
const path: any[] = [];
|
|
42
|
-
/* eslint-disable complexity */
|
|
43
46
|
function traverse(obj: any) {
|
|
44
47
|
const isArray = Array.isArray(obj);
|
|
45
48
|
for (const k in obj) {
|
package/src/types.ts
CHANGED
|
@@ -24,7 +24,6 @@ export interface AppInfo {
|
|
|
24
24
|
release: string;
|
|
25
25
|
};
|
|
26
26
|
hostname: string;
|
|
27
|
-
version: string;
|
|
28
27
|
name: string;
|
|
29
28
|
pkg: object; // package.json
|
|
30
29
|
agentVersion: string;
|
|
@@ -35,6 +34,7 @@ export interface AppInfo {
|
|
|
35
34
|
indexFile: string;
|
|
36
35
|
serverName: string;
|
|
37
36
|
serverEnvironment: string;
|
|
37
|
+
version: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type SemanticAnalysisRules =
|
|
@@ -59,6 +59,8 @@ export interface Result {
|
|
|
59
59
|
export interface SemanticAnalysisResult extends Result {
|
|
60
60
|
findings?: {
|
|
61
61
|
command?: string;
|
|
62
|
+
prolog?: string;
|
|
63
|
+
xml?: string;
|
|
62
64
|
};
|
|
63
65
|
sinkContext?: any;
|
|
64
66
|
}
|
|
@@ -130,29 +132,15 @@ export interface RequestStore {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
export interface Messages extends EventEmitter {
|
|
133
|
-
addListener(event: Event.PROTECT,
|
|
134
|
-
|
|
135
|
-
): this;
|
|
136
|
-
addListener(
|
|
137
|
-
event: Event.SERVER_SETTINGS_UPDATE,
|
|
138
|
-
listener: (msg: Record<string, any>) => void,
|
|
139
|
-
): this;
|
|
135
|
+
addListener(event: Event.PROTECT, listener: (msg: RequestStore) => void): this;
|
|
136
|
+
addListener(event: Event.SERVER_SETTINGS_UPDATE, listener: (msg: Record<string, any>) => void): this;
|
|
140
137
|
|
|
141
138
|
emit(event: Event.PROTECT, msg: RequestStore): boolean;
|
|
142
139
|
emit(event: Event.SERVER_SETTINGS_UPDATE, msg: Record<string, any>): boolean;
|
|
143
140
|
|
|
144
141
|
on(event: Event.PROTECT, listener: (msg: RequestStore) => void): this;
|
|
145
|
-
on(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
): this;
|
|
149
|
-
|
|
150
|
-
prependListener(
|
|
151
|
-
event: Event.PROTECT,
|
|
152
|
-
listener: (msg: RequestStore) => void,
|
|
153
|
-
): this;
|
|
154
|
-
prependOnceListener(
|
|
155
|
-
event: Event.PROTECT,
|
|
156
|
-
listener: (msg: RequestStore) => void,
|
|
157
|
-
): this;
|
|
142
|
+
on(event: Event.SERVER_SETTINGS_UPDATE, listener: (msg: Record<string, any>) => void): this;
|
|
143
|
+
|
|
144
|
+
prependListener(event: Event.PROTECT, listener: (msg: RequestStore) => void,): this;
|
|
145
|
+
prependOnceListener(event: Event.PROTECT, listener: (msg: RequestStore) => void): this;
|
|
158
146
|
}
|