mobbdev 1.1.14 → 1.1.17
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.d.mts +28 -28
- package/dist/args/commands/upload_ai_blame.mjs +223 -132
- package/dist/index.mjs +263 -154
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -1318,7 +1318,7 @@ ${rootContent}`;
|
|
|
1318
1318
|
});
|
|
1319
1319
|
|
|
1320
1320
|
// src/index.ts
|
|
1321
|
-
import
|
|
1321
|
+
import Debug19 from "debug";
|
|
1322
1322
|
import { hideBin } from "yargs/helpers";
|
|
1323
1323
|
|
|
1324
1324
|
// src/args/yargs.ts
|
|
@@ -2075,6 +2075,57 @@ var UploadS3BucketInfoDocument = `
|
|
|
2075
2075
|
}
|
|
2076
2076
|
}
|
|
2077
2077
|
`;
|
|
2078
|
+
var AnalyzeCommitForExtensionAiBlameDocument = `
|
|
2079
|
+
mutation AnalyzeCommitForExtensionAIBlame($repositoryURL: String!, $commitSha: String!, $organizationId: String!) {
|
|
2080
|
+
analyzeCommitForAIBlame(
|
|
2081
|
+
repositoryURL: $repositoryURL
|
|
2082
|
+
commitSha: $commitSha
|
|
2083
|
+
organizationId: $organizationId
|
|
2084
|
+
) {
|
|
2085
|
+
__typename
|
|
2086
|
+
... on ProcessAIBlameFinalResult {
|
|
2087
|
+
status
|
|
2088
|
+
inferencesProcessed
|
|
2089
|
+
attributionsCreated
|
|
2090
|
+
attributions {
|
|
2091
|
+
id
|
|
2092
|
+
aiBlameCommitId
|
|
2093
|
+
aiBlameInferenceId
|
|
2094
|
+
filePath
|
|
2095
|
+
lineNumber
|
|
2096
|
+
model
|
|
2097
|
+
toolName
|
|
2098
|
+
commitSha
|
|
2099
|
+
inferenceType
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
... on ProcessAIBlameErrorResult {
|
|
2103
|
+
status
|
|
2104
|
+
error
|
|
2105
|
+
}
|
|
2106
|
+
... on ProcessAIBlameRequestedResult {
|
|
2107
|
+
status
|
|
2108
|
+
requestIds
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
`;
|
|
2113
|
+
var GetAiBlameInferenceDocument = `
|
|
2114
|
+
query GetAIBlameInference($aiBlameInferenceIds: [uuid!]) {
|
|
2115
|
+
ai_blame_inference(where: {id: {_in: $aiBlameInferenceIds}}) {
|
|
2116
|
+
id
|
|
2117
|
+
type
|
|
2118
|
+
aiResponseAt
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
`;
|
|
2122
|
+
var GetAiBlameAttributionPromptDocument = `
|
|
2123
|
+
query GetAIBlameAttributionPrompt($aiBlameAttributionId: String!) {
|
|
2124
|
+
getAIBlameInferenceData(aiBlameAttributionId: $aiBlameAttributionId) {
|
|
2125
|
+
promptUrl
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
`;
|
|
2078
2129
|
var UploadAiBlameInferencesInitDocument = `
|
|
2079
2130
|
mutation UploadAIBlameInferencesInit($sessions: [AIBlameInferenceInitInput!]!) {
|
|
2080
2131
|
uploadAIBlameInferencesInit(sessions: $sessions) {
|
|
@@ -2368,6 +2419,15 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
2368
2419
|
uploadS3BucketInfo(variables, requestHeaders, signal) {
|
|
2369
2420
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: UploadS3BucketInfoDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "uploadS3BucketInfo", "mutation", variables);
|
|
2370
2421
|
},
|
|
2422
|
+
AnalyzeCommitForExtensionAIBlame(variables, requestHeaders, signal) {
|
|
2423
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: AnalyzeCommitForExtensionAiBlameDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "AnalyzeCommitForExtensionAIBlame", "mutation", variables);
|
|
2424
|
+
},
|
|
2425
|
+
GetAIBlameInference(variables, requestHeaders, signal) {
|
|
2426
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAiBlameInferenceDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAIBlameInference", "query", variables);
|
|
2427
|
+
},
|
|
2428
|
+
GetAIBlameAttributionPrompt(variables, requestHeaders, signal) {
|
|
2429
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAiBlameAttributionPromptDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAIBlameAttributionPrompt", "query", variables);
|
|
2430
|
+
},
|
|
2371
2431
|
UploadAIBlameInferencesInit(variables, requestHeaders, signal) {
|
|
2372
2432
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: UploadAiBlameInferencesInitDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "UploadAIBlameInferencesInit", "mutation", variables);
|
|
2373
2433
|
},
|
|
@@ -10565,7 +10625,7 @@ import path9 from "path";
|
|
|
10565
10625
|
import { env as env2 } from "process";
|
|
10566
10626
|
import { pipeline } from "stream/promises";
|
|
10567
10627
|
import chalk6 from "chalk";
|
|
10568
|
-
import
|
|
10628
|
+
import Debug18 from "debug";
|
|
10569
10629
|
import extract from "extract-zip";
|
|
10570
10630
|
import { createSpinner as createSpinner4 } from "nanospinner";
|
|
10571
10631
|
import fetch4 from "node-fetch";
|
|
@@ -10577,15 +10637,14 @@ import { z as z29 } from "zod";
|
|
|
10577
10637
|
import crypto from "crypto";
|
|
10578
10638
|
import os from "os";
|
|
10579
10639
|
import chalk3 from "chalk";
|
|
10580
|
-
import
|
|
10640
|
+
import Debug6 from "debug";
|
|
10581
10641
|
import open from "open";
|
|
10582
10642
|
|
|
10583
10643
|
// src/features/analysis/graphql/gql.ts
|
|
10584
10644
|
import fetchOrig from "cross-fetch";
|
|
10585
|
-
import
|
|
10645
|
+
import Debug5 from "debug";
|
|
10586
10646
|
import { GraphQLClient } from "graphql-request";
|
|
10587
|
-
import {
|
|
10588
|
-
import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
10647
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
10589
10648
|
import { v4 as uuidv4 } from "uuid";
|
|
10590
10649
|
|
|
10591
10650
|
// src/mcp/core/Errors.ts
|
|
@@ -10660,39 +10719,56 @@ var _ReportDigestError = class _ReportDigestError extends Error {
|
|
|
10660
10719
|
__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.");
|
|
10661
10720
|
var ReportDigestError = _ReportDigestError;
|
|
10662
10721
|
|
|
10663
|
-
// src/
|
|
10664
|
-
import Debug5 from "debug";
|
|
10722
|
+
// src/utils/subscribe/subscribe.ts
|
|
10665
10723
|
import { createClient } from "graphql-ws";
|
|
10666
|
-
import
|
|
10667
|
-
|
|
10724
|
+
import WebsocketNode from "isomorphic-ws";
|
|
10725
|
+
|
|
10726
|
+
// src/utils/subscribe/graphql.ts
|
|
10727
|
+
function getGraphQlHeaders(options) {
|
|
10728
|
+
const headers = {
|
|
10729
|
+
"Content-Type": "application/json"
|
|
10730
|
+
};
|
|
10731
|
+
if ("type" in options) {
|
|
10732
|
+
if (options.type === "apiKey") {
|
|
10733
|
+
headers["x-mobb-key"] = options.apiKey;
|
|
10734
|
+
} else if (options.type === "token") {
|
|
10735
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
10736
|
+
}
|
|
10737
|
+
return headers;
|
|
10738
|
+
}
|
|
10739
|
+
if ("isAdmin" in options && options.isAdmin) {
|
|
10740
|
+
headers["x-hasura-access-key"] = options.adminPassword;
|
|
10741
|
+
} else if ("isApiKey" in options && options.isApiKey) {
|
|
10742
|
+
headers["x-mobb-key"] = options.apiKey;
|
|
10743
|
+
} else if ("accessToken" in options) {
|
|
10744
|
+
headers["Authorization"] = `Bearer ${options.accessToken}`;
|
|
10745
|
+
}
|
|
10746
|
+
return headers;
|
|
10747
|
+
}
|
|
10748
|
+
|
|
10749
|
+
// src/utils/subscribe/subscribe.ts
|
|
10668
10750
|
var DEFAULT_API_URL2 = "https://api.mobb.ai/v1/graphql";
|
|
10669
|
-
var debug6 = Debug5("mobbdev:subscribe");
|
|
10670
10751
|
var SUBSCRIPTION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
10671
10752
|
function createWSClient(options) {
|
|
10672
|
-
const
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
protocols,
|
|
10681
|
-
proxy ? { agent: proxy } : void 0
|
|
10682
|
-
);
|
|
10753
|
+
const url = options.url || (process.env["API_URL"] || DEFAULT_API_URL2).replace("http", "ws");
|
|
10754
|
+
const websocketImpl = options.websocket || (typeof WebSocket !== "undefined" ? WebSocket : WebsocketNode);
|
|
10755
|
+
const CustomWebSocket = options.proxyAgent ? (
|
|
10756
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic WebSocket extension requires any cast for cross-platform compatibility
|
|
10757
|
+
class extends websocketImpl {
|
|
10758
|
+
constructor(address, protocols) {
|
|
10759
|
+
super(address, protocols, { agent: options.proxyAgent });
|
|
10760
|
+
}
|
|
10683
10761
|
}
|
|
10684
|
-
|
|
10762
|
+
) : websocketImpl;
|
|
10685
10763
|
return createClient({
|
|
10686
10764
|
//this is needed to prevent AWS from killing the connection
|
|
10687
10765
|
//currently our load balancer has a 29s idle timeout
|
|
10688
10766
|
keepAlive: 1e4,
|
|
10689
|
-
url
|
|
10690
|
-
webSocketImpl:
|
|
10767
|
+
url,
|
|
10768
|
+
webSocketImpl: CustomWebSocket,
|
|
10691
10769
|
connectionParams: () => {
|
|
10692
10770
|
return {
|
|
10693
|
-
headers: options
|
|
10694
|
-
[API_KEY_HEADER_NAME]: options.apiKey
|
|
10695
|
-
} : { authorization: `Bearer ${options.token}` }
|
|
10771
|
+
headers: getGraphQlHeaders(options)
|
|
10696
10772
|
};
|
|
10697
10773
|
}
|
|
10698
10774
|
});
|
|
@@ -10700,33 +10776,44 @@ function createWSClient(options) {
|
|
|
10700
10776
|
function subscribe(query, variables, callback, wsClientOptions) {
|
|
10701
10777
|
return new Promise((resolve, reject) => {
|
|
10702
10778
|
let timer = null;
|
|
10779
|
+
let settled = false;
|
|
10703
10780
|
const { timeoutInMs = SUBSCRIPTION_TIMEOUT_MS } = wsClientOptions;
|
|
10704
|
-
const
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10781
|
+
const client = createWSClient(wsClientOptions);
|
|
10782
|
+
let unsubscribe = () => {
|
|
10783
|
+
return;
|
|
10784
|
+
};
|
|
10785
|
+
function cleanup() {
|
|
10786
|
+
try {
|
|
10787
|
+
unsubscribe();
|
|
10788
|
+
} catch {
|
|
10789
|
+
}
|
|
10790
|
+
if (timer) {
|
|
10791
|
+
clearTimeout(timer);
|
|
10792
|
+
timer = null;
|
|
10793
|
+
}
|
|
10794
|
+
}
|
|
10795
|
+
function finalizeResolve(data) {
|
|
10796
|
+
if (settled) {
|
|
10797
|
+
return;
|
|
10798
|
+
}
|
|
10799
|
+
settled = true;
|
|
10800
|
+
cleanup();
|
|
10801
|
+
resolve(data);
|
|
10802
|
+
}
|
|
10803
|
+
function finalizeReject(error) {
|
|
10804
|
+
if (settled) {
|
|
10805
|
+
return;
|
|
10806
|
+
}
|
|
10807
|
+
settled = true;
|
|
10808
|
+
cleanup();
|
|
10809
|
+
reject(error);
|
|
10810
|
+
}
|
|
10811
|
+
unsubscribe = client.subscribe(
|
|
10711
10812
|
{ query, variables },
|
|
10712
10813
|
{
|
|
10713
10814
|
next: (data) => {
|
|
10714
|
-
function callbackResolve(data2) {
|
|
10715
|
-
unsubscribe();
|
|
10716
|
-
if (timer) {
|
|
10717
|
-
clearTimeout(timer);
|
|
10718
|
-
}
|
|
10719
|
-
resolve(data2);
|
|
10720
|
-
}
|
|
10721
|
-
function callbackReject(data2) {
|
|
10722
|
-
unsubscribe();
|
|
10723
|
-
if (timer) {
|
|
10724
|
-
clearTimeout(timer);
|
|
10725
|
-
}
|
|
10726
|
-
reject(data2);
|
|
10727
|
-
}
|
|
10728
10815
|
if (!data.data) {
|
|
10729
|
-
|
|
10816
|
+
finalizeReject(
|
|
10730
10817
|
new Error(
|
|
10731
10818
|
`Broken data object from graphQL subscribe: ${JSON.stringify(
|
|
10732
10819
|
data
|
|
@@ -10734,14 +10821,11 @@ function subscribe(query, variables, callback, wsClientOptions) {
|
|
|
10734
10821
|
)
|
|
10735
10822
|
);
|
|
10736
10823
|
} else {
|
|
10737
|
-
callback(
|
|
10824
|
+
callback(finalizeResolve, finalizeReject, data.data);
|
|
10738
10825
|
}
|
|
10739
10826
|
},
|
|
10740
10827
|
error: (error) => {
|
|
10741
|
-
|
|
10742
|
-
clearTimeout(timer);
|
|
10743
|
-
}
|
|
10744
|
-
reject(error);
|
|
10828
|
+
finalizeReject(error);
|
|
10745
10829
|
},
|
|
10746
10830
|
complete: () => {
|
|
10747
10831
|
return;
|
|
@@ -10750,8 +10834,7 @@ function subscribe(query, variables, callback, wsClientOptions) {
|
|
|
10750
10834
|
);
|
|
10751
10835
|
if (typeof timeoutInMs === "number") {
|
|
10752
10836
|
timer = setTimeout(() => {
|
|
10753
|
-
|
|
10754
|
-
reject(
|
|
10837
|
+
finalizeReject(
|
|
10755
10838
|
new Error(
|
|
10756
10839
|
`Timeout expired for graphQL subscribe query: ${query} with timeout: ${timeoutInMs}`
|
|
10757
10840
|
)
|
|
@@ -10823,7 +10906,7 @@ var GetVulByNodesMetadataZ = z25.object({
|
|
|
10823
10906
|
});
|
|
10824
10907
|
|
|
10825
10908
|
// src/features/analysis/graphql/gql.ts
|
|
10826
|
-
var
|
|
10909
|
+
var debug6 = Debug5("mobbdev:gql");
|
|
10827
10910
|
var API_KEY_HEADER_NAME = "x-mobb-key";
|
|
10828
10911
|
var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
|
|
10829
10912
|
function getProxyAgent(url) {
|
|
@@ -10831,14 +10914,14 @@ function getProxyAgent(url) {
|
|
|
10831
10914
|
const parsedUrl = new URL(url);
|
|
10832
10915
|
const isHttp = parsedUrl.protocol === "http:";
|
|
10833
10916
|
const isHttps = parsedUrl.protocol === "https:";
|
|
10834
|
-
const proxy = isHttps ? HTTPS_PROXY : isHttp ? HTTP_PROXY : null;
|
|
10917
|
+
const proxy = isHttps ? HTTPS_PROXY || HTTP_PROXY : isHttp ? HTTP_PROXY : null;
|
|
10835
10918
|
if (proxy) {
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
return
|
|
10919
|
+
debug6("Using proxy %s", proxy);
|
|
10920
|
+
debug6("Proxy agent %o", proxy);
|
|
10921
|
+
return new HttpsProxyAgent(proxy);
|
|
10839
10922
|
}
|
|
10840
10923
|
} catch (err) {
|
|
10841
|
-
|
|
10924
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
10842
10925
|
}
|
|
10843
10926
|
return void 0;
|
|
10844
10927
|
}
|
|
@@ -10853,7 +10936,7 @@ var fetchWithProxy = (url, options = {}) => {
|
|
|
10853
10936
|
});
|
|
10854
10937
|
}
|
|
10855
10938
|
} catch (err) {
|
|
10856
|
-
|
|
10939
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
10857
10940
|
}
|
|
10858
10941
|
return fetchOrig(url, options);
|
|
10859
10942
|
};
|
|
@@ -10862,7 +10945,7 @@ var GQLClient = class {
|
|
|
10862
10945
|
__publicField(this, "_client");
|
|
10863
10946
|
__publicField(this, "_clientSdk");
|
|
10864
10947
|
__publicField(this, "_auth");
|
|
10865
|
-
|
|
10948
|
+
debug6(`init with ${args}`);
|
|
10866
10949
|
this._auth = args;
|
|
10867
10950
|
this._client = new GraphQLClient(API_URL, {
|
|
10868
10951
|
headers: args.type === "apiKey" ? { [API_KEY_HEADER_NAME]: args.apiKey || "" } : {
|
|
@@ -10871,7 +10954,7 @@ var GQLClient = class {
|
|
|
10871
10954
|
fetch: fetchWithProxy,
|
|
10872
10955
|
requestMiddleware: (request) => {
|
|
10873
10956
|
const requestId = uuidv4();
|
|
10874
|
-
|
|
10957
|
+
debug6(
|
|
10875
10958
|
`sending API request with id: ${requestId} and with request: ${request.body}`
|
|
10876
10959
|
);
|
|
10877
10960
|
return {
|
|
@@ -10908,7 +10991,7 @@ var GQLClient = class {
|
|
|
10908
10991
|
await this.getUserInfo();
|
|
10909
10992
|
} catch (e) {
|
|
10910
10993
|
if (e?.toString().startsWith("FetchError")) {
|
|
10911
|
-
|
|
10994
|
+
debug6("verify connection failed %o", e);
|
|
10912
10995
|
return false;
|
|
10913
10996
|
}
|
|
10914
10997
|
}
|
|
@@ -10920,7 +11003,7 @@ var GQLClient = class {
|
|
|
10920
11003
|
try {
|
|
10921
11004
|
info = await this.getUserInfo();
|
|
10922
11005
|
} catch (e) {
|
|
10923
|
-
|
|
11006
|
+
debug6("verify token failed %o", e);
|
|
10924
11007
|
return false;
|
|
10925
11008
|
}
|
|
10926
11009
|
return info?.email || true;
|
|
@@ -10981,7 +11064,7 @@ var GQLClient = class {
|
|
|
10981
11064
|
try {
|
|
10982
11065
|
await this._clientSdk.CreateCommunityUser();
|
|
10983
11066
|
} catch (e) {
|
|
10984
|
-
|
|
11067
|
+
debug6("create community user failed %o", e);
|
|
10985
11068
|
}
|
|
10986
11069
|
}
|
|
10987
11070
|
async updateScmToken(args) {
|
|
@@ -11148,11 +11231,13 @@ var GQLClient = class {
|
|
|
11148
11231
|
this._auth.type === "apiKey" ? {
|
|
11149
11232
|
apiKey: this._auth.apiKey,
|
|
11150
11233
|
type: "apiKey",
|
|
11151
|
-
timeoutInMs: params.timeoutInMs
|
|
11234
|
+
timeoutInMs: params.timeoutInMs,
|
|
11235
|
+
proxyAgent: getProxyAgent(API_URL)
|
|
11152
11236
|
} : {
|
|
11153
11237
|
token: this._auth.token,
|
|
11154
11238
|
type: "token",
|
|
11155
|
-
timeoutInMs: params.timeoutInMs
|
|
11239
|
+
timeoutInMs: params.timeoutInMs,
|
|
11240
|
+
proxyAgent: getProxyAgent(API_URL)
|
|
11156
11241
|
}
|
|
11157
11242
|
);
|
|
11158
11243
|
}
|
|
@@ -11205,6 +11290,12 @@ var GQLClient = class {
|
|
|
11205
11290
|
async finalizeAIBlameInferencesUploadRaw(variables) {
|
|
11206
11291
|
return await this._clientSdk.FinalizeAIBlameInferencesUpload(variables);
|
|
11207
11292
|
}
|
|
11293
|
+
async analyzeCommitForExtensionAIBlame(variables) {
|
|
11294
|
+
return await this._clientSdk.AnalyzeCommitForExtensionAIBlame(variables);
|
|
11295
|
+
}
|
|
11296
|
+
async getAIBlameAttributionPrompt(variables) {
|
|
11297
|
+
return await this._clientSdk.GetAIBlameAttributionPrompt(variables);
|
|
11298
|
+
}
|
|
11208
11299
|
};
|
|
11209
11300
|
|
|
11210
11301
|
// src/utils/ConfigStoreService.ts
|
|
@@ -11227,7 +11318,7 @@ function getConfigStore() {
|
|
|
11227
11318
|
var configStore = getConfigStore();
|
|
11228
11319
|
|
|
11229
11320
|
// src/commands/handleMobbLogin.ts
|
|
11230
|
-
var
|
|
11321
|
+
var debug7 = Debug6("mobbdev:commands");
|
|
11231
11322
|
var LOGIN_MAX_WAIT = 10 * 60 * 1e3;
|
|
11232
11323
|
var LOGIN_CHECK_DELAY = 5 * 1e3;
|
|
11233
11324
|
var webLoginUrl = `${WEB_APP_URL}/cli-login`;
|
|
@@ -11306,9 +11397,9 @@ async function handleMobbLogin({
|
|
|
11306
11397
|
});
|
|
11307
11398
|
loginSpinner.spin();
|
|
11308
11399
|
if (encryptedApiToken) {
|
|
11309
|
-
|
|
11400
|
+
debug7("encrypted API token received %s", encryptedApiToken);
|
|
11310
11401
|
newApiToken = crypto.privateDecrypt(privateKey, Buffer.from(encryptedApiToken, "base64")).toString("utf-8");
|
|
11311
|
-
|
|
11402
|
+
debug7("API token decrypted");
|
|
11312
11403
|
break;
|
|
11313
11404
|
}
|
|
11314
11405
|
await sleep(LOGIN_CHECK_DELAY);
|
|
@@ -11322,7 +11413,7 @@ async function handleMobbLogin({
|
|
|
11322
11413
|
const newGqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
|
|
11323
11414
|
const loginSuccess = await newGqlClient.validateUserToken();
|
|
11324
11415
|
if (loginSuccess) {
|
|
11325
|
-
|
|
11416
|
+
debug7(`set api token ${newApiToken}`);
|
|
11326
11417
|
configStore.set("apiToken", newApiToken);
|
|
11327
11418
|
loginSpinner.success({
|
|
11328
11419
|
text: `\u{1F513} Login to Mobb successful! ${typeof loginSpinner === "string" ? `Logged in as ${loginSuccess}` : ""}`
|
|
@@ -11337,10 +11428,10 @@ async function handleMobbLogin({
|
|
|
11337
11428
|
}
|
|
11338
11429
|
|
|
11339
11430
|
// src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
|
|
11340
|
-
import
|
|
11431
|
+
import Debug10 from "debug";
|
|
11341
11432
|
|
|
11342
11433
|
// src/features/analysis/add_fix_comments_for_pr/utils/utils.ts
|
|
11343
|
-
import
|
|
11434
|
+
import Debug9 from "debug";
|
|
11344
11435
|
import parseDiff from "parse-diff";
|
|
11345
11436
|
import { z as z27 } from "zod";
|
|
11346
11437
|
|
|
@@ -11352,8 +11443,8 @@ function keyBy(array, keyBy2) {
|
|
|
11352
11443
|
}
|
|
11353
11444
|
|
|
11354
11445
|
// src/features/analysis/utils/send_report.ts
|
|
11355
|
-
import
|
|
11356
|
-
var
|
|
11446
|
+
import Debug7 from "debug";
|
|
11447
|
+
var debug8 = Debug7("mobbdev:index");
|
|
11357
11448
|
async function sendReport({
|
|
11358
11449
|
spinner,
|
|
11359
11450
|
submitVulnerabilityReportVariables,
|
|
@@ -11364,7 +11455,7 @@ async function sendReport({
|
|
|
11364
11455
|
submitVulnerabilityReportVariables
|
|
11365
11456
|
);
|
|
11366
11457
|
if (submitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
|
|
11367
|
-
|
|
11458
|
+
debug8("error submit vul report %s", submitRes);
|
|
11368
11459
|
throw new Error("\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed");
|
|
11369
11460
|
}
|
|
11370
11461
|
spinner.update({ text: progressMassages.processingVulnerabilityReport });
|
|
@@ -11414,9 +11505,9 @@ var scannerToFriendlyString = {
|
|
|
11414
11505
|
};
|
|
11415
11506
|
|
|
11416
11507
|
// src/features/analysis/add_fix_comments_for_pr/utils/buildCommentBody.ts
|
|
11417
|
-
import
|
|
11508
|
+
import Debug8 from "debug";
|
|
11418
11509
|
import { z as z26 } from "zod";
|
|
11419
|
-
var
|
|
11510
|
+
var debug9 = Debug8("mobbdev:handle-finished-analysis");
|
|
11420
11511
|
var getCommitFixButton = (commitUrl) => `<a href="${commitUrl}"><img src=${COMMIT_FIX_SVG}></a>`;
|
|
11421
11512
|
function buildFixCommentBody({
|
|
11422
11513
|
fix,
|
|
@@ -11475,7 +11566,7 @@ function buildFixCommentBody({
|
|
|
11475
11566
|
safeIssueType: z26.nativeEnum(IssueType_Enum)
|
|
11476
11567
|
}).safeParse(fix);
|
|
11477
11568
|
if (!validFixParseRes.success) {
|
|
11478
|
-
|
|
11569
|
+
debug9(
|
|
11479
11570
|
`fix ${fixId} has custom issue type or language, therefore the commit description will not be added`,
|
|
11480
11571
|
validFixParseRes.error
|
|
11481
11572
|
);
|
|
@@ -11539,7 +11630,7 @@ ${issuePageLink}`;
|
|
|
11539
11630
|
}
|
|
11540
11631
|
|
|
11541
11632
|
// src/features/analysis/add_fix_comments_for_pr/utils/utils.ts
|
|
11542
|
-
var
|
|
11633
|
+
var debug10 = Debug9("mobbdev:handle-finished-analysis");
|
|
11543
11634
|
function calculateRanges(integers) {
|
|
11544
11635
|
if (integers.length === 0) {
|
|
11545
11636
|
return [];
|
|
@@ -11573,7 +11664,7 @@ function deleteAllPreviousComments({
|
|
|
11573
11664
|
try {
|
|
11574
11665
|
return scm.deleteComment({ comment_id: comment.id });
|
|
11575
11666
|
} catch (e) {
|
|
11576
|
-
|
|
11667
|
+
debug10("delete comment failed %s", e);
|
|
11577
11668
|
return Promise.resolve();
|
|
11578
11669
|
}
|
|
11579
11670
|
});
|
|
@@ -11589,7 +11680,7 @@ function deleteAllPreviousGeneralPrComments(params) {
|
|
|
11589
11680
|
try {
|
|
11590
11681
|
return scm.deleteGeneralPrComment({ commentId: comment.id });
|
|
11591
11682
|
} catch (e) {
|
|
11592
|
-
|
|
11683
|
+
debug10("delete comment failed %s", e);
|
|
11593
11684
|
return Promise.resolve();
|
|
11594
11685
|
}
|
|
11595
11686
|
});
|
|
@@ -11733,7 +11824,7 @@ async function postAnalysisInsightComment(params) {
|
|
|
11733
11824
|
fixablePrVuls,
|
|
11734
11825
|
nonFixablePrVuls
|
|
11735
11826
|
} = prVulenrabilities;
|
|
11736
|
-
|
|
11827
|
+
debug10({
|
|
11737
11828
|
fixablePrVuls,
|
|
11738
11829
|
nonFixablePrVuls,
|
|
11739
11830
|
vulnerabilitiesOutsidePr,
|
|
@@ -11788,7 +11879,7 @@ ${contactUsMarkdown}`;
|
|
|
11788
11879
|
}
|
|
11789
11880
|
|
|
11790
11881
|
// src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
|
|
11791
|
-
var
|
|
11882
|
+
var debug11 = Debug10("mobbdev:handle-finished-analysis");
|
|
11792
11883
|
async function addFixCommentsForPr({
|
|
11793
11884
|
analysisId,
|
|
11794
11885
|
scm: _scm,
|
|
@@ -11800,7 +11891,7 @@ async function addFixCommentsForPr({
|
|
|
11800
11891
|
}
|
|
11801
11892
|
const scm = _scm;
|
|
11802
11893
|
const getAnalysisRes = await gqlClient.getAnalysis(analysisId);
|
|
11803
|
-
|
|
11894
|
+
debug11("getAnalysis %o", getAnalysisRes);
|
|
11804
11895
|
const {
|
|
11805
11896
|
vulnerabilityReport: {
|
|
11806
11897
|
projectId,
|
|
@@ -11909,8 +12000,8 @@ ${contextString}` : description;
|
|
|
11909
12000
|
}
|
|
11910
12001
|
|
|
11911
12002
|
// src/features/analysis/auto_pr_handler.ts
|
|
11912
|
-
import
|
|
11913
|
-
var
|
|
12003
|
+
import Debug11 from "debug";
|
|
12004
|
+
var debug12 = Debug11("mobbdev:handleAutoPr");
|
|
11914
12005
|
async function handleAutoPr(params) {
|
|
11915
12006
|
const {
|
|
11916
12007
|
gqlClient,
|
|
@@ -11934,7 +12025,7 @@ async function handleAutoPr(params) {
|
|
|
11934
12025
|
prId,
|
|
11935
12026
|
prStrategy: createOnePr ? "CONDENSE" /* Condense */ : "SPREAD" /* Spread */
|
|
11936
12027
|
});
|
|
11937
|
-
|
|
12028
|
+
debug12("auto pr analysis res %o", autoPrAnalysisRes);
|
|
11938
12029
|
if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
|
|
11939
12030
|
createAutoPrSpinner.error({
|
|
11940
12031
|
text: `\u{1F504} Automatic pull request failed - ${autoPrAnalysisRes.autoPrAnalysis.error}`
|
|
@@ -11960,15 +12051,15 @@ async function handleAutoPr(params) {
|
|
|
11960
12051
|
|
|
11961
12052
|
// src/features/analysis/git.ts
|
|
11962
12053
|
init_GitService();
|
|
11963
|
-
import
|
|
11964
|
-
var
|
|
12054
|
+
import Debug12 from "debug";
|
|
12055
|
+
var debug13 = Debug12("mobbdev:git");
|
|
11965
12056
|
async function getGitInfo(srcDirPath) {
|
|
11966
|
-
|
|
12057
|
+
debug13("getting git info for %s", srcDirPath);
|
|
11967
12058
|
const gitService = new GitService(srcDirPath);
|
|
11968
12059
|
try {
|
|
11969
12060
|
const validationResult = await gitService.validateRepository();
|
|
11970
12061
|
if (!validationResult.isValid) {
|
|
11971
|
-
|
|
12062
|
+
debug13("folder is not a git repo");
|
|
11972
12063
|
return {
|
|
11973
12064
|
success: false,
|
|
11974
12065
|
hash: void 0,
|
|
@@ -11983,9 +12074,9 @@ async function getGitInfo(srcDirPath) {
|
|
|
11983
12074
|
};
|
|
11984
12075
|
} catch (e) {
|
|
11985
12076
|
if (e instanceof Error) {
|
|
11986
|
-
|
|
12077
|
+
debug13("failed to run git %o", e);
|
|
11987
12078
|
if (e.message.includes(" spawn ")) {
|
|
11988
|
-
|
|
12079
|
+
debug13("git cli not installed");
|
|
11989
12080
|
} else {
|
|
11990
12081
|
throw e;
|
|
11991
12082
|
}
|
|
@@ -11999,13 +12090,13 @@ init_configs();
|
|
|
11999
12090
|
import fs8 from "fs";
|
|
12000
12091
|
import path7 from "path";
|
|
12001
12092
|
import AdmZip from "adm-zip";
|
|
12002
|
-
import
|
|
12093
|
+
import Debug13 from "debug";
|
|
12003
12094
|
import { globby } from "globby";
|
|
12004
12095
|
import { isBinary as isBinary2 } from "istextorbinary";
|
|
12005
12096
|
import { simpleGit as simpleGit2 } from "simple-git";
|
|
12006
12097
|
import { parseStringPromise } from "xml2js";
|
|
12007
12098
|
import { z as z28 } from "zod";
|
|
12008
|
-
var
|
|
12099
|
+
var debug14 = Debug13("mobbdev:pack");
|
|
12009
12100
|
var FPR_SOURCE_CODE_FILE_MAPPING_SCHEMA = z28.object({
|
|
12010
12101
|
properties: z28.object({
|
|
12011
12102
|
entry: z28.array(
|
|
@@ -12027,7 +12118,7 @@ function getManifestFilesSuffixes() {
|
|
|
12027
12118
|
return ["package.json", "pom.xml"];
|
|
12028
12119
|
}
|
|
12029
12120
|
async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
12030
|
-
|
|
12121
|
+
debug14("pack folder %s", srcDirPath);
|
|
12031
12122
|
let git = void 0;
|
|
12032
12123
|
try {
|
|
12033
12124
|
git = simpleGit2({
|
|
@@ -12037,13 +12128,13 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
12037
12128
|
});
|
|
12038
12129
|
await git.status();
|
|
12039
12130
|
} catch (e) {
|
|
12040
|
-
|
|
12131
|
+
debug14("failed to run git %o", e);
|
|
12041
12132
|
git = void 0;
|
|
12042
12133
|
if (e instanceof Error) {
|
|
12043
12134
|
if (e.message.includes(" spawn ")) {
|
|
12044
|
-
|
|
12135
|
+
debug14("git cli not installed");
|
|
12045
12136
|
} else if (e.message.includes("not a git repository")) {
|
|
12046
|
-
|
|
12137
|
+
debug14("folder is not a git repo");
|
|
12047
12138
|
} else {
|
|
12048
12139
|
throw e;
|
|
12049
12140
|
}
|
|
@@ -12058,9 +12149,9 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
12058
12149
|
followSymbolicLinks: false,
|
|
12059
12150
|
dot: true
|
|
12060
12151
|
});
|
|
12061
|
-
|
|
12152
|
+
debug14("files found %d", filepaths.length);
|
|
12062
12153
|
const zip = new AdmZip();
|
|
12063
|
-
|
|
12154
|
+
debug14("compressing files");
|
|
12064
12155
|
for (const filepath of filepaths) {
|
|
12065
12156
|
const absFilepath = path7.join(srcDirPath, filepath.toString());
|
|
12066
12157
|
if (!isIncludeAllFiles) {
|
|
@@ -12069,12 +12160,12 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
12069
12160
|
absFilepath.toString().replaceAll(path7.win32.sep, path7.posix.sep),
|
|
12070
12161
|
vulnFiles
|
|
12071
12162
|
)) {
|
|
12072
|
-
|
|
12163
|
+
debug14("ignoring %s because it is not a vulnerability file", filepath);
|
|
12073
12164
|
continue;
|
|
12074
12165
|
}
|
|
12075
12166
|
}
|
|
12076
12167
|
if (fs8.lstatSync(absFilepath).size > MCP_MAX_FILE_SIZE) {
|
|
12077
|
-
|
|
12168
|
+
debug14("ignoring %s because the size is > 5MB", filepath);
|
|
12078
12169
|
continue;
|
|
12079
12170
|
}
|
|
12080
12171
|
let data;
|
|
@@ -12088,16 +12179,16 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
|
|
|
12088
12179
|
data = fs8.readFileSync(absFilepath);
|
|
12089
12180
|
}
|
|
12090
12181
|
if (isBinary2(null, data)) {
|
|
12091
|
-
|
|
12182
|
+
debug14("ignoring %s because is seems to be a binary file", filepath);
|
|
12092
12183
|
continue;
|
|
12093
12184
|
}
|
|
12094
12185
|
zip.addFile(filepath.toString(), data);
|
|
12095
12186
|
}
|
|
12096
|
-
|
|
12187
|
+
debug14("get zip file buffer");
|
|
12097
12188
|
return zip.toBuffer();
|
|
12098
12189
|
}
|
|
12099
12190
|
async function repackFpr(fprPath) {
|
|
12100
|
-
|
|
12191
|
+
debug14("repack fpr file %s", fprPath);
|
|
12101
12192
|
const zipIn = new AdmZip(fprPath);
|
|
12102
12193
|
const zipOut = new AdmZip();
|
|
12103
12194
|
const mappingXML = zipIn.readAsText("src-archive/index.xml", "utf-8");
|
|
@@ -12112,7 +12203,7 @@ async function repackFpr(fprPath) {
|
|
|
12112
12203
|
zipOut.addFile(realPath, buf);
|
|
12113
12204
|
}
|
|
12114
12205
|
}
|
|
12115
|
-
|
|
12206
|
+
debug14("get repacked zip file buffer");
|
|
12116
12207
|
return zipOut.toBuffer();
|
|
12117
12208
|
}
|
|
12118
12209
|
|
|
@@ -12183,7 +12274,7 @@ async function snykArticlePrompt() {
|
|
|
12183
12274
|
// src/features/analysis/scanners/checkmarx.ts
|
|
12184
12275
|
import { createRequire } from "module";
|
|
12185
12276
|
import chalk4 from "chalk";
|
|
12186
|
-
import
|
|
12277
|
+
import Debug15 from "debug";
|
|
12187
12278
|
import { existsSync } from "fs";
|
|
12188
12279
|
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
12189
12280
|
import { type } from "os";
|
|
@@ -12195,7 +12286,7 @@ var cxOperatingSystemSupportMessage = `Your operating system does not support ch
|
|
|
12195
12286
|
|
|
12196
12287
|
// src/utils/child_process.ts
|
|
12197
12288
|
import cp from "child_process";
|
|
12198
|
-
import
|
|
12289
|
+
import Debug14 from "debug";
|
|
12199
12290
|
import * as process2 from "process";
|
|
12200
12291
|
function createFork({ args, processPath, name }, options) {
|
|
12201
12292
|
const child = cp.fork(processPath, args, {
|
|
@@ -12213,16 +12304,16 @@ function createSpawn({ args, processPath, name, cwd }, options) {
|
|
|
12213
12304
|
return createChildProcess({ childProcess: child, name }, options);
|
|
12214
12305
|
}
|
|
12215
12306
|
function createChildProcess({ childProcess, name }, options) {
|
|
12216
|
-
const
|
|
12307
|
+
const debug20 = Debug14(`mobbdev:${name}`);
|
|
12217
12308
|
const { display } = options;
|
|
12218
12309
|
return new Promise((resolve, reject) => {
|
|
12219
12310
|
let out = "";
|
|
12220
12311
|
const onData = (chunk) => {
|
|
12221
|
-
|
|
12312
|
+
debug20(`chunk received from ${name} std ${chunk}`);
|
|
12222
12313
|
out += chunk;
|
|
12223
12314
|
};
|
|
12224
12315
|
if (!childProcess?.stdout || !childProcess?.stderr) {
|
|
12225
|
-
|
|
12316
|
+
debug20(`unable to fork ${name}`);
|
|
12226
12317
|
reject(new Error(`unable to fork ${name}`));
|
|
12227
12318
|
}
|
|
12228
12319
|
childProcess.stdout?.on("data", onData);
|
|
@@ -12232,18 +12323,18 @@ function createChildProcess({ childProcess, name }, options) {
|
|
|
12232
12323
|
childProcess.stderr?.pipe(process2.stderr);
|
|
12233
12324
|
}
|
|
12234
12325
|
childProcess.on("exit", (code) => {
|
|
12235
|
-
|
|
12326
|
+
debug20(`${name} exit code ${code}`);
|
|
12236
12327
|
resolve({ message: out, code });
|
|
12237
12328
|
});
|
|
12238
12329
|
childProcess.on("error", (err) => {
|
|
12239
|
-
|
|
12330
|
+
debug20(`${name} error %o`, err);
|
|
12240
12331
|
reject(err);
|
|
12241
12332
|
});
|
|
12242
12333
|
});
|
|
12243
12334
|
}
|
|
12244
12335
|
|
|
12245
12336
|
// src/features/analysis/scanners/checkmarx.ts
|
|
12246
|
-
var
|
|
12337
|
+
var debug15 = Debug15("mobbdev:checkmarx");
|
|
12247
12338
|
var moduleUrl;
|
|
12248
12339
|
if (typeof __filename !== "undefined") {
|
|
12249
12340
|
moduleUrl = __filename;
|
|
@@ -12302,14 +12393,14 @@ function validateCheckmarxInstallation() {
|
|
|
12302
12393
|
existsSync(getCheckmarxPath());
|
|
12303
12394
|
}
|
|
12304
12395
|
async function forkCheckmarx(args, { display }) {
|
|
12305
|
-
|
|
12396
|
+
debug15("fork checkmarx with args %o %s", args.join(" "), display);
|
|
12306
12397
|
return createSpawn(
|
|
12307
12398
|
{ args, processPath: getCheckmarxPath(), name: "checkmarx" },
|
|
12308
12399
|
{ display }
|
|
12309
12400
|
);
|
|
12310
12401
|
}
|
|
12311
12402
|
async function getCheckmarxReport({ reportPath, repositoryRoot, branch, projectName }, { skipPrompts = false }) {
|
|
12312
|
-
|
|
12403
|
+
debug15("get checkmarx report start %s %s", reportPath, repositoryRoot);
|
|
12313
12404
|
const { code: loginCode } = await forkCheckmarx(VALIDATE_COMMAND, {
|
|
12314
12405
|
display: false
|
|
12315
12406
|
});
|
|
@@ -12377,10 +12468,10 @@ async function validateCheckamxCredentials() {
|
|
|
12377
12468
|
// src/features/analysis/scanners/snyk.ts
|
|
12378
12469
|
import { createRequire as createRequire2 } from "module";
|
|
12379
12470
|
import chalk5 from "chalk";
|
|
12380
|
-
import
|
|
12471
|
+
import Debug16 from "debug";
|
|
12381
12472
|
import { createSpinner as createSpinner3 } from "nanospinner";
|
|
12382
12473
|
import open2 from "open";
|
|
12383
|
-
var
|
|
12474
|
+
var debug16 = Debug16("mobbdev:snyk");
|
|
12384
12475
|
var moduleUrl2;
|
|
12385
12476
|
if (typeof __filename !== "undefined") {
|
|
12386
12477
|
moduleUrl2 = __filename;
|
|
@@ -12402,13 +12493,13 @@ if (typeof __filename !== "undefined") {
|
|
|
12402
12493
|
var costumeRequire2 = createRequire2(moduleUrl2);
|
|
12403
12494
|
var SNYK_PATH = costumeRequire2.resolve("snyk/bin/snyk");
|
|
12404
12495
|
var SNYK_ARTICLE_URL = "https://docs.snyk.io/scan-using-snyk/snyk-code/configure-snyk-code#enable-snyk-code";
|
|
12405
|
-
|
|
12496
|
+
debug16("snyk executable path %s", SNYK_PATH);
|
|
12406
12497
|
async function forkSnyk(args, { display }) {
|
|
12407
|
-
|
|
12498
|
+
debug16("fork snyk with args %o %s", args, display);
|
|
12408
12499
|
return createFork({ args, processPath: SNYK_PATH, name: "snyk" }, { display });
|
|
12409
12500
|
}
|
|
12410
12501
|
async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
12411
|
-
|
|
12502
|
+
debug16("get snyk report start %s %s", reportPath, repoRoot);
|
|
12412
12503
|
const config2 = await forkSnyk(["config"], { display: false });
|
|
12413
12504
|
const { message: configMessage } = config2;
|
|
12414
12505
|
if (!configMessage.includes("api: ")) {
|
|
@@ -12422,7 +12513,7 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
12422
12513
|
snykLoginSpinner.update({
|
|
12423
12514
|
text: "\u{1F513} Waiting for Snyk login to complete"
|
|
12424
12515
|
});
|
|
12425
|
-
|
|
12516
|
+
debug16("no token in the config %s", config2);
|
|
12426
12517
|
await forkSnyk(["auth"], { display: true });
|
|
12427
12518
|
snykLoginSpinner.success({ text: "\u{1F513} Login to Snyk Successful" });
|
|
12428
12519
|
}
|
|
@@ -12432,12 +12523,12 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
12432
12523
|
{ display: true }
|
|
12433
12524
|
);
|
|
12434
12525
|
if (scanOutput.includes("Snyk Code is not supported for org")) {
|
|
12435
|
-
|
|
12526
|
+
debug16("snyk code is not enabled %s", scanOutput);
|
|
12436
12527
|
snykSpinner.error({ text: "\u{1F50D} Snyk configuration needed" });
|
|
12437
12528
|
const answer = await snykArticlePrompt();
|
|
12438
|
-
|
|
12529
|
+
debug16("answer %s", answer);
|
|
12439
12530
|
if (answer) {
|
|
12440
|
-
|
|
12531
|
+
debug16("opening the browser");
|
|
12441
12532
|
await open2(SNYK_ARTICLE_URL);
|
|
12442
12533
|
}
|
|
12443
12534
|
console.log(
|
|
@@ -12452,9 +12543,9 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
|
|
|
12452
12543
|
}
|
|
12453
12544
|
|
|
12454
12545
|
// src/features/analysis/upload-file.ts
|
|
12455
|
-
import
|
|
12546
|
+
import Debug17 from "debug";
|
|
12456
12547
|
import fetch3, { File, fileFrom, FormData } from "node-fetch";
|
|
12457
|
-
var
|
|
12548
|
+
var debug17 = Debug17("mobbdev:upload-file");
|
|
12458
12549
|
async function uploadFile({
|
|
12459
12550
|
file,
|
|
12460
12551
|
url,
|
|
@@ -12467,9 +12558,9 @@ async function uploadFile({
|
|
|
12467
12558
|
logInfo2(`FileUpload: upload file start ${url}`);
|
|
12468
12559
|
logInfo2(`FileUpload: upload fields`, uploadFields);
|
|
12469
12560
|
logInfo2(`FileUpload: upload key ${uploadKey}`);
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
|
-
|
|
12561
|
+
debug17("upload file start %s", url);
|
|
12562
|
+
debug17("upload fields %o", uploadFields);
|
|
12563
|
+
debug17("upload key %s", uploadKey);
|
|
12473
12564
|
const form = new FormData();
|
|
12474
12565
|
Object.entries(uploadFields).forEach(([key, value]) => {
|
|
12475
12566
|
form.append(key, value);
|
|
@@ -12478,11 +12569,11 @@ async function uploadFile({
|
|
|
12478
12569
|
form.append("key", uploadKey);
|
|
12479
12570
|
}
|
|
12480
12571
|
if (typeof file === "string") {
|
|
12481
|
-
|
|
12572
|
+
debug17("upload file from path %s", file);
|
|
12482
12573
|
logInfo2(`FileUpload: upload file from path ${file}`);
|
|
12483
12574
|
form.append("file", await fileFrom(file));
|
|
12484
12575
|
} else {
|
|
12485
|
-
|
|
12576
|
+
debug17("upload file from buffer");
|
|
12486
12577
|
logInfo2(`FileUpload: upload file from buffer`);
|
|
12487
12578
|
form.append("file", new File([new Uint8Array(file)], "file"));
|
|
12488
12579
|
}
|
|
@@ -12493,11 +12584,11 @@ async function uploadFile({
|
|
|
12493
12584
|
agent
|
|
12494
12585
|
});
|
|
12495
12586
|
if (!response.ok) {
|
|
12496
|
-
|
|
12587
|
+
debug17("error from S3 %s %s", response.body, response.status);
|
|
12497
12588
|
logInfo2(`FileUpload: error from S3 ${response.body} ${response.status}`);
|
|
12498
12589
|
throw new Error(`Failed to upload the file: ${response.status}`);
|
|
12499
12590
|
}
|
|
12500
|
-
|
|
12591
|
+
debug17("upload file done");
|
|
12501
12592
|
logInfo2(`FileUpload: upload file done`);
|
|
12502
12593
|
}
|
|
12503
12594
|
|
|
@@ -12532,9 +12623,9 @@ async function downloadRepo({
|
|
|
12532
12623
|
}) {
|
|
12533
12624
|
const { createSpinner: createSpinner5 } = Spinner2({ ci });
|
|
12534
12625
|
const repoSpinner = createSpinner5("\u{1F4BE} Downloading Repo").start();
|
|
12535
|
-
|
|
12626
|
+
debug18("download repo %s %s %s", repoUrl, dirname);
|
|
12536
12627
|
const zipFilePath = path9.join(dirname, "repo.zip");
|
|
12537
|
-
|
|
12628
|
+
debug18("download URL: %s auth headers: %o", downloadUrl, authHeaders);
|
|
12538
12629
|
const response = await fetch4(downloadUrl, {
|
|
12539
12630
|
method: "GET",
|
|
12540
12631
|
headers: {
|
|
@@ -12542,7 +12633,7 @@ async function downloadRepo({
|
|
|
12542
12633
|
}
|
|
12543
12634
|
});
|
|
12544
12635
|
if (!response.ok) {
|
|
12545
|
-
|
|
12636
|
+
debug18("SCM zipball request failed %s %s", response.body, response.status);
|
|
12546
12637
|
repoSpinner.error({ text: "\u{1F4BE} Repo download failed" });
|
|
12547
12638
|
throw new Error(`Can't access ${chalk6.bold(repoUrl)}`);
|
|
12548
12639
|
}
|
|
@@ -12556,7 +12647,7 @@ async function downloadRepo({
|
|
|
12556
12647
|
if (!repoRoot) {
|
|
12557
12648
|
throw new Error("Repo root not found");
|
|
12558
12649
|
}
|
|
12559
|
-
|
|
12650
|
+
debug18("repo root %s", repoRoot);
|
|
12560
12651
|
repoSpinner.success({ text: "\u{1F4BE} Repo downloaded successfully" });
|
|
12561
12652
|
return path9.join(dirname, repoRoot);
|
|
12562
12653
|
}
|
|
@@ -12565,7 +12656,7 @@ var getReportUrl = ({
|
|
|
12565
12656
|
projectId,
|
|
12566
12657
|
fixReportId
|
|
12567
12658
|
}) => `${WEB_APP_URL}/organization/${organizationId}/project/${projectId}/report/${fixReportId}`;
|
|
12568
|
-
var
|
|
12659
|
+
var debug18 = Debug18("mobbdev:index");
|
|
12569
12660
|
async function runAnalysis(params, options) {
|
|
12570
12661
|
const tmpObj = tmp2.dirSync({
|
|
12571
12662
|
unsafeCleanup: true
|
|
@@ -12710,7 +12801,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
12710
12801
|
commitDirectly,
|
|
12711
12802
|
pullRequest
|
|
12712
12803
|
} = params;
|
|
12713
|
-
|
|
12804
|
+
debug18("start %s %s", dirname, repo);
|
|
12714
12805
|
const { createSpinner: createSpinner5 } = Spinner2({ ci });
|
|
12715
12806
|
skipPrompts = skipPrompts || ci;
|
|
12716
12807
|
const gqlClient = await getAuthenticatedGQLClient({
|
|
@@ -12779,8 +12870,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
12779
12870
|
);
|
|
12780
12871
|
}
|
|
12781
12872
|
const { sha } = getReferenceDataRes.gitReference;
|
|
12782
|
-
|
|
12783
|
-
|
|
12873
|
+
debug18("project id %s", projectId);
|
|
12874
|
+
debug18("default branch %s", reference);
|
|
12784
12875
|
if (command === "scan") {
|
|
12785
12876
|
reportPath = await getReport(
|
|
12786
12877
|
{
|
|
@@ -14483,6 +14574,7 @@ var log = logger.log.bind(logger);
|
|
|
14483
14574
|
// src/mcp/services/McpGQLClient.ts
|
|
14484
14575
|
import crypto3 from "crypto";
|
|
14485
14576
|
import { GraphQLClient as GraphQLClient2 } from "graphql-request";
|
|
14577
|
+
import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
14486
14578
|
import { v4 as uuidv42 } from "uuid";
|
|
14487
14579
|
init_configs();
|
|
14488
14580
|
|
|
@@ -14694,6 +14786,23 @@ var McpAuthService = class {
|
|
|
14694
14786
|
};
|
|
14695
14787
|
|
|
14696
14788
|
// src/mcp/services/McpGQLClient.ts
|
|
14789
|
+
function getProxyAgent2(url) {
|
|
14790
|
+
try {
|
|
14791
|
+
const parsedUrl = new URL(url);
|
|
14792
|
+
const isHttp = parsedUrl.protocol === "http:";
|
|
14793
|
+
const isHttps = parsedUrl.protocol === "https:";
|
|
14794
|
+
const proxy = isHttps ? HTTPS_PROXY || HTTP_PROXY : isHttp ? HTTP_PROXY : null;
|
|
14795
|
+
if (proxy) {
|
|
14796
|
+
logDebug("[GraphQL] Using proxy for websocket subscriptions", { proxy });
|
|
14797
|
+
return new HttpsProxyAgent2(proxy);
|
|
14798
|
+
}
|
|
14799
|
+
} catch (err) {
|
|
14800
|
+
logDebug(`[GraphQL] Skipping proxy for ${url}`, {
|
|
14801
|
+
error: err.message
|
|
14802
|
+
});
|
|
14803
|
+
}
|
|
14804
|
+
return void 0;
|
|
14805
|
+
}
|
|
14697
14806
|
var McpGQLClient = class {
|
|
14698
14807
|
constructor(args) {
|
|
14699
14808
|
__publicField(this, "client");
|
|
@@ -14867,11 +14976,13 @@ var McpGQLClient = class {
|
|
|
14867
14976
|
this._auth.type === "apiKey" ? {
|
|
14868
14977
|
apiKey: this._auth.apiKey,
|
|
14869
14978
|
type: "apiKey",
|
|
14870
|
-
timeoutInMs: params.timeoutInMs
|
|
14979
|
+
timeoutInMs: params.timeoutInMs,
|
|
14980
|
+
proxyAgent: getProxyAgent2(this.apiUrl)
|
|
14871
14981
|
} : {
|
|
14872
14982
|
token: this._auth.token,
|
|
14873
14983
|
type: "token",
|
|
14874
|
-
timeoutInMs: params.timeoutInMs
|
|
14984
|
+
timeoutInMs: params.timeoutInMs,
|
|
14985
|
+
proxyAgent: getProxyAgent2(this.apiUrl)
|
|
14875
14986
|
}
|
|
14876
14987
|
);
|
|
14877
14988
|
logDebug(`[${scanContext}] GraphQL: GetAnalysis subscription completed`, {
|
|
@@ -16267,7 +16378,6 @@ var McpServer = class {
|
|
|
16267
16378
|
tools: [
|
|
16268
16379
|
{
|
|
16269
16380
|
name: mcpCheckerTool.name,
|
|
16270
|
-
display_name: mcpCheckerTool.display_name || mcpCheckerTool.name,
|
|
16271
16381
|
description: mcpCheckerTool.description,
|
|
16272
16382
|
inputSchema: {
|
|
16273
16383
|
type: "object",
|
|
@@ -16297,7 +16407,6 @@ var McpServer = class {
|
|
|
16297
16407
|
const response = {
|
|
16298
16408
|
tools: toolsDefinitions.map((tool) => ({
|
|
16299
16409
|
name: tool.name,
|
|
16300
|
-
display_name: tool.display_name || tool.name,
|
|
16301
16410
|
description: tool.description || "",
|
|
16302
16411
|
inputSchema: {
|
|
16303
16412
|
type: "object",
|
|
@@ -22598,13 +22707,13 @@ var parseArgs = async (args) => {
|
|
|
22598
22707
|
};
|
|
22599
22708
|
|
|
22600
22709
|
// src/index.ts
|
|
22601
|
-
var
|
|
22710
|
+
var debug19 = Debug19("mobbdev:index");
|
|
22602
22711
|
async function run() {
|
|
22603
22712
|
return parseArgs(hideBin(process.argv));
|
|
22604
22713
|
}
|
|
22605
22714
|
(async () => {
|
|
22606
22715
|
try {
|
|
22607
|
-
|
|
22716
|
+
debug19("Bugsy CLI v%s running...", packageJson.version);
|
|
22608
22717
|
await run();
|
|
22609
22718
|
process.exit(0);
|
|
22610
22719
|
} catch (err) {
|