mobbdev 1.0.46 → 1.0.50

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 +198 -63
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -614,8 +614,12 @@ var GitReferenceDocument = `
614
614
  }
615
615
  `;
616
616
  var AutoPrAnalysisDocument = `
617
- mutation autoPrAnalysis($analysisId: String!, $commitDirectly: Boolean) {
618
- autoPrAnalysis(analysisId: $analysisId, sameBranchCommit: $commitDirectly) {
617
+ mutation autoPrAnalysis($analysisId: String!, $commitDirectly: Boolean, $prId: Int) {
618
+ autoPrAnalysis(
619
+ analysisId: $analysisId
620
+ sameBranchCommit: $commitDirectly
621
+ prId: $prId
622
+ ) {
619
623
  __typename
620
624
  ... on AutoPrSuccess {
621
625
  status
@@ -4303,6 +4307,26 @@ async function getAdoSdk(params) {
4303
4307
  }
4304
4308
  return parsedPullRequestStatus.data;
4305
4309
  },
4310
+ async addCommentToAdoPullRequest({
4311
+ repoUrl,
4312
+ prNumber,
4313
+ markdownComment
4314
+ }) {
4315
+ const { repo, projectName } = parseAdoOwnerAndRepo(repoUrl);
4316
+ const git = await api2.getGitApi();
4317
+ const comment = {
4318
+ comments: [
4319
+ {
4320
+ parentCommentId: 0,
4321
+ // Root comment
4322
+ content: markdownComment,
4323
+ commentType: 1
4324
+ // Default type
4325
+ }
4326
+ ]
4327
+ };
4328
+ await git.createThread(comment, repo, prNumber, projectName);
4329
+ },
4306
4330
  async getAdoIsRemoteBranch({
4307
4331
  repoUrl,
4308
4332
  branch
@@ -4618,7 +4642,8 @@ var CommitToSameBranchParamsZ = BaseSubmitToScmMessageZ.merge(
4618
4642
  branch: z19.string(),
4619
4643
  commitMessages: z19.array(z19.string()),
4620
4644
  commitDescriptions: z19.array(z19.string().nullish()),
4621
- githubCommentId: z19.number().nullish()
4645
+ githubCommentId: z19.number().nullish(),
4646
+ prId: z19.number().nullish()
4622
4647
  })
4623
4648
  );
4624
4649
  var SubmitFixesToDifferentBranchParamsZ = z19.object({
@@ -4677,7 +4702,8 @@ var GitCommitZ = z19.object({
4677
4702
  var SubmitFixesToSameBranchResponseMessageZ = z19.object({
4678
4703
  type: z19.literal(submitToScmMessageType.commitToSameBranch),
4679
4704
  githubCommentId: z19.number().nullish(),
4680
- commits: z19.array(GitCommitZ)
4705
+ commits: z19.array(GitCommitZ),
4706
+ prId: z19.number().nullish()
4681
4707
  }).merge(SubmitFixesBaseResponseMessageZ);
4682
4708
  var SubmitFixesToDifferentBranchResponseMessageZ = z19.object({
4683
4709
  type: z19.literal(submitToScmMessageType.submitFixesForDifferentBranch),
@@ -4932,16 +4958,16 @@ var AdoSCMLib = class extends SCMLib {
4932
4958
  repoUrl: this.url
4933
4959
  });
4934
4960
  }
4935
- async getPrUrl(prNumber) {
4961
+ async getSubmitRequestUrl(submitRequestIdNumber) {
4936
4962
  this._validateUrl();
4937
4963
  const adoSdk = await this.getAdoSdk();
4938
4964
  return adoSdk.getAdoPrUrl({
4939
4965
  url: this.url,
4940
- prNumber
4966
+ prNumber: submitRequestIdNumber
4941
4967
  });
4942
4968
  }
4943
- async getPrId(prUrl) {
4944
- const match = prUrl.match(/\/pullrequest\/(\d+)/);
4969
+ async getSubmitRequestId(submitRequestUrl) {
4970
+ const match = submitRequestUrl.match(/\/pullrequest\/(\d+)/);
4945
4971
  return match?.[1] || "";
4946
4972
  }
4947
4973
  async getCommitUrl(commitId) {
@@ -4952,6 +4978,15 @@ var AdoSCMLib = class extends SCMLib {
4952
4978
  commitId
4953
4979
  });
4954
4980
  }
4981
+ async addCommentToSubmitRequest(scmSubmitRequestId, comment) {
4982
+ this._validateAccessTokenAndUrl();
4983
+ const adoSdk = await this.getAdoSdk();
4984
+ await adoSdk.addCommentToAdoPullRequest({
4985
+ repoUrl: this.url,
4986
+ prNumber: Number(scmSubmitRequestId),
4987
+ markdownComment: comment
4988
+ });
4989
+ }
4955
4990
  };
4956
4991
 
4957
4992
  // src/features/analysis/scm/bitbucket/bitbucket.ts
@@ -4993,7 +5028,7 @@ function parseBitbucketOrganizationAndRepo(bitbucketUrl) {
4993
5028
  const validatedBitbucketResult = BitbucketParseResultZ.parse(parsingResult);
4994
5029
  return {
4995
5030
  workspace: validatedBitbucketResult.organization,
4996
- repoSlug: validatedBitbucketResult.repoName
5031
+ repo_slug: validatedBitbucketResult.repoName
4997
5032
  };
4998
5033
  }
4999
5034
  function getBitbucketIntance(params) {
@@ -5033,11 +5068,11 @@ function getBitbucketSdk(params) {
5033
5068
  }));
5034
5069
  },
5035
5070
  async getBranchList(params2) {
5036
- const { workspace, repoSlug } = parseBitbucketOrganizationAndRepo(
5071
+ const { workspace, repo_slug } = parseBitbucketOrganizationAndRepo(
5037
5072
  params2.repoUrl
5038
5073
  );
5039
5074
  const res = await bitbucketClient.refs.listBranches({
5040
- repo_slug: repoSlug,
5075
+ repo_slug,
5041
5076
  workspace,
5042
5077
  pagelen: 100,
5043
5078
  //It seems to not work with very large numbers like 1000 (MAX_BRANCHES_FETCH) and returns a bad request response
@@ -5050,8 +5085,8 @@ function getBitbucketSdk(params) {
5050
5085
  },
5051
5086
  async getIsUserCollaborator(params2) {
5052
5087
  const { repoUrl } = params2;
5053
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
5054
- const fullRepoName = `${workspace}/${repoSlug}`;
5088
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
5089
+ const fullRepoName = `${workspace}/${repo_slug}`;
5055
5090
  const res = await bitbucketClient.user.listPermissionsForRepos({
5056
5091
  q: `repository.full_name~"${fullRepoName}"`
5057
5092
  });
@@ -5060,11 +5095,11 @@ function getBitbucketSdk(params) {
5060
5095
  ) ?? false;
5061
5096
  },
5062
5097
  async createPullRequest(params2) {
5063
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5098
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5064
5099
  params2.repoUrl
5065
5100
  );
5066
5101
  const res = await bitbucketClient.pullrequests.create({
5067
- repo_slug: repoSlug,
5102
+ repo_slug,
5068
5103
  workspace,
5069
5104
  _body: {
5070
5105
  type: "pullrequest",
@@ -5087,43 +5122,43 @@ function getBitbucketSdk(params) {
5087
5122
  return res.data;
5088
5123
  },
5089
5124
  async getDownloadlink(params2) {
5090
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5125
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5091
5126
  params2.repoUrl
5092
5127
  );
5093
5128
  const res = await bitbucketClient.downloads.list({
5094
- repo_slug: repoSlug,
5129
+ repo_slug,
5095
5130
  workspace
5096
5131
  });
5097
5132
  return res.data;
5098
5133
  },
5099
5134
  async getBranch(params2) {
5100
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5135
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5101
5136
  params2.repoUrl
5102
5137
  );
5103
5138
  const res = await bitbucketClient.refs.getBranch({
5104
5139
  name: params2.branchName,
5105
- repo_slug: repoSlug,
5140
+ repo_slug,
5106
5141
  workspace
5107
5142
  });
5108
5143
  return res.data;
5109
5144
  },
5110
5145
  async getRepo(params2) {
5111
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5146
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5112
5147
  params2.repoUrl
5113
5148
  );
5114
5149
  const res = await bitbucketClient.repositories.get({
5115
- repo_slug: repoSlug,
5150
+ repo_slug,
5116
5151
  workspace
5117
5152
  });
5118
5153
  return res.data;
5119
5154
  },
5120
5155
  async getCommit(params2) {
5121
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5156
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5122
5157
  params2.repoUrl
5123
5158
  );
5124
5159
  const res = await bitbucketClient.commits.get({
5125
5160
  commit: params2.commitSha,
5126
- repo_slug: repoSlug,
5161
+ repo_slug,
5127
5162
  workspace
5128
5163
  });
5129
5164
  return res.data;
@@ -5152,9 +5187,9 @@ function getBitbucketSdk(params) {
5152
5187
  },
5153
5188
  async getTagRef(params2) {
5154
5189
  const { tagName, repoUrl } = params2;
5155
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
5190
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
5156
5191
  const tagRes = await bitbucketClient.refs.getTag({
5157
- repo_slug: repoSlug,
5192
+ repo_slug,
5158
5193
  workspace,
5159
5194
  name: tagName
5160
5195
  });
@@ -5187,12 +5222,31 @@ function getBitbucketSdk(params) {
5187
5222
  return `${parsedRepoUrl}/get/${sha}.zip`;
5188
5223
  },
5189
5224
  async getPullRequest(params2) {
5190
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(
5225
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
5191
5226
  params2.url
5192
5227
  );
5193
5228
  const res = await bitbucketClient.pullrequests.get({
5194
5229
  pull_request_id: params2.prNumber,
5195
- repo_slug: repoSlug,
5230
+ repo_slug,
5231
+ workspace
5232
+ });
5233
+ return res.data;
5234
+ },
5235
+ async addCommentToPullRequest({
5236
+ url,
5237
+ prNumber,
5238
+ markdownComment
5239
+ }) {
5240
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(url);
5241
+ const res = await bitbucketClient.pullrequests.createComment({
5242
+ //@ts-expect-error tyep requires _body.type, but it its uses api fails
5243
+ _body: {
5244
+ content: {
5245
+ raw: markdownComment
5246
+ }
5247
+ },
5248
+ pull_request_id: prNumber,
5249
+ repo_slug,
5196
5250
  workspace
5197
5251
  });
5198
5252
  return res.data;
@@ -5462,24 +5516,32 @@ var BitbucketSCMLib = class extends SCMLib {
5462
5516
  const repoRes = await this.bitbucketSdk.getRepo({ repoUrl: this.url });
5463
5517
  return z23.string().parse(repoRes.mainbranch?.name);
5464
5518
  }
5465
- getPrUrl(prNumber) {
5519
+ getSubmitRequestUrl(submitRequestId) {
5466
5520
  this._validateUrl();
5467
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
5521
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
5468
5522
  return Promise.resolve(
5469
- `https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/${prNumber}`
5523
+ `https://bitbucket.org/${workspace}/${repo_slug}/pull-requests/${submitRequestId}`
5470
5524
  );
