@socketsecurity/cli 0.14.42 → 0.14.44
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/README.md +16 -38
- package/bin/cli.js +17 -7
- package/bin/npm-cli.js +1 -1
- package/bin/npx-cli.js +1 -1
- package/dist/constants.d.ts +121 -11
- package/dist/constants.js +91 -10
- package/dist/constants.js.map +1 -0
- package/dist/init.gradle +250 -0
- package/dist/module-sync/cli.js +6115 -3836
- package/dist/module-sync/cli.js.map +1 -0
- package/dist/module-sync/edge.d.ts +66 -0
- package/dist/module-sync/errors.d.ts +6 -1
- package/dist/module-sync/index.d.ts +192 -0
- package/dist/module-sync/index.js +1879 -0
- package/dist/module-sync/index.js.map +1 -0
- package/dist/module-sync/logging.d.ts +3 -3
- package/dist/module-sync/node.d.ts +84 -0
- package/dist/module-sync/npm-injection.js +7 -1495
- package/dist/module-sync/npm-injection.js.map +1 -0
- package/dist/module-sync/npm-paths.d.ts +3 -2
- package/dist/module-sync/npm-paths.js +91 -42
- package/dist/module-sync/npm-paths.js.map +1 -0
- package/dist/module-sync/npm.d.ts +24 -0
- package/dist/module-sync/npm.js +99 -0
- package/dist/module-sync/npm.js.map +1 -0
- package/dist/module-sync/path-resolve.d.ts +1 -1
- package/dist/module-sync/proc-log.d.ts +3 -0
- package/dist/module-sync/reify.d.ts +1018 -0
- package/dist/module-sync/sdk.d.ts +5 -0
- package/dist/module-sync/settings.d.ts +5 -4
- package/dist/module-sync/shadow-bin.d.ts +1 -1
- package/dist/module-sync/shadow-bin.js +33 -12
- package/dist/module-sync/shadow-bin.js.map +1 -0
- package/dist/module-sync/types.d.ts +45 -0
- package/dist/require/cli.js +6114 -3836
- package/dist/require/constants.js +1 -1
- package/dist/require/index.js +3 -0
- package/dist/require/npm.js +3 -0
- package/dist/require/vendor.js +2336 -6
- package/package.json +69 -42
- package/dist/constants.d.ts.map +0 -1
- package/dist/module-sync/socket-url.d.ts +0 -40
- package/dist/module-sync/socket-url.js +0 -301
- package/dist/require/socket-url.js +0 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/// <reference types="npmcli__arborist" />
|
|
2
|
+
import { SafeNode } from "./node.js";
|
|
3
|
+
import { SafeOverrideSet } from "./index.js";
|
|
4
|
+
import { DependencyProblem } from '@npmcli/arborist';
|
|
5
|
+
import { Edge as BaseEdge } from "@npmcli/arborist";
|
|
6
|
+
type EdgeClass = Omit<BaseEdge, 'accept' | 'detach' | 'optional' | 'overrides' | 'peer' | 'peerConflicted' | 'rawSpec' | 'reload' | 'satisfiedBy' | 'spec' | 'to'> & {
|
|
7
|
+
optional: boolean;
|
|
8
|
+
overrides: SafeOverrideSet | undefined;
|
|
9
|
+
peer: boolean;
|
|
10
|
+
peerConflicted: boolean;
|
|
11
|
+
rawSpec: string;
|
|
12
|
+
get accept(): string | undefined;
|
|
13
|
+
get spec(): string;
|
|
14
|
+
get to(): SafeNode | null;
|
|
15
|
+
new (...args: any): EdgeClass;
|
|
16
|
+
detach(): void;
|
|
17
|
+
reload(hard?: boolean): void;
|
|
18
|
+
satisfiedBy(node: SafeNode): boolean;
|
|
19
|
+
};
|
|
20
|
+
type EdgeOptions = {
|
|
21
|
+
type: string;
|
|
22
|
+
name: string;
|
|
23
|
+
spec: string;
|
|
24
|
+
from: SafeNode;
|
|
25
|
+
accept?: string | undefined;
|
|
26
|
+
overrides?: SafeOverrideSet | undefined;
|
|
27
|
+
to?: SafeNode;
|
|
28
|
+
};
|
|
29
|
+
type ErrorStatus = DependencyProblem | 'OK';
|
|
30
|
+
type Explanation = {
|
|
31
|
+
type: string;
|
|
32
|
+
name: string;
|
|
33
|
+
spec: string;
|
|
34
|
+
bundled: boolean;
|
|
35
|
+
overridden: boolean;
|
|
36
|
+
error: ErrorStatus | undefined;
|
|
37
|
+
rawSpec: string | undefined;
|
|
38
|
+
from: object | undefined;
|
|
39
|
+
} | null;
|
|
40
|
+
declare const Edge: EdgeClass;
|
|
41
|
+
declare class SafeEdge extends Edge {
|
|
42
|
+
#private;
|
|
43
|
+
constructor(options: EdgeOptions);
|
|
44
|
+
get accept(): string | undefined;
|
|
45
|
+
get bundled(): boolean;
|
|
46
|
+
get error(): "DETACHED" | "MISSING" | "PEER LOCAL" | "INVALID" | null;
|
|
47
|
+
get from(): SafeNode | null;
|
|
48
|
+
get spec(): string;
|
|
49
|
+
get to(): SafeNode | null;
|
|
50
|
+
detach(): void;
|
|
51
|
+
// Return the edge data, and an explanation of how that edge came to be here.
|
|
52
|
+
// @ts-ignore: Edge#explain is defined with an unused `seen = []` param.
|
|
53
|
+
explain(): {
|
|
54
|
+
type: string;
|
|
55
|
+
name: string;
|
|
56
|
+
spec: string;
|
|
57
|
+
bundled: boolean;
|
|
58
|
+
overridden: boolean;
|
|
59
|
+
error: ErrorStatus | undefined;
|
|
60
|
+
rawSpec: string | undefined;
|
|
61
|
+
from: object | undefined;
|
|
62
|
+
};
|
|
63
|
+
reload(hard?: boolean): void;
|
|
64
|
+
satisfiedBy(node: SafeNode): boolean;
|
|
65
|
+
}
|
|
66
|
+
export { EdgeOptions, ErrorStatus, Explanation, Edge, SafeEdge };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
type EventHintOrCaptureContext = {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
} | Function;
|
|
2
5
|
declare class AuthError extends Error {
|
|
3
6
|
}
|
|
4
7
|
declare class InputError extends Error {
|
|
5
8
|
body: string | undefined;
|
|
6
9
|
constructor(message: string, body?: string);
|
|
7
10
|
}
|
|
11
|
+
declare function captureException(exception: unknown, hint?: EventHintOrCaptureContext | undefined): Promise<string>;
|
|
12
|
+
declare function captureExceptionSync(exception: unknown, hint?: EventHintOrCaptureContext | undefined): string;
|
|
8
13
|
declare function isErrnoException(value: unknown): value is NodeJS.ErrnoException;
|
|
9
|
-
export { AuthError, InputError, isErrnoException };
|
|
14
|
+
export { AuthError, InputError, captureException, captureExceptionSync, isErrnoException };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SafeEdge } from "./edge.js";
|
|
3
|
+
import { SafeNode } from "./node.js";
|
|
4
|
+
import indentString from "@socketregistry/indent-string/index.cjs";
|
|
5
|
+
import { LogSymbols } from "./logging.js";
|
|
6
|
+
import { SocketSdkResultType } from "@socketsecurity/sdk";
|
|
7
|
+
import { Diff, ArboristClass } from "./types.js";
|
|
8
|
+
import { ObjectEncodingOptions, OpenMode, PathLike } from "node:fs";
|
|
9
|
+
import { promises as fs } from "node:fs";
|
|
10
|
+
import { readFileSync as fsReadFileSync } from "node:fs";
|
|
11
|
+
import { Abortable } from "node:events";
|
|
12
|
+
import { FileHandle } from "node:fs/promises";
|
|
13
|
+
import { kRiskyReify } from "./reify.js";
|
|
14
|
+
interface OverrideSetClass {
|
|
15
|
+
children: Map<string, SafeOverrideSet>;
|
|
16
|
+
key: string | undefined;
|
|
17
|
+
keySpec: string | undefined;
|
|
18
|
+
name: string | undefined;
|
|
19
|
+
parent: SafeOverrideSet | undefined;
|
|
20
|
+
value: string | undefined;
|
|
21
|
+
version: string | undefined;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
|
23
|
+
new (...args: any[]): OverrideSetClass;
|
|
24
|
+
get isRoot(): boolean;
|
|
25
|
+
get ruleset(): Map<string, SafeOverrideSet>;
|
|
26
|
+
ancestry(): Generator<SafeOverrideSet>;
|
|
27
|
+
childrenAreEqual(otherOverrideSet: SafeOverrideSet | undefined): boolean;
|
|
28
|
+
getEdgeRule(edge: SafeEdge): SafeOverrideSet;
|
|
29
|
+
getNodeRule(node: SafeNode): SafeOverrideSet;
|
|
30
|
+
getMatchingRule(node: SafeNode): SafeOverrideSet | null;
|
|
31
|
+
isEqual(otherOverrideSet: SafeOverrideSet | undefined): boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const OverrideSet: OverrideSetClass;
|
|
34
|
+
// Implementation code not related to patch https://github.com/npm/cli/pull/7025
|
|
35
|
+
// is based on https://github.com/npm/cli/blob/v11.0.0/workspaces/arborist/lib/override-set.js:
|
|
36
|
+
declare class SafeOverrideSet extends OverrideSet {
|
|
37
|
+
// Patch adding doOverrideSetsConflict is based on
|
|
38
|
+
// https://github.com/npm/cli/pull/7025.
|
|
39
|
+
static doOverrideSetsConflict(first: SafeOverrideSet | undefined, second: SafeOverrideSet | undefined): boolean;
|
|
40
|
+
// Patch adding findSpecificOverrideSet is based on
|
|
41
|
+
// https://github.com/npm/cli/pull/7025.
|
|
42
|
+
static findSpecificOverrideSet(first: SafeOverrideSet | undefined, second: SafeOverrideSet | undefined): SafeOverrideSet | undefined;
|
|
43
|
+
// Patch adding childrenAreEqual is based on
|
|
44
|
+
// https://github.com/npm/cli/pull/7025.
|
|
45
|
+
childrenAreEqual(otherOverrideSet: SafeOverrideSet): boolean;
|
|
46
|
+
getEdgeRule(edge: SafeEdge): SafeOverrideSet;
|
|
47
|
+
// Patch adding isEqual is based on
|
|
48
|
+
// https://github.com/npm/cli/pull/7025.
|
|
49
|
+
isEqual(otherOverrideSet: SafeOverrideSet | undefined): boolean;
|
|
50
|
+
}
|
|
51
|
+
declare const depValid: (child: SafeNode, requested: string, accept: string | undefined, requester: SafeNode) => boolean;
|
|
52
|
+
declare function getSocketDevAlertUrl(alertType: string): string;
|
|
53
|
+
declare function getSocketDevPackageOverviewUrl(eco: string, name: string, version?: string): string;
|
|
54
|
+
declare class ColorOrMarkdown {
|
|
55
|
+
useMarkdown: boolean;
|
|
56
|
+
constructor(useMarkdown: boolean);
|
|
57
|
+
bold(text: string): string;
|
|
58
|
+
header(text: string, level?: number): string;
|
|
59
|
+
hyperlink(text: string, url: string | undefined, { fallback, fallbackToUrl }?: {
|
|
60
|
+
fallback?: boolean;
|
|
61
|
+
fallbackToUrl?: boolean;
|
|
62
|
+
}): string;
|
|
63
|
+
indent(...args: Parameters<typeof indentString>): ReturnType<typeof indentString>;
|
|
64
|
+
italic(text: string): string;
|
|
65
|
+
json(value: any): string;
|
|
66
|
+
list(items: string[]): string;
|
|
67
|
+
get logSymbols(): LogSymbols;
|
|
68
|
+
}
|
|
69
|
+
type AlertUxLookup = ReturnType<typeof createAlertUXLookup>;
|
|
70
|
+
type AlertUxLookupSettings = Parameters<AlertUxLookup>[0];
|
|
71
|
+
type AlertUxLookupResult = ReturnType<AlertUxLookup>;
|
|
72
|
+
type RuleActionUX = {
|
|
73
|
+
block: boolean;
|
|
74
|
+
display: boolean;
|
|
75
|
+
};
|
|
76
|
+
type SettingsType = (SocketSdkResultType<"postSettings"> & {
|
|
77
|
+
success: true;
|
|
78
|
+
})["data"];
|
|
79
|
+
declare function createAlertUXLookup(settings: SettingsType): (context: {
|
|
80
|
+
package: {
|
|
81
|
+
name: string;
|
|
82
|
+
version: string;
|
|
83
|
+
};
|
|
84
|
+
alert: {
|
|
85
|
+
type: string;
|
|
86
|
+
};
|
|
87
|
+
}) => RuleActionUX;
|
|
88
|
+
declare function uxLookup(settings: AlertUxLookupSettings): Promise<AlertUxLookupResult>;
|
|
89
|
+
type CveAlertType = "cve" | "mediumCVE" | "mildCVE" | "criticalCVE";
|
|
90
|
+
type ArtifactAlertCveFixable = Omit<SocketArtifactAlert, "props" | "title"> & {
|
|
91
|
+
type: CveAlertType;
|
|
92
|
+
props: {
|
|
93
|
+
firstPatchedVersionIdentifier: string;
|
|
94
|
+
vulnerableVersionRange: string;
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
type ArtifactAlertFixable = ArtifactAlertCveFixable & {
|
|
99
|
+
type: CveAlertType | "socketUpgradeAvailable";
|
|
100
|
+
};
|
|
101
|
+
type SocketArtifactAlert = {
|
|
102
|
+
key: string;
|
|
103
|
+
type: string;
|
|
104
|
+
severity: string;
|
|
105
|
+
category: string;
|
|
106
|
+
action?: string;
|
|
107
|
+
actionPolicyIndex?: number;
|
|
108
|
+
file?: string;
|
|
109
|
+
props?: any;
|
|
110
|
+
start?: number;
|
|
111
|
+
end?: number;
|
|
112
|
+
};
|
|
113
|
+
type SocketArtifact = {
|
|
114
|
+
type: string;
|
|
115
|
+
name: string;
|
|
116
|
+
namespace?: string;
|
|
117
|
+
version?: string;
|
|
118
|
+
subpath?: string;
|
|
119
|
+
release?: string;
|
|
120
|
+
id?: string;
|
|
121
|
+
author?: string[];
|
|
122
|
+
license?: string;
|
|
123
|
+
licenseDetails?: {
|
|
124
|
+
spdxDisj: string;
|
|
125
|
+
provenance: string;
|
|
126
|
+
filepath: string;
|
|
127
|
+
match_strength: number;
|
|
128
|
+
}[];
|
|
129
|
+
licenseAttrib?: {
|
|
130
|
+
attribText: string;
|
|
131
|
+
attribData: {
|
|
132
|
+
purl: string;
|
|
133
|
+
foundInFilepath: string;
|
|
134
|
+
spdxExpr: string;
|
|
135
|
+
foundAuthors: string[];
|
|
136
|
+
}[];
|
|
137
|
+
}[];
|
|
138
|
+
score?: {
|
|
139
|
+
supplyChain: number;
|
|
140
|
+
quality: number;
|
|
141
|
+
maintenance: number;
|
|
142
|
+
vulnerability: number;
|
|
143
|
+
license: number;
|
|
144
|
+
overall: number;
|
|
145
|
+
};
|
|
146
|
+
alerts?: SocketArtifactAlert[];
|
|
147
|
+
size?: number;
|
|
148
|
+
batchIndex?: number;
|
|
149
|
+
};
|
|
150
|
+
declare function batchScan(pkgIds: string[], concurrencyLimit?: number): AsyncGenerator<SocketArtifact>;
|
|
151
|
+
declare function isArtifactAlertCveFixable(alert: SocketArtifactAlert): alert is ArtifactAlertCveFixable;
|
|
152
|
+
declare function isArtifactAlertUpgradeFixable(alert: SocketArtifactAlert): alert is ArtifactAlertFixable;
|
|
153
|
+
declare function isArtifactAlertFixable(alert: SocketArtifactAlert): alert is ArtifactAlertFixable;
|
|
154
|
+
type PackageDetail = {
|
|
155
|
+
node: SafeNode;
|
|
156
|
+
existing?: SafeNode | undefined;
|
|
157
|
+
};
|
|
158
|
+
type GetPackagesToQueryFromDiffOptions = {
|
|
159
|
+
includeUnchanged?: boolean;
|
|
160
|
+
includeUnknownOrigin?: boolean;
|
|
161
|
+
};
|
|
162
|
+
declare function getPackagesToQueryFromDiff(diff_: Diff | null, options?: GetPackagesToQueryFromDiffOptions): PackageDetail[];
|
|
163
|
+
declare function findUp(name: string | string[], { cwd }: {
|
|
164
|
+
cwd: string;
|
|
165
|
+
}): Promise<string | undefined>;
|
|
166
|
+
type ReadFileOptions = ObjectEncodingOptions & Abortable & {
|
|
167
|
+
flag?: OpenMode | undefined;
|
|
168
|
+
};
|
|
169
|
+
declare function readFileBinary(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<Buffer>;
|
|
170
|
+
declare function readFileUtf8(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<string>;
|
|
171
|
+
declare function safeReadFile(...args: Parameters<typeof fs.readFile>): ReturnType<typeof fs.readFile> | undefined;
|
|
172
|
+
declare function safeReadFileSync(...args: Parameters<typeof fsReadFileSync>): ReturnType<typeof fsReadFileSync> | undefined;
|
|
173
|
+
declare const Arborist: ArboristClass;
|
|
174
|
+
declare const kCtorArgs: unique symbol;
|
|
175
|
+
declare const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES: {
|
|
176
|
+
__proto__: null;
|
|
177
|
+
audit: boolean;
|
|
178
|
+
dryRun: boolean;
|
|
179
|
+
fund: boolean;
|
|
180
|
+
ignoreScripts: boolean;
|
|
181
|
+
progress: boolean;
|
|
182
|
+
save: boolean;
|
|
183
|
+
saveBundle: boolean;
|
|
184
|
+
silent: boolean;
|
|
185
|
+
};
|
|
186
|
+
declare class SafeArborist extends Arborist {
|
|
187
|
+
constructor(...ctorArgs: ConstructorParameters<ArboristClass>);
|
|
188
|
+
[kRiskyReify](...args: Parameters<InstanceType<ArboristClass>['reify']>): Promise<SafeNode>;
|
|
189
|
+
// @ts-ignore Incorrectly typed.
|
|
190
|
+
reify(this: SafeArborist, ...args: Parameters<InstanceType<ArboristClass>['reify']>): Promise<SafeNode>;
|
|
191
|
+
}
|
|
192
|
+
export { SafeOverrideSet, depValid, getSocketDevAlertUrl, getSocketDevPackageOverviewUrl, ColorOrMarkdown, createAlertUXLookup, uxLookup, CveAlertType, ArtifactAlertCveFixable, ArtifactAlertFixable, SocketArtifactAlert, SocketArtifact, batchScan, isArtifactAlertCveFixable, isArtifactAlertUpgradeFixable, isArtifactAlertFixable, PackageDetail, getPackagesToQueryFromDiff, findUp, ReadFileOptions, readFileBinary, readFileUtf8, safeReadFile, safeReadFileSync, Arborist, kCtorArgs, SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES, SafeArborist };
|