-
Notifications
You must be signed in to change notification settings - Fork 534
/
types.ts
87 lines (76 loc) · 2.19 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import * as depGraphLib from '@snyk/dep-graph';
import { SupportedPackageManagers } from './package-managers';
// TODO(kyegupov): use a shared repository snyk-cli-interface
export interface PluginMetadata {
name: string;
packageFormatVersion?: string;
packageManager: string;
imageLayers?: any;
targetFile?: string; // this is wrong (because Shaun said it)
runtime?: any;
dockerImageId: any;
meta?: {
allSubProjectNames: string[]; // To warn the user about subprojects not being scanned
};
}
export interface DepDict {
[name: string]: DepTree;
}
export interface DepTree {
name: string;
version: string;
dependencies?: DepDict;
packageFormatVersion?: string;
docker?: any;
files?: any;
targetFile?: string;
}
export interface DepRoot {
depTree: DepTree; // to be soon replaced with depGraph
targetFile?: string;
}
// Legacy result type. Will be deprecated soon.
export interface SingleDepRootResult {
plugin: PluginMetadata;
package: DepTree;
}
export interface MultiDepRootsResult {
plugin: PluginMetadata;
depRoots: DepRoot[];
}
// https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
export function isMultiResult(pet: SingleDepRootResult | MultiDepRootsResult): pet is MultiDepRootsResult {
return !!(pet as MultiDepRootsResult).depRoots;
}
export class MonitorError extends Error {
public code?: number;
public userMessage?: string;
}
export interface TestOptions {
org: string;
path: string;
docker?: boolean;
file?: string;
policy?: string;
json?: boolean;
'all-sub-projects'?: boolean; // Corresponds to multiDepRoot in plugins
'project-name'?: string;
'show-vulnerable-paths'?: string;
showVulnPaths?: boolean;
packageManager: SupportedPackageManagers;
advertiseSubprojectsCount?: number;
subProjectNames?: string[];
severityThreshold?: string;
'print-deps'?: boolean;
}
// TODO(kyegupov): catch accessing ['undefined-properties'] via noImplicitAny
export interface MonitorOptions {
id?: string;
docker?: boolean;
file?: string;
policy?: string;
json?: boolean;
'all-sub-projects'?: boolean; // Corresponds to multiDepRoot in plugins
'project-name'?: string;
'print-deps'?: boolean;
}