5471
5525
  }
5472
- async getPrId(prUrl) {
5473
- const match = prUrl.match(/\/pull-requests\/(\d+)/);
5526
+ async getSubmitRequestId(submitRequestUrl) {
5527
+ const match = submitRequestUrl.match(/\/pull-requests\/(\d+)/);
5474
5528
  return match?.[1] || "";
5475
5529
  }
5476
5530
  getCommitUrl(commitId) {
5477
5531
  this._validateUrl();
5478
- const { repoSlug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
5532
+ const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
5479
5533
  return Promise.resolve(
5480
- `https://bitbucket.org/${workspace}/${repoSlug}/commits/${commitId}`
5534
+ `https://bitbucket.org/${workspace}/${repo_slug}/commits/${commitId}`
5481
5535
  );
5482
5536
  }
5537
+ async addCommentToSubmitRequest(submitRequestId, comment) {
5538
+ this._validateUrl();
5539
+ await this.bitbucketSdk.addCommentToPullRequest({
5540
+ prNumber: Number(submitRequestId),
5541
+ url: this.url,
5542
+ markdownComment: comment
5543
+ });
5544
+ }
5483
5545
  };
5484
5546
 
5485
5547
  // src/features/analysis/scm/github/GithubSCMLib.ts
@@ -5640,6 +5702,14 @@ var GithubSCMLib = class extends SCMLib {
5640
5702
  prNumber: Number(scmSubmitRequestId)
5641
5703
  });
