mobbdev 1.2.28 → 1.2.32
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/dist/args/commands/upload_ai_blame.mjs +420 -188
- package/dist/index.mjs +694 -477
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -851,12 +851,15 @@ var init_client_generates = __esm({
|
|
|
851
851
|
}
|
|
852
852
|
`;
|
|
853
853
|
AnalyzeCommitForExtensionAiBlameDocument = `
|
|
854
|
-
mutation AnalyzeCommitForExtensionAIBlame($repositoryURL: String!, $commitSha: String!, $organizationId: String!, $commitTimestamp: Timestamp) {
|
|
854
|
+
mutation AnalyzeCommitForExtensionAIBlame($repositoryURL: String!, $commitSha: String!, $organizationId: String!, $commitTimestamp: Timestamp, $commitAuthor: GitIdentityInput, $commitCommitter: GitIdentityInput, $commitCoAuthors: [GitIdentityInput!]) {
|
|
855
855
|
analyzeCommitForAIBlame(
|
|
856
856
|
repositoryURL: $repositoryURL
|
|
857
857
|
commitSha: $commitSha
|
|
858
858
|
organizationId: $organizationId
|
|
859
859
|
commitTimestamp: $commitTimestamp
|
|
860
|
+
commitAuthor: $commitAuthor
|
|
861
|
+
commitCommitter: $commitCommitter
|
|
862
|
+
commitCoAuthors: $commitCoAuthors
|
|
860
863
|
) {
|
|
861
864
|
__typename
|
|
862
865
|
... on ProcessAIBlameFinalResult {
|
|
@@ -2689,6 +2692,217 @@ var init_configs = __esm({
|
|
|
2689
2692
|
}
|
|
2690
2693
|
});
|
|
2691
2694
|
|
|
2695
|
+
// src/utils/blame/gitBlameTypes.ts
|
|
2696
|
+
import { z as z18 } from "zod";
|
|
2697
|
+
function parseCoAuthorValue(raw) {
|
|
2698
|
+
const trimmed = raw.trim();
|
|
2699
|
+
if (!trimmed) {
|
|
2700
|
+
return null;
|
|
2701
|
+
}
|
|
2702
|
+
const openBracket = trimmed.lastIndexOf("<");
|
|
2703
|
+
const closeBracket = trimmed.lastIndexOf(">");
|
|
2704
|
+
if (openBracket === -1 || closeBracket === -1 || closeBracket < openBracket) {
|
|
2705
|
+
return null;
|
|
2706
|
+
}
|
|
2707
|
+
const name = trimmed.slice(0, openBracket).trim();
|
|
2708
|
+
const email = trimmed.slice(openBracket + 1, closeBracket).trim();
|
|
2709
|
+
if (!name || !email) {
|
|
2710
|
+
return null;
|
|
2711
|
+
}
|
|
2712
|
+
return { name, email };
|
|
2713
|
+
}
|
|
2714
|
+
function parseCommitLine(line) {
|
|
2715
|
+
const parts = line.split("\0");
|
|
2716
|
+
if (parts.length < 7) {
|
|
2717
|
+
return null;
|
|
2718
|
+
}
|
|
2719
|
+
return {
|
|
2720
|
+
sha: parts[0],
|
|
2721
|
+
author: { name: parts[2], email: parts[1] },
|
|
2722
|
+
committer: { name: parts[4], email: parts[3] },
|
|
2723
|
+
coAuthors: parts.slice(7).map(parseCoAuthorValue).filter((v) => v !== null),
|
|
2724
|
+
timestamp: parseInt(parts[5], 10),
|
|
2725
|
+
message: parts[6]
|
|
2726
|
+
};
|
|
2727
|
+
}
|
|
2728
|
+
var PrepareGitBlameMessageZ, PrepareGitBlameResponseMessageZ, CommitMetadataZ, LineToCommitMapZ, CommitMetadataMapZ, BlameInfoZ, LineRangeZ, PrContextZ, PrepareCommitBlameMessageZ, BlameLineInfoZ, FileBlameDataZ, ChunkFetchResultZ, FileBlameResponseEntryZ, CommitBlameDataZ, CommitInfoZ, GitIdentityZ, COMMIT_LOG_FORMAT, CommitDataZ, PrDiffDataZ, PrStatsZ, CommitsManifestZ, BlameLineEntryZ, BlameLinesDataZ, PrepareCommitBlameResponseMessageZ;
|
|
2729
|
+
var init_gitBlameTypes = __esm({
|
|
2730
|
+
"src/utils/blame/gitBlameTypes.ts"() {
|
|
2731
|
+
"use strict";
|
|
2732
|
+
PrepareGitBlameMessageZ = z18.object({
|
|
2733
|
+
reportId: z18.string(),
|
|
2734
|
+
repoArchivePath: z18.string()
|
|
2735
|
+
});
|
|
2736
|
+
PrepareGitBlameResponseMessageZ = z18.object({
|
|
2737
|
+
reportId: z18.string()
|
|
2738
|
+
});
|
|
2739
|
+
CommitMetadataZ = z18.object({
|
|
2740
|
+
author: z18.string().optional(),
|
|
2741
|
+
"author-mail": z18.string().optional(),
|
|
2742
|
+
"author-time": z18.string().optional(),
|
|
2743
|
+
"author-tz": z18.string().optional(),
|
|
2744
|
+
committer: z18.string().optional(),
|
|
2745
|
+
"committer-mail": z18.string().optional(),
|
|
2746
|
+
"committer-time": z18.string().optional(),
|
|
2747
|
+
"committer-tz": z18.string().optional(),
|
|
2748
|
+
summary: z18.string().optional(),
|
|
2749
|
+
filename: z18.string().optional()
|
|
2750
|
+
});
|
|
2751
|
+
LineToCommitMapZ = z18.record(z18.string(), z18.string());
|
|
2752
|
+
CommitMetadataMapZ = z18.record(z18.string(), CommitMetadataZ);
|
|
2753
|
+
BlameInfoZ = z18.object({
|
|
2754
|
+
lineToCommit: LineToCommitMapZ,
|
|
2755
|
+
commitMetadata: CommitMetadataMapZ
|
|
2756
|
+
});
|
|
2757
|
+
LineRangeZ = z18.object({
|
|
2758
|
+
/** First line in chunk (1-indexed) */
|
|
2759
|
+
start: z18.number(),
|
|
2760
|
+
/** Last line in chunk (inclusive) */
|
|
2761
|
+
end: z18.number()
|
|
2762
|
+
});
|
|
2763
|
+
PrContextZ = z18.object({
|
|
2764
|
+
prNumber: z18.number(),
|
|
2765
|
+
repositoryUrl: z18.string(),
|
|
2766
|
+
organizationId: z18.string(),
|
|
2767
|
+
userEmail: z18.string(),
|
|
2768
|
+
source: z18.enum(["pr", "github"]),
|
|
2769
|
+
githubContext: z18.object({
|
|
2770
|
+
prNumber: z18.number(),
|
|
2771
|
+
installationId: z18.number(),
|
|
2772
|
+
repositoryURL: z18.string()
|
|
2773
|
+
}).optional()
|
|
2774
|
+
});
|
|
2775
|
+
PrepareCommitBlameMessageZ = z18.object({
|
|
2776
|
+
/** Commit blame request ID from database (for tracking and updating status) */
|
|
2777
|
+
commitBlameRequestId: z18.string(),
|
|
2778
|
+
/** Organization ID (for org-scoped caching) */
|
|
2779
|
+
organizationId: z18.string(),
|
|
2780
|
+
/** Full repository URL (e.g., https://github.com/org/repo) */
|
|
2781
|
+
repositoryUrl: z18.string(),
|
|
2782
|
+
/** Commit SHA to analyze (typically PR head commit) */
|
|
2783
|
+
commitSha: z18.string(),
|
|
2784
|
+
/** Authentication headers for repository access (e.g., GitHub token) */
|
|
2785
|
+
extraHeaders: z18.record(z18.string(), z18.string()).default({}),
|
|
2786
|
+
// --- PR analysis fields ---
|
|
2787
|
+
/** Target branch name (from getPr() base.ref). When set, enables PR analysis mode. */
|
|
2788
|
+
targetBranch: z18.string().optional(),
|
|
2789
|
+
/** Context for triggering blame attribution analysis after SCM agent completes. */
|
|
2790
|
+
prContext: PrContextZ.optional(),
|
|
2791
|
+
/** User email for blame attribution analysis trigger context (used for both PR and single commit flows). */
|
|
2792
|
+
userEmail: z18.string().optional()
|
|
2793
|
+
});
|
|
2794
|
+
BlameLineInfoZ = z18.object({
|
|
2795
|
+
/** Line number as it appeared in the introducing commit */
|
|
2796
|
+
originalLineNumber: z18.number(),
|
|
2797
|
+
/** Commit SHA that introduced this line */
|
|
2798
|
+
commitSha: z18.string(),
|
|
2799
|
+
/** Author name for this line */
|
|
2800
|
+
authorName: z18.string().optional(),
|
|
2801
|
+
/** Author email for this line */
|
|
2802
|
+
authorEmail: z18.string().optional()
|
|
2803
|
+
}).nullable();
|
|
2804
|
+
FileBlameDataZ = z18.array(BlameLineInfoZ);
|
|
2805
|
+
ChunkFetchResultZ = z18.object({
|
|
2806
|
+
filePath: z18.string(),
|
|
2807
|
+
lines: z18.array(z18.number()),
|
|
2808
|
+
data: FileBlameDataZ.nullable()
|
|
2809
|
+
});
|
|
2810
|
+
FileBlameResponseEntryZ = z18.object({
|
|
2811
|
+
/** Chunk index (0 for small files, 0-N for large file chunks) */
|
|
2812
|
+
chunkIndex: z18.number(),
|
|
2813
|
+
/** Blame data array (1-indexed, index 0 is null) */
|
|
2814
|
+
blameData: FileBlameDataZ
|
|
2815
|
+
});
|
|
2816
|
+
CommitBlameDataZ = z18.record(
|
|
2817
|
+
z18.string(),
|
|
2818
|
+
// fileName
|
|
2819
|
+
z18.array(FileBlameResponseEntryZ)
|
|
2820
|
+
);
|
|
2821
|
+
CommitInfoZ = z18.object({
|
|
2822
|
+
/** Number of parent commits (1 = normal commit, 2+ = merge commit, null = failed to determine) */
|
|
2823
|
+
parentCount: z18.number().nullable()
|
|
2824
|
+
});
|
|
2825
|
+
GitIdentityZ = z18.object({
|
|
2826
|
+
name: z18.string(),
|
|
2827
|
+
email: z18.string()
|
|
2828
|
+
});
|
|
2829
|
+
COMMIT_LOG_FORMAT = "%H%x00%ae%x00%an%x00%ce%x00%cn%x00%at%x00%s%x00%(trailers:key=Co-authored-by,valueonly,separator=%x00)";
|
|
2830
|
+
CommitDataZ = z18.object({
|
|
2831
|
+
diff: z18.string(),
|
|
2832
|
+
author: GitIdentityZ,
|
|
2833
|
+
committer: GitIdentityZ,
|
|
2834
|
+
coAuthors: z18.array(GitIdentityZ),
|
|
2835
|
+
timestamp: z18.number(),
|
|
2836
|
+
// Unix timestamp in seconds
|
|
2837
|
+
message: z18.string().optional(),
|
|
2838
|
+
parentCount: z18.number().nullable()
|
|
2839
|
+
});
|
|
2840
|
+
PrDiffDataZ = z18.object({
|
|
2841
|
+
diff: z18.string()
|
|
2842
|
+
});
|
|
2843
|
+
PrStatsZ = z18.object({
|
|
2844
|
+
additions: z18.number(),
|
|
2845
|
+
deletions: z18.number()
|
|
2846
|
+
});
|
|
2847
|
+
CommitsManifestZ = z18.object({
|
|
2848
|
+
commits: z18.array(z18.string())
|
|
2849
|
+
// Array of commit SHAs in order
|
|
2850
|
+
});
|
|
2851
|
+
BlameLineEntryZ = z18.object({
|
|
2852
|
+
file: z18.string(),
|
|
2853
|
+
line: z18.number(),
|
|
2854
|
+
originalCommitSha: z18.string(),
|
|
2855
|
+
originalLineNumber: z18.number()
|
|
2856
|
+
});
|
|
2857
|
+
BlameLinesDataZ = z18.object({
|
|
2858
|
+
lines: z18.array(BlameLineEntryZ)
|
|
2859
|
+
});
|
|
2860
|
+
PrepareCommitBlameResponseMessageZ = z18.object({
|
|
2861
|
+
/** Commit blame request ID (matches request, used to update specific DB record) */
|
|
2862
|
+
commitBlameRequestId: z18.string(),
|
|
2863
|
+
/** Organization ID (matches request) */
|
|
2864
|
+
organizationId: z18.string(),
|
|
2865
|
+
/** Repository URL (matches request) */
|
|
2866
|
+
repositoryUrl: z18.string(),
|
|
2867
|
+
/** Commit SHA analyzed (matches request) */
|
|
2868
|
+
commitSha: z18.string(),
|
|
2869
|
+
/** Processing status */
|
|
2870
|
+
status: z18.enum(["success", "failure"]),
|
|
2871
|
+
/** Error message (only present if status is 'failure') */
|
|
2872
|
+
error: z18.string().optional(),
|
|
2873
|
+
/**
|
|
2874
|
+
* Blame data for all processed files/chunks.
|
|
2875
|
+
* Empty dictionary if status is 'failure'.
|
|
2876
|
+
* Contains line mappings as arrays if status is 'success'.
|
|
2877
|
+
*/
|
|
2878
|
+
blameData: CommitBlameDataZ,
|
|
2879
|
+
/**
|
|
2880
|
+
* Info about each commit referenced in the blame data plus the head commit.
|
|
2881
|
+
* Keyed by commit SHA, deduplicated.
|
|
2882
|
+
* Empty dictionary if status is 'failure'.
|
|
2883
|
+
*/
|
|
2884
|
+
commits: z18.record(z18.string(), CommitInfoZ).default({}),
|
|
2885
|
+
// --- New PR diff computation response fields ---
|
|
2886
|
+
/** S3 paths for commit-level data (commitSha → S3 key). Present in PR analysis mode and single commit mode. */
|
|
2887
|
+
commitDataS3Paths: z18.record(z18.string(), z18.string()).optional(),
|
|
2888
|
+
/** S3 key for PR diff JSON. Present in PR analysis mode. */
|
|
2889
|
+
prDiffS3Path: z18.string().optional(),
|
|
2890
|
+
/** S3 key for commits manifest. Present in PR analysis mode. */
|
|
2891
|
+
commitsManifestS3Path: z18.string().optional(),
|
|
2892
|
+
/** S3 key for per-line targeted blame data. Present in PR analysis mode. */
|
|
2893
|
+
blameLinesS3Path: z18.string().optional(),
|
|
2894
|
+
/** S3 key for PR stats (additions/deletions). Present in PR analysis mode. */
|
|
2895
|
+
prStatsS3Path: z18.string().optional(),
|
|
2896
|
+
/** PR context passed through from request for response handler. */
|
|
2897
|
+
prContext: PrContextZ.optional(),
|
|
2898
|
+
/** PR title from the request metadata (passed through). */
|
|
2899
|
+
prTitle: z18.string().optional(),
|
|
2900
|
+
/** User email passed through from request for single commit blame attribution analysis trigger. */
|
|
2901
|
+
userEmail: z18.string().optional()
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
|
|
2692
2906
|
// src/features/analysis/scm/services/ExcludedDirs.ts
|
|
2693
2907
|
var EXCLUDED_DIRS;
|
|
2694
2908
|
var init_ExcludedDirs = __esm({
|
|
@@ -3361,6 +3575,7 @@ var init_GitService = __esm({
|
|
|
3361
3575
|
"src/features/analysis/scm/services/GitService.ts"() {
|
|
3362
3576
|
"use strict";
|
|
3363
3577
|
init_configs();
|
|
3578
|
+
init_gitBlameTypes();
|
|
3364
3579
|
init_urlParser2();
|
|
3365
3580
|
init_FileUtils();
|
|
3366
3581
|
MAX_COMMIT_DIFF_SIZE_BYTES = 3 * 1024 * 1024;
|
|
@@ -3857,7 +4072,7 @@ ${rootContent}`;
|
|
|
3857
4072
|
const DIFF_DELIMITER = "---MOBB_DIFF_START---";
|
|
3858
4073
|
const output = await this.git.show([
|
|
3859
4074
|
commitSha,
|
|
3860
|
-
`--format
|
|
4075
|
+
`--format=${COMMIT_LOG_FORMAT}%n${DIFF_DELIMITER}`,
|
|
3861
4076
|
"--patch"
|
|
3862
4077
|
]);
|
|
3863
4078
|
const delimiterIndex = output.indexOf(DIFF_DELIMITER);
|
|
@@ -3878,16 +4093,16 @@ ${rootContent}`;
|
|
|
3878
4093
|
});
|
|
3879
4094
|
return null;
|
|
3880
4095
|
}
|
|
3881
|
-
const
|
|
3882
|
-
|
|
4096
|
+
const metadataLine = metadataOutput.trim();
|
|
4097
|
+
const parsed = parseCommitLine(metadataLine);
|
|
4098
|
+
if (!parsed) {
|
|
3883
4099
|
this.log("[GitService] Unexpected metadata format", "warning", {
|
|
3884
4100
|
commitSha,
|
|
3885
|
-
|
|
4101
|
+
metadataLine
|
|
3886
4102
|
});
|
|
3887
4103
|
return null;
|
|
3888
4104
|
}
|
|
3889
|
-
const
|
|
3890
|
-
const timestamp = new Date(timestampStr);
|
|
4105
|
+
const timestamp = new Date(parsed.timestamp * 1e3);
|
|
3891
4106
|
this.log("[GitService] Local commit data retrieved", "debug", {
|
|
3892
4107
|
commitSha,
|
|
3893
4108
|
diffSizeBytes,
|
|
@@ -3895,7 +4110,10 @@ ${rootContent}`;
|
|
|
3895
4110
|
});
|
|
3896
4111
|
return {
|
|
3897
4112
|
diff,
|
|
3898
|
-
timestamp
|
|
4113
|
+
timestamp,
|
|
4114
|
+
author: parsed.author,
|
|
4115
|
+
committer: parsed.committer,
|
|
4116
|
+
coAuthors: parsed.coAuthors
|
|
3899
4117
|
};
|
|
3900
4118
|
} catch (error) {
|
|
3901
4119
|
const errorMessage = `Failed to get local commit data: ${error.message}`;
|
|
@@ -3908,7 +4126,7 @@ ${rootContent}`;
|
|
|
3908
4126
|
});
|
|
3909
4127
|
|
|
3910
4128
|
// src/index.ts
|
|
3911
|
-
import
|
|
4129
|
+
import Debug20 from "debug";
|
|
3912
4130
|
import { hideBin } from "yargs/helpers";
|
|
3913
4131
|
|
|
3914
4132
|
// src/args/yargs.ts
|
|
@@ -7381,34 +7599,34 @@ import querystring2 from "querystring";
|
|
|
7381
7599
|
import * as bitbucketPkgNode from "bitbucket";
|
|
7382
7600
|
import bitbucketPkg from "bitbucket";
|
|
7383
7601
|
import Debug2 from "debug";
|
|
7384
|
-
import { z as
|
|
7602
|
+
import { z as z20 } from "zod";
|
|
7385
7603
|
|
|
7386
7604
|
// src/features/analysis/scm/bitbucket/validation.ts
|
|
7387
|
-
import { z as
|
|
7388
|
-
var BitbucketAuthResultZ =
|
|
7389
|
-
access_token:
|
|
7390
|
-
token_type:
|
|
7391
|
-
refresh_token:
|
|
7605
|
+
import { z as z19 } from "zod";
|
|
7606
|
+
var BitbucketAuthResultZ = z19.object({
|
|
7607
|
+
access_token: z19.string(),
|
|
7608
|
+
token_type: z19.string(),
|
|
7609
|
+
refresh_token: z19.string()
|
|
7392
7610
|
});
|
|
7393
7611
|
|
|
7394
7612
|
// src/features/analysis/scm/bitbucket/bitbucket.ts
|
|
7395
7613
|
var debug2 = Debug2("scm:bitbucket");
|
|
7396
7614
|
var BITBUCKET_HOSTNAME = "bitbucket.org";
|
|
7397
|
-
var TokenExpiredErrorZ =
|
|
7398
|
-
status:
|
|
7399
|
-
error:
|
|
7400
|
-
type:
|
|
7401
|
-
error:
|
|
7402
|
-
message:
|
|
7615
|
+
var TokenExpiredErrorZ = z20.object({
|
|
7616
|
+
status: z20.number(),
|
|
7617
|
+
error: z20.object({
|
|
7618
|
+
type: z20.string(),
|
|
7619
|
+
error: z20.object({
|
|
7620
|
+
message: z20.string()
|
|
7403
7621
|
})
|
|
7404
7622
|
})
|
|
7405
7623
|
});
|
|
7406
7624
|
var BITBUCKET_ACCESS_TOKEN_URL = `https://${BITBUCKET_HOSTNAME}/site/oauth2/access_token`;
|
|
7407
7625
|
var MAX_BITBUCKET_PR_BODY_LENGTH = 32768;
|
|
7408
|
-
var BitbucketParseResultZ =
|
|
7409
|
-
organization:
|
|
7410
|
-
repoName:
|
|
7411
|
-
hostname:
|
|
7626
|
+
var BitbucketParseResultZ = z20.object({
|
|
7627
|
+
organization: z20.string(),
|
|
7628
|
+
repoName: z20.string(),
|
|
7629
|
+
hostname: z20.literal(BITBUCKET_HOSTNAME)
|
|
7412
7630
|
});
|
|
7413
7631
|
function parseBitbucketOrganizationAndRepo(bitbucketUrl) {
|
|
7414
7632
|
const parsedGitHubUrl = normalizeUrl(bitbucketUrl);
|
|
@@ -7468,7 +7686,7 @@ function getBitbucketSdk(params) {
|
|
|
7468
7686
|
if (!res.data.values) {
|
|
7469
7687
|
return [];
|
|
7470
7688
|
}
|
|
7471
|
-
return res.data.values.filter((branch) => !!branch.name).map((branch) =>
|
|
7689
|
+
return res.data.values.filter((branch) => !!branch.name).map((branch) => z20.string().parse(branch.name));
|
|
7472
7690
|
},
|
|
7473
7691
|
async getIsUserCollaborator(params2) {
|
|
7474
7692
|
const { repoUrl } = params2;
|
|
@@ -7583,7 +7801,7 @@ function getBitbucketSdk(params) {
|
|
|
7583
7801
|
return GetReferenceResultZ.parse({
|
|
7584
7802
|
sha: tagRes.data.target?.hash,
|
|
7585
7803
|
type: "TAG" /* TAG */,
|
|
7586
|
-
date: new Date(
|
|
7804
|
+
date: new Date(z20.string().parse(tagRes.data.target?.date))
|
|
7587
7805
|
});
|
|
7588
7806
|
},
|
|
7589
7807
|
async getBranchRef(params2) {
|
|
@@ -7591,7 +7809,7 @@ function getBitbucketSdk(params) {
|
|
|
7591
7809
|
return GetReferenceResultZ.parse({
|
|
7592
7810
|
sha: getBranchRes.target?.hash,
|
|
7593
7811
|
type: "BRANCH" /* BRANCH */,
|
|
7594
|
-
date: new Date(
|
|
7812
|
+
date: new Date(z20.string().parse(getBranchRes.target?.date))
|
|
7595
7813
|
});
|
|
7596
7814
|
},
|
|
7597
7815
|
async getCommitRef(params2) {
|
|
@@ -7599,13 +7817,13 @@ function getBitbucketSdk(params) {
|
|
|
7599
7817
|
return GetReferenceResultZ.parse({
|
|
7600
7818
|
sha: getCommitRes.hash,
|
|
7601
7819
|
type: "COMMIT" /* COMMIT */,
|
|
7602
|
-
date: new Date(
|
|
7820
|
+
date: new Date(z20.string().parse(getCommitRes.date))
|
|
7603
7821
|
});
|
|
7604
7822
|
},
|
|
7605
7823
|
async getDownloadUrl({ url, sha }) {
|
|
7606
7824
|
this.getReferenceData({ ref: sha, url });
|
|
7607
7825
|
const repoRes = await this.getRepo({ repoUrl: url });
|
|
7608
|
-
const parsedRepoUrl =
|
|
7826
|
+
const parsedRepoUrl = z20.string().url().parse(repoRes.links?.html?.href);
|
|
7609
7827
|
return `${parsedRepoUrl}/get/${sha}.zip`;
|
|
7610
7828
|
},
|
|
7611
7829
|
async getPullRequest(params2) {
|
|
@@ -7670,7 +7888,7 @@ async function validateBitbucketParams(params) {
|
|
|
7670
7888
|
}
|
|
7671
7889
|
async function getUsersWorkspacesSlugs(bitbucketClient) {
|
|
7672
7890
|
const res = await bitbucketClient.workspaces.getWorkspaces({});
|
|
7673
|
-
return res.data.values?.map((v) =>
|
|
7891
|
+
return res.data.values?.map((v) => z20.string().parse(v.slug));
|
|
7674
7892
|
}
|
|
7675
7893
|
async function getAllUsersRepositories(bitbucketClient) {
|
|
7676
7894
|
const userWorkspacesSlugs = await getUsersWorkspacesSlugs(bitbucketClient);
|
|
@@ -7698,10 +7916,10 @@ async function getRepositoriesByWorkspace(bitbucketClient, { workspaceSlug }) {
|
|
|
7698
7916
|
|
|
7699
7917
|
// src/features/analysis/scm/bitbucket/BitbucketSCMLib.ts
|
|
7700
7918
|
import { setTimeout as setTimeout3 } from "timers/promises";
|
|
7701
|
-
import { z as
|
|
7919
|
+
import { z as z21 } from "zod";
|
|
7702
7920
|
function getUserAndPassword(token) {
|
|
7703
7921
|
const [username, password] = token.split(":");
|
|
7704
|
-
const safePasswordAndUsername =
|
|
7922
|
+
const safePasswordAndUsername = z21.object({ username: z21.string(), password: z21.string() }).parse({ username, password });
|
|
7705
7923
|
return {
|
|
7706
7924
|
username: safePasswordAndUsername.username,
|
|
7707
7925
|
password: safePasswordAndUsername.password
|
|
@@ -7773,7 +7991,7 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7773
7991
|
return { username, password, authType };
|
|
7774
7992
|
}
|
|
7775
7993
|
case "token": {
|
|
7776
|
-
return { authType, token:
|
|
7994
|
+
return { authType, token: z21.string().parse(this.accessToken) };
|
|
7777
7995
|
}
|
|
7778
7996
|
case "public":
|
|
7779
7997
|
return { authType };
|
|
@@ -7787,7 +8005,7 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7787
8005
|
...params,
|
|
7788
8006
|
repoUrl: this.url
|
|
7789
8007
|
});
|
|
7790
|
-
return String(
|
|
8008
|
+
return String(z21.number().parse(pullRequestRes.id));
|
|
7791
8009
|
} catch (e) {
|
|
7792
8010
|
console.warn(
|
|
7793
8011
|
`error creating pull request for BB. Try number ${String(i + 1).replace(/\n|\r/g, "")}`,
|
|
@@ -7872,7 +8090,7 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7872
8090
|
async getUsername() {
|
|
7873
8091
|
this._validateAccessToken();
|
|
7874
8092
|
const res = await this.bitbucketSdk.getUser();
|
|
7875
|
-
return
|
|
8093
|
+
return z21.string().parse(res["username"]);
|
|
7876
8094
|
}
|
|
7877
8095
|
async getSubmitRequestStatus(_scmSubmitRequestId) {
|
|
7878
8096
|
this._validateAccessTokenAndUrl();
|
|
@@ -7898,7 +8116,7 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7898
8116
|
async getRepoDefaultBranch() {
|
|
7899
8117
|
this._validateUrl();
|
|
7900
8118
|
const repoRes = await this.bitbucketSdk.getRepo({ repoUrl: this.url });
|
|
7901
|
-
return
|
|
8119
|
+
return z21.string().parse(repoRes.mainbranch?.name);
|
|
7902
8120
|
}
|
|
7903
8121
|
getSubmitRequestUrl(submitRequestId) {
|
|
7904
8122
|
this._validateUrl();
|
|
@@ -7964,7 +8182,7 @@ var REPORT_DEFAULT_FILE_NAME = "report.json";
|
|
|
7964
8182
|
init_env();
|
|
7965
8183
|
|
|
7966
8184
|
// src/features/analysis/scm/github/GithubSCMLib.ts
|
|
7967
|
-
import { z as
|
|
8185
|
+
import { z as z22 } from "zod";
|
|
7968
8186
|
init_client_generates();
|
|
7969
8187
|
|
|
7970
8188
|
// src/features/analysis/scm/utils/cursorValidation.ts
|
|
@@ -8949,7 +9167,7 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
8949
9167
|
owner,
|
|
8950
9168
|
repo
|
|
8951
9169
|
});
|
|
8952
|
-
return
|
|
9170
|
+
return z22.string().parse(prRes.data);
|
|
8953
9171
|
}
|
|
8954
9172
|
async getRepoList(_scmOrg) {
|
|
8955
9173
|
this._validateAccessToken();
|
|
@@ -9402,11 +9620,11 @@ var contextLogger = {
|
|
|
9402
9620
|
init_env();
|
|
9403
9621
|
|
|
9404
9622
|
// src/features/analysis/scm/gitlab/types.ts
|
|
9405
|
-
import { z as
|
|
9406
|
-
var GitlabAuthResultZ =
|
|
9407
|
-
access_token:
|
|
9408
|
-
token_type:
|
|
9409
|
-
refresh_token:
|
|
9623
|
+
import { z as z23 } from "zod";
|
|
9624
|
+
var GitlabAuthResultZ = z23.object({
|
|
9625
|
+
access_token: z23.string(),
|
|
9626
|
+
token_type: z23.string(),
|
|
9627
|
+
refresh_token: z23.string()
|
|
9410
9628
|
});
|
|
9411
9629
|
|
|
9412
9630
|
// src/features/analysis/scm/gitlab/gitlab.ts
|
|
@@ -10442,7 +10660,7 @@ var GitlabSCMLib = class extends SCMLib {
|
|
|
10442
10660
|
};
|
|
10443
10661
|
|
|
10444
10662
|
// src/features/analysis/scm/scmFactory.ts
|
|
10445
|
-
import { z as
|
|
10663
|
+
import { z as z24 } from "zod";
|
|
10446
10664
|
|
|
10447
10665
|
// src/features/analysis/scm/StubSCMLib.ts
|
|
10448
10666
|
var StubSCMLib = class extends SCMLib {
|
|
@@ -10579,7 +10797,7 @@ async function createScmLib({ url, accessToken, scmType, scmOrg }, { propagateEx
|
|
|
10579
10797
|
if (e instanceof InvalidRepoUrlError && url) {
|
|
10580
10798
|
throw new RepoNoTokenAccessError(
|
|
10581
10799
|
"no access to repo",
|
|
10582
|
-
scmLibScmTypeToScmType[
|
|
10800
|
+
scmLibScmTypeToScmType[z24.nativeEnum(ScmLibScmType).parse(scmType)]
|
|
10583
10801
|
);
|
|
10584
10802
|
}
|
|
10585
10803
|
console.error(`error validating scm: ${scmType} `, e);
|
|
@@ -11169,7 +11387,7 @@ import path6 from "path";
|
|
|
11169
11387
|
import chalk from "chalk";
|
|
11170
11388
|
import Debug4 from "debug";
|
|
11171
11389
|
import * as dotenv from "dotenv";
|
|
11172
|
-
import { z as
|
|
11390
|
+
import { z as z25 } from "zod";
|
|
11173
11391
|
var debug5 = Debug4("mobbdev:constants");
|
|
11174
11392
|
var runtimeConfigPath = path6.join(
|
|
11175
11393
|
getModuleRootDir(),
|
|
@@ -11214,17 +11432,17 @@ var scannerToVulnerabilityReportVendorEnum = {
|
|
|
11214
11432
|
[SCANNERS.Semgrep]: "semgrep" /* Semgrep */,
|
|
11215
11433
|
[SCANNERS.Datadog]: "datadog" /* Datadog */
|
|
11216
11434
|
};
|
|
11217
|
-
var SupportedScannersZ =
|
|
11218
|
-
var envVariablesSchema =
|
|
11435
|
+
var SupportedScannersZ = z25.enum([SCANNERS.Checkmarx, SCANNERS.Snyk]);
|
|
11436
|
+
var envVariablesSchema = z25.object({
|
|
11219
11437
|
// These have safe defaults for production - the VS Code extension passes explicit URLs
|
|
11220
|
-
WEB_APP_URL:
|
|
11221
|
-
API_URL:
|
|
11438
|
+
WEB_APP_URL: z25.string().optional().default(DEFAULT_WEB_APP_URL),
|
|
11439
|
+
API_URL: z25.string().optional().default(DEFAULT_API_URL),
|
|
11222
11440
|
// These are only needed for local development with Hasura
|
|
11223
|
-
HASURA_ACCESS_KEY:
|
|
11224
|
-
LOCAL_GRAPHQL_ENDPOINT:
|
|
11441
|
+
HASURA_ACCESS_KEY: z25.string().optional().default(""),
|
|
11442
|
+
LOCAL_GRAPHQL_ENDPOINT: z25.string().optional().default(""),
|
|
11225
11443
|
// Proxy settings
|
|
11226
|
-
HTTP_PROXY:
|
|
11227
|
-
HTTPS_PROXY:
|
|
11444
|
+
HTTP_PROXY: z25.string().optional().default(""),
|
|
11445
|
+
HTTPS_PROXY: z25.string().optional().default("")
|
|
11228
11446
|
});
|
|
11229
11447
|
var envVariables = envVariablesSchema.parse(process.env);
|
|
11230
11448
|
debug5("config %o", envVariables);
|
|
@@ -11469,17 +11687,17 @@ import path9 from "path";
|
|
|
11469
11687
|
import { env as env2 } from "process";
|
|
11470
11688
|
import { pipeline } from "stream/promises";
|
|
11471
11689
|
import chalk6 from "chalk";
|
|
11472
|
-
import
|
|
11690
|
+
import Debug19 from "debug";
|
|
11473
11691
|
import extract from "extract-zip";
|
|
11474
11692
|
import { createSpinner as createSpinner4 } from "nanospinner";
|
|
11475
11693
|
import fetch4 from "node-fetch";
|
|
11476
11694
|
import open3 from "open";
|
|
11477
11695
|
import tmp2 from "tmp";
|
|
11478
|
-
import { z as
|
|
11696
|
+
import { z as z30 } from "zod";
|
|
11479
11697
|
|
|
11480
11698
|
// src/commands/handleMobbLogin.ts
|
|
11481
11699
|
import chalk3 from "chalk";
|
|
11482
|
-
import
|
|
11700
|
+
import Debug7 from "debug";
|
|
11483
11701
|
|
|
11484
11702
|
// src/commands/AuthManager.ts
|
|
11485
11703
|
import crypto from "crypto";
|
|
@@ -11487,10 +11705,8 @@ import os from "os";
|
|
|
11487
11705
|
import open from "open";
|
|
11488
11706
|
|
|
11489
11707
|
// src/features/analysis/graphql/gql.ts
|
|
11490
|
-
import
|
|
11491
|
-
import Debug5 from "debug";
|
|
11708
|
+
import Debug6 from "debug";
|
|
11492
11709
|
import { GraphQLClient } from "graphql-request";
|
|
11493
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
11494
11710
|
import { v4 as uuidv4 } from "uuid";
|
|
11495
11711
|
|
|
11496
11712
|
// src/mcp/core/Errors.ts
|
|
@@ -11565,6 +11781,71 @@ var _ReportDigestError = class _ReportDigestError extends Error {
|
|
|
11565
11781
|
__publicField(_ReportDigestError, "defaultMessage", "\u{1F575}\uFE0F\u200D\u2642\uFE0F Digesting report failed. Please verify that the file provided is of a valid supported report format.");
|
|
11566
11782
|
var ReportDigestError = _ReportDigestError;
|
|
11567
11783
|
|
|
11784
|
+
// src/utils/proxy.ts
|
|
11785
|
+
import fetchOrig from "cross-fetch";
|
|
11786
|
+
import Debug5 from "debug";
|
|
11787
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
11788
|
+
|
|
11789
|
+
// src/utils/url.ts
|
|
11790
|
+
function httpToWsUrl(url) {
|
|
11791
|
+
const parsed = new URL(url);
|
|
11792
|
+
parsed.protocol = parsed.protocol === "https:" ? "wss:" : "ws:";
|
|
11793
|
+
return parsed.toString();
|
|
11794
|
+
}
|
|
11795
|
+
|
|
11796
|
+
// src/utils/proxy.ts
|
|
11797
|
+
var debug6 = Debug5("mobbdev:proxy");
|
|
11798
|
+
function getHttpProxy() {
|
|
11799
|
+
return process.env["HTTPS_PROXY"] || process.env["HTTP_PROXY"] || "";
|
|
11800
|
+
}
|
|
11801
|
+
function getHttpProxyOnly() {
|
|
11802
|
+
return process.env["HTTP_PROXY"] || "";
|
|
11803
|
+
}
|
|
11804
|
+
function getProxyAgent(url) {
|
|
11805
|
+
try {
|
|
11806
|
+
const parsedUrl = new URL(url);
|
|
11807
|
+
const hostname = parsedUrl.hostname.toLowerCase();
|
|
11808
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]") {
|
|
11809
|
+
debug6("Skipping proxy for localhost URL: %s", url);
|
|
11810
|
+
return void 0;
|
|
11811
|
+
}
|
|
11812
|
+
const noProxy = process.env["NO_PROXY"] || process.env["no_proxy"];
|
|
11813
|
+
if (noProxy) {
|
|
11814
|
+
const noProxyList = noProxy.split(",").map((h) => h.trim().toLowerCase());
|
|
11815
|
+
if (noProxyList.includes(hostname) || noProxyList.includes("*")) {
|
|
11816
|
+
debug6("Skipping proxy due to NO_PROXY for: %s", url);
|
|
11817
|
+
return void 0;
|
|
11818
|
+
}
|
|
11819
|
+
}
|
|
11820
|
+
const isHttp = parsedUrl.protocol === "http:";
|
|
11821
|
+
const isHttps = parsedUrl.protocol === "https:";
|
|
11822
|
+
const proxy = isHttps ? getHttpProxy() : isHttp ? getHttpProxyOnly() : null;
|
|
11823
|
+
if (proxy) {
|
|
11824
|
+
debug6("Using proxy %s", proxy);
|
|
11825
|
+
debug6("Proxy agent %o", proxy);
|
|
11826
|
+
return new HttpsProxyAgent(proxy);
|
|
11827
|
+
}
|
|
11828
|
+
} catch (err) {
|
|
11829
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
11830
|
+
}
|
|
11831
|
+
return void 0;
|
|
11832
|
+
}
|
|
11833
|
+
var fetchWithProxy = (url, options = {}) => {
|
|
11834
|
+
try {
|
|
11835
|
+
const agent = getProxyAgent(url.toString());
|
|
11836
|
+
if (agent) {
|
|
11837
|
+
return fetchOrig(url, {
|
|
11838
|
+
...options,
|
|
11839
|
+
// @ts-expect-error Node-fetch doesn't type 'agent', but it's valid
|
|
11840
|
+
agent
|
|
11841
|
+
});
|
|
11842
|
+
}
|
|
11843
|
+
} catch (err) {
|
|
11844
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
11845
|
+
}
|
|
11846
|
+
return fetchOrig(url, options);
|
|
11847
|
+
};
|
|
11848
|
+
|
|
11568
11849
|
// src/utils/subscribe/subscribe.ts
|
|
11569
11850
|
import { createClient } from "graphql-ws";
|
|
11570
11851
|
import WebsocketNode from "isomorphic-ws";
|
|
@@ -11593,11 +11874,11 @@ function getGraphQlHeaders(options) {
|
|
|
11593
11874
|
}
|
|
11594
11875
|
|
|
11595
11876
|
// src/utils/subscribe/subscribe.ts
|
|
11596
|
-
var DEFAULT_API_URL2 = "
|
|
11877
|
+
var DEFAULT_API_URL2 = "wss://api.mobb.ai/v1/graphql";
|
|
11597
11878
|
var SUBSCRIPTION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
11598
11879
|
function createWSClient(options) {
|
|
11599
|
-
const url = options.url || (process.env["API_URL"]
|
|
11600
|
-
const websocketImpl = options.websocket ||
|
|
11880
|
+
const url = options.url || (process.env["API_URL"] ? httpToWsUrl(process.env["API_URL"]) : DEFAULT_API_URL2);
|
|
11881
|
+
const websocketImpl = options.websocket || WebsocketNode;
|
|
11601
11882
|
const CustomWebSocket = options.proxyAgent ? (
|
|
11602
11883
|
// biome-ignore lint/suspicious/noExplicitAny: Dynamic WebSocket extension requires any cast for cross-platform compatibility
|
|
11603
11884
|
class extends websocketImpl {
|
|
@@ -11700,124 +11981,80 @@ init_client_generates();
|
|
|
11700
11981
|
|
|
11701
11982
|
// src/features/analysis/graphql/types.ts
|
|
11702
11983
|
init_client_generates();
|
|
11703
|
-
import { z as
|
|
11704
|
-
var VulnerabilityReportIssueCodeNodeZ =
|
|
11705
|
-
vulnerabilityReportIssueId:
|
|
11706
|
-
path:
|
|
11707
|
-
startLine:
|
|
11708
|
-
vulnerabilityReportIssue:
|
|
11709
|
-
fixId:
|
|
11710
|
-
category:
|
|
11711
|
-
safeIssueType:
|
|
11712
|
-
vulnerabilityReportIssueTags:
|
|
11713
|
-
|
|
11714
|
-
tag:
|
|
11984
|
+
import { z as z26 } from "zod";
|
|
11985
|
+
var VulnerabilityReportIssueCodeNodeZ = z26.object({
|
|
11986
|
+
vulnerabilityReportIssueId: z26.string(),
|
|
11987
|
+
path: z26.string(),
|
|
11988
|
+
startLine: z26.number(),
|
|
11989
|
+
vulnerabilityReportIssue: z26.object({
|
|
11990
|
+
fixId: z26.string(),
|
|
11991
|
+
category: z26.nativeEnum(Vulnerability_Report_Issue_Category_Enum),
|
|
11992
|
+
safeIssueType: z26.string(),
|
|
11993
|
+
vulnerabilityReportIssueTags: z26.array(
|
|
11994
|
+
z26.object({
|
|
11995
|
+
tag: z26.nativeEnum(Vulnerability_Report_Issue_Tag_Enum)
|
|
11715
11996
|
})
|
|
11716
11997
|
)
|
|
11717
11998
|
})
|
|
11718
11999
|
});
|
|
11719
|
-
var VulnerabilityReportIssueNoFixCodeNodeZ =
|
|
11720
|
-
vulnerabilityReportIssues:
|
|
11721
|
-
|
|
11722
|
-
id:
|
|
11723
|
-
fixId:
|
|
11724
|
-
category:
|
|
11725
|
-
safeIssueType:
|
|
11726
|
-
fpId:
|
|
11727
|
-
codeNodes:
|
|
11728
|
-
|
|
11729
|
-
path:
|
|
11730
|
-
startLine:
|
|
12000
|
+
var VulnerabilityReportIssueNoFixCodeNodeZ = z26.object({
|
|
12001
|
+
vulnerabilityReportIssues: z26.array(
|
|
12002
|
+
z26.object({
|
|
12003
|
+
id: z26.string(),
|
|
12004
|
+
fixId: z26.string().nullable(),
|
|
12005
|
+
category: z26.nativeEnum(Vulnerability_Report_Issue_Category_Enum),
|
|
12006
|
+
safeIssueType: z26.string(),
|
|
12007
|
+
fpId: z26.string().uuid().nullable(),
|
|
12008
|
+
codeNodes: z26.array(
|
|
12009
|
+
z26.object({
|
|
12010
|
+
path: z26.string(),
|
|
12011
|
+
startLine: z26.number()
|
|
11731
12012
|
})
|
|
11732
12013
|
),
|
|
11733
|
-
vulnerabilityReportIssueTags:
|
|
11734
|
-
|
|
11735
|
-
tag:
|
|
12014
|
+
vulnerabilityReportIssueTags: z26.array(
|
|
12015
|
+
z26.object({
|
|
12016
|
+
tag: z26.nativeEnum(Vulnerability_Report_Issue_Tag_Enum)
|
|
11736
12017
|
})
|
|
11737
12018
|
)
|
|
11738
12019
|
})
|
|
11739
12020
|
)
|
|
11740
12021
|
});
|
|
11741
|
-
var GetVulByNodesMetadataZ =
|
|
11742
|
-
vulnerabilityReportIssueCodeNodes:
|
|
11743
|
-
nonFixablePrVuls:
|
|
11744
|
-
aggregate:
|
|
11745
|
-
count:
|
|
12022
|
+
var GetVulByNodesMetadataZ = z26.object({
|
|
12023
|
+
vulnerabilityReportIssueCodeNodes: z26.array(VulnerabilityReportIssueCodeNodeZ),
|
|
12024
|
+
nonFixablePrVuls: z26.object({
|
|
12025
|
+
aggregate: z26.object({
|
|
12026
|
+
count: z26.number()
|
|
11746
12027
|
})
|
|
11747
12028
|
}),
|
|
11748
|
-
fixablePrVuls:
|
|
11749
|
-
aggregate:
|
|
11750
|
-
count:
|
|
12029
|
+
fixablePrVuls: z26.object({
|
|
12030
|
+
aggregate: z26.object({
|
|
12031
|
+
count: z26.number()
|
|
11751
12032
|
})
|
|
11752
12033
|
}),
|
|
11753
|
-
totalScanVulnerabilities:
|
|
11754
|
-
aggregate:
|
|
11755
|
-
count:
|
|
12034
|
+
totalScanVulnerabilities: z26.object({
|
|
12035
|
+
aggregate: z26.object({
|
|
12036
|
+
count: z26.number()
|
|
11756
12037
|
})
|
|
11757
12038
|
}),
|
|
11758
|
-
irrelevantVulnerabilityReportIssue:
|
|
12039
|
+
irrelevantVulnerabilityReportIssue: z26.array(
|
|
11759
12040
|
VulnerabilityReportIssueNoFixCodeNodeZ
|
|
11760
12041
|
)
|
|
11761
12042
|
});
|
|
11762
12043
|
|
|
11763
12044
|
// src/features/analysis/graphql/gql.ts
|
|
11764
|
-
var
|
|
12045
|
+
var debug7 = Debug6("mobbdev:gql");
|
|
11765
12046
|
var API_KEY_HEADER_NAME = "x-mobb-key";
|
|
11766
12047
|
var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
|
|
11767
|
-
function getProxyAgent(url) {
|
|
11768
|
-
try {
|
|
11769
|
-
const parsedUrl = new URL(url);
|
|
11770
|
-
const hostname = parsedUrl.hostname.toLowerCase();
|
|
11771
|
-
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]") {
|
|
11772
|
-
debug6("Skipping proxy for localhost URL: %s", url);
|
|
11773
|
-
return void 0;
|
|
11774
|
-
}
|
|
11775
|
-
const noProxy = process.env["NO_PROXY"] || process.env["no_proxy"];
|
|
11776
|
-
if (noProxy) {
|
|
11777
|
-
const noProxyList = noProxy.split(",").map((h) => h.trim().toLowerCase());
|
|
11778
|
-
if (noProxyList.includes(hostname) || noProxyList.includes("*")) {
|
|
11779
|
-
debug6("Skipping proxy due to NO_PROXY for: %s", url);
|
|
11780
|
-
return void 0;
|
|
11781
|
-
}
|
|
11782
|
-
}
|
|
11783
|
-
const isHttp = parsedUrl.protocol === "http:";
|
|
11784
|
-
const isHttps = parsedUrl.protocol === "https:";
|
|
11785
|
-
const proxy = isHttps ? HTTPS_PROXY || HTTP_PROXY : isHttp ? HTTP_PROXY : null;
|
|
11786
|
-
if (proxy) {
|
|
11787
|
-
debug6("Using proxy %s", proxy);
|
|
11788
|
-
debug6("Proxy agent %o", proxy);
|
|
11789
|
-
return new HttpsProxyAgent(proxy);
|
|
11790
|
-
}
|
|
11791
|
-
} catch (err) {
|
|
11792
|
-
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
11793
|
-
}
|
|
11794
|
-
return void 0;
|
|
11795
|
-
}
|
|
11796
|
-
var fetchWithProxy = (url, options = {}) => {
|
|
11797
|
-
try {
|
|
11798
|
-
const agent = getProxyAgent(url.toString());
|
|
11799
|
-
if (agent) {
|
|
11800
|
-
return fetchOrig(url, {
|
|
11801
|
-
...options,
|
|
11802
|
-
// @ts-expect-error Node-fetch doesn't type 'agent', but it's valid
|
|
11803
|
-
agent
|
|
11804
|
-
});
|
|
11805
|
-
}
|
|
11806
|
-
} catch (err) {
|
|
11807
|
-
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
11808
|
-
}
|
|
11809
|
-
return fetchOrig(url, options);
|
|
11810
|
-
};
|
|
11811
12048
|
var GQLClient = class {
|
|
11812
12049
|
constructor(args) {
|
|
11813
12050
|
__publicField(this, "_client");
|
|
11814
12051
|
__publicField(this, "_clientSdk");
|
|
11815
12052
|
__publicField(this, "_apiUrl");
|
|
11816
12053
|
__publicField(this, "_auth");
|
|
11817
|
-
|
|
12054
|
+
debug7(`init with ${args}`);
|
|
11818
12055
|
this._auth = args;
|
|
11819
12056
|
this._apiUrl = args.apiUrl || API_URL;
|
|
11820
|
-
|
|
12057
|
+
debug7(
|
|
11821
12058
|
"GQLClient constructor: resolved apiUrl=%s (from param: %s)",
|
|
11822
12059
|
this._apiUrl,
|
|
11823
12060
|
args.apiUrl || "fallback to API_URL constant"
|
|
@@ -11829,7 +12066,7 @@ var GQLClient = class {
|
|
|
11829
12066
|
fetch: fetchWithProxy,
|
|
11830
12067
|
requestMiddleware: (request) => {
|
|
11831
12068
|
const requestId = uuidv4();
|
|
11832
|
-
|
|
12069
|
+
debug7(
|
|
11833
12070
|
`sending API request with id: ${requestId} and with request: ${request.body}`
|
|
11834
12071
|
);
|
|
11835
12072
|
return {
|
|
@@ -11866,7 +12103,7 @@ var GQLClient = class {
|
|
|
11866
12103
|
await this.getUserInfo();
|
|
11867
12104
|
} catch (e) {
|
|
11868
12105
|
if (e?.toString().startsWith("FetchError")) {
|
|
11869
|
-
|
|
12106
|
+
debug7("verify connection failed %o", e);
|
|
11870
12107
|
return false;
|
|
11871
12108
|
}
|
|
11872
12109
|
}
|
|
@@ -11878,7 +12115,7 @@ var GQLClient = class {
|
|
|
11878
12115
|
try {
|
|
11879
12116
|
info = await this.getUserInfo();
|
|
11880
12117
|
} catch (e) {
|
|
11881
|
-
|
|
12118
|
+
debug7("verify token failed %o", e);
|
|
11882
12119
|
return false;
|
|
11883
12120
|
}
|
|
11884
12121
|
return info?.email || true;
|
|
@@ -11939,7 +12176,7 @@ var GQLClient = class {
|
|
|
11939
12176
|
try {
|
|
11940
12177
|
await this._clientSdk.CreateCommunityUser();
|
|
11941
12178
|
} catch (e) {
|
|
11942
|
-
|
|
12179
|
+
debug7("create community user failed %o", e);
|
|
11943
12180
|
}
|
|
11944
12181
|
}
|
|
11945
12182
|
async updateScmToken(args) {
|
|
@@ -12119,11 +12356,13 @@ var GQLClient = class {
|
|
|
12119
12356
|
this._auth.type === "apiKey" ? {
|
|
12120
12357
|
apiKey: this._auth.apiKey,
|
|
12121
12358
|
type: "apiKey",
|
|
12359
|
+
url: httpToWsUrl(this._apiUrl),
|
|
12122
12360
|
timeoutInMs: params.timeoutInMs,
|
|
12123
12361
|
proxyAgent: getProxyAgent(this._apiUrl)
|
|
12124
12362
|
} : {
|
|
12125
12363
|
token: this._auth.token,
|
|
12126
12364
|
type: "token",
|
|
12365
|
+
url: httpToWsUrl(this._apiUrl),
|
|
12127
12366
|
timeoutInMs: params.timeoutInMs,
|
|
12128
12367
|
proxyAgent: getProxyAgent(this._apiUrl)
|
|
12129
12368
|
}
|
|
@@ -12136,7 +12375,7 @@ var GQLClient = class {
|
|
|
12136
12375
|
const startTime = Date.now();
|
|
12137
12376
|
const maxDuration = timeoutInMs ?? 30 * 60 * 1e3;
|
|
12138
12377
|
const pollingIntervalSec = REPORT_STATE_CHECK_DELAY / 1e3;
|
|
12139
|
-
|
|
12378
|
+
debug7(
|
|
12140
12379
|
`[pollForAnalysisState] Starting polling for analysis ${analysisId}, target states: ${callbackStates.join(", ")}, interval: ${pollingIntervalSec}s`
|
|
12141
12380
|
);
|
|
12142
12381
|
let isPolling = true;
|
|
@@ -12145,7 +12384,7 @@ var GQLClient = class {
|
|
|
12145
12384
|
pollCount++;
|
|
12146
12385
|
const elapsedSec = Math.round((Date.now() - startTime) / 1e3);
|
|
12147
12386
|
if (Date.now() - startTime > maxDuration) {
|
|
12148
|
-
|
|
12387
|
+
debug7(
|
|
12149
12388
|
`[pollForAnalysisState] Timeout expired after ${pollCount} polls (${elapsedSec}s)`
|
|
12150
12389
|
);
|
|
12151
12390
|
throw new ReportDigestError(
|
|
@@ -12153,20 +12392,20 @@ var GQLClient = class {
|
|
|
12153
12392
|
`Analysis timed out after ${Math.round(maxDuration / 6e4)} minutes. Please try again or check the Mobb platform for status.`
|
|
12154
12393
|
);
|
|
12155
12394
|
}
|
|
12156
|
-
|
|
12395
|
+
debug7(
|
|
12157
12396
|
`[pollForAnalysisState] Poll #${pollCount} (elapsed: ${elapsedSec}s) - fetching analysis state...`
|
|
12158
12397
|
);
|
|
12159
12398
|
const analysis = await this.getAnalysis(analysisId);
|
|
12160
|
-
|
|
12399
|
+
debug7(
|
|
12161
12400
|
`[pollForAnalysisState] Poll #${pollCount} - current state: ${analysis.state}`
|
|
12162
12401
|
);
|
|
12163
12402
|
if (!analysis.state || analysis.state === "Failed" /* Failed */) {
|
|
12164
12403
|
const errorMessage = analysis.failReason || `Analysis failed with id: ${analysis.id}`;
|
|
12165
|
-
|
|
12404
|
+
debug7(`[pollForAnalysisState] Analysis failed: ${errorMessage}`);
|
|
12166
12405
|
throw new ReportDigestError(errorMessage, analysis.failReason ?? "");
|
|
12167
12406
|
}
|
|
12168
12407
|
if (callbackStates.includes(analysis.state)) {
|
|
12169
|
-
|
|
12408
|
+
debug7(
|
|
12170
12409
|
`[pollForAnalysisState] Target state reached: ${analysis.state} after ${pollCount} polls (${elapsedSec}s)`
|
|
12171
12410
|
);
|
|
12172
12411
|
await callback(analysis.id);
|
|
@@ -12179,7 +12418,7 @@ var GQLClient = class {
|
|
|
12179
12418
|
}
|
|
12180
12419
|
};
|
|
12181
12420
|
}
|
|
12182
|
-
|
|
12421
|
+
debug7(
|
|
12183
12422
|
`[pollForAnalysisState] State ${analysis.state} not in target states, waiting ${pollingIntervalSec}s before next poll...`
|
|
12184
12423
|
);
|
|
12185
12424
|
await sleep(REPORT_STATE_CHECK_DELAY);
|
|
@@ -12468,7 +12707,7 @@ var AuthManager = class {
|
|
|
12468
12707
|
};
|
|
12469
12708
|
|
|
12470
12709
|
// src/commands/handleMobbLogin.ts
|
|
12471
|
-
var
|
|
12710
|
+
var debug8 = Debug7("mobbdev:commands");
|
|
12472
12711
|
var LOGIN_MAX_WAIT2 = 10 * 60 * 1e3;
|
|
12473
12712
|
var LOGIN_CHECK_DELAY2 = 5 * 1e3;
|
|
12474
12713
|
var MOBB_LOGIN_REQUIRED_MSG = `\u{1F513} Login to Mobb is Required, you will be redirected to our login page, once the authorization is complete return to this prompt, ${chalk3.bgBlue(
|
|
@@ -12480,7 +12719,7 @@ async function getAuthenticatedGQLClient({
|
|
|
12480
12719
|
apiUrl,
|
|
12481
12720
|
webAppUrl
|
|
12482
12721
|
}) {
|
|
12483
|
-
|
|
12722
|
+
debug8(
|
|
12484
12723
|
"getAuthenticatedGQLClient called with: apiUrl=%s, webAppUrl=%s",
|
|
12485
12724
|
apiUrl || "undefined",
|
|
12486
12725
|
webAppUrl || "undefined"
|
|
@@ -12503,7 +12742,7 @@ async function handleMobbLogin({
|
|
|
12503
12742
|
webAppUrl,
|
|
12504
12743
|
loginContext
|
|
12505
12744
|
}) {
|
|
12506
|
-
|
|
12745
|
+
debug8(
|
|
12507
12746
|
"handleMobbLogin: resolved URLs - apiUrl=%s (from param: %s), webAppUrl=%s (from param: %s)",
|
|
12508
12747
|
apiUrl || "fallback",
|
|
12509
12748
|
apiUrl || "fallback",
|
|
@@ -12522,7 +12761,7 @@ async function handleMobbLogin({
|
|
|
12522
12761
|
return authManager.getGQLClient();
|
|
12523
12762
|
}
|
|
12524
12763
|
} catch (error) {
|
|
12525
|
-
|
|
12764
|
+
debug8("Authentication check failed:", error);
|
|
12526
12765
|
}
|
|
12527
12766
|
if (apiKey) {
|
|
12528
12767
|
createSpinner5().start().error({
|
|
@@ -12569,12 +12808,12 @@ async function handleMobbLogin({
|
|
|
12569
12808
|
}
|
|
12570
12809
|
|
|
12571
12810
|
// src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
|
|
12572
|
-
import
|
|
12811
|
+
import Debug11 from "debug";
|
|
12573
12812
|
|
|
12574
12813
|
// src/features/analysis/add_fix_comments_for_pr/utils/utils.ts
|
|
12575
|
-
import
|
|
12814
|
+
import Debug10 from "debug";
|
|
12576
12815
|
import parseDiff from "parse-diff";
|
|
12577
|
-
import { z as
|
|
12816
|
+
import { z as z28 } from "zod";
|
|
12578
12817
|
|
|
12579
12818
|
// src/features/analysis/utils/by_key.ts
|
|
12580
12819
|
function keyBy(array, keyBy2) {
|
|
@@ -12584,9 +12823,9 @@ function keyBy(array, keyBy2) {
|
|
|
12584
12823
|
}
|
|
12585
12824
|
|
|
12586
12825
|
// src/features/analysis/utils/send_report.ts
|
|
12587
|
-
import
|
|
12826
|
+
import Debug8 from "debug";
|
|
12588
12827
|
init_client_generates();
|
|
12589
|
-
var
|
|
12828
|
+
var debug9 = Debug8("mobbdev:index");
|
|
12590
12829
|
async function sendReport({
|
|
12591
12830
|
spinner,
|
|
12592
12831
|
submitVulnerabilityReportVariables,
|
|
@@ -12598,7 +12837,7 @@ async function sendReport({
|
|
|
12598
12837
|
submitVulnerabilityReportVariables
|
|
12599
12838
|
);
|
|
12600
12839
|
if (submitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
|
|
12601
|
-
|
|
12840
|
+
debug9("error submit vul report %s", submitRes);
|
|
12602
12841
|
throw new Error("\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed");
|
|
12603
12842
|
}
|
|
12604
12843
|
spinner.update({ text: progressMassages.processingVulnerabilityReport });
|
|
@@ -12610,7 +12849,7 @@ async function sendReport({
|
|
|
12610
12849
|
"Finished" /* Finished */
|
|
12611
12850
|
];
|
|
12612
12851
|
if (polling) {
|
|
12613
|
-
|
|
12852
|
+
debug9("[sendReport] Using POLLING mode for analysis state updates");
|
|
12614
12853
|
await gqlClient.pollForAnalysisState({
|
|
12615
12854
|
analysisId: submitRes.submitVulnerabilityReport.fixReportId,
|
|
12616
12855
|
callback,
|
|
@@ -12618,7 +12857,7 @@ async function sendReport({
|
|
|
12618
12857
|
timeoutInMs: VUL_REPORT_DIGEST_TIMEOUT_MS
|
|
12619
12858
|
});
|
|
12620
12859
|
} else {
|
|
12621
|
-
|
|
12860
|
+
debug9("[sendReport] Using WEBSOCKET mode for analysis state updates");
|
|
12622
12861
|
await gqlClient.subscribeToAnalysis({
|
|
12623
12862
|
subscribeToAnalysisParams: {
|
|
12624
12863
|
analysisId: submitRes.submitVulnerabilityReport.fixReportId
|
|
@@ -12661,10 +12900,10 @@ var scannerToFriendlyString = {
|
|
|
12661
12900
|
};
|
|
12662
12901
|
|
|
12663
12902
|
// src/features/analysis/add_fix_comments_for_pr/utils/buildCommentBody.ts
|
|
12664
|
-
import
|
|
12665
|
-
import { z as
|
|
12903
|
+
import Debug9 from "debug";
|
|
12904
|
+
import { z as z27 } from "zod";
|
|
12666
12905
|
init_client_generates();
|
|
12667
|
-
var
|
|
12906
|
+
var debug10 = Debug9("mobbdev:handle-finished-analysis");
|
|
12668
12907
|
var getCommitFixButton = (commitUrl) => `<a href="${commitUrl}"><img src=${COMMIT_FIX_SVG}></a>`;
|
|
12669
12908
|
function buildFixCommentBody({
|
|
12670
12909
|
fix,
|
|
@@ -12716,14 +12955,14 @@ function buildFixCommentBody({
|
|
|
12716
12955
|
});
|
|
12717
12956
|
const issueType = getIssueTypeFriendlyString(fix.safeIssueType);
|
|
12718
12957
|
const title = `# ${MobbIconMarkdown} ${issueType} fix is ready`;
|
|
12719
|
-
const validFixParseRes =
|
|
12958
|
+
const validFixParseRes = z27.object({
|
|
12720
12959
|
patchAndQuestions: PatchAndQuestionsZ,
|
|
12721
|
-
safeIssueLanguage:
|
|
12722
|
-
severityText:
|
|
12723
|
-
safeIssueType:
|
|
12960
|
+
safeIssueLanguage: z27.nativeEnum(IssueLanguage_Enum),
|
|
12961
|
+
severityText: z27.nativeEnum(Vulnerability_Severity_Enum),
|
|
12962
|
+
safeIssueType: z27.nativeEnum(IssueType_Enum)
|
|
12724
12963
|
}).safeParse(fix);
|
|
12725
12964
|
if (!validFixParseRes.success) {
|
|
12726
|
-
|
|
12965
|
+
debug10(
|
|
12727
12966
|
`fix ${fixId} has custom issue type or language, therefore the commit description will not be added`,
|
|
12728
12967
|
validFixParseRes.error
|
|
12729
12968
|
);
|
|
@@ -12787,7 +13026,7 @@ ${issuePageLink}`;
|
|
|
12787
13026
|
}
|
|
12788
13027
|
|
|
12789
13028
|
// src/features/analysis/add_fix_comments_for_pr/utils/utils.ts
|
|
12790
|
-
var
|
|
13029
|
+
var debug11 = Debug10("mobbdev:handle-finished-analysis");
|
|
12791
13030
|
function calculateRanges(integers) {
|
|
12792
13031
|
if (integers.length === 0) {
|
|
12793
13032
|
return [];
|
|
@@ -12821,7 +13060,7 @@ function deleteAllPreviousComments({
|
|
|
12821
13060
|
try {
|
|
12822
13061
|
return scm.deleteComment({ comment_id: comment.id });
|
|
12823
13062
|
} catch (e) {
|
|
12824
|
-
|
|
13063
|
+
debug11("delete comment failed %s", e);
|
|
12825
13064
|
return Promise.resolve();
|
|
12826
13065
|
}
|
|
12827
13066
|
});
|
|
@@ -12837,7 +13076,7 @@ function deleteAllPreviousGeneralPrComments(params) {
|
|
|
12837
13076
|
try {
|
|
12838
13077
|
return scm.deleteGeneralPrComment({ commentId: comment.id });
|
|
12839
13078
|
} catch (e) {
|
|
12840
|
-
|
|
13079
|
+
debug11("delete comment failed %s", e);
|
|
12841
13080
|
return Promise.resolve();
|
|
12842
13081
|
}
|
|
12843
13082
|
});
|
|
@@ -12954,7 +13193,7 @@ async function getRelevantVulenrabilitiesFromDiff(params) {
|
|
|
12954
13193
|
});
|
|
12955
13194
|
const lineAddedRanges = calculateRanges(fileNumbers);
|
|
12956
13195
|
const fileFilter = {
|
|
12957
|
-
path:
|
|
13196
|
+
path: z28.string().parse(file.to),
|
|
12958
13197
|
ranges: lineAddedRanges.map(([startLine, endLine]) => ({
|
|
12959
13198
|
endLine,
|
|
12960
13199
|
startLine
|
|
@@ -12981,7 +13220,7 @@ async function postAnalysisInsightComment(params) {
|
|
|
12981
13220
|
fixablePrVuls,
|
|
12982
13221
|
nonFixablePrVuls
|
|
12983
13222
|
} = prVulenrabilities;
|
|
12984
|
-
|
|
13223
|
+
debug11({
|
|
12985
13224
|
fixablePrVuls,
|
|
12986
13225
|
nonFixablePrVuls,
|
|
12987
13226
|
vulnerabilitiesOutsidePr,
|
|
@@ -13036,7 +13275,7 @@ ${contactUsMarkdown}`;
|
|
|
13036
13275
|
}
|
|
13037
13276
|
|
|
13038
13277
|
// src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
|
|
13039
|
-
var
|
|
13278
|
+
var debug12 = Debug11("mobbdev:handle-finished-analysis");
|
|
13040
13279
|
async function addFixCommentsForPr({
|
|
13041
13280
|
analysisId,
|
|
13042
13281
|
scm: _scm,
|
|
@@ -13048,7 +13287,7 @@ async function addFixCommentsForPr({
|
|
|
13048
13287
|
}
|
|
13049
13288
|
const scm = _scm;
|
|
13050
13289
|
const getAnalysisRes = await gqlClient.getAnalysis(analysisId);
|
|
13051
|
-
|
|
13290
|
+
debug12("getAnalysis %o", getAnalysisRes);
|
|
13052
13291
|
const {
|
|
13053
13292
|
vulnerabilityReport: {
|
|
13054
13293
|
projectId,
|
|
@@ -13158,8 +13397,8 @@ ${contextString}` : description;
|
|
|
13158
13397
|
|
|
13159
13398
|
// src/features/analysis/auto_pr_handler.ts
|
|
13160
13399
|
init_client_generates();
|
|
13161
|
-
import
|
|
13162
|
-
var
|
|
13400
|
+
import Debug12 from "debug";
|
|
13401
|
+
var debug13 = Debug12("mobbdev:handleAutoPr");
|
|
13163
13402
|
async function handleAutoPr(params) {
|
|
13164
13403
|
const {
|
|
13165
13404
|
gqlClient,
|
|
@@ -13180,7 +13419,7 @@ async function handleAutoPr(params) {
|
|
|
13180
13419
|
prId,
|
|
13181
13420
|
prStrategy: createOnePr ? "CONDENSE" /* Condense */ : "SPREAD" /* Spread */
|
|
13182
13421
|
});
|
|
13183
|
-
|
|
13422
|
+
debug13("auto pr analysis res %o", autoPrAnalysisRes);
|
|
13184
13423
|
if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
|
|
13185
13424
|
createAutoPrSpinner.error({
|
|
13186
13425
|
text: `\u{1F504} Automatic pull request failed - ${autoPrAnalysisRes.autoPrAnalysis.error}`
|
|
@@ -13202,14 +13441,14 @@ async function handleAutoPr(params) {
|
|
|
13202
13441
|
};
|
|
13203
13442
|
const callbackStates = ["Finished" /* Finished */];
|
|
13204
13443
|
if (polling) {
|
|
13205
|
-
|
|
13444
|
+
debug13("[handleAutoPr] Using POLLING mode for analysis state updates");
|
|
13206
13445
|
return await gqlClient.pollForAnalysisState({
|
|
13207
13446
|
analysisId,
|
|
13208
13447
|
callback,
|
|
13209
13448
|
callbackStates
|
|
13210
13449
|
});
|
|
13211
13450
|
} else {
|
|
13212
|
-
|
|
13451
|
+
debug13("[handleAutoPr] Using WEBSOCKET mode for analysis state updates");
|
|
13213
13452
|
return await gqlClient.subscribeToAnalysis({
|
|
13214
13453
|
subscribeToAnalysisParams: {
|
|
13215
13454
|
analysisId
|
|
@@ -13222,15 +13461,15 @@ async function handleAutoPr(params) {
|
|
|
13222
13461
|
|
|
13223
13462
|
// src/features/analysis/git.ts
|
|
13224
13463
|
init_GitService();
|
|
13225
|
-
import
|
|
13226
|
-
var
|
|
13464
|
+
import Debug13 from "debug";
|
|
13465
|
+
var debug14 = Debug13("mobbdev:git");
|
|
13227
13466
|
async function getGitInfo(srcDirPath) {
|
|
13228
|
-
|
|
13467
|
+
debug14("getting git info for %s", srcDirPath);
|
|
13229
13468
|
const gitService = new GitService(srcDirPath);
|
|
13230
13469
|
try {
|
|
13231
13470
|
const validationResult = await gitService.validateRepository();
|
|
13232
13471
|
if (!validationResult.isValid) {
|
|
13233
|
-
|
|
13472
|
+
debug14("folder is not a git repo");
|
|
13234
13473
|
return {
|
|
13235
13474
|
success: false,
|
|
13236
13475
|
hash: void 0,
|
|
@@ -13245,9 +13484,9 @@ async function getGitInfo(srcDirPath) {
|
|
|
13245
13484
|
};
|
|
13246
13485
|
} catch (e) {
|
|
13247
13486
|
if (e instanceof Error) {
|
|
13248
|
-
|
|
13487
|
+
debug14("failed to run git %o", e);
|
|
13249
13488
|
if (e.message.includes(" spawn ")) {
|
|
13250
|
-
|
|
13489
|
+
debug14("git cli not installed");
|
|
13251
13490
|
} else {
|
|
13252
13491
|
throw e;
|
|
13253
13492
|
}
|
|
@@ -13261,20 +13500,20 @@ init_configs();
|
|
|
13261
13500
|
import fs9 from "fs";
|
|
13262
13501
|
import path7 from "path";
|
|
13263
13502
|
import AdmZip from "adm-zip";
|
|
13264
|
-
import
|
|
13503
|
+
import Debug14 from "debug";
|
|
13265
13504
|
import { globby } from "globby";
|
|
13266
13505
|
import { isBinary as isBinary2 } from "istextorbinary";
|
|
13267
13506
|
import { simpleGit as simpleGit3 } from "simple-git";
|
|
13268
13507
|
import { parseStringPromise } from "xml2js";
|
|
13269
|
-
import { z as
|
|
13270
|
-
var
|
|
13271
|
-
var FPR_SOURCE_CODE_FILE_MAPPING_SCHEMA =
|
|
13272
|
-
properties:
|
|
13273
|
-
entry:
|
|
13274
|
-
|
|
13275
|
-
_:
|
|
13276
|
-
$:
|
|
13277
|
-
key:
|
|
13508
|
+
import { z as z29 } from "zod";
|
|
13509
|
+
var debug15 = Debug14("mobbdev:pack");
|
|
13510
|
+
var FPR_SOURCE_CODE_FILE_MAPPING_SCHEMA = z29.object({
|
|
13511
|
+
properties: z29.object({
|
|
13512
|
+
entry: z29.array(
|
|
13513
|
+
z29.object({
|
|
13514
|
+
_: z29.string(),
|
|
13515
|
+
$: z29.object({
|
|
13516
|
+
key: z29.string()
|
|
13278
13517
|
})
|
|
13279
13518
|
})
|
|
13280
13519
|
)
|
|
@@ -13289,7 +13528,7 @@ function getManifestFilesSuffixes() {
|
|
|
13289
13528
|
return ["package.json", "pom.xml"];
|
|
13290
13529
|
}
|
|
13291
13530
|
async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
13292
|
-
|
|
13531
|
+
debug15("pack folder %s", srcDirPath);
|
|
13293
13532
|
let git = void 0;
|
|
13294
13533
|
try {
|
|
13295
13534
|
git = simpleGit3({
|
|
@@ -13299,13 +13538,13 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
13299
13538
|
});
|
|
13300
13539
|
await git.status();
|
|
13301
13540
|
} catch (e) {
|
|
13302
|
-
|
|
13541
|
+
debug15("failed to run git %o", e);
|
|
13303
13542
|
git = void 0;
|
|
13304
13543
|
if (e instanceof Error) {
|
|
13305
13544
|
if (e.message.includes(" spawn ")) {
|
|
13306
|
-
|
|
13545
|
+
debug15("git cli not installed");
|
|
13307
13546
|
} else if (e.message.includes("not a git repository")) {
|
|
13308
|
-
|
|
13547
|
+
debug15("folder is not a git repo");
|
|
13309
13548
|
} else {
|
|
13310
13549
|
throw e;
|
|
13311
13550
|
}
|
|
@@ -13320,9 +13559,9 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
13320
13559
|
followSymbolicLinks: false,
|
|
13321
13560
|
dot: true
|
|
13322
13561
|
});
|
|
13323
|
-
|
|
13562
|
+
debug15("files found %d", filepaths.length);
|
|
13324
13563
|
const zip = new AdmZip();
|
|
13325
|
-
|
|
13564
|
+
debug15("compressing files");
|
|
13326
13565
|
for (const filepath of filepaths) {
|
|
13327
13566
|
const absFilepath = path7.join(srcDirPath, filepath.toString());
|
|
13328
13567
|
if (!isIncludeAllFiles) {
|
|
@@ -13331,12 +13570,12 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
13331
13570
|
absFilepath.toString().replaceAll(path7.win32.sep, path7.posix.sep),
|
|
13332
13571
|
vulnFiles
|
|
13333
13572
|
)) {
|
|
13334
|
-
|
|
13573
|
+
debug15("ignoring %s because it is not a vulnerability file", filepath);
|
|
13335
13574
|
continue;
|
|
13336
13575
|
}
|
|
13337
13576
|
}
|
|
13338
13577
|
if (fs9.lstatSync(absFilepath).size > MCP_MAX_FILE_SIZE) {
|
|
13339
|
-
|
|
13578
|
+
debug15("ignoring %s because the size is > 5MB", filepath);
|
|
13340
13579
|
continue;
|
|
13341
13580
|
}
|
|
13342
13581
|
let data;
|
|
@@ -13350,16 +13589,16 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
13350
13589
|
data = fs9.readFileSync(absFilepath);
|
|
13351
13590
|
}
|
|
13352
13591
|
if (isBinary2(null, data)) {
|
|
13353
|
-
|
|
13592
|
+
debug15("ignoring %s because is seems to be a binary file", filepath);
|
|
13354
13593
|
continue;
|
|
13355
13594
|
}
|
|
13356
13595
|
zip.addFile(filepath.toString(), data);
|
|
13357
13596
|
}
|
|
13358
|
-
|
|
13597
|
+
debug15("get zip file buffer");
|
|
13359
13598
|
return zip.toBuffer();
|
|
13360
13599
|
}
|
|
13361
13600
|
async function repackFpr(fprPath) {
|
|
13362
|
-
|
|
13601
|
+
debug15("repack fpr file %s", fprPath);
|
|
13363
13602
|
const zipIn = new AdmZip(fprPath);
|
|
13364
13603
|
const zipOut = new AdmZip();
|
|
13365
13604
|
const mappingXML = zipIn.readAsText("src-archive/index.xml", "utf-8");
|
|
@@ -13374,7 +13613,7 @@ async function repackFpr(fprPath) {
|
|
|
13374
13613
|
zipOut.addFile(realPath, buf);
|
|
13375
13614
|
}
|
|
13376
13615
|
}
|
|
13377
|
-
|
|
13616
|
+
debug15("get repacked zip file buffer");
|
|
13378
13617
|
return zipOut.toBuffer();
|
|
13379
13618
|
}
|
|
13380
13619
|
|
|
@@ -13445,7 +13684,7 @@ async function snykArticlePrompt() {
|
|
|
13445
13684
|
// src/features/analysis/scanners/checkmarx.ts
|
|
13446
13685
|
import { createRequire } from "module";
|
|
13447
13686
|
import chalk4 from "chalk";
|
|
13448
|
-
import
|
|
13687
|
+
import Debug16 from "debug";
|
|
13449
13688
|
import { existsSync } from "fs";
|
|
13450
13689
|
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
13451
13690
|
import { type } from "os";
|
|
@@ -13457,7 +13696,7 @@ var cxOperatingSystemSupportMessage = `Your operating system does not support ch
|
|
|
13457
13696
|
|
|
13458
13697
|
// src/utils/child_process.ts
|
|
13459
13698
|
import cp from "child_process";
|
|
13460
|
-
import
|
|
13699
|
+
import Debug15 from "debug";
|
|
13461
13700
|
import * as process2 from "process";
|
|
13462
13701
|
function createFork({ args, processPath, name }, options) {
|
|
13463
13702
|
const child = cp.fork(processPath, args, {
|
|
@@ -13475,16 +13714,16 @@ function createSpawn({ args, processPath, name, cwd }, options) {
|
|
|
13475
13714
|
return createChildProcess({ childProcess: child, name }, options);
|
|
13476
13715
|
}
|
|
13477
13716
|
function createChildProcess({ childProcess, name }, options) {
|
|
13478
|
-
const
|
|
13717
|
+
const debug21 = Debug15(`mobbdev:${name}`);
|
|
13479
13718
|
const { display } = options;
|
|
13480
13719
|
return new Promise((resolve, reject) => {
|
|
13481
13720
|
let out = "";
|
|
13482
13721
|
const onData = (chunk) => {
|
|
13483
|
-
|
|
13722
|
+
debug21(`chunk received from ${name} std ${chunk}`);
|
|
13484
13723
|
out += chunk;
|
|
13485
13724
|
};
|
|
13486
13725
|
if (!childProcess?.stdout || !childProcess?.stderr) {
|
|
13487
|
-
|
|
13726
|
+
debug21(`unable to fork ${name}`);
|
|
13488
13727
|
reject(new Error(`unable to fork ${name}`));
|
|
13489
13728
|
}
|
|
13490
13729
|
childProcess.stdout?.on("data", onData);
|
|
@@ -13494,18 +13733,18 @@ function createChildProcess({ childProcess, name }, options) {
|
|
|
13494
13733
|
childProcess.stderr?.pipe(process2.stderr);
|
|
13495
13734
|
}
|
|
13496
13735
|
childProcess.on("exit", (code) => {
|
|
13497
|
-
|
|
13736
|
+
debug21(`${name} exit code ${code}`);
|
|
13498
13737
|
resolve({ message: out, code });
|
|
13499
13738
|
});
|
|
13500
13739
|
childProcess.on("error", (err) => {
|
|
13501
|
-
|
|
13740
|
+
debug21(`${name} error %o`, err);
|
|
13502
13741
|
reject(err);
|
|
13503
13742
|
});
|
|
13504
13743
|
});
|
|
13505
13744
|
}
|
|
13506
13745
|
|
|
13507
13746
|
// src/features/analysis/scanners/checkmarx.ts
|
|
13508
|
-
var
|
|
13747
|
+
var debug16 = Debug16("mobbdev:checkmarx");
|
|
13509
13748
|
var moduleUrl;
|
|
13510
13749
|
if (typeof __filename !== "undefined") {
|
|
13511
13750
|
moduleUrl = __filename;
|
|
@@ -13564,14 +13803,14 @@ function validateCheckmarxInstallation() {
|
|
|
13564
13803
|
existsSync(getCheckmarxPath());
|
|
13565
13804
|
}
|
|
13566
13805
|
async function forkCheckmarx(args, { display }) {
|
|
13567
|
-
|
|
13806
|
+
debug16("fork checkmarx with args %o %s", args.join(" "), display);
|
|
13568
13807
|
return createSpawn(
|
|
13569
13808
|
{ args, processPath: getCheckmarxPath(), name: "checkmarx" },
|
|
13570
13809
|
{ display }
|
|
13571
13810
|
);
|
|
13572
13811
|
}
|
|
13573
13812
|
async function getCheckmarxReport({ reportPath, repositoryRoot, branch, projectName }, { skipPrompts = false }) {
|
|
13574
|
-
|
|
13813
|
+
debug16("get checkmarx report start %s %s", reportPath, repositoryRoot);
|
|
13575
13814
|
const { code: loginCode } = await forkCheckmarx(VALIDATE_COMMAND, {
|
|
13576
13815
|
display: false
|
|
13577
13816
|
});
|
|
@@ -13639,10 +13878,10 @@ async function validateCheckamxCredentials() {
|
|
|
13639
13878
|
// src/features/analysis/scanners/snyk.ts
|
|
13640
13879
|
import { createRequire as createRequire2 } from "module";
|
|
13641
13880
|
import chalk5 from "chalk";
|
|
13642
|
-
import
|
|
13881
|
+
import Debug17 from "debug";
|
|
13643
13882
|
import { createSpinner as createSpinner3 } from "nanospinner";
|
|
13644
13883
|
import open2 from "open";
|
|
13645
|
-
var
|
|
13884
|
+
var debug17 = Debug17("mobbdev:snyk");
|
|
13646
13885
|
var moduleUrl2;
|
|
13647
13886
|
if (typeof __filename !== "undefined") {
|
|
13648
13887
|
moduleUrl2 = __filename;
|
|
@@ -13664,13 +13903,13 @@ if (typeof __filename !== "undefined") {
|
|
|
13664
13903
|
var costumeRequire2 = createRequire2(moduleUrl2);
|
|
13665
13904
|
var SNYK_PATH = costumeRequire2.resolve("snyk/bin/snyk");
|
|
13666
13905
|
var SNYK_ARTICLE_URL = "https://docs.snyk.io/scan-using-snyk/snyk-code/configure-snyk-code#enable-snyk-code";
|
|
13667
|
-
|
|
13906
|
+
debug17("snyk executable path %s", SNYK_PATH);
|
|
13668
13907
|
async function forkSnyk(args, { display }) {
|
|
13669
|
-
|
|
13908
|
+
debug17("fork snyk with args %o %s", args, display);
|
|
13670
13909
|
return createFork({ args, processPath: SNYK_PATH, name: "snyk" }, { display });
|
|
13671
13910
|
}
|
|
13672
13911
|
async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
13673
|
-
|
|
13912
|
+
debug17("get snyk report start %s %s", reportPath, repoRoot);
|
|
13674
13913
|
const config2 = await forkSnyk(["config"], { display: false });
|
|
13675
13914
|
const { message: configMessage } = config2;
|
|
13676
13915
|
if (!configMessage.includes("api: ")) {
|
|
@@ -13684,7 +13923,7 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
13684
13923
|
snykLoginSpinner.update({
|
|
13685
13924
|
text: "\u{1F513} Waiting for Snyk login to complete"
|
|
13686
13925
|
});
|
|
13687
|
-
|
|
13926
|
+
debug17("no token in the config %s", config2);
|
|
13688
13927
|
await forkSnyk(["auth"], { display: true });
|
|
13689
13928
|
snykLoginSpinner.success({ text: "\u{1F513} Login to Snyk Successful" });
|
|
13690
13929
|
}
|
|
@@ -13694,12 +13933,12 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
13694
13933
|
{ display: true }
|
|
13695
13934
|
);
|
|
13696
13935
|
if (scanOutput.includes("Snyk Code is not supported for org")) {
|
|
13697
|
-
|
|
13936
|
+
debug17("snyk code is not enabled %s", scanOutput);
|
|
13698
13937
|
snykSpinner.error({ text: "\u{1F50D} Snyk configuration needed" });
|
|
13699
13938
|
const answer = await snykArticlePrompt();
|
|
13700
|
-
|
|
13939
|
+
debug17("answer %s", answer);
|
|
13701
13940
|
if (answer) {
|
|
13702
|
-
|
|
13941
|
+
debug17("opening the browser");
|
|
13703
13942
|
await open2(SNYK_ARTICLE_URL);
|
|
13704
13943
|
}
|
|
13705
13944
|
console.log(
|
|
@@ -13717,9 +13956,9 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
13717
13956
|
init_client_generates();
|
|
13718
13957
|
|
|
13719
13958
|
// src/features/analysis/upload-file.ts
|
|
13720
|
-
import
|
|
13959
|
+
import Debug18 from "debug";
|
|
13721
13960
|
import fetch3, { File, fileFrom, FormData } from "node-fetch";
|
|
13722
|
-
var
|
|
13961
|
+
var debug18 = Debug18("mobbdev:upload-file");
|
|
13723
13962
|
async function uploadFile({
|
|
13724
13963
|
file,
|
|
13725
13964
|
url,
|
|
@@ -13732,9 +13971,9 @@ async function uploadFile({
|
|
|
13732
13971
|
logInfo2(`FileUpload: upload file start ${url}`);
|
|
13733
13972
|
logInfo2(`FileUpload: upload fields`, uploadFields);
|
|
13734
13973
|
logInfo2(`FileUpload: upload key ${uploadKey}`);
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13974
|
+
debug18("upload file start %s", url);
|
|
13975
|
+
debug18("upload fields %o", uploadFields);
|
|
13976
|
+
debug18("upload key %s", uploadKey);
|
|
13738
13977
|
const form = new FormData();
|
|
13739
13978
|
Object.entries(uploadFields).forEach(([key, value]) => {
|
|
13740
13979
|
form.append(key, value);
|
|
@@ -13743,11 +13982,11 @@ async function uploadFile({
|
|
|
13743
13982
|
form.append("key", uploadKey);
|
|
13744
13983
|
}
|
|
13745
13984
|
if (typeof file === "string") {
|
|
13746
|
-
|
|
13985
|
+
debug18("upload file from path %s", file);
|
|
13747
13986
|
logInfo2(`FileUpload: upload file from path ${file}`);
|
|
13748
13987
|
form.append("file", await fileFrom(file));
|
|
13749
13988
|
} else {
|
|
13750
|
-
|
|
13989
|
+
debug18("upload file from buffer");
|
|
13751
13990
|
logInfo2(`FileUpload: upload file from buffer`);
|
|
13752
13991
|
form.append("file", new File([new Uint8Array(file)], "file"));
|
|
13753
13992
|
}
|
|
@@ -13758,11 +13997,11 @@ async function uploadFile({
|
|
|
13758
13997
|
agent
|
|
13759
13998
|
});
|
|
13760
13999
|
if (!response.ok) {
|
|
13761
|
-
|
|
14000
|
+
debug18("error from S3 %s %s", response.body, response.status);
|
|
13762
14001
|
logInfo2(`FileUpload: error from S3 ${response.body} ${response.status}`);
|
|
13763
14002
|
throw new Error(`Failed to upload the file: ${response.status}`);
|
|
13764
14003
|
}
|
|
13765
|
-
|
|
14004
|
+
debug18("upload file done");
|
|
13766
14005
|
logInfo2(`FileUpload: upload file done`);
|
|
13767
14006
|
}
|
|
13768
14007
|
|
|
@@ -13797,9 +14036,9 @@ async function downloadRepo({
|
|
|
13797
14036
|
}) {
|
|
13798
14037
|
const { createSpinner: createSpinner5 } = Spinner2({ ci });
|
|
13799
14038
|
const repoSpinner = createSpinner5("\u{1F4BE} Downloading Repo").start();
|
|
13800
|
-
|
|
14039
|
+
debug19("download repo %s %s %s", repoUrl, dirname);
|
|
13801
14040
|
const zipFilePath = path9.join(dirname, "repo.zip");
|
|
13802
|
-
|
|
14041
|
+
debug19("download URL: %s auth headers: %o", downloadUrl, authHeaders);
|
|
13803
14042
|
const response = await fetch4(downloadUrl, {
|
|
13804
14043
|
method: "GET",
|
|
13805
14044
|
headers: {
|
|
@@ -13807,7 +14046,7 @@ async function downloadRepo({
|
|
|
13807
14046
|
}
|
|
13808
14047
|
});
|
|
13809
14048
|
if (!response.ok) {
|
|
13810
|
-
|
|
14049
|
+
debug19("SCM zipball request failed %s %s", response.body, response.status);
|
|
13811
14050
|
repoSpinner.error({ text: "\u{1F4BE} Repo download failed" });
|
|
13812
14051
|
throw new Error(`Can't access ${chalk6.bold(repoUrl)}`);
|
|
13813
14052
|
}
|
|
@@ -13821,7 +14060,7 @@ async function downloadRepo({
|
|
|
13821
14060
|
if (!repoRoot) {
|
|
13822
14061
|
throw new Error("Repo root not found");
|
|
13823
14062
|
}
|
|
13824
|
-
|
|
14063
|
+
debug19("repo root %s", repoRoot);
|
|
13825
14064
|
repoSpinner.success({ text: "\u{1F4BE} Repo downloaded successfully" });
|
|
13826
14065
|
return path9.join(dirname, repoRoot);
|
|
13827
14066
|
}
|
|
@@ -13830,7 +14069,7 @@ var getReportUrl = ({
|
|
|
13830
14069
|
projectId,
|
|
13831
14070
|
fixReportId
|
|
13832
14071
|
}) => `${WEB_APP_URL}/organization/${organizationId}/project/${projectId}/report/${fixReportId}`;
|
|
13833
|
-
var
|
|
14072
|
+
var debug19 = Debug19("mobbdev:index");
|
|
13834
14073
|
async function runAnalysis(params, options) {
|
|
13835
14074
|
const tmpObj = tmp2.dirSync({
|
|
13836
14075
|
unsafeCleanup: true
|
|
@@ -13976,7 +14215,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
13976
14215
|
pullRequest,
|
|
13977
14216
|
polling
|
|
13978
14217
|
} = params;
|
|
13979
|
-
|
|
14218
|
+
debug19("start %s %s", dirname, repo);
|
|
13980
14219
|
const { createSpinner: createSpinner5 } = Spinner2({ ci });
|
|
13981
14220
|
skipPrompts = skipPrompts || ci;
|
|
13982
14221
|
const gqlClient = await getAuthenticatedGQLClient({
|
|
@@ -14045,8 +14284,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
14045
14284
|
);
|
|
14046
14285
|
}
|
|
14047
14286
|
const { sha } = getReferenceDataRes.gitReference;
|
|
14048
|
-
|
|
14049
|
-
|
|
14287
|
+
debug19("project id %s", projectId);
|
|
14288
|
+
debug19("default branch %s", reference);
|
|
14050
14289
|
if (command === "scan") {
|
|
14051
14290
|
reportPath = await getReport(
|
|
14052
14291
|
{
|
|
@@ -14096,7 +14335,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
14096
14335
|
spinner: mobbSpinner,
|
|
14097
14336
|
submitVulnerabilityReportVariables: {
|
|
14098
14337
|
fixReportId: reportUploadInfo.fixReportId,
|
|
14099
|
-
repoUrl:
|
|
14338
|
+
repoUrl: z30.string().parse(repo),
|
|
14100
14339
|
reference,
|
|
14101
14340
|
projectId,
|
|
14102
14341
|
vulnerabilityReportFileName: shouldScan ? void 0 : REPORT_DEFAULT_FILE_NAME,
|
|
@@ -14374,7 +14613,7 @@ async function _digestReport({
|
|
|
14374
14613
|
text: progressMassages.processingVulnerabilityReportSuccess
|
|
14375
14614
|
});
|
|
14376
14615
|
if (polling) {
|
|
14377
|
-
|
|
14616
|
+
debug19(
|
|
14378
14617
|
"[_digestReport] Using POLLING mode for analysis state updates (--polling flag enabled)"
|
|
14379
14618
|
);
|
|
14380
14619
|
console.log(
|
|
@@ -14389,7 +14628,7 @@ async function _digestReport({
|
|
|
14389
14628
|
timeoutInMs: VUL_REPORT_DIGEST_TIMEOUT_MS
|
|
14390
14629
|
});
|
|
14391
14630
|
} else {
|
|
14392
|
-
|
|
14631
|
+
debug19(
|
|
14393
14632
|
"[_digestReport] Using WEBSOCKET mode for analysis state updates (default)"
|
|
14394
14633
|
);
|
|
14395
14634
|
console.log(
|
|
@@ -14429,9 +14668,9 @@ async function waitForAnaysisAndReviewPr({
|
|
|
14429
14668
|
gqlClient,
|
|
14430
14669
|
polling
|
|
14431
14670
|
}) {
|
|
14432
|
-
const params =
|
|
14433
|
-
repo:
|
|
14434
|
-
githubActionToken:
|
|
14671
|
+
const params = z30.object({
|
|
14672
|
+
repo: z30.string().url(),
|
|
14673
|
+
githubActionToken: z30.string()
|
|
14435
14674
|
}).parse({ repo, githubActionToken });
|
|
14436
14675
|
const scm = await createScmLib(
|
|
14437
14676
|
{
|
|
@@ -14449,11 +14688,11 @@ async function waitForAnaysisAndReviewPr({
|
|
|
14449
14688
|
analysisId: analysisId2,
|
|
14450
14689
|
gqlClient,
|
|
14451
14690
|
scm,
|
|
14452
|
-
scanner:
|
|
14691
|
+
scanner: z30.nativeEnum(SCANNERS).parse(scanner)
|
|
14453
14692
|
});
|
|
14454
14693
|
};
|
|
14455
14694
|
if (polling) {
|
|
14456
|
-
|
|
14695
|
+
debug19(
|
|
14457
14696
|
"[waitForAnaysisAndReviewPr] Using POLLING mode for analysis state updates"
|
|
14458
14697
|
);
|
|
14459
14698
|
console.log(
|
|
@@ -14467,7 +14706,7 @@ async function waitForAnaysisAndReviewPr({
|
|
|
14467
14706
|
callbackStates: ["Finished" /* Finished */]
|
|
14468
14707
|
});
|
|
14469
14708
|
} else {
|
|
14470
|
-
|
|
14709
|
+
debug19(
|
|
14471
14710
|
"[waitForAnaysisAndReviewPr] Using WEBSOCKET mode for analysis state updates"
|
|
14472
14711
|
);
|
|
14473
14712
|
console.log(
|
|
@@ -14763,7 +15002,7 @@ async function scanSkill(options) {
|
|
|
14763
15002
|
// src/args/validation.ts
|
|
14764
15003
|
import chalk8 from "chalk";
|
|
14765
15004
|
import path11 from "path";
|
|
14766
|
-
import { z as
|
|
15005
|
+
import { z as z31 } from "zod";
|
|
14767
15006
|
function throwRepoUrlErrorMessage({
|
|
14768
15007
|
error,
|
|
14769
15008
|
repoUrl,
|
|
@@ -14780,11 +15019,11 @@ Example:
|
|
|
14780
15019
|
)}`;
|
|
14781
15020
|
throw new CliError(formattedErrorMessage);
|
|
14782
15021
|
}
|
|
14783
|
-
var UrlZ =
|
|
15022
|
+
var UrlZ = z31.string({
|
|
14784
15023
|
invalid_type_error: `is not a valid ${Object.values(ScmType).join("/ ")} URL`
|
|
14785
15024
|
});
|
|
14786
15025
|
function validateOrganizationId(organizationId) {
|
|
14787
|
-
const orgIdValidation =
|
|
15026
|
+
const orgIdValidation = z31.string().uuid().nullish().safeParse(organizationId);
|
|
14788
15027
|
if (!orgIdValidation.success) {
|
|
14789
15028
|
throw new CliError(`organizationId: ${organizationId} is not a valid UUID`);
|
|
14790
15029
|
}
|
|
@@ -14892,7 +15131,7 @@ async function analyzeHandler(args) {
|
|
|
14892
15131
|
}
|
|
14893
15132
|
|
|
14894
15133
|
// src/features/claude_code/data_collector.ts
|
|
14895
|
-
import { z as
|
|
15134
|
+
import { z as z33 } from "zod";
|
|
14896
15135
|
|
|
14897
15136
|
// src/args/commands/upload_ai_blame.ts
|
|
14898
15137
|
import fsPromises3 from "fs/promises";
|
|
@@ -14900,7 +15139,7 @@ import * as os3 from "os";
|
|
|
14900
15139
|
import path12 from "path";
|
|
14901
15140
|
import chalk10 from "chalk";
|
|
14902
15141
|
import { withFile } from "tmp-promise";
|
|
14903
|
-
import
|
|
15142
|
+
import z32 from "zod";
|
|
14904
15143
|
init_client_generates();
|
|
14905
15144
|
init_GitService();
|
|
14906
15145
|
init_urlParser2();
|
|
@@ -14999,7 +15238,8 @@ import { OpenRedaction } from "@openredaction/openredaction";
|
|
|
14999
15238
|
var openRedaction = new OpenRedaction({
|
|
15000
15239
|
patterns: [
|
|
15001
15240
|
// Core Personal Data
|
|
15002
|
-
|
|
15241
|
+
// Removed EMAIL - causes false positives in code/test snippets (e.g. --author="Eve Author <eve@example.com>")
|
|
15242
|
+
// Prefer false negatives over false positives for this use case.
|
|
15003
15243
|
"SSN",
|
|
15004
15244
|
"NATIONAL_INSURANCE_UK",
|
|
15005
15245
|
"DATE_OF_BIRTH",
|
|
@@ -15014,7 +15254,8 @@ var openRedaction = new OpenRedaction({
|
|
|
15014
15254
|
"VISA_MRZ",
|
|
15015
15255
|
"TAX_ID",
|
|
15016
15256
|
// Financial Data (removed SWIFT_BIC, CARD_AUTH_CODE - too broad, causing false positives with authentication words)
|
|
15017
|
-
|
|
15257
|
+
// Removed CREDIT_CARD - causes false positives on zero-filled UUIDs (e.g. '00000000-0000-0000-0000-000000000000')
|
|
15258
|
+
// Prefer false negatives over false positives for this use case.
|
|
15018
15259
|
"IBAN",
|
|
15019
15260
|
"BANK_ACCOUNT_UK",
|
|
15020
15261
|
"ROUTING_NUMBER_US",
|
|
@@ -15100,15 +15341,6 @@ async function sanitizeDataWithCounts(obj) {
|
|
|
15100
15341
|
...piiDetections.low
|
|
15101
15342
|
];
|
|
15102
15343
|
for (const detection of allDetections) {
|
|
15103
|
-
if (detection.type === "CREDIT_CARD") {
|
|
15104
|
-
const start = detection.position[0];
|
|
15105
|
-
const end = detection.position[1];
|
|
15106
|
-
const charBefore = (start > 0 ? str[start - 1] : "") ?? "";
|
|
15107
|
-
const charAfter = str[end] ?? "";
|
|
15108
|
-
if (charBefore === "." || charBefore >= "0" && charBefore <= "9" || charAfter >= "0" && charAfter <= "9") {
|
|
15109
|
-
continue;
|
|
15110
|
-
}
|
|
15111
|
-
}
|
|
15112
15344
|
counts.detections.total++;
|
|
15113
15345
|
if (detection.severity === "high") counts.detections.high++;
|
|
15114
15346
|
else if (detection.severity === "medium") counts.detections.medium++;
|
|
@@ -15161,8 +15393,8 @@ var defaultLogger2 = {
|
|
|
15161
15393
|
}
|
|
15162
15394
|
}
|
|
15163
15395
|
};
|
|
15164
|
-
var PromptItemZ =
|
|
15165
|
-
type:
|
|
15396
|
+
var PromptItemZ = z32.object({
|
|
15397
|
+
type: z32.enum([
|
|
15166
15398
|
"USER_PROMPT",
|
|
15167
15399
|
"AI_RESPONSE",
|
|
15168
15400
|
"TOOL_EXECUTION",
|
|
@@ -15170,32 +15402,32 @@ var PromptItemZ = z31.object({
|
|
|
15170
15402
|
"MCP_TOOL_CALL"
|
|
15171
15403
|
// MCP (Model Context Protocol) tool invocation
|
|
15172
15404
|
]),
|
|
15173
|
-
attachedFiles:
|
|
15174
|
-
|
|
15175
|
-
relativePath:
|
|
15176
|
-
startLine:
|
|
15405
|
+
attachedFiles: z32.array(
|
|
15406
|
+
z32.object({
|
|
15407
|
+
relativePath: z32.string(),
|
|
15408
|
+
startLine: z32.number().optional()
|
|
15177
15409
|
})
|
|
15178
15410
|
).optional(),
|
|
15179
|
-
tokens:
|
|
15180
|
-
inputCount:
|
|
15181
|
-
outputCount:
|
|
15411
|
+
tokens: z32.object({
|
|
15412
|
+
inputCount: z32.number(),
|
|
15413
|
+
outputCount: z32.number()
|
|
15182
15414
|
}).optional(),
|
|
15183
|
-
text:
|
|
15184
|
-
date:
|
|
15185
|
-
tool:
|
|
15186
|
-
name:
|
|
15187
|
-
parameters:
|
|
15188
|
-
result:
|
|
15189
|
-
rawArguments:
|
|
15190
|
-
accepted:
|
|
15415
|
+
text: z32.string().optional(),
|
|
15416
|
+
date: z32.date().optional(),
|
|
15417
|
+
tool: z32.object({
|
|
15418
|
+
name: z32.string(),
|
|
15419
|
+
parameters: z32.string(),
|
|
15420
|
+
result: z32.string(),
|
|
15421
|
+
rawArguments: z32.string().optional(),
|
|
15422
|
+
accepted: z32.boolean().optional(),
|
|
15191
15423
|
// MCP-specific fields (only populated for MCP_TOOL_CALL type)
|
|
15192
|
-
mcpServer:
|
|
15424
|
+
mcpServer: z32.string().optional(),
|
|
15193
15425
|
// MCP server name (e.g., "datadog", "mobb-mcp")
|
|
15194
|
-
mcpToolName:
|
|
15426
|
+
mcpToolName: z32.string().optional()
|
|
15195
15427
|
// MCP tool name without prefix (e.g., "scan_and_fix_vulnerabilities")
|
|
15196
15428
|
}).optional()
|
|
15197
15429
|
});
|
|
15198
|
-
var PromptItemArrayZ =
|
|
15430
|
+
var PromptItemArrayZ = z32.array(PromptItemZ);
|
|
15199
15431
|
async function getRepositoryUrl() {
|
|
15200
15432
|
try {
|
|
15201
15433
|
const gitService = new GitService(process.cwd());
|
|
@@ -15585,46 +15817,46 @@ async function parseTranscriptAndCreateTrace(transcriptPath, hookData, inference
|
|
|
15585
15817
|
}
|
|
15586
15818
|
|
|
15587
15819
|
// src/features/claude_code/data_collector.ts
|
|
15588
|
-
var StructuredPatchItemSchema =
|
|
15589
|
-
oldStart:
|
|
15590
|
-
oldLines:
|
|
15591
|
-
newStart:
|
|
15592
|
-
newLines:
|
|
15593
|
-
lines:
|
|
15820
|
+
var StructuredPatchItemSchema = z33.object({
|
|
15821
|
+
oldStart: z33.number(),
|
|
15822
|
+
oldLines: z33.number(),
|
|
15823
|
+
newStart: z33.number(),
|
|
15824
|
+
newLines: z33.number(),
|
|
15825
|
+
lines: z33.array(z33.string())
|
|
15594
15826
|
});
|
|
15595
|
-
var EditToolInputSchema =
|
|
15596
|
-
file_path:
|
|
15597
|
-
old_string:
|
|
15598
|
-
new_string:
|
|
15827
|
+
var EditToolInputSchema = z33.object({
|
|
15828
|
+
file_path: z33.string(),
|
|
15829
|
+
old_string: z33.string(),
|
|
15830
|
+
new_string: z33.string()
|
|
15599
15831
|
});
|
|
15600
|
-
var WriteToolInputSchema =
|
|
15601
|
-
file_path:
|
|
15602
|
-
content:
|
|
15832
|
+
var WriteToolInputSchema = z33.object({
|
|
15833
|
+
file_path: z33.string(),
|
|
15834
|
+
content: z33.string()
|
|
15603
15835
|
});
|
|
15604
|
-
var EditToolResponseSchema =
|
|
15605
|
-
filePath:
|
|
15606
|
-
oldString:
|
|
15607
|
-
newString:
|
|
15608
|
-
originalFile:
|
|
15609
|
-
structuredPatch:
|
|
15610
|
-
userModified:
|
|
15611
|
-
replaceAll:
|
|
15836
|
+
var EditToolResponseSchema = z33.object({
|
|
15837
|
+
filePath: z33.string(),
|
|
15838
|
+
oldString: z33.string().optional(),
|
|
15839
|
+
newString: z33.string().optional(),
|
|
15840
|
+
originalFile: z33.string().optional(),
|
|
15841
|
+
structuredPatch: z33.array(StructuredPatchItemSchema),
|
|
15842
|
+
userModified: z33.boolean().optional(),
|
|
15843
|
+
replaceAll: z33.boolean().optional()
|
|
15612
15844
|
});
|
|
15613
|
-
var WriteToolResponseSchema =
|
|
15614
|
-
type:
|
|
15615
|
-
filePath:
|
|
15616
|
-
content:
|
|
15617
|
-
structuredPatch:
|
|
15845
|
+
var WriteToolResponseSchema = z33.object({
|
|
15846
|
+
type: z33.string().optional(),
|
|
15847
|
+
filePath: z33.string(),
|
|
15848
|
+
content: z33.string().optional(),
|
|
15849
|
+
structuredPatch: z33.array(z33.any()).optional()
|
|
15618
15850
|
});
|
|
15619
|
-
var HookDataSchema =
|
|
15620
|
-
session_id:
|
|
15621
|
-
transcript_path:
|
|
15622
|
-
cwd:
|
|
15623
|
-
permission_mode:
|
|
15624
|
-
hook_event_name:
|
|
15625
|
-
tool_name:
|
|
15626
|
-
tool_input:
|
|
15627
|
-
tool_response:
|
|
15851
|
+
var HookDataSchema = z33.object({
|
|
15852
|
+
session_id: z33.string(),
|
|
15853
|
+
transcript_path: z33.string(),
|
|
15854
|
+
cwd: z33.string(),
|
|
15855
|
+
permission_mode: z33.string().optional(),
|
|
15856
|
+
hook_event_name: z33.literal("PostToolUse"),
|
|
15857
|
+
tool_name: z33.enum(["Edit", "Write"]),
|
|
15858
|
+
tool_input: z33.union([EditToolInputSchema, WriteToolInputSchema]),
|
|
15859
|
+
tool_response: z33.union([EditToolResponseSchema, WriteToolResponseSchema])
|
|
15628
15860
|
});
|
|
15629
15861
|
async function readStdinData() {
|
|
15630
15862
|
return new Promise((resolve, reject) => {
|
|
@@ -16091,138 +16323,137 @@ var log = logger.log.bind(logger);
|
|
|
16091
16323
|
// src/mcp/services/McpGQLClient.ts
|
|
16092
16324
|
import crypto3 from "crypto";
|
|
16093
16325
|
import { GraphQLClient as GraphQLClient2 } from "graphql-request";
|
|
16094
|
-
import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
16095
16326
|
import { v4 as uuidv42 } from "uuid";
|
|
16096
16327
|
init_client_generates();
|
|
16097
16328
|
init_configs();
|
|
16098
16329
|
|
|
16099
16330
|
// src/mcp/types.ts
|
|
16100
16331
|
init_client_generates();
|
|
16101
|
-
import { z as
|
|
16102
|
-
var ScanAndFixVulnerabilitiesToolSchema =
|
|
16103
|
-
path:
|
|
16332
|
+
import { z as z34 } from "zod";
|
|
16333
|
+
var ScanAndFixVulnerabilitiesToolSchema = z34.object({
|
|
16334
|
+
path: z34.string()
|
|
16104
16335
|
});
|
|
16105
|
-
var VulnerabilityReportIssueTagSchema =
|
|
16106
|
-
vulnerability_report_issue_tag_value:
|
|
16336
|
+
var VulnerabilityReportIssueTagSchema = z34.object({
|
|
16337
|
+
vulnerability_report_issue_tag_value: z34.nativeEnum(
|
|
16107
16338
|
Vulnerability_Report_Issue_Tag_Enum
|
|
16108
16339
|
)
|
|
16109
16340
|
});
|
|
16110
|
-
var VulnerabilityReportIssueSchema =
|
|
16111
|
-
category:
|
|
16112
|
-
parsedIssueType:
|
|
16113
|
-
parsedSeverity:
|
|
16114
|
-
vulnerabilityReportIssueTags:
|
|
16341
|
+
var VulnerabilityReportIssueSchema = z34.object({
|
|
16342
|
+
category: z34.any().optional().nullable(),
|
|
16343
|
+
parsedIssueType: z34.nativeEnum(IssueType_Enum).nullable().optional(),
|
|
16344
|
+
parsedSeverity: z34.nativeEnum(Vulnerability_Severity_Enum).nullable().optional(),
|
|
16345
|
+
vulnerabilityReportIssueTags: z34.array(VulnerabilityReportIssueTagSchema)
|
|
16115
16346
|
});
|
|
16116
|
-
var SharedStateSchema =
|
|
16117
|
-
__typename:
|
|
16118
|
-
id:
|
|
16347
|
+
var SharedStateSchema = z34.object({
|
|
16348
|
+
__typename: z34.literal("fix_shared_state").optional(),
|
|
16349
|
+
id: z34.any(),
|
|
16119
16350
|
// GraphQL uses `any` type for UUID
|
|
16120
|
-
downloadedBy:
|
|
16351
|
+
downloadedBy: z34.array(z34.any().nullable()).optional().nullable()
|
|
16121
16352
|
});
|
|
16122
|
-
var UnstructuredFixExtraContextSchema =
|
|
16123
|
-
__typename:
|
|
16124
|
-
key:
|
|
16125
|
-
value:
|
|
16353
|
+
var UnstructuredFixExtraContextSchema = z34.object({
|
|
16354
|
+
__typename: z34.literal("UnstructuredFixExtraContext").optional(),
|
|
16355
|
+
key: z34.string(),
|
|
16356
|
+
value: z34.any()
|
|
16126
16357
|
// GraphQL JSON type
|
|
16127
16358
|
});
|
|
16128
|
-
var FixExtraContextResponseSchema =
|
|
16129
|
-
__typename:
|
|
16130
|
-
extraContext:
|
|
16131
|
-
fixDescription:
|
|
16359
|
+
var FixExtraContextResponseSchema = z34.object({
|
|
16360
|
+
__typename: z34.literal("FixExtraContextResponse").optional(),
|
|
16361
|
+
extraContext: z34.array(UnstructuredFixExtraContextSchema),
|
|
16362
|
+
fixDescription: z34.string()
|
|
16132
16363
|
});
|
|
16133
|
-
var FixDataSchema =
|
|
16134
|
-
__typename:
|
|
16135
|
-
patch:
|
|
16136
|
-
patchOriginalEncodingBase64:
|
|
16364
|
+
var FixDataSchema = z34.object({
|
|
16365
|
+
__typename: z34.literal("FixData"),
|
|
16366
|
+
patch: z34.string(),
|
|
16367
|
+
patchOriginalEncodingBase64: z34.string(),
|
|
16137
16368
|
extraContext: FixExtraContextResponseSchema
|
|
16138
16369
|
});
|
|
16139
|
-
var GetFixNoFixErrorSchema =
|
|
16140
|
-
__typename:
|
|
16370
|
+
var GetFixNoFixErrorSchema = z34.object({
|
|
16371
|
+
__typename: z34.literal("GetFixNoFixError")
|
|
16141
16372
|
});
|
|
16142
|
-
var PatchAndQuestionsSchema =
|
|
16143
|
-
var McpFixSchema =
|
|
16144
|
-
__typename:
|
|
16145
|
-
id:
|
|
16373
|
+
var PatchAndQuestionsSchema = z34.union([FixDataSchema, GetFixNoFixErrorSchema]);
|
|
16374
|
+
var McpFixSchema = z34.object({
|
|
16375
|
+
__typename: z34.literal("fix").optional(),
|
|
16376
|
+
id: z34.any(),
|
|
16146
16377
|
// GraphQL uses `any` type for UUID
|
|
16147
|
-
confidence:
|
|
16148
|
-
safeIssueType:
|
|
16149
|
-
severityText:
|
|
16150
|
-
gitBlameLogin:
|
|
16378
|
+
confidence: z34.number(),
|
|
16379
|
+
safeIssueType: z34.string().nullable(),
|
|
16380
|
+
severityText: z34.string().nullable(),
|
|
16381
|
+
gitBlameLogin: z34.string().nullable().optional(),
|
|
16151
16382
|
// Optional in GraphQL
|
|
16152
|
-
severityValue:
|
|
16153
|
-
vulnerabilityReportIssues:
|
|
16383
|
+
severityValue: z34.number().nullable(),
|
|
16384
|
+
vulnerabilityReportIssues: z34.array(VulnerabilityReportIssueSchema),
|
|
16154
16385
|
sharedState: SharedStateSchema.nullable().optional(),
|
|
16155
16386
|
// Optional in GraphQL
|
|
16156
16387
|
patchAndQuestions: PatchAndQuestionsSchema,
|
|
16157
16388
|
// Additional field added by the client
|
|
16158
|
-
fixUrl:
|
|
16389
|
+
fixUrl: z34.string().optional()
|
|
16159
16390
|
});
|
|
16160
|
-
var FixAggregateSchema =
|
|
16161
|
-
__typename:
|
|
16162
|
-
aggregate:
|
|
16163
|
-
__typename:
|
|
16164
|
-
count:
|
|
16391
|
+
var FixAggregateSchema = z34.object({
|
|
16392
|
+
__typename: z34.literal("fix_aggregate").optional(),
|
|
16393
|
+
aggregate: z34.object({
|
|
16394
|
+
__typename: z34.literal("fix_aggregate_fields").optional(),
|
|
16395
|
+
count: z34.number()
|
|
16165
16396
|
}).nullable()
|
|
16166
16397
|
});
|
|
16167
|
-
var VulnerabilityReportIssueAggregateSchema =
|
|
16168
|
-
__typename:
|
|
16169
|
-
aggregate:
|
|
16170
|
-
__typename:
|
|
16171
|
-
count:
|
|
16398
|
+
var VulnerabilityReportIssueAggregateSchema = z34.object({
|
|
16399
|
+
__typename: z34.literal("vulnerability_report_issue_aggregate").optional(),
|
|
16400
|
+
aggregate: z34.object({
|
|
16401
|
+
__typename: z34.literal("vulnerability_report_issue_aggregate_fields").optional(),
|
|
16402
|
+
count: z34.number()
|
|
16172
16403
|
}).nullable()
|
|
16173
16404
|
});
|
|
16174
|
-
var RepoSchema =
|
|
16175
|
-
__typename:
|
|
16176
|
-
originalUrl:
|
|
16405
|
+
var RepoSchema = z34.object({
|
|
16406
|
+
__typename: z34.literal("repo").optional(),
|
|
16407
|
+
originalUrl: z34.string()
|
|
16177
16408
|
});
|
|
16178
|
-
var ProjectSchema =
|
|
16179
|
-
id:
|
|
16409
|
+
var ProjectSchema = z34.object({
|
|
16410
|
+
id: z34.any(),
|
|
16180
16411
|
// GraphQL uses `any` type for UUID
|
|
16181
|
-
organizationId:
|
|
16412
|
+
organizationId: z34.any()
|
|
16182
16413
|
// GraphQL uses `any` type for UUID
|
|
16183
16414
|
});
|
|
16184
|
-
var VulnerabilityReportSchema =
|
|
16185
|
-
scanDate:
|
|
16415
|
+
var VulnerabilityReportSchema = z34.object({
|
|
16416
|
+
scanDate: z34.any().nullable(),
|
|
16186
16417
|
// GraphQL uses `any` type for timestamp
|
|
16187
|
-
vendor:
|
|
16418
|
+
vendor: z34.string(),
|
|
16188
16419
|
// GraphQL generates as string, not enum
|
|
16189
|
-
projectId:
|
|
16420
|
+
projectId: z34.any().optional(),
|
|
16190
16421
|
// GraphQL uses `any` type for UUID
|
|
16191
16422
|
project: ProjectSchema,
|
|
16192
16423
|
totalVulnerabilityReportIssuesCount: VulnerabilityReportIssueAggregateSchema,
|
|
16193
16424
|
notFixableVulnerabilityReportIssuesCount: VulnerabilityReportIssueAggregateSchema
|
|
16194
16425
|
});
|
|
16195
|
-
var FixReportSummarySchema =
|
|
16196
|
-
__typename:
|
|
16197
|
-
id:
|
|
16426
|
+
var FixReportSummarySchema = z34.object({
|
|
16427
|
+
__typename: z34.literal("fixReport").optional(),
|
|
16428
|
+
id: z34.any(),
|
|
16198
16429
|
// GraphQL uses `any` type for UUID
|
|
16199
|
-
createdOn:
|
|
16430
|
+
createdOn: z34.any(),
|
|
16200
16431
|
// GraphQL uses `any` type for timestamp
|
|
16201
16432
|
repo: RepoSchema.nullable(),
|
|
16202
|
-
issueTypes:
|
|
16433
|
+
issueTypes: z34.any().nullable(),
|
|
16203
16434
|
// GraphQL uses `any` type for JSON
|
|
16204
16435
|
CRITICAL: FixAggregateSchema,
|
|
16205
16436
|
HIGH: FixAggregateSchema,
|
|
16206
16437
|
MEDIUM: FixAggregateSchema,
|
|
16207
16438
|
LOW: FixAggregateSchema,
|
|
16208
|
-
fixes:
|
|
16209
|
-
userFixes:
|
|
16439
|
+
fixes: z34.array(McpFixSchema),
|
|
16440
|
+
userFixes: z34.array(McpFixSchema).optional(),
|
|
16210
16441
|
// Present in some responses but can be omitted
|
|
16211
16442
|
filteredFixesCount: FixAggregateSchema,
|
|
16212
16443
|
totalFixesCount: FixAggregateSchema,
|
|
16213
16444
|
vulnerabilityReport: VulnerabilityReportSchema
|
|
16214
16445
|
});
|
|
16215
|
-
var ExpiredReportSchema =
|
|
16216
|
-
__typename:
|
|
16217
|
-
id:
|
|
16446
|
+
var ExpiredReportSchema = z34.object({
|
|
16447
|
+
__typename: z34.literal("fixReport").optional(),
|
|
16448
|
+
id: z34.any(),
|
|
16218
16449
|
// GraphQL uses `any` type for UUID
|
|
16219
|
-
expirationOn:
|
|
16450
|
+
expirationOn: z34.any().nullable()
|
|
16220
16451
|
// GraphQL uses `any` type for timestamp
|
|
16221
16452
|
});
|
|
16222
|
-
var GetLatestReportByRepoUrlResponseSchema =
|
|
16223
|
-
__typename:
|
|
16224
|
-
fixReport:
|
|
16225
|
-
expiredReport:
|
|
16453
|
+
var GetLatestReportByRepoUrlResponseSchema = z34.object({
|
|
16454
|
+
__typename: z34.literal("query_root").optional(),
|
|
16455
|
+
fixReport: z34.array(FixReportSummarySchema),
|
|
16456
|
+
expiredReport: z34.array(ExpiredReportSchema)
|
|
16226
16457
|
});
|
|
16227
16458
|
|
|
16228
16459
|
// src/mcp/services/McpAuthService.ts
|
|
@@ -16306,23 +16537,6 @@ var McpAuthService = class {
|
|
|
16306
16537
|
};
|
|
16307
16538
|
|
|
16308
16539
|
// src/mcp/services/McpGQLClient.ts
|
|
16309
|
-
function getProxyAgent2(url) {
|
|
16310
|
-
try {
|
|
16311
|
-
const parsedUrl = new URL(url);
|
|
16312
|
-
const isHttp = parsedUrl.protocol === "http:";
|
|
16313
|
-
const isHttps = parsedUrl.protocol === "https:";
|
|
16314
|
-
const proxy = isHttps ? HTTPS_PROXY || HTTP_PROXY : isHttp ? HTTP_PROXY : null;
|
|
16315
|
-
if (proxy) {
|
|
16316
|
-
logDebug("[GraphQL] Using proxy for websocket subscriptions", { proxy });
|
|
16317
|
-
return new HttpsProxyAgent2(proxy);
|
|
16318
|
-
}
|
|
16319
|
-
} catch (err) {
|
|
16320
|
-
logDebug(`[GraphQL] Skipping proxy for ${url}`, {
|
|
16321
|
-
error: err.message
|
|
16322
|
-
});
|
|
16323
|
-
}
|
|
16324
|
-
return void 0;
|
|
16325
|
-
}
|
|
16326
16540
|
var McpGQLClient = class {
|
|
16327
16541
|
constructor(args) {
|
|
16328
16542
|
__publicField(this, "client");
|
|
@@ -16339,6 +16553,7 @@ var McpGQLClient = class {
|
|
|
16339
16553
|
headers: args.type === "apiKey" ? { [MCP_API_KEY_HEADER_NAME]: args.apiKey || "" } : {
|
|
16340
16554
|
Authorization: `Bearer ${args.token}`
|
|
16341
16555
|
},
|
|
16556
|
+
fetch: fetchWithProxy,
|
|
16342
16557
|
requestMiddleware: (request) => {
|
|
16343
16558
|
const requestId = uuidv42();
|
|
16344
16559
|
return {
|
|
@@ -16521,13 +16736,15 @@ var McpGQLClient = class {
|
|
|
16521
16736
|
this._auth.type === "apiKey" ? {
|
|
16522
16737
|
apiKey: this._auth.apiKey,
|
|
16523
16738
|
type: "apiKey",
|
|
16739
|
+
url: httpToWsUrl(this.apiUrl),
|
|
16524
16740
|
timeoutInMs: params.timeoutInMs,
|
|
16525
|
-
proxyAgent:
|
|
16741
|
+
proxyAgent: getProxyAgent(this.apiUrl)
|
|
16526
16742
|
} : {
|
|
16527
16743
|
token: this._auth.token,
|
|
16528
16744
|
type: "token",
|
|
16745
|
+
url: httpToWsUrl(this.apiUrl),
|
|
16529
16746
|
timeoutInMs: params.timeoutInMs,
|
|
16530
|
-
proxyAgent:
|
|
16747
|
+
proxyAgent: getProxyAgent(this.apiUrl)
|
|
16531
16748
|
}
|
|
16532
16749
|
);
|
|
16533
16750
|
}
|
|
@@ -18147,10 +18364,10 @@ var McpServer = class {
|
|
|
18147
18364
|
};
|
|
18148
18365
|
|
|
18149
18366
|
// src/mcp/prompts/CheckForNewVulnerabilitiesPrompt.ts
|
|
18150
|
-
import { z as
|
|
18367
|
+
import { z as z36 } from "zod";
|
|
18151
18368
|
|
|
18152
18369
|
// src/mcp/prompts/base/BasePrompt.ts
|
|
18153
|
-
import { z as
|
|
18370
|
+
import { z as z35 } from "zod";
|
|
18154
18371
|
var BasePrompt = class {
|
|
18155
18372
|
getDefinition() {
|
|
18156
18373
|
return {
|
|
@@ -18179,7 +18396,7 @@ var BasePrompt = class {
|
|
|
18179
18396
|
const argsToValidate = args === void 0 ? {} : args;
|
|
18180
18397
|
return this.argumentsValidationSchema.parse(argsToValidate);
|
|
18181
18398
|
} catch (error) {
|
|
18182
|
-
if (error instanceof
|
|
18399
|
+
if (error instanceof z35.ZodError) {
|
|
18183
18400
|
const errorDetails = error.errors.map((e) => {
|
|
18184
18401
|
const fieldPath = e.path.length > 0 ? e.path.join(".") : "root";
|
|
18185
18402
|
const message = e.message === "Required" ? `Missing required argument '${fieldPath}'` : `Invalid value for '${fieldPath}': ${e.message}`;
|
|
@@ -18208,8 +18425,8 @@ var BasePrompt = class {
|
|
|
18208
18425
|
};
|
|
18209
18426
|
|
|
18210
18427
|
// src/mcp/prompts/CheckForNewVulnerabilitiesPrompt.ts
|
|
18211
|
-
var CheckForNewVulnerabilitiesArgsSchema =
|
|
18212
|
-
path:
|
|
18428
|
+
var CheckForNewVulnerabilitiesArgsSchema = z36.object({
|
|
18429
|
+
path: z36.string().optional()
|
|
18213
18430
|
});
|
|
18214
18431
|
var CheckForNewVulnerabilitiesPrompt = class extends BasePrompt {
|
|
18215
18432
|
constructor() {
|
|
@@ -18454,9 +18671,9 @@ Call the \`check_for_new_available_fixes\` tool now${args?.path ? ` for ${args.p
|
|
|
18454
18671
|
};
|
|
18455
18672
|
|
|
18456
18673
|
// src/mcp/prompts/FullSecurityAuditPrompt.ts
|
|
18457
|
-
import { z as
|
|
18458
|
-
var FullSecurityAuditArgsSchema =
|
|
18459
|
-
path:
|
|
18674
|
+
import { z as z37 } from "zod";
|
|
18675
|
+
var FullSecurityAuditArgsSchema = z37.object({
|
|
18676
|
+
path: z37.string().optional()
|
|
18460
18677
|
});
|
|
18461
18678
|
var FullSecurityAuditPrompt = class extends BasePrompt {
|
|
18462
18679
|
constructor() {
|
|
@@ -18907,9 +19124,9 @@ Begin the audit now${args?.path ? ` for ${args.path}` : ""}.
|
|
|
18907
19124
|
};
|
|
18908
19125
|
|
|
18909
19126
|
// src/mcp/prompts/ReviewAndFixCriticalPrompt.ts
|
|
18910
|
-
import { z as
|
|
18911
|
-
var ReviewAndFixCriticalArgsSchema =
|
|
18912
|
-
path:
|
|
19127
|
+
import { z as z38 } from "zod";
|
|
19128
|
+
var ReviewAndFixCriticalArgsSchema = z38.object({
|
|
19129
|
+
path: z38.string().optional()
|
|
18913
19130
|
});
|
|
18914
19131
|
var ReviewAndFixCriticalPrompt = class extends BasePrompt {
|
|
18915
19132
|
constructor() {
|
|
@@ -19213,9 +19430,9 @@ Start by scanning${args?.path ? ` ${args.path}` : " the repository"} and priorit
|
|
|
19213
19430
|
};
|
|
19214
19431
|
|
|
19215
19432
|
// src/mcp/prompts/ScanRecentChangesPrompt.ts
|
|
19216
|
-
import { z as
|
|
19217
|
-
var ScanRecentChangesArgsSchema =
|
|
19218
|
-
path:
|
|
19433
|
+
import { z as z39 } from "zod";
|
|
19434
|
+
var ScanRecentChangesArgsSchema = z39.object({
|
|
19435
|
+
path: z39.string().optional()
|
|
19219
19436
|
});
|
|
19220
19437
|
var ScanRecentChangesPrompt = class extends BasePrompt {
|
|
19221
19438
|
constructor() {
|
|
@@ -19426,9 +19643,9 @@ You now have the guidance needed to perform a fast, targeted security scan of re
|
|
|
19426
19643
|
};
|
|
19427
19644
|
|
|
19428
19645
|
// src/mcp/prompts/ScanRepositoryPrompt.ts
|
|
19429
|
-
import { z as
|
|
19430
|
-
var ScanRepositoryArgsSchema =
|
|
19431
|
-
path:
|
|
19646
|
+
import { z as z40 } from "zod";
|
|
19647
|
+
var ScanRepositoryArgsSchema = z40.object({
|
|
19648
|
+
path: z40.string().optional()
|
|
19432
19649
|
});
|
|
19433
19650
|
var ScanRepositoryPrompt = class extends BasePrompt {
|
|
19434
19651
|
constructor() {
|
|
@@ -19826,7 +20043,7 @@ import * as os11 from "os";
|
|
|
19826
20043
|
import * as path18 from "path";
|
|
19827
20044
|
|
|
19828
20045
|
// src/mcp/tools/checkForNewAvailableFixes/CheckForNewAvailableFixesTool.ts
|
|
19829
|
-
import { z as
|
|
20046
|
+
import { z as z43 } from "zod";
|
|
19830
20047
|
|
|
19831
20048
|
// src/mcp/services/PathValidation.ts
|
|
19832
20049
|
import fs19 from "fs";
|
|
@@ -19902,7 +20119,7 @@ async function validatePath(inputPath) {
|
|
|
19902
20119
|
}
|
|
19903
20120
|
|
|
19904
20121
|
// src/mcp/tools/base/BaseTool.ts
|
|
19905
|
-
import { z as
|
|
20122
|
+
import { z as z41 } from "zod";
|
|
19906
20123
|
var BaseTool = class {
|
|
19907
20124
|
getDefinition() {
|
|
19908
20125
|
return {
|
|
@@ -19935,7 +20152,7 @@ var BaseTool = class {
|
|
|
19935
20152
|
try {
|
|
19936
20153
|
return this.inputValidationSchema.parse(args);
|
|
19937
20154
|
} catch (error) {
|
|
19938
|
-
if (error instanceof
|
|
20155
|
+
if (error instanceof z41.ZodError) {
|
|
19939
20156
|
const errorDetails = error.errors.map((e) => {
|
|
19940
20157
|
const fieldPath = e.path.length > 0 ? e.path.join(".") : "root";
|
|
19941
20158
|
const message = e.message === "Required" ? `Missing required parameter '${fieldPath}'` : `Invalid value for '${fieldPath}': ${e.message}`;
|
|
@@ -20654,13 +20871,13 @@ init_client_generates();
|
|
|
20654
20871
|
init_GitService();
|
|
20655
20872
|
import fs21 from "fs";
|
|
20656
20873
|
import path20 from "path";
|
|
20657
|
-
import { z as
|
|
20874
|
+
import { z as z42 } from "zod";
|
|
20658
20875
|
function extractPathFromPatch(patch) {
|
|
20659
20876
|
const match = patch?.match(/diff --git a\/([^\s]+) b\//);
|
|
20660
20877
|
return match?.[1] ?? null;
|
|
20661
20878
|
}
|
|
20662
20879
|
function parsedIssueTypeRes(issueType) {
|
|
20663
|
-
return
|
|
20880
|
+
return z42.nativeEnum(IssueType_Enum).safeParse(issueType);
|
|
20664
20881
|
}
|
|
20665
20882
|
var LocalMobbFolderService = class {
|
|
20666
20883
|
/**
|
|
@@ -23357,8 +23574,8 @@ Example payload:
|
|
|
23357
23574
|
},
|
|
23358
23575
|
required: ["path"]
|
|
23359
23576
|
});
|
|
23360
|
-
__publicField(this, "inputValidationSchema",
|
|
23361
|
-
path:
|
|
23577
|
+
__publicField(this, "inputValidationSchema", z43.object({
|
|
23578
|
+
path: z43.string().describe(
|
|
23362
23579
|
"Full local path to the cloned git repository to check for new available fixes"
|
|
23363
23580
|
)
|
|
23364
23581
|
}));
|
|
@@ -23388,7 +23605,7 @@ Example payload:
|
|
|
23388
23605
|
|
|
23389
23606
|
// src/mcp/tools/fetchAvailableFixes/FetchAvailableFixesTool.ts
|
|
23390
23607
|
init_GitService();
|
|
23391
|
-
import { z as
|
|
23608
|
+
import { z as z44 } from "zod";
|
|
23392
23609
|
|
|
23393
23610
|
// src/mcp/tools/fetchAvailableFixes/FetchAvailableFixesService.ts
|
|
23394
23611
|
init_configs();
|
|
@@ -23531,16 +23748,16 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
23531
23748
|
},
|
|
23532
23749
|
required: ["path"]
|
|
23533
23750
|
});
|
|
23534
|
-
__publicField(this, "inputValidationSchema",
|
|
23535
|
-
path:
|
|
23751
|
+
__publicField(this, "inputValidationSchema", z44.object({
|
|
23752
|
+
path: z44.string().describe(
|
|
23536
23753
|
"Full local path to the cloned git repository to check for available fixes"
|
|
23537
23754
|
),
|
|
23538
|
-
offset:
|
|
23539
|
-
limit:
|
|
23540
|
-
fileFilter:
|
|
23755
|
+
offset: z44.number().optional().describe("Optional offset for pagination"),
|
|
23756
|
+
limit: z44.number().optional().describe("Optional maximum number of fixes to return"),
|
|
23757
|
+
fileFilter: z44.array(z44.string()).optional().describe(
|
|
23541
23758
|
"Optional list of file paths relative to the path parameter to filter fixes by. INCOMPATIBLE with fetchFixesFromAnyFile"
|
|
23542
23759
|
),
|
|
23543
|
-
fetchFixesFromAnyFile:
|
|
23760
|
+
fetchFixesFromAnyFile: z44.boolean().optional().describe(
|
|
23544
23761
|
"Optional boolean to fetch fixes for all files. INCOMPATIBLE with fileFilter"
|
|
23545
23762
|
)
|
|
23546
23763
|
}));
|
|
@@ -23605,7 +23822,7 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
23605
23822
|
};
|
|
23606
23823
|
|
|
23607
23824
|
// src/mcp/tools/mcpChecker/mcpCheckerTool.ts
|
|
23608
|
-
import
|
|
23825
|
+
import z45 from "zod";
|
|
23609
23826
|
|
|
23610
23827
|
// src/mcp/tools/mcpChecker/mcpCheckerService.ts
|
|
23611
23828
|
var _McpCheckerService = class _McpCheckerService {
|
|
@@ -23666,7 +23883,7 @@ var McpCheckerTool = class extends BaseTool {
|
|
|
23666
23883
|
__publicField(this, "displayName", "MCP Checker");
|
|
23667
23884
|
// A detailed description to guide the LLM on when and how to invoke this tool.
|
|
23668
23885
|
__publicField(this, "description", "Check the MCP servers running on this IDE against organization policies.");
|
|
23669
|
-
__publicField(this, "inputValidationSchema",
|
|
23886
|
+
__publicField(this, "inputValidationSchema", z45.object({}));
|
|
23670
23887
|
__publicField(this, "inputSchema", {
|
|
23671
23888
|
type: "object",
|
|
23672
23889
|
properties: {},
|
|
@@ -23692,7 +23909,7 @@ var McpCheckerTool = class extends BaseTool {
|
|
|
23692
23909
|
};
|
|
23693
23910
|
|
|
23694
23911
|
// src/mcp/tools/scanAndFixVulnerabilities/ScanAndFixVulnerabilitiesTool.ts
|
|
23695
|
-
import
|
|
23912
|
+
import z46 from "zod";
|
|
23696
23913
|
init_configs();
|
|
23697
23914
|
|
|
23698
23915
|
// src/mcp/tools/scanAndFixVulnerabilities/ScanAndFixVulnerabilitiesService.ts
|
|
@@ -23880,17 +24097,17 @@ Example payload:
|
|
|
23880
24097
|
"rescan": false
|
|
23881
24098
|
}`);
|
|
23882
24099
|
__publicField(this, "hasAuthentication", true);
|
|
23883
|
-
__publicField(this, "inputValidationSchema",
|
|
23884
|
-
path:
|
|
24100
|
+
__publicField(this, "inputValidationSchema", z46.object({
|
|
24101
|
+
path: z46.string().describe(
|
|
23885
24102
|
"Full local path to repository to scan and fix vulnerabilities"
|
|
23886
24103
|
),
|
|
23887
|
-
offset:
|
|
23888
|
-
limit:
|
|
23889
|
-
maxFiles:
|
|
24104
|
+
offset: z46.number().optional().describe("Optional offset for pagination"),
|
|
24105
|
+
limit: z46.number().optional().describe("Optional maximum number of results to return"),
|
|
24106
|
+
maxFiles: z46.number().optional().describe(
|
|
23890
24107
|
`Optional maximum number of files to scan (default: ${MCP_DEFAULT_MAX_FILES_TO_SCAN}). Increase for comprehensive scans of larger codebases or decrease for faster focused scans.`
|
|
23891
24108
|
),
|
|
23892
|
-
rescan:
|
|
23893
|
-
scanRecentlyChangedFiles:
|
|
24109
|
+
rescan: z46.boolean().optional().describe("Optional whether to rescan the repository"),
|
|
24110
|
+
scanRecentlyChangedFiles: z46.boolean().optional().describe(
|
|
23894
24111
|
"Optional whether to automatically scan recently changed files when no changed files are found in git status. If false, the tool will prompt the user instead."
|
|
23895
24112
|
)
|
|
23896
24113
|
}));
|
|
@@ -24198,7 +24415,7 @@ async function addScmTokenHandler(args) {
|
|
|
24198
24415
|
}
|
|
24199
24416
|
|
|
24200
24417
|
// src/features/codeium_intellij/data_collector.ts
|
|
24201
|
-
import { z as
|
|
24418
|
+
import { z as z47 } from "zod";
|
|
24202
24419
|
init_client_generates();
|
|
24203
24420
|
init_urlParser2();
|
|
24204
24421
|
|
|
@@ -24339,8 +24556,8 @@ function findRunningCodeiumLanguageServers() {
|
|
|
24339
24556
|
}
|
|
24340
24557
|
|
|
24341
24558
|
// src/features/codeium_intellij/data_collector.ts
|
|
24342
|
-
var HookDataSchema2 =
|
|
24343
|
-
trajectory_id:
|
|
24559
|
+
var HookDataSchema2 = z47.object({
|
|
24560
|
+
trajectory_id: z47.string()
|
|
24344
24561
|
});
|
|
24345
24562
|
async function processAndUploadHookData2() {
|
|
24346
24563
|
const tracePayload = await getTraceDataForHook();
|
|
@@ -24720,13 +24937,13 @@ var parseArgs = async (args) => {
|
|
|
24720
24937
|
};
|
|
24721
24938
|
|
|
24722
24939
|
// src/index.ts
|
|
24723
|
-
var
|
|
24940
|
+
var debug20 = Debug20("mobbdev:index");
|
|
24724
24941
|
async function run() {
|
|
24725
24942
|
return parseArgs(hideBin(process.argv));
|
|
24726
24943
|
}
|
|
24727
24944
|
(async () => {
|
|
24728
24945
|
try {
|
|
24729
|
-
|
|
24946
|
+
debug20("Bugsy CLI v%s running...", packageJson.version);
|
|
24730
24947
|
await run();
|
|
24731
24948
|
process.exit(0);
|
|
24732
24949
|
} catch (err) {
|