mobbdev 1.0.108 → 1.0.109

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.
Files changed (2) hide show
  1. package/dist/index.mjs +141 -85
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -707,6 +707,7 @@ var GetAnalysisSubscriptionDocument = `
707
707
  analysis: fixReport_by_pk(id: $analysisId) {
708
708
  id
709
709
  state
710
+ failReason
710
711
  }
711
712
  }
712
713
  `;
@@ -715,6 +716,7 @@ var GetAnalysisDocument = `
715
716
  analysis: fixReport_by_pk(id: $analysisId) {
716
717
  id
717
718
  state
719
+ failReason
718
720
  repo {
719
721
  commitSha
720
722
  pullRequest
@@ -1094,6 +1096,13 @@ var GetReportFixesDocument = `
1094
1096
  }
1095
1097
  }
1096
1098
  ${FixReportSummaryFieldsFragmentDoc}`;
1099
+ var UpdateDownloadedFixDataDocument = `
1100
+ mutation updateDownloadedFixData($fixIds: [String!]!, $source: FixDownloadSource!) {
1101
+ updateDownloadedFixData(fixIds: $fixIds, source: $source) {
1102
+ status
1103
+ }
1104
+ }
1105
+ `;
1097
1106
  var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
1098
1107
  function getSdk(client, withWrapper = defaultWrapper) {
1099
1108
  return {
@@ -1165,6 +1174,9 @@ function getSdk(client, withWrapper = defaultWrapper) {
1165
1174
  },
1166
1175
  GetReportFixes(variables, requestHeaders, signal) {
1167
1176
  return withWrapper((wrappedRequestHeaders) => client.request({ document: GetReportFixesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetReportFixes", "query", variables);
1177
+ },
1178
+ updateDownloadedFixData(variables, requestHeaders, signal) {
1179
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: UpdateDownloadedFixDataDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "updateDownloadedFixData", "mutation", variables);
1168
1180
  }
1169
1181
  };
1170
1182
  }
@@ -3674,6 +3686,7 @@ var ReportQueryResultZ = z11.object({
3674
3686
  createdOn: z11.string(),
3675
3687
  expirationOn: z11.string().nullable(),
3676
3688
  state: z11.nativeEnum(Fix_Report_State_Enum),
3689
+ failReason: z11.string().nullable(),
3677
3690
  fixes: z11.array(
3678
3691
  z11.object({
3679
3692
  id: z11.string().uuid(),
@@ -8569,6 +8582,84 @@ import open2 from "open";
8569
8582
  import tmp2 from "tmp";
8570
8583
  import { z as z29 } from "zod";
8571
8584
 
8585
+ // src/mcp/core/Errors.ts
8586
+ var ApiConnectionError = class extends Error {
8587
+ constructor(message = "Failed to connect to the API") {
8588
+ super(message);
8589
+ this.name = "ApiConnectionError";
8590
+ }
8591
+ };
8592
+ var CliLoginError = class extends Error {
8593
+ constructor(message = "CLI login failed") {
8594
+ super(message);
8595
+ this.name = "CliLoginError";
8596
+ }
8597
+ };
8598
+ var AuthenticationError = class extends Error {
8599
+ constructor(message = "Authentication failed") {
8600
+ super(message);
8601
+ this.name = "AuthenticationError";
8602
+ }
8603
+ };
8604
+ var NoFilesError = class extends Error {
8605
+ constructor(message = "No files to fix") {
8606
+ super(message);
8607
+ this.name = "NoFilesError";
8608
+ }
8609
+ };
8610
+ var GqlClientError = class extends Error {
8611
+ constructor(message = "GraphQL client not initialized") {
8612
+ super(message);
8613
+ this.name = "GqlClientError";
8614
+ }
8615
+ };
8616
+ var FileProcessingError = class extends Error {
8617
+ constructor(message) {
8618
+ super(message);
8619
+ this.name = "FileProcessingError";
8620
+ }
8621
+ };
8622
+ var ReportInitializationError = class extends Error {
8623
+ constructor(message) {
8624
+ super(message);
8625
+ this.name = "ReportInitializationError";
8626
+ }
8627
+ };
8628
+ var FileUploadError = class extends Error {
8629
+ constructor(message) {
8630
+ super(message);
8631
+ this.name = "FileUploadError";
8632
+ }
8633
+ };
8634
+ var ScanError = class extends Error {
8635
+ constructor(message) {
8636
+ super(message);
8637
+ this.name = "ScanError";
8638
+ }
8639
+ };
8640
+ var FailedToGetApiTokenError = class extends Error {
8641
+ constructor(message) {
8642
+ super(message);
8643
+ this.name = "FailedToGetApiTokenError";
8644
+ }
8645
+ };
8646
+ var _ReportDigestError = class _ReportDigestError extends Error {
8647
+ constructor(message, failReason) {
8648
+ super(message);
8649
+ this.failReason = failReason;
8650
+ this.name = "ReportDigestError";
8651
+ this.failReason = failReason;
8652
+ }
8653
+ getDisplayMessage() {
8654
+ if (this.failReason?.trim()) {
8655
+ return `\u{1F575}\uFE0F\u200D\u2642\uFE0F Digesting report failed. ${this.failReason}`;
8656
+ }
8657
+ return _ReportDigestError.defaultMessage;
8658
+ }
8659
+ };
8660
+ __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.");
8661
+ var ReportDigestError = _ReportDigestError;
8662
+
8572
8663
  // src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
8573
8664
  import Debug8 from "debug";
8574
8665
 
@@ -9674,7 +9765,10 @@ var GQLClient = class {
9674
9765
  params.subscribeToAnalysisParams,
9675
9766
  async (resolve, reject, data) => {
9676
9767
  if (!data.analysis?.state || data.analysis?.state === "Failed" /* Failed */) {
9677
- reject(new Error(`Analysis failed with id: ${data.analysis?.id}`));
9768
+ const errorMessage = data.analysis?.failReason || `Analysis failed with id: ${data.analysis?.id}`;
9769
+ reject(
9770
+ new ReportDigestError(errorMessage, data.analysis?.failReason ?? "")
9771
+ );
9678
9772
  return;
9679
9773
  }
9680
9774
  if (callbackStates.includes(data.analysis?.state)) {
@@ -10785,23 +10879,19 @@ async function _digestReport({
10785
10879
  shouldScan
10786
10880
  }
10787
10881
  );
10788
- try {
10789
- await gqlClient.subscribeToAnalysis({
10790
- subscribeToAnalysisParams: {
10791
- analysisId: fixReportId
10792
- },
10793
- callback: () => digestSpinner.update({
10794
- text: progressMassages.processingVulnerabilityReportSuccess
10795
- }),
10796
- callbackStates: [
10797
- "Digested" /* Digested */,
10798
- "Finished" /* Finished */
10799
- ],
10800
- timeoutInMs: VUL_REPORT_DIGEST_TIMEOUT_MS
10801
- });
10802
- } catch (e) {
10803
- throw new Error(progressMassages.processingVulnerabilityReportFailed);
10804
- }
10882
+ await gqlClient.subscribeToAnalysis({
10883
+ subscribeToAnalysisParams: {
10884
+ analysisId: fixReportId
10885
+ },
10886
+ callback: () => digestSpinner.update({
10887
+ text: progressMassages.processingVulnerabilityReportSuccess
10888
+ }),
10889
+ callbackStates: [
10890
+ "Digested" /* Digested */,
10891
+ "Finished" /* Finished */
10892
+ ],
10893
+ timeoutInMs: VUL_REPORT_DIGEST_TIMEOUT_MS
10894
+ });
10805
10895
  const vulnFiles = await gqlClient.getVulnerabilityReportPaths(
10806
10896
  vulnerabilityReportId
10807
10897
  );
@@ -10810,8 +10900,9 @@ async function _digestReport({
10810
10900
  });
10811
10901
  return vulnFiles;
10812
10902
  } catch (e) {
10903
+ const errorMessage = e instanceof ReportDigestError ? e.getDisplayMessage() : ReportDigestError.defaultMessage;
10813
10904
  digestSpinner.error({
10814
- text: "\u{1F575}\uFE0F\u200D\u2642\uFE0F Digesting report failed. Please verify that the file provided is of a valid supported report format."
10905
+ text: errorMessage
10815
10906
  });
10816
10907
  throw e;
10817
10908
  }
@@ -11331,70 +11422,6 @@ import Configstore3 from "configstore";
11331
11422
  import { GraphQLClient as GraphQLClient2 } from "graphql-request";
11332
11423
  import open4 from "open";
11333
11424
  import { v4 as uuidv42 } from "uuid";
11334
-
11335
- // src/mcp/core/Errors.ts
11336
- var ApiConnectionError = class extends Error {
11337
- constructor(message = "Failed to connect to the API") {
11338
- super(message);
11339
- this.name = "ApiConnectionError";
11340
- }
11341
- };
11342
- var CliLoginError = class extends Error {
11343
- constructor(message = "CLI login failed") {
11344
- super(message);
11345
- this.name = "CliLoginError";
11346
- }
11347
- };
11348
- var AuthenticationError = class extends Error {
11349
- constructor(message = "Authentication failed") {
11350
- super(message);
11351
- this.name = "AuthenticationError";
11352
- }
11353
- };
11354
- var NoFilesError = class extends Error {
11355
- constructor(message = "No files to fix") {
11356
- super(message);
11357
- this.name = "NoFilesError";
11358
- }
11359
- };
11360
- var GqlClientError = class extends Error {
11361
- constructor(message = "GraphQL client not initialized") {
11362
- super(message);
11363
- this.name = "GqlClientError";
11364
- }
11365
- };
11366
- var FileProcessingError = class extends Error {
11367
- constructor(message) {
11368
- super(message);
11369
- this.name = "FileProcessingError";
11370
- }
11371
- };
11372
- var ReportInitializationError = class extends Error {
11373
- constructor(message) {
11374
- super(message);
11375
- this.name = "ReportInitializationError";
11376
- }
11377
- };
11378
- var FileUploadError = class extends Error {
11379
- constructor(message) {
11380
- super(message);
11381
- this.name = "FileUploadError";
11382
- }
11383
- };
11384
- var ScanError = class extends Error {
11385
- constructor(message) {
11386
- super(message);
11387
- this.name = "ScanError";
11388
- }
11389
- };
11390
- var FailedToGetApiTokenError = class extends Error {
11391
- constructor(message) {
11392
- super(message);
11393
- this.name = "FailedToGetApiTokenError";
11394
- }
11395
- };
11396
-
11397
- // src/mcp/services/McpGQLClient.ts
11398
11425
  var mobbConfigStore = new Configstore3(packageJson.name, { apiToken: "" });
11399
11426
  var McpGQLClient = class {
11400
11427
  constructor(args) {
@@ -11512,12 +11539,14 @@ var McpGQLClient = class {
11512
11539
  async (resolve, reject, data) => {
11513
11540
  logDebug("GraphQL: GetAnalysis subscription data received", { data });
11514
11541
  if (!data.analysis?.state || data.analysis?.state === "Failed" /* Failed */) {
11542
+ const errorMessage = data.analysis?.failReason || `Analysis failed with id: ${data.analysis?.id}`;
11515
11543
  logError("GraphQL: Analysis failed", {
11516
11544
  analysisId: data.analysis?.id,
11517
11545
  state: data.analysis?.state,
11546
+ failReason: data.analysis?.failReason,
11518
11547
  ...this.getErrorContext()
11519
11548
  });
11520
- reject(new Error(`Analysis failed with id: ${data.analysis?.id}`));
11549
+ reject(new Error(errorMessage));
11521
11550
  return;
11522
11551
  }
11523
11552
  if (callbackStates.includes(data.analysis?.state)) {
@@ -11553,7 +11582,16 @@ var McpGQLClient = class {
11553
11582
  }
11554
11583
  async getProjectId() {
11555
11584
  try {
11556
- const projectName = "MCP Scans";
11585
+ const me = await this.getUserInfo();
11586
+ if (!me) {
11587
+ throw new Error("User not found");
11588
+ }
11589
+ const userEmail = me.email;
11590
+ if (!userEmail) {
11591
+ throw new Error("User email not found");
11592
+ }
11593
+ const shortEmailHash = crypto2.createHash("sha256").update(userEmail).digest("hex").slice(0, 8).toUpperCase();
11594
+ const projectName = `MCP Scans ${shortEmailHash}`;
11557
11595
  logDebug("GraphQL: Calling getOrgAndProjectId query", { projectName });
11558
11596
  const getOrgAndProjectIdResult = await this.clientSdk.getOrgAndProjectId({
11559
11597
  filters: {},
@@ -11638,6 +11676,20 @@ var McpGQLClient = class {
11638
11676
  return null;
11639
11677
  }
11640
11678
  }
11679
+ async _updateFixesArchiveState(fixIds) {
11680
+ if (fixIds.length > 0) {
11681
+ const resUpdate = await this.clientSdk.updateDownloadedFixData({
11682
+ fixIds,
11683
+ source: "MCP" /* Mcp */
11684
+ });
11685
+ logInfo("GraphQL: updateFixesArchiveState successful", {
11686
+ result: resUpdate,
11687
+ fixIds
11688
+ });
11689
+ } else {
11690
+ logInfo("GraphQL: No fixes found");
11691
+ }
11692
+ }
11641
11693
  async getLatestReportByRepoUrl({
11642
11694
  repoUrl,
11643
11695
  limit = 3,
@@ -11658,6 +11710,8 @@ var McpGQLClient = class {
11658
11710
  result: res,
11659
11711
  reportCount: res.fixReport?.length || 0
11660
11712
  });
11713
+ const fixIds = res.fixReport?.[0]?.fixes?.map((fix) => fix.id) || [];
11714
+ await this._updateFixesArchiveState(fixIds);
11661
11715
  return {
11662
11716
  fixReport: res.fixReport?.[0] || null,
11663
11717
  expiredReport: res.expiredReport?.[0] || null
@@ -11708,6 +11762,8 @@ var McpGQLClient = class {
11708
11762
  if (res.fixReport.length === 0) {
11709
11763
  return null;
11710
11764
  }
11765
+ const fixIds = res.fixReport?.[0]?.fixes?.map((fix) => fix.id) || [];
11766
+ await this._updateFixesArchiveState(fixIds);
11711
11767
  return {
11712
11768
  fixes: res.fixReport?.[0]?.fixes || [],
11713
11769
  totalCount: res.fixReport?.[0]?.filteredFixesCount?.aggregate?.count || 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.0.108",
3
+ "version": "1.0.109",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.js",