5642
5704
  }
5705
+ async addCommentToSubmitRequest(submitRequestId, comment) {
5706
+ this._validateAccessTokenAndUrl();
5707
+ await this.githubSdk.createMarkdownCommentOnPullRequest({
5708
+ repoUrl: this.url,
5709
+ prNumber: Number(submitRequestId),
5710
+ markdownComment: comment
5711
+ });
5712
+ }
5643
5713
  async getRepoBlameRanges(ref, path9) {
5644
5714
  this._validateUrl();
5645
5715
  return await this.githubSdk.getGithubBlameRanges({
@@ -5665,18 +5735,18 @@ var GithubSCMLib = class extends SCMLib {
5665
5735
  this._validateUrl();
5666
5736
  return await this.githubSdk.getGithubRepoDefaultBranch(this.url);
5667
5737
  }
5668
- async getPrUrl(prNumber) {
5738
+ async getSubmitRequestUrl(submitRequestUrl) {
5669
5739
  this._validateAccessTokenAndUrl();
5670
5740
  const { owner, repo } = parseGithubOwnerAndRepo(this.url);
5671
5741
  const getPrRes = await this.githubSdk.getPr({
5672
5742
  owner,
5673
5743
  repo,
5674
- pull_number: prNumber
5744
+ pull_number: submitRequestUrl
5675
5745
  });
5676
5746
  return getPrRes.data.html_url;
5677
5747
  }
5678
- async getPrId(prUrl) {
5679
- const match = prUrl.match(/\/pull\/(\d+)/);
5748
+ async getSubmitRequestId(submitRequestUrl) {
5749
+ const match = submitRequestUrl.match(/\/pull\/(\d+)/);
5680
5750
  return match?.[1] || "";
5681
5751
  }
5682
5752
  async getCommitUrl(commitId) {
@@ -5826,6 +5896,9 @@ async function getGitlabIsUserCollaborator({
5826
5896
  const members = await api2.ProjectMembers.all(res.id, {
5827
5897
  includeInherited: true
5828
5898
  });
5899
+ if (!username) {
5900
+ return true;
5901
+ }
5829
5902
  return !!members.find((member) => member.username === username);
5830
5903
  } catch (e) {
5831
5904
  return false;
@@ -5853,6 +5926,16 @@ async function getGitlabMergeRequestStatus({
5853
5926
  throw new Error(`unknown merge request state ${res.state}`);
5854
5927
  }
5855
5928
  }
5929
+ async function createMarkdownCommentOnPullRequest({
5930
+ markdownComment,
5931
+ accessToken,
5932
+ repoUrl,
5933
+ mrNumber
5934
+ }) {
5935
+ const { projectPath } = parseGitlabOwnerAndRepo(repoUrl);
5936
+ const api2 = getGitBeaker({ url: repoUrl, gitlabAuthToken: accessToken });
5937
+ return api2.MergeRequestNotes.create(projectPath, mrNumber, markdownComment);
5938
+ }
5856
5939
  async function getGitlabIsRemoteBranch({
5857
5940
  accessToken,
5858
5941
  repoUrl,
@@ -6174,7 +6257,14 @@ var GitlabSCMLib = class extends SCMLib {
6174
6257
  }
6175
6258
  async getUserHasAccessToRepo() {
6176
6259
  this._validateAccessTokenAndUrl();
6177
- const username = await this.getUsername();
6260
+ let username = void 0;
6261
+ try {
6262
+ username = await this.getUsername();
6263
+ } catch (e) {
6264
+ console.warn(
6265
+ "could not get username. this is okay if a project token is used"
6266
+ );
6267
+ }
6178
6268
  return getGitlabIsUserCollaborator({
6179
6269
  username,
6180
6270
  accessToken: this.accessToken,
@@ -6203,6 +6293,15 @@ var GitlabSCMLib = class extends SCMLib {
6203
6293
  throw new Error(`unknown state ${state}`);
6204
6294
  }
6205
6295
  }
6296
+ async addCommentToSubmitRequest(submitRequestId, comment) {
6297
+ this._validateAccessTokenAndUrl();
6298
+ await createMarkdownCommentOnPullRequest({
6299
+ accessToken: this.accessToken,
6300
+ repoUrl: this.url,
6301
+ mrNumber: Number(submitRequestId),
6302
+ markdownComment: comment
6303
+ });
6304
+ }
6206
6305
  async getRepoBlameRanges(ref, path9) {
6207
6306
  this._validateUrl();
6208
6307
  return await getGitlabBlameRanges(
@@ -6230,17 +6329,17 @@ var GitlabSCMLib = class extends SCMLib {
6230
6329
  gitlabAuthToken: this.accessToken
6231
6330
  });
6232
6331
  }
6233
- async getPrUrl(prNumber) {
6332
+ async getSubmitRequestUrl(submitRequestUrl) {
6234
6333
  this._validateAccessTokenAndUrl();
6235
6334
  const res = await getGitlabMergeRequest({
6236
6335
  url: this.url,
6237
- prNumber,
6336
+ prNumber: submitRequestUrl,
6238
6337
  accessToken: this.accessToken
6239
6338
  });
6240
6339
  return res.web_url;
6241
6340
  }
6242
- async getPrId(prUrl) {
6243
- const match = prUrl.match(/\/merge_requests\/(\d+)/);
6341
+ async getSubmitRequestId(submitRequestUrl) {
6342
+ const match = submitRequestUrl.match(/\/merge_requests\/(\d+)/);
6244
6343
  return match?.[1] || "";
6245
6344
  }
6246
6345
  async getCommitUrl(commitId) {
@@ -6325,12 +6424,12 @@ var StubSCMLib = class extends SCMLib {
6325
6424
  console.warn("getRepoDefaultBranch() returning empty string");
6326
6425
  return "";
6327
6426
  }
6328
- async getPrUrl(_prNumber) {
6329
- console.warn("getPrUrl() returning empty string");
6427
+ async getSubmitRequestUrl(_submitRequestIdNumber) {
6428
+ console.warn("getSubmitRequestUrl() returning empty string");
6330
6429
  return "";
6331
6430
  }
6332
- async getPrId(_prUrl) {
6333
- console.warn("getPrId() returning empty string");
6431
+ async getSubmitRequestId(_submitRequestUrl) {
6432
+ console.warn("getSubmitRequestId() returning empty string");
6334
6433
  return "";
6335
6434
  }
6336
6435
  async getCommitUrl(_commitId) {
@@ -6341,6 +6440,9 @@ var StubSCMLib = class extends SCMLib {
6341
6440
  console.warn("_getUsernameForAuthUrl() returning empty string");
6342
6441
  return "";
6343
6442
  }
6443
+ async addCommentToSubmitRequest(_submitRequestId, _comment) {
6444
+ console.warn("addCommentToSubmitRequest() no-op");
6445
+ }
6344
6446
  };
6345
6447
 
6346
6448
  // src/features/analysis/scm/scmFactory.ts
@@ -6566,6 +6668,16 @@ function getGithubSdk(params = {}) {
6566
6668
  }
6567
6669
  return res.data.state;
6568
6670
  },
6671
+ async createMarkdownCommentOnPullRequest(params2) {
6672
+ const { repoUrl, prNumber, markdownComment } = params2;
6673
+ const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
6674
+ return octokit.rest.issues.createComment({
6675
+ owner,
6676
+ repo,
6677
+ issue_number: prNumber,
6678
+ body: markdownComment
6679
+ });
6680
+ },
6569
6681
  async getGithubIsRemoteBranch(params2) {
6570
6682
  const { repoUrl, branch } = params2;
6571
6683
  const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
@@ -7302,7 +7414,7 @@ async function addFixCommentsForPr({
7302
7414
  import Debug9 from "debug";
7303
7415
  var debug9 = Debug9("mobbdev:handleAutoPr");
7304
7416
  async function handleAutoPr(params) {
7305
- const { gqlClient, analysisId, commitDirectly, createSpinner: createSpinner5 } = params;
7417
+ const { gqlClient, analysisId, commitDirectly, prId, createSpinner: createSpinner5 } = params;
7306
7418
  const createAutoPrSpinner = createSpinner5(
7307
7419
  "\u{1F504} Waiting for the analysis to finish before initiating automatic pull request creation"
7308
7420
  ).start();
@@ -7313,7 +7425,8 @@ async function handleAutoPr(params) {
7313
7425
  callback: async (analysisId2) => {
7314
7426
  const autoPrAnalysisRes = await gqlClient.autoPrAnalysis(
7315
7427
  analysisId2,
7316
- commitDirectly
7428
+ commitDirectly,
7429
+ prId
7317
7430
  );
7318
7431
  debug9("auto pr analysis res %o", autoPrAnalysisRes);
7319
7432
  if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
@@ -7771,10 +7884,11 @@ var GQLClient = class {
7771
7884
  }
7772
7885
  return res.analysis;
7773
7886
  }
7774
- async autoPrAnalysis(analysisId, commitDirectly) {
7887
+ async autoPrAnalysis(analysisId, commitDirectly, prId) {
7775
7888
  return this._clientSdk.autoPrAnalysis({
7776
7889
  analysisId,
7777
- commitDirectly
7890
+ commitDirectly,
7891
+ prId
7778
7892
  });
7779
7893
  }
7780
7894
  async getFixes(fixIds) {
@@ -8242,7 +8356,7 @@ async function uploadFile({
8242
8356
 
8243
8357
  // src/features/analysis/index.ts
8244
8358
  var { CliError: CliError2, Spinner: Spinner2 } = utils_exports;
8245
- function _getScanSource(command) {
8359
+ function _getScanSource(command, ci) {
8246
8360
  if (command === "review")
8247
8361
  return "AUTO_FIXER" /* AutoFixer */;
8248
8362
  const envToCi = [
@@ -8258,6 +8372,9 @@ function _getScanSource(command) {
8258
8372
  return source;
8259
8373
  }
8260
8374
  }
8375
+ if (ci) {
8376
+ return "CI_UNKNOWN" /* CiUnknown */;
8377
+ }
8261
8378
  return "CLI" /* Cli */;
8262
8379
  }
8263
8380
  async function downloadRepo({
@@ -8445,7 +8562,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
8445
8562
  command,
8446
8563
  organizationId: userOrganizationId,
8447
8564
  autoPr,
8448
- commitDirectly
8565
+ commitDirectly,
8566
+ pullRequest
8449
8567
  } = params;
8450
8568
  debug16("start %s %s", dirname, repo);
8451
8569
  const { createSpinner: createSpinner5 } = Spinner2({ ci });
@@ -8554,7 +8672,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
8554
8672
  gqlClient,
8555
8673
  fixReportId: reportUploadInfo.fixReportId,
8556
8674
  projectId,
8557
- command
8675
+ command,
8676
+ ci
8558
8677
  });
8559
8678
  uploadReportSpinner.success({ text: "\u{1F4C1} Report uploaded successfully" });
8560
8679
  const mobbSpinner = createSpinner5("\u{1F575}\uFE0F\u200D\u2642\uFE0F Initiating Mobb analysis").start();
@@ -8570,7 +8689,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
8570
8689
  sha,
8571
8690
  experimentalEnabled,
8572
8691
  pullRequest: params.pullRequest,
8573
- scanSource: _getScanSource(command)
8692
+ scanSource: _getScanSource(command, ci)
8574
8693
  }
8575
8694
  });
8576
8695
  if (sendReportRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
@@ -8585,6 +8704,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
8585
8704
  gqlClient,
8586
8705
  analysisId: reportUploadInfo.fixReportId,
8587
8706
  commitDirectly,
8707
+ prId: pullRequest,
8588
8708
  createSpinner: createSpinner5
8589
8709
  });
8590
8710
  }
@@ -8674,7 +8794,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
8674
8794
  gqlClient,
8675
8795
  fixReportId: reportUploadInfo.fixReportId,
8676
8796
  projectId,
8677
- command
8797
+ command,
8798
+ ci
8678
8799
  });
8679
8800
  const srcFileStatus = await fsPromises.lstat(srcPath);
8680
8801
  const zippingSpinner = createSpinner5("\u{1F4E6} Zipping repo").start();
@@ -8711,7 +8832,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
8711
8832
  repoUrl: repo || gitInfo.repoUrl || getTopLevelDirName(srcPath),
8712
8833
  reference: ref || gitInfo.reference || "no-branch",
8713
8834
  sha: commitHash || gitInfo.hash || "0123456789abcdef",
8714
- scanSource: _getScanSource(command),
8835
+ scanSource: _getScanSource(command, ci),
8715
8836
  pullRequest: params.pullRequest
8716
8837
  }
8717
8838
  });
@@ -8758,6 +8879,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
8758
8879
  gqlClient,
8759
8880
  analysisId: reportUploadInfo.fixReportId,
8760
8881
  commitDirectly,
8882
+ prId: pullRequest,
8761
8883
  createSpinner: createSpinner5
8762
8884
  });
8763
8885
  }
@@ -8769,7 +8891,8 @@ async function _digestReport({
8769
8891
  gqlClient,
8770
8892
  fixReportId,
8771
8893
  projectId,
8772
- command
8894
+ command,
8895
+ ci
8773
8896
  }) {
8774
8897
  const digestSpinner = createSpinner4(
8775
8898
  progressMassages.processingVulnerabilityReport
@@ -8779,7 +8902,7 @@ async function _digestReport({
8779
8902
  {
8780
8903
  fixReportId,
8781
8904
  projectId,
8782
- scanSource: _getScanSource(command)
8905
+ scanSource: _getScanSource(command, ci)
8783
8906
  }
8784
8907
  );
8785
8908
  try {
@@ -8864,7 +8987,8 @@ async function analyze({
8864
8987
  mobbProjectName,
8865
8988
  organizationId,
8866
8989
  autoPr,
8867
- commitDirectly
8990
+ commitDirectly,
8991
+ pullRequest
8868
8992
  }, { skipPrompts = false } = {}) {
8869
8993
  !ci && await showWelcomeMessage(skipPrompts);
8870
8994
  await runAnalysis(
@@ -8880,7 +9004,8 @@ async function analyze({
8880
9004
  organizationId,
8881
9005
  command: "analyze",
8882
9006
  autoPr,
8883
- commitDirectly
9007
+ commitDirectly,
9008
+ pullRequest
8884
9009
  },
8885
9010
  { skipPrompts }
8886
9011
  );
@@ -9198,7 +9323,12 @@ function analyzeBuilder(yargs2) {
9198
9323
  alias: "commit-hash",
9199
9324
  describe: chalk8.bold("Hash of the commit"),
9200
9325
  type: "string"
9201
- }).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("org", organizationIdOptions).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).option("auto-pr", autoPrOption).option("commit-directly", commitDirectlyOption).example(
9326
+ }).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("org", organizationIdOptions).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).option("auto-pr", autoPrOption).option("commit-directly", commitDirectlyOption).option("pull-request", {
9327
+ alias: ["pr", "pr-number", "pr-id"],
9328
+ describe: chalk8.bold("Number of the pull request"),
9329
+ type: "number",
9330
+ demandOption: false
9331
+ }).example(
9202
9332
  "npx mobbdev@latest analyze -r https://github.com/WebGoat/WebGoat -f <your_vulnerability_report_path>",
9203
9333
  "analyze an existing repository"
9204
9334
  ).help();
@@ -9223,6 +9353,11 @@ Can't access ${chalk8.bold(argv.f)}`);
9223
9353
  "--commit-directly flag requires --auto-pr to be provided as well"
9224
9354
  );
9225
9355
  }
9356
+ if (argv.pullRequest && !argv["commit-directly"]) {
9357
+ throw new CliError(
9358
+ "--pull-request flag requires --commit-directly to be provided as well"
9359
+ );
9360
+ }
9226
9361
  validateReportFileFormat(argv.f);
9227
9362
  }
9228
9363
  async function analyzeHandler(args) {
@@ -9251,7 +9386,7 @@ function reviewBuilder(yargs2) {
9251
9386
  type: "string",
9252
9387
  demandOption: true
9253
9388
  }).option("pull-request", {
9254
- alias: "pr",
9389
+ alias: ["pr", "pr-number", "pr-id"],
9255
9390
  describe: chalk9.bold("Number of the pull request"),
9256
9391
  type: "number",
9257
9392
  demandOption: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.0.46",
3
+ "version": "1.0.50",
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",
@@ -35,10 +35,10 @@
35
35
  "@octokit/core": "5.2.0",
36
36
  "@octokit/graphql": "5.0.6",
37
37
  "@octokit/plugin-rest-endpoint-methods": "7.2.3",
38
- "@octokit/request-error": "5.1.0",
38
+ "@octokit/request-error": "5.1.1",
39
39
  "@types/libsodium-wrappers": "0.7.14",
40
40
  "adm-zip": "0.5.16",
41
- "axios": "1.7.9",
41
+ "axios": "1.8.2",
42
42
  "azure-devops-node-api": "12.1.0",
43
43
  "bitbucket": "2.11.0",
44
44
  "chalk": "5.4.1",