@socketsecurity/cli 1.1.29 → 1.1.30
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/CHANGELOG.md +9 -0
- package/dist/cli.js +181 -25
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/branch-cleanup.d.mts +23 -0
- package/dist/types/commands/fix/branch-cleanup.d.mts.map +1 -0
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts +27 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/utils/dlx.d.mts.map +1 -1
- package/dist/utils.js +25 -4
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clean up a stale branch (both remote and local).
|
|
3
|
+
* Safe to delete both since no PR exists for this branch.
|
|
4
|
+
*
|
|
5
|
+
* Returns true if cleanup succeeded or should continue, false if should skip GHSA.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanupStaleBranch(branch: string, ghsaId: string, cwd: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Clean up branches after PR creation failure.
|
|
10
|
+
* Safe to delete both remote and local since no PR was created.
|
|
11
|
+
*/
|
|
12
|
+
export declare function cleanupFailedPrBranches(branch: string, cwd: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Clean up local branch after successful PR creation.
|
|
15
|
+
* Keeps remote branch - PR needs it to be mergeable.
|
|
16
|
+
*/
|
|
17
|
+
export declare function cleanupSuccessfulPrLocalBranch(branch: string, cwd: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Clean up branches in catch block after unexpected error.
|
|
20
|
+
* Safe to delete both remote and local since no PR was created.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cleanupErrorBranches(branch: string, cwd: string, remoteBranchExists: boolean): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=branch-cleanup.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-cleanup.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/branch-cleanup.mts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coana-fix.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/coana-fix.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coana-fix.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/coana-fix.mts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CA0etD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestError } from '@octokit/request-error';
|
|
1
2
|
import { type GhsaDetails, type Pr } from '../../utils/github.mts';
|
|
2
3
|
import type { OctokitResponse } from '@octokit/types';
|
|
3
4
|
export type OpenSocketFixPrOptions = {
|
|
@@ -5,7 +6,32 @@ export type OpenSocketFixPrOptions = {
|
|
|
5
6
|
cwd?: string | undefined;
|
|
6
7
|
ghsaDetails?: Map<string, GhsaDetails> | undefined;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export type OpenPrResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
pr: OctokitResponse<Pr>;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
reason: 'already_exists';
|
|
15
|
+
error: RequestError;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
reason: 'validation_error';
|
|
19
|
+
error: RequestError;
|
|
20
|
+
details: string;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
reason: 'permission_denied';
|
|
24
|
+
error: RequestError;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
reason: 'network_error';
|
|
28
|
+
error: RequestError;
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
reason: 'unknown';
|
|
32
|
+
error: Error;
|
|
33
|
+
};
|
|
34
|
+
export declare function openSocketFixPr(owner: string, repo: string, branch: string, ghsaIds: string[], options?: OpenSocketFixPrOptions | undefined): Promise<OpenPrResult>;
|
|
9
35
|
export type GQL_MERGE_STATE_STATUS = 'BEHIND' | 'BLOCKED' | 'CLEAN' | 'DIRTY' | 'DRAFT' | 'HAS_HOOKS' | 'UNKNOWN' | 'UNSTABLE';
|
|
10
36
|
export type GQL_PR_STATE = 'OPEN' | 'CLOSED' | 'MERGED';
|
|
11
37
|
export type PrMatch = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-request.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/pull-request.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pull-request.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/pull-request.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAmBrD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,EAAE,EAKR,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGrD,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC,CAAA;CAAE,GACrC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GAC5D;IACE,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,kBAAkB,CAAA;IAC1B,KAAK,EAAE,YAAY,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GAC/D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GAC3D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAA;AAElD,wBAAsB,eAAe,CACnC,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O,EAAE,CAAC,CAIpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dlx.d.mts","sourceRoot":"","sources":["../../../src/utils/dlx.mts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAMpE,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG;IAC1C,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC3C,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAQD;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,WAAW,EAAE,cAAc,EAC3B,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,EAChC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,GAClC,OAAO,CAAC,eAAe,CAAC,CA8F1B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,EAChC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,GAClC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"dlx.d.mts","sourceRoot":"","sources":["../../../src/utils/dlx.mts"],"names":[],"mappings":"AAsCA,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AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,EAChC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,GAClC,OAAO,CAAC,eAAe,CAAC,CAU1B"}
|
package/dist/utils.js
CHANGED
|
@@ -2678,6 +2678,24 @@ async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
|
2678
2678
|
}
|
|
2679
2679
|
return false;
|
|
2680
2680
|
}
|
|
2681
|
+
async function gitDeleteRemoteBranch(branch, cwd = process.cwd()) {
|
|
2682
|
+
const stdioIgnoreOptions = {
|
|
2683
|
+
cwd,
|
|
2684
|
+
stdio: require$$9.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
2685
|
+
};
|
|
2686
|
+
try {
|
|
2687
|
+
// Will throw with exit code 1 if branch does not exist.
|
|
2688
|
+
await spawn.spawn('git', ['push', 'origin', '--delete', branch], stdioIgnoreOptions);
|
|
2689
|
+
return true;
|
|
2690
|
+
} catch (e) {
|
|
2691
|
+
// Expected failure when remote branch doesn't exist.
|
|
2692
|
+
require$$9.debugDir('inspect', {
|
|
2693
|
+
message: `Remote branch deletion failed (may not exist): ${branch}`,
|
|
2694
|
+
error: e
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
return false;
|
|
2698
|
+
}
|
|
2681
2699
|
async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
2682
2700
|
const stdioPipeOptions = {
|
|
2683
2701
|
cwd
|
|
@@ -3576,13 +3594,15 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
|
|
|
3576
3594
|
const localCoanaPath = process.env['SOCKET_CLI_COANA_LOCAL_PATH'];
|
|
3577
3595
|
// Use local Coana CLI if path is provided.
|
|
3578
3596
|
if (localCoanaPath) {
|
|
3597
|
+
const isBinary = !localCoanaPath.endsWith('.js') && !localCoanaPath.endsWith('.mjs');
|
|
3579
3598
|
const finalEnv = {
|
|
3580
3599
|
...process.env,
|
|
3581
3600
|
...constants.default.processEnv,
|
|
3582
3601
|
...mixinsEnv,
|
|
3583
3602
|
...spawnEnv
|
|
3584
3603
|
};
|
|
3585
|
-
const
|
|
3604
|
+
const spawnArgs = isBinary ? args : [localCoanaPath, ...args];
|
|
3605
|
+
const spawnResult = await spawn.spawn(isBinary ? localCoanaPath : 'node', spawnArgs, {
|
|
3586
3606
|
cwd: dlxOptions.cwd,
|
|
3587
3607
|
env: finalEnv,
|
|
3588
3608
|
stdio: spawnExtra?.['stdio'] || 'inherit'
|
|
@@ -3596,7 +3616,7 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
|
|
|
3596
3616
|
// Use npm/dlx version.
|
|
3597
3617
|
const result = await spawnDlx({
|
|
3598
3618
|
name: '@coana-tech/cli',
|
|
3599
|
-
version:
|
|
3619
|
+
version: constants.default.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION
|
|
3600
3620
|
}, args, {
|
|
3601
3621
|
force: true,
|
|
3602
3622
|
silent: true,
|
|
@@ -5860,7 +5880,7 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
5860
5880
|
opts.filter.fixable = true;
|
|
5861
5881
|
}
|
|
5862
5882
|
const {
|
|
5863
|
-
apiToken
|
|
5883
|
+
apiToken,
|
|
5864
5884
|
spinner
|
|
5865
5885
|
} = opts;
|
|
5866
5886
|
const getText = () => `Looking up data for ${remaining} packages`;
|
|
@@ -6123,6 +6143,7 @@ exports.gitCheckoutBranch = gitCheckoutBranch;
|
|
|
6123
6143
|
exports.gitCommit = gitCommit;
|
|
6124
6144
|
exports.gitCreateBranch = gitCreateBranch;
|
|
6125
6145
|
exports.gitDeleteBranch = gitDeleteBranch;
|
|
6146
|
+
exports.gitDeleteRemoteBranch = gitDeleteRemoteBranch;
|
|
6126
6147
|
exports.gitPushBranch = gitPushBranch;
|
|
6127
6148
|
exports.gitRemoteBranchExists = gitRemoteBranchExists;
|
|
6128
6149
|
exports.gitResetAndClean = gitResetAndClean;
|
|
@@ -6183,5 +6204,5 @@ exports.updateConfigValue = updateConfigValue;
|
|
|
6183
6204
|
exports.walkNestedMap = walkNestedMap;
|
|
6184
6205
|
exports.webLink = webLink;
|
|
6185
6206
|
exports.writeSocketJson = writeSocketJson;
|
|
6186
|
-
//# debugId=
|
|
6207
|
+
//# debugId=f4170516-b8da-4ecd-ae5a-489d00a6d603
|
|
6187
6208
|
//# sourceMappingURL=utils.js.map
|