mobbdev 0.0.165 → 0.0.167

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 +239 -252
  2. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -1271,16 +1271,16 @@ var CliError = class extends Error {
1271
1271
  // src/features/analysis/index.ts
1272
1272
  import chalk4 from "chalk";
1273
1273
  import Configstore from "configstore";
1274
- import Debug13 from "debug";
1274
+ import Debug15 from "debug";
1275
1275
  import extract from "extract-zip";
1276
1276
  import fetch4 from "node-fetch";
1277
1277
  import open2 from "open";
1278
1278
  import semver from "semver";
1279
1279
  import tmp2 from "tmp";
1280
- import { z as z19 } from "zod";
1280
+ import { z as z20 } from "zod";
1281
1281
 
1282
1282
  // src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
1283
- import Debug4 from "debug";
1283
+ import Debug6 from "debug";
1284
1284
 
1285
1285
  // src/features/analysis/scm/ado/constants.ts
1286
1286
  var DEFUALT_ADO_ORIGIN = scmCloudUrl.Ado;
@@ -1288,7 +1288,8 @@ var DEFUALT_ADO_ORIGIN = scmCloudUrl.Ado;
1288
1288
  // src/features/analysis/scm/ado/utils.ts
1289
1289
  import querystring3 from "node:querystring";
1290
1290
  import * as api from "azure-devops-node-api";
1291
- import { z as z16 } from "zod";
1291
+ import Debug3 from "debug";
1292
+ import { z as z17 } from "zod";
1292
1293
 
1293
1294
  // src/features/analysis/scm/env.ts
1294
1295
  import { z as z3 } from "zod";
@@ -1300,13 +1301,14 @@ var EnvVariablesZod = z3.object({
1300
1301
  var { GITLAB_API_TOKEN, GITHUB_API_TOKEN, GIT_PROXY_HOST } = EnvVariablesZod.parse(process.env);
1301
1302
 
1302
1303
  // src/features/analysis/scm/scm.ts
1303
- import { z as z14 } from "zod";
1304
+ import { z as z15 } from "zod";
1304
1305
 
1305
1306
  // src/features/analysis/scm/bitbucket/bitbucket.ts
1306
1307
  import querystring from "node:querystring";
1307
1308
  import bitbucketPkg from "bitbucket";
1308
1309
  import * as bitbucketPkgNode from "bitbucket";
1309
- import { z as z10 } from "zod";
1310
+ import Debug2 from "debug";
1311
+ import { z as z11 } from "zod";
1310
1312
 
1311
1313
  // src/features/analysis/scm/shared/src/commitDescriptionMarkup.ts
1312
1314
  import { z as z5 } from "zod";
@@ -3244,27 +3246,31 @@ var sanityRepoURL = (scmURL) => {
3244
3246
  }
3245
3247
  };
3246
3248
 
3249
+ // src/features/analysis/scm/bitbucket/validation.ts
3250
+ import { z as z10 } from "zod";
3251
+ var BitbucketAuthResultZ = z10.object({
3252
+ access_token: z10.string(),
3253
+ token_type: z10.string(),
3254
+ refresh_token: z10.string()
3255
+ });
3256
+
3247
3257
  // src/features/analysis/scm/bitbucket/bitbucket.ts
3258
+ var debug2 = Debug2("scm:bitbucket");
3248
3259
  var BITBUCKET_HOSTNAME = "bitbucket.org";
3249
- var TokenExpiredErrorZ = z10.object({
3250
- status: z10.number(),
3251
- error: z10.object({
3252
- type: z10.string(),
3253
- error: z10.object({
3254
- message: z10.string()
3260
+ var TokenExpiredErrorZ = z11.object({
3261
+ status: z11.number(),
3262
+ error: z11.object({
3263
+ type: z11.string(),
3264
+ error: z11.object({
3265
+ message: z11.string()
3255
3266
  })
3256
3267
  })
3257
3268
  });
3258
3269
  var BITBUCKET_ACCESS_TOKEN_URL = `https://${BITBUCKET_HOSTNAME}/site/oauth2/access_token`;
3259
- var BitbucketAuthResultZ = z10.object({
3260
- access_token: z10.string(),
3261
- token_type: z10.string(),
3262
- refresh_token: z10.string()
3263
- });
3264
- var BitbucketParseResultZ = z10.object({
3265
- organization: z10.string(),
3266
- repoName: z10.string(),
3267
- hostname: z10.literal(BITBUCKET_HOSTNAME)
3270
+ var BitbucketParseResultZ = z11.object({
3271
+ organization: z11.string(),
3272
+ repoName: z11.string(),
3273
+ hostname: z11.literal(BITBUCKET_HOSTNAME)
3268
3274
  });
3269
3275
  function parseBitbucketOrganizationAndRepo(bitbucketUrl) {
3270
3276
  const parsedGitHubUrl = normalizeUrl(bitbucketUrl);
@@ -3275,27 +3281,6 @@ function parseBitbucketOrganizationAndRepo(bitbucketUrl) {
3275
3281
  repoSlug: validatedBitbucketResult.repoName
3276
3282
  };
3277
3283
  }
3278
- async function getBitbucketToken(params) {
3279
- const { bitbucketClientId, bitbucketClientSecret, authType } = params;
3280
- const res = await fetch(BITBUCKET_ACCESS_TOKEN_URL, {
3281
- method: "POST",
3282
- headers: {
3283
- "Content-Type": "application/x-www-form-urlencoded",
3284
- Authorization: "Basic " + btoa(`${bitbucketClientId}:${bitbucketClientSecret}`)
3285
- },
3286
- body: querystring.stringify(
3287
- authType === "refresh_token" ? {
3288
- grant_type: authType,
3289
- refresh_token: params.refreshToken
3290
- } : {
3291
- grant_type: authType,
3292
- code: params.code
3293
- }
3294
- )
3295
- });
3296
- const authResult = await res.json();
3297
- return BitbucketAuthResultZ.parse(authResult);
3298
- }
3299
3284
  function getBitbucketIntance(params) {
3300
3285
  const BitbucketContstructor = bitbucketPkg && "Bitbucket" in bitbucketPkg ? bitbucketPkg.Bitbucket : bitbucketPkgNode.Bitbucket;
3301
3286
  switch (params.authType) {
@@ -3343,7 +3328,7 @@ function getBitbucketSdk(params) {
3343
3328
  if (!res.data.values) {
3344
3329
  return [];
3345
3330
  }
3346
- return res.data.values.filter((branch) => !!branch.name).map((branch) => z10.string().parse(branch.name));
3331
+ return res.data.values.filter((branch) => !!branch.name).map((branch) => z11.string().parse(branch.name));
3347
3332
  },
3348
3333
  async getIsUserCollaborator(params2) {
3349
3334
  const { repoUrl } = params2;
@@ -3458,7 +3443,7 @@ function getBitbucketSdk(params) {
3458
3443
  return GetRefererenceResultZ.parse({
3459
3444
  sha: tagRes.data.target?.hash,
3460
3445
  type: "TAG" /* TAG */,
3461
- date: new Date(z10.string().parse(tagRes.data.target?.date))
3446
+ date: new Date(z11.string().parse(tagRes.data.target?.date))
3462
3447
  });
3463
3448
  },
3464
3449
  async getBranchRef(params2) {
@@ -3466,7 +3451,7 @@ function getBitbucketSdk(params) {
3466
3451
  return GetRefererenceResultZ.parse({
3467
3452
  sha: getBranchRes.target?.hash,
3468
3453
  type: "BRANCH" /* BRANCH */,
3469
- date: new Date(z10.string().parse(getBranchRes.target?.date))
3454
+ date: new Date(z11.string().parse(getBranchRes.target?.date))
3470
3455
  });
3471
3456
  },
3472
3457
  async getCommitRef(params2) {
@@ -3474,13 +3459,13 @@ function getBitbucketSdk(params) {
3474
3459
  return GetRefererenceResultZ.parse({
3475
3460
  sha: getCommitRes.hash,
3476
3461
  type: "COMMIT" /* COMMIT */,
3477
- date: new Date(z10.string().parse(getCommitRes.date))
3462
+ date: new Date(z11.string().parse(getCommitRes.date))
3478
3463
  });
3479
3464
  },
3480
3465
  async getDownloadUrl({ url, sha }) {
3481
3466
  this.getReferenceData({ ref: sha, url });
3482
3467
  const repoRes = await this.getRepo({ repoUrl: url });
3483
- const parsedRepoUrl = z10.string().url().parse(repoRes.links?.html?.href);
3468
+ const parsedRepoUrl = z11.string().url().parse(repoRes.links?.html?.href);
3484
3469
  return `${parsedRepoUrl}/get/${sha}.zip`;
3485
3470
  },
3486
3471
  async getPullRequest(params2) {
@@ -3523,7 +3508,7 @@ async function validateBitbucketParams(params) {
3523
3508
  }
3524
3509
  async function getUsersworkspacesSlugs(bitbucketClient) {
3525
3510
  const res = await bitbucketClient.workspaces.getWorkspaces({});
3526
- return res.data.values?.map((v) => z10.string().parse(v.slug));
3511
+ return res.data.values?.map((v) => z11.string().parse(v.slug));
3527
3512
  }
3528
3513
  async function getllUsersrepositories(bitbucketClient) {
3529
3514
  const userWorspacesSlugs = await getUsersworkspacesSlugs(bitbucketClient);
@@ -4063,11 +4048,11 @@ import {
4063
4048
  import { ProxyAgent as ProxyAgent2 } from "undici";
4064
4049
 
4065
4050
  // src/features/analysis/scm/gitlab/types.ts
4066
- import { z as z11 } from "zod";
4067
- var GitlabAuthResultZ = z11.object({
4068
- access_token: z11.string(),
4069
- token_type: z11.string(),
4070
- refresh_token: z11.string()
4051
+ import { z as z12 } from "zod";
4052
+ var GitlabAuthResultZ = z12.object({
4053
+ access_token: z12.string(),
4054
+ token_type: z12.string(),
4055
+ refresh_token: z12.string()
4071
4056
  });
4072
4057
 
4073
4058
  // src/features/analysis/scm/gitlab/gitlab.ts
@@ -4075,6 +4060,7 @@ function removeTrailingSlash(str) {
4075
4060
  return str.trim().replace(/\/+$/, "");
4076
4061
  }
4077
4062
  function getGitBeaker(options) {
4063
+ console.log("getGitBeaker starting");
4078
4064
  const token = options?.gitlabAuthToken ?? GITLAB_API_TOKEN ?? "";
4079
4065
  const url = options.url;
4080
4066
  const host = url ? new URL(url).origin : "https://gitlab.com";
@@ -4332,8 +4318,14 @@ async function getGitlabBlameRanges({ ref, gitlabUrl, path: path9 }, options) {
4332
4318
  });
4333
4319
  }
4334
4320
  function initGitlabFetchMock() {
4321
+ console.log("initGitlabFetchMock starting");
4335
4322
  const globalFetch = global.fetch;
4336
4323
  function myFetch(input, init) {
4324
+ console.log(
4325
+ `myFetch called with input: ${input} ${JSON.stringify(input)} ${JSON.stringify(init)}`,
4326
+ input,
4327
+ input?.url
4328
+ );
4337
4329
  let urlParsed = null;
4338
4330
  try {
4339
4331
  urlParsed = input?.url ? new URL(input?.url) : null;
@@ -4342,7 +4334,9 @@ function initGitlabFetchMock() {
4342
4334
  `this block is used for unit tests only. URL ${input?.url} starts from local directory`
4343
4335
  );
4344
4336
  }
4337
+ console.log(`urlParsed: ${urlParsed} ${urlParsed?.href}`);
4345
4338
  if (urlParsed && isBrokerUrl(urlParsed.href)) {
4339
+ console.log(`urlParsed is broker url: ${urlParsed.href}`);
4346
4340
  const dispatcher = new ProxyAgent2({
4347
4341
  uri: GIT_PROXY_HOST,
4348
4342
  requestTls: {
@@ -4351,9 +4345,11 @@ function initGitlabFetchMock() {
4351
4345
  });
4352
4346
  return globalFetch(input, { dispatcher });
4353
4347
  }
4348
+ console.log("urlParsed is not broker url");
4354
4349
  return globalFetch(input, init);
4355
4350
  }
4356
4351
  global.fetch = myFetch;
4352
+ console.log("initGitlabFetchMock finished");
4357
4353
  }
4358
4354
  initGitlabFetchMock();
4359
4355
 
@@ -4363,80 +4359,80 @@ import parseDiff from "parse-diff";
4363
4359
  import path3 from "path";
4364
4360
  import { simpleGit } from "simple-git";
4365
4361
  import tmp from "tmp";
4366
- import { z as z13 } from "zod";
4362
+ import { z as z14 } from "zod";
4367
4363
 
4368
4364
  // src/features/analysis/scm/scmSubmit/types.ts
4369
- import { z as z12 } from "zod";
4370
- var BaseSubmitToScmMessageZ = z12.object({
4371
- submitFixRequestId: z12.string().uuid(),
4372
- fixes: z12.array(
4373
- z12.object({
4374
- fixId: z12.string().uuid(),
4375
- patches: z12.array(z12.string())
4365
+ import { z as z13 } from "zod";
4366
+ var BaseSubmitToScmMessageZ = z13.object({
4367
+ submitFixRequestId: z13.string().uuid(),
4368
+ fixes: z13.array(
4369
+ z13.object({
4370
+ fixId: z13.string().uuid(),
4371
+ patches: z13.array(z13.string())
4376
4372
  })
4377
4373
  ),
4378
- commitHash: z12.string(),
4379
- repoUrl: z12.string(),
4380
- mobbUserEmail: z12.string(),
4381
- extraHeaders: z12.record(z12.string(), z12.string()).default({})
4374
+ commitHash: z13.string(),
4375
+ repoUrl: z13.string(),
4376
+ mobbUserEmail: z13.string(),
4377
+ extraHeaders: z13.record(z13.string(), z13.string()).default({})
4382
4378
  });
4383
4379
  var submitToScmMessageType = {
4384
4380
  commitToSameBranch: "commitToSameBranch",
4385
4381
  submitFixesForDifferentBranch: "submitFixesForDifferentBranch"
4386
4382
  };
4387
4383
  var CommitToSameBranchParamsZ = BaseSubmitToScmMessageZ.merge(
4388
- z12.object({
4389
- type: z12.literal(submitToScmMessageType.commitToSameBranch),
4390
- branch: z12.string(),
4391
- commitMessage: z12.string(),
4392
- commitDescription: z12.string().nullish(),
4393
- githubCommentId: z12.number().nullish()
4384
+ z13.object({
4385
+ type: z13.literal(submitToScmMessageType.commitToSameBranch),
4386
+ branch: z13.string(),
4387
+ commitMessage: z13.string(),
4388
+ commitDescription: z13.string().nullish(),
4389
+ githubCommentId: z13.number().nullish()
4394
4390
  })
4395
4391
  );
4396
- var SubmitFixesToDifferentBranchParamsZ = z12.object({
4397
- type: z12.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4398
- submitBranch: z12.string(),
4399
- baseBranch: z12.string()
4392
+ var SubmitFixesToDifferentBranchParamsZ = z13.object({
4393
+ type: z13.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4394
+ submitBranch: z13.string(),
4395
+ baseBranch: z13.string()
4400
4396
  }).merge(BaseSubmitToScmMessageZ);
4401
- var SubmitFixesMessageZ = z12.union([
4397
+ var SubmitFixesMessageZ = z13.union([
4402
4398
  CommitToSameBranchParamsZ,
4403
4399
  SubmitFixesToDifferentBranchParamsZ
4404
4400
  ]);
4405
- var FixResponseArrayZ = z12.array(
4406
- z12.object({
4407
- fixId: z12.string().uuid()
4401
+ var FixResponseArrayZ = z13.array(
4402
+ z13.object({
4403
+ fixId: z13.string().uuid()
4408
4404
  })
4409
4405
  );
4410
- var SubmitFixesBaseResponseMessageZ = z12.object({
4411
- mobbUserEmail: z12.string(),
4412
- submitFixRequestId: z12.string().uuid(),
4413
- submitBranches: z12.array(
4414
- z12.object({
4415
- branchName: z12.string(),
4406
+ var SubmitFixesBaseResponseMessageZ = z13.object({
4407
+ mobbUserEmail: z13.string(),
4408
+ submitFixRequestId: z13.string().uuid(),
4409
+ submitBranches: z13.array(
4410
+ z13.object({
4411
+ branchName: z13.string(),
4416
4412
  fixes: FixResponseArrayZ
4417
4413
  })
4418
4414
  ),
4419
- error: z12.object({
4420
- type: z12.enum([
4415
+ error: z13.object({
4416
+ type: z13.enum([
4421
4417
  "InitialRepoAccessError",
4422
4418
  "PushBranchError",
4423
4419
  "UnknownError"
4424
4420
  ]),
4425
- info: z12.object({
4426
- message: z12.string(),
4427
- pushBranchName: z12.string().optional()
4421
+ info: z13.object({
4422
+ message: z13.string(),
4423
+ pushBranchName: z13.string().optional()
4428
4424
  })
4429
4425
  }).optional()
4430
4426
  });
4431
- var SubmitFixesToSameBranchResponseMessageZ = z12.object({
4432
- type: z12.literal(submitToScmMessageType.commitToSameBranch),
4433
- githubCommentId: z12.number().nullish()
4427
+ var SubmitFixesToSameBranchResponseMessageZ = z13.object({
4428
+ type: z13.literal(submitToScmMessageType.commitToSameBranch),
4429
+ githubCommentId: z13.number().nullish()
4434
4430
  }).merge(SubmitFixesBaseResponseMessageZ);
4435
- var SubmitFixesToDifferentBranchResponseMessageZ = z12.object({
4436
- type: z12.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4437
- githubCommentId: z12.number().optional()
4431
+ var SubmitFixesToDifferentBranchResponseMessageZ = z13.object({
4432
+ type: z13.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4433
+ githubCommentId: z13.number().optional()
4438
4434
  }).merge(SubmitFixesBaseResponseMessageZ);
4439
- var SubmitFixesResponseMessageZ = z12.discriminatedUnion("type", [
4435
+ var SubmitFixesResponseMessageZ = z13.discriminatedUnion("type", [
4440
4436
  SubmitFixesToSameBranchResponseMessageZ,
4441
4437
  SubmitFixesToDifferentBranchResponseMessageZ
4442
4438
  ]);
@@ -4454,21 +4450,21 @@ var isValidBranchName = async (branchName) => {
4454
4450
  return false;
4455
4451
  }
4456
4452
  };
4457
- var FixesZ = z13.array(
4458
- z13.object({
4459
- fixId: z13.string(),
4460
- patches: z13.array(z13.string())
4453
+ var FixesZ = z14.array(
4454
+ z14.object({
4455
+ fixId: z14.string(),
4456
+ patches: z14.array(z14.string())
4461
4457
  })
4462
4458
  ).nonempty();
4463
4459
 
4464
4460
  // src/features/analysis/scm/scm.ts
4465
4461
  function isBrokerUrl(url) {
4466
- return z14.string().uuid().safeParse(new URL(url).host).success;
4462
+ return z15.string().uuid().safeParse(new URL(url).host).success;
4467
4463
  }
4468
- var GetRefererenceResultZ = z14.object({
4469
- date: z14.date().optional(),
4470
- sha: z14.string(),
4471
- type: z14.nativeEnum(ReferenceType)
4464
+ var GetRefererenceResultZ = z15.object({
4465
+ date: z15.date().optional(),
4466
+ sha: z15.string(),
4467
+ type: z15.nativeEnum(ReferenceType)
4472
4468
  });
4473
4469
  function getCloudScmLibTypeFromUrl(url) {
4474
4470
  if (!url) {
@@ -4509,7 +4505,7 @@ var scmTypeToScmLibScmType = {
4509
4505
  ["Bitbucket" /* Bitbucket */]: "BITBUCKET" /* BITBUCKET */
4510
4506
  };
4511
4507
  function getScmLibTypeFromScmType(scmType) {
4512
- const parsedScmType = z14.nativeEnum(ScmType).parse(scmType);
4508
+ const parsedScmType = z15.nativeEnum(ScmType).parse(scmType);
4513
4509
  return scmTypeToScmLibScmType[parsedScmType];
4514
4510
  }
4515
4511
  function getScmConfig({
@@ -4723,7 +4719,7 @@ var SCMLib = class {
4723
4719
  if (e instanceof InvalidRepoUrlError && url) {
4724
4720
  throw new RepoNoTokenAccessError(
4725
4721
  "no access to repo",
4726
- scmLibScmTypeToScmType[z14.nativeEnum(ScmLibScmType).parse(scmType)]
4722
+ scmLibScmTypeToScmType[z15.nativeEnum(ScmLibScmType).parse(scmType)]
4727
4723
  );
4728
4724
  }
4729
4725
  console.error(`error validating scm: ${scmType} `, e);
@@ -5134,7 +5130,7 @@ var GithubSCMLib = class extends SCMLib {
5134
5130
  owner,
5135
5131
  repo
5136
5132
  });
5137
- return z14.string().parse(prRes.data);
5133
+ return z15.string().parse(prRes.data);
5138
5134
  }
5139
5135
  async getRepoList(_scmOrg) {
5140
5136
  this._validateAccessToken();
@@ -5325,7 +5321,7 @@ var StubSCMLib = class extends SCMLib {
5325
5321
  };
5326
5322
  function getUserAndPassword(token) {
5327
5323
  const [username, password] = token.split(":");
5328
- const safePasswordAndUsername = z14.object({ username: z14.string(), password: z14.string() }).parse({ username, password });
5324
+ const safePasswordAndUsername = z15.object({ username: z15.string(), password: z15.string() }).parse({ username, password });
5329
5325
  return {
5330
5326
  username: safePasswordAndUsername.username,
5331
5327
  password: safePasswordAndUsername.password
@@ -5361,7 +5357,7 @@ var BitbucketSCMLib = class extends SCMLib {
5361
5357
  return { username, password, authType };
5362
5358
  }
5363
5359
  case "token": {
5364
- return { authType, token: z14.string().parse(this.accessToken) };
5360
+ return { authType, token: z15.string().parse(this.accessToken) };
5365
5361
  }
5366
5362
  case "public":
5367
5363
  return { authType };
@@ -5373,7 +5369,7 @@ var BitbucketSCMLib = class extends SCMLib {
5373
5369
  ...params,
5374
5370
  repoUrl: this.url
5375
5371
  });
5376
- return String(z14.number().parse(pullRequestRes.id));
5372
+ return String(z15.number().parse(pullRequestRes.id));
5377
5373
  }
5378
5374
  async validateParams() {
5379
5375
  return validateBitbucketParams({
@@ -5445,7 +5441,7 @@ var BitbucketSCMLib = class extends SCMLib {
5445
5441
  async getUsername() {
5446
5442
  this._validateAccessToken();
5447
5443
  const res = await this.bitbucketSdk.getUser();
5448
- return z14.string().parse(res.username);
5444
+ return z15.string().parse(res.username);
5449
5445
  }
5450
5446
  async getSubmitRequestStatus(_scmSubmitRequestId) {
5451
5447
  this._validateAccessTokenAndUrl();
@@ -5474,7 +5470,7 @@ var BitbucketSCMLib = class extends SCMLib {
5474
5470
  async getRepoDefaultBranch() {
5475
5471
  this._validateUrl();
5476
5472
  const repoRes = await this.bitbucketSdk.getRepo({ repoUrl: this.url });
5477
- return z14.string().parse(repoRes.mainbranch?.name);
5473
+ return z15.string().parse(repoRes.mainbranch?.name);
5478
5474
  }
5479
5475
  getPrUrl(prNumber) {
5480
5476
  this._validateUrl();
@@ -5483,51 +5479,42 @@ var BitbucketSCMLib = class extends SCMLib {
5483
5479
  `https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/${prNumber}`
5484
5480
  );
5485
5481
  }
5486
- async refreshToken(params) {
5487
- const getBitbucketTokenResponse = await getBitbucketToken({
5488
- authType: "refresh_token",
5489
- ...params
5490
- });
5491
- return {
5492
- accessToken: getBitbucketTokenResponse.access_token,
5493
- refreshToken: getBitbucketTokenResponse.refresh_token
5494
- };
5495
- }
5496
5482
  };
5497
5483
 
5498
5484
  // src/features/analysis/scm/ado/validation.ts
5499
- import { z as z15 } from "zod";
5500
- var ValidPullRequestStatusZ = z15.union([
5501
- z15.literal(1 /* Active */),
5502
- z15.literal(2 /* Abandoned */),
5503
- z15.literal(3 /* Completed */)
5485
+ import { z as z16 } from "zod";
5486
+ var ValidPullRequestStatusZ = z16.union([
5487
+ z16.literal(1 /* Active */),
5488
+ z16.literal(2 /* Abandoned */),
5489
+ z16.literal(3 /* Completed */)
5504
5490
  ]);
5505
- var AdoAuthResultZ = z15.object({
5506
- access_token: z15.string().min(1),
5507
- token_type: z15.string().min(1),
5508
- refresh_token: z15.string().min(1)
5491
+ var AdoAuthResultZ = z16.object({
5492
+ access_token: z16.string().min(1),
5493
+ token_type: z16.string().min(1),
5494
+ refresh_token: z16.string().min(1)
5509
5495
  });
5510
- var profileZ = z15.object({
5511
- displayName: z15.string(),
5512
- publicAlias: z15.string().min(1),
5513
- emailAddress: z15.string(),
5514
- coreRevision: z15.number(),
5515
- timeStamp: z15.string(),
5516
- id: z15.string(),
5517
- revision: z15.number()
5496
+ var profileZ = z16.object({
5497
+ displayName: z16.string(),
5498
+ publicAlias: z16.string().min(1),
5499
+ emailAddress: z16.string(),
5500
+ coreRevision: z16.number(),
5501
+ timeStamp: z16.string(),
5502
+ id: z16.string(),
5503
+ revision: z16.number()
5518
5504
  });
5519
- var accountsZ = z15.object({
5520
- count: z15.number(),
5521
- value: z15.array(
5522
- z15.object({
5523
- accountId: z15.string(),
5524
- accountUri: z15.string(),
5525
- accountName: z15.string()
5505
+ var accountsZ = z16.object({
5506
+ count: z16.number(),
5507
+ value: z16.array(
5508
+ z16.object({
5509
+ accountId: z16.string(),
5510
+ accountUri: z16.string(),
5511
+ accountName: z16.string()
5526
5512
  })
5527
5513
  )
5528
5514
  });
5529
5515
 
5530
5516
  // src/features/analysis/scm/ado/utils.ts
5517
+ var debug3 = Debug3("mobbdev:scm:ado");
5531
5518
  function _getPublicAdoClient({
5532
5519
  orgName,
5533
5520
  origin: origin2
@@ -5595,7 +5582,7 @@ async function getAdoConnectData({
5595
5582
  oauthToken: adoTokenInfo.accessToken
5596
5583
  });
5597
5584
  return {
5598
- org: z16.string().parse(org),
5585
+ org: z17.string().parse(org),
5599
5586
  origin: DEFUALT_ADO_ORIGIN
5600
5587
  };
5601
5588
  }
@@ -5681,7 +5668,7 @@ async function getAdoClientParams(params) {
5681
5668
  return {
5682
5669
  tokenType: "PAT" /* PAT */,
5683
5670
  accessToken: adoTokenInfo.accessToken,
5684
- patTokenOrg: z16.string().parse(tokenOrg).toLowerCase(),
5671
+ patTokenOrg: z17.string().parse(tokenOrg).toLowerCase(),
5685
5672
  origin: origin2,
5686
5673
  orgName: org.toLowerCase()
5687
5674
  };
@@ -6036,9 +6023,9 @@ async function getAdoRepoList({
6036
6023
  var MOBB_ICON_IMG = "https://app.mobb.ai/gh-action/Logo_Rounded_Icon.svg";
6037
6024
 
6038
6025
  // src/features/analysis/add_fix_comments_for_pr/utils.ts
6039
- import Debug3 from "debug";
6026
+ import Debug5 from "debug";
6040
6027
  import parseDiff2 from "parse-diff";
6041
- import { z as z17 } from "zod";
6028
+ import { z as z18 } from "zod";
6042
6029
 
6043
6030
  // src/features/analysis/utils/by_key.ts
6044
6031
  function keyBy(array, keyBy2) {
@@ -6048,8 +6035,8 @@ function keyBy(array, keyBy2) {
6048
6035
  }
6049
6036
 
6050
6037
  // src/features/analysis/utils/send_report.ts
6051
- import Debug2 from "debug";
6052
- var debug2 = Debug2("mobbdev:index");
6038
+ import Debug4 from "debug";
6039
+ var debug4 = Debug4("mobbdev:index");
6053
6040
  async function sendReport({
6054
6041
  spinner,
6055
6042
  submitVulnerabilityReportVariables,
@@ -6060,7 +6047,7 @@ async function sendReport({
6060
6047
  submitVulnerabilityReportVariables
6061
6048
  );
6062
6049
  if (submitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
6063
- debug2("error submit vul report %s", submitRes);
6050
+ debug4("error submit vul report %s", submitRes);
6064
6051
  throw new Error("\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed");
6065
6052
  }
6066
6053
  spinner.update({ text: progressMassages.processingVulnerabilityReport });
@@ -6108,7 +6095,7 @@ var scannerToFriendlyString = {
6108
6095
  };
6109
6096
 
6110
6097
  // src/features/analysis/add_fix_comments_for_pr/utils.ts
6111
- var debug3 = Debug3("mobbdev:handle-finished-analysis");
6098
+ var debug5 = Debug5("mobbdev:handle-finished-analysis");
6112
6099
  var getCommitFixButton = (commitUrl) => `<a href="${commitUrl}"><img src=${COMMIT_FIX_SVG}></a>`;
6113
6100
  function calculateRanges(integers) {
6114
6101
  if (integers.length === 0) {
@@ -6143,7 +6130,7 @@ function deleteAllPreviousComments({
6143
6130
  try {
6144
6131
  return scm.deleteComment({ comment_id: comment.id });
6145
6132
  } catch (e) {
6146
- debug3("delete comment failed %s", e);
6133
+ debug5("delete comment failed %s", e);
6147
6134
  return Promise.resolve();
6148
6135
  }
6149
6136
  });
@@ -6159,7 +6146,7 @@ function deleteAllPreviousGeneralPrComments(params) {
6159
6146
  try {
6160
6147
  return scm.deleteGeneralPrComment({ commentId: comment.id });
6161
6148
  } catch (e) {
6162
- debug3("delete comment failed %s", e);
6149
+ debug5("delete comment failed %s", e);
6163
6150
  return Promise.resolve();
6164
6151
  }
6165
6152
  });
@@ -6283,7 +6270,7 @@ async function getRelevantVulenrabilitiesFromDiff(params) {
6283
6270
  });
6284
6271
  const lineAddedRanges = calculateRanges(fileNumbers);
6285
6272
  const fileFilter = {
6286
- path: z17.string().parse(file.to),
6273
+ path: z18.string().parse(file.to),
6287
6274
  ranges: lineAddedRanges.map(([startLine, endLine]) => ({
6288
6275
  endLine,
6289
6276
  startLine
@@ -6324,7 +6311,7 @@ async function postAnalysisInsightComment(params) {
6324
6311
  fixablePrVuls,
6325
6312
  nonFixablePrVuls
6326
6313
  } = prVulenrabilities;
6327
- debug3({
6314
+ debug5({
6328
6315
  fixablePrVuls,
6329
6316
  nonFixablePrVuls,
6330
6317
  vulnerabilitiesOutsidePr,
@@ -6379,7 +6366,7 @@ ${contactUsMarkdown}`;
6379
6366
  }
6380
6367
 
6381
6368
  // src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
6382
- var debug4 = Debug4("mobbdev:handle-finished-analysis");
6369
+ var debug6 = Debug6("mobbdev:handle-finished-analysis");
6383
6370
  async function addFixCommentsForPr({
6384
6371
  analysisId,
6385
6372
  scm: _scm,
@@ -6391,7 +6378,7 @@ async function addFixCommentsForPr({
6391
6378
  }
6392
6379
  const scm = _scm;
6393
6380
  const getAnalysisRes = await gqlClient.getAnalysis(analysisId);
6394
- debug4("getAnalysis %o", getAnalysisRes);
6381
+ debug6("getAnalysis %o", getAnalysisRes);
6395
6382
  const {
6396
6383
  vulnerabilityReport: {
6397
6384
  projectId,
@@ -6453,8 +6440,8 @@ async function addFixCommentsForPr({
6453
6440
  }
6454
6441
 
6455
6442
  // src/features/analysis/auto_pr_handler.ts
6456
- import Debug5 from "debug";
6457
- var debug5 = Debug5("mobbdev:handleAutoPr");
6443
+ import Debug7 from "debug";
6444
+ var debug7 = Debug7("mobbdev:handleAutoPr");
6458
6445
  async function handleAutoPr(params) {
6459
6446
  const { gqlClient, analysisId, createSpinner: createSpinner4 } = params;
6460
6447
  const createAutoPrSpinner = createSpinner4(
@@ -6466,7 +6453,7 @@ async function handleAutoPr(params) {
6466
6453
  },
6467
6454
  callback: async (analysisId2) => {
6468
6455
  const autoPrAnalysisRes = await gqlClient.autoPrAnalysis(analysisId2);
6469
- debug5("auto pr analysis res %o", autoPrAnalysisRes);
6456
+ debug7("auto pr analysis res %o", autoPrAnalysisRes);
6470
6457
  if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
6471
6458
  createAutoPrSpinner.error({
6472
6459
  text: `\u{1F504} Automatic pull request failed - ${autoPrAnalysisRes.autoPrAnalysis.error}`
@@ -6491,12 +6478,12 @@ async function handleAutoPr(params) {
6491
6478
  }
6492
6479
 
6493
6480
  // src/features/analysis/git.ts
6494
- import Debug6 from "debug";
6481
+ import Debug8 from "debug";
6495
6482
  import { simpleGit as simpleGit2 } from "simple-git";
6496
- var debug6 = Debug6("mobbdev:git");
6483
+ var debug8 = Debug8("mobbdev:git");
6497
6484
  var GIT_NOT_INITIALIZED_ERROR_MESSAGE = "not a git repository";
6498
6485
  async function getGitInfo(srcDirPath) {
6499
- debug6("getting git info for %s", srcDirPath);
6486
+ debug8("getting git info for %s", srcDirPath);
6500
6487
  const git = simpleGit2({
6501
6488
  baseDir: srcDirPath,
6502
6489
  maxConcurrentProcesses: 1,
@@ -6511,11 +6498,11 @@ async function getGitInfo(srcDirPath) {
6511
6498
  reference = await git.revparse(["--abbrev-ref", "HEAD"]) || "";
6512
6499
  } catch (e) {
6513
6500
  if (e instanceof Error) {
6514
- debug6("failed to run git %o", e);
6501
+ debug8("failed to run git %o", e);
6515
6502
  if (e.message.includes(" spawn ")) {
6516
- debug6("git cli not installed");
6503
+ debug8("git cli not installed");
6517
6504
  } else if (e.message.includes(GIT_NOT_INITIALIZED_ERROR_MESSAGE)) {
6518
- debug6("folder is not a git repo");
6505
+ debug8("folder is not a git repo");
6519
6506
  return {
6520
6507
  success: false,
6521
6508
  hash: void 0,
@@ -6543,7 +6530,7 @@ async function getGitInfo(srcDirPath) {
6543
6530
  }
6544
6531
 
6545
6532
  // src/features/analysis/graphql/gql.ts
6546
- import Debug7 from "debug";
6533
+ import Debug9 from "debug";
6547
6534
  import { GraphQLClient } from "graphql-request";
6548
6535
  import { v4 as uuidv4 } from "uuid";
6549
6536
 
@@ -6628,36 +6615,36 @@ function subscribe(query, variables, callback, wsClientOptions) {
6628
6615
  }
6629
6616
 
6630
6617
  // src/features/analysis/graphql/types.ts
6631
- import { z as z18 } from "zod";
6632
- var VulnerabilityReportIssueCodeNodeZ = z18.object({
6633
- vulnerabilityReportIssueId: z18.string(),
6634
- path: z18.string(),
6635
- startLine: z18.number(),
6636
- vulnerabilityReportIssue: z18.object({
6637
- fixId: z18.string()
6618
+ import { z as z19 } from "zod";
6619
+ var VulnerabilityReportIssueCodeNodeZ = z19.object({
6620
+ vulnerabilityReportIssueId: z19.string(),
6621
+ path: z19.string(),
6622
+ startLine: z19.number(),
6623
+ vulnerabilityReportIssue: z19.object({
6624
+ fixId: z19.string()
6638
6625
  })
6639
6626
  });
6640
- var GetVulByNodesMetadataZ = z18.object({
6641
- vulnerabilityReportIssueCodeNodes: z18.array(VulnerabilityReportIssueCodeNodeZ),
6642
- nonFixablePrVuls: z18.object({
6643
- aggregate: z18.object({
6644
- count: z18.number()
6627
+ var GetVulByNodesMetadataZ = z19.object({
6628
+ vulnerabilityReportIssueCodeNodes: z19.array(VulnerabilityReportIssueCodeNodeZ),
6629
+ nonFixablePrVuls: z19.object({
6630
+ aggregate: z19.object({
6631
+ count: z19.number()
6645
6632
  })
6646
6633
  }),
6647
- fixablePrVuls: z18.object({
6648
- aggregate: z18.object({
6649
- count: z18.number()
6634
+ fixablePrVuls: z19.object({
6635
+ aggregate: z19.object({
6636
+ count: z19.number()
6650
6637
  })
6651
6638
  }),
6652
- totalScanVulnerabilities: z18.object({
6653
- aggregate: z18.object({
6654
- count: z18.number()
6639
+ totalScanVulnerabilities: z19.object({
6640
+ aggregate: z19.object({
6641
+ count: z19.number()
6655
6642
  })
6656
6643
  })
6657
6644
  });
6658
6645
 
6659
6646
  // src/features/analysis/graphql/gql.ts
6660
- var debug7 = Debug7("mobbdev:gql");
6647
+ var debug9 = Debug9("mobbdev:gql");
6661
6648
  var API_KEY_HEADER_NAME = "x-mobb-key";
6662
6649
  var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
6663
6650
  var GQLClient = class {
@@ -6665,7 +6652,7 @@ var GQLClient = class {
6665
6652
  __publicField(this, "_client");
6666
6653
  __publicField(this, "_clientSdk");
6667
6654
  __publicField(this, "_auth");
6668
- debug7(`init with ${args}`);
6655
+ debug9(`init with ${args}`);
6669
6656
  this._auth = args;
6670
6657
  this._client = new GraphQLClient(API_URL, {
6671
6658
  headers: args.type === "apiKey" ? { [API_KEY_HEADER_NAME]: args.apiKey || "" } : {
@@ -6673,7 +6660,7 @@ var GQLClient = class {
6673
6660
  },
6674
6661
  requestMiddleware: (request) => {
6675
6662
  const requestId = uuidv4();
6676
- debug7(
6663
+ debug9(
6677
6664
  `sending API request with id: ${requestId} and with request: ${request.body}`
6678
6665
  );
6679
6666
  return {
@@ -6703,7 +6690,7 @@ var GQLClient = class {
6703
6690
  try {
6704
6691
  await this.getUserInfo();
6705
6692
  } catch (e) {
6706
- debug7("verify token failed %o", e);
6693
+ debug9("verify token failed %o", e);
6707
6694
  return false;
6708
6695
  }
6709
6696
  return true;
@@ -6747,7 +6734,7 @@ var GQLClient = class {
6747
6734
  try {
6748
6735
  await this._clientSdk.CreateCommunityUser();
6749
6736
  } catch (e) {
6750
- debug7("create community user failed %o", e);
6737
+ debug9("create community user failed %o", e);
6751
6738
  }
6752
6739
  }
6753
6740
  async updateScmToken(args) {
@@ -6941,10 +6928,10 @@ var GQLClient = class {
6941
6928
  import fs2 from "node:fs";
6942
6929
  import path4 from "node:path";
6943
6930
  import AdmZip from "adm-zip";
6944
- import Debug8 from "debug";
6931
+ import Debug10 from "debug";
6945
6932
  import { globby } from "globby";
6946
6933
  import { isBinary } from "istextorbinary";
6947
- var debug8 = Debug8("mobbdev:pack");
6934
+ var debug10 = Debug10("mobbdev:pack");
6948
6935
  var MAX_FILE_SIZE = 1024 * 1024 * 5;
6949
6936
  function endsWithAny(str, suffixes) {
6950
6937
  return suffixes.some(function(suffix) {
@@ -6955,7 +6942,7 @@ function _get_manifest_files_suffixes() {
6955
6942
  return ["package.json"];
6956
6943
  }
6957
6944
  async function pack(srcDirPath, vulnFiles) {
6958
- debug8("pack folder %s", srcDirPath);
6945
+ debug10("pack folder %s", srcDirPath);
6959
6946
  const filepaths = await globby("**", {
6960
6947
  gitignore: true,
6961
6948
  onlyFiles: true,
@@ -6963,9 +6950,9 @@ async function pack(srcDirPath, vulnFiles) {
6963
6950
  followSymbolicLinks: false,
6964
6951
  dot: true
6965
6952
  });
6966
- debug8("files found %d", filepaths.length);
6953
+ debug10("files found %d", filepaths.length);
6967
6954
  const zip = new AdmZip();
6968
- debug8("compressing files");
6955
+ debug10("compressing files");
6969
6956
  for (const filepath of filepaths) {
6970
6957
  const absFilepath = path4.join(srcDirPath, filepath.toString());
6971
6958
  vulnFiles = vulnFiles.concat(_get_manifest_files_suffixes());
@@ -6973,21 +6960,21 @@ async function pack(srcDirPath, vulnFiles) {
6973
6960
  absFilepath.toString().replaceAll(path4.win32.sep, path4.posix.sep),
6974
6961
  vulnFiles
6975
6962
  )) {
6976
- debug8("ignoring %s because it is not a vulnerability file", filepath);
6963
+ debug10("ignoring %s because it is not a vulnerability file", filepath);
6977
6964
  continue;
6978
6965
  }
6979
6966
  if (fs2.lstatSync(absFilepath).size > MAX_FILE_SIZE) {
6980
- debug8("ignoring %s because the size is > 5MB", filepath);
6967
+ debug10("ignoring %s because the size is > 5MB", filepath);
6981
6968
  continue;
6982
6969
  }
6983
6970
  const data = fs2.readFileSync(absFilepath);
6984
6971
  if (isBinary(null, data)) {
6985
- debug8("ignoring %s because is seems to be a binary file", filepath);
6972
+ debug10("ignoring %s because is seems to be a binary file", filepath);
6986
6973
  continue;
6987
6974
  }
6988
6975
  zip.addFile(filepath.toString(), data);
6989
6976
  }
6990
- debug8("get zip file buffer");
6977
+ debug10("get zip file buffer");
6991
6978
  return zip.toBuffer();
6992
6979
  }
6993
6980
 
@@ -7063,7 +7050,7 @@ var cxOperatingSystemSupportMessage = `Your operating system does not support ch
7063
7050
 
7064
7051
  // src/utils/child_process.ts
7065
7052
  import cp from "node:child_process";
7066
- import Debug9 from "debug";
7053
+ import Debug11 from "debug";
7067
7054
  import * as process2 from "process";
7068
7055
  import supportsColor from "supports-color";
7069
7056
  var { stdout: stdout2 } = supportsColor;
@@ -7082,16 +7069,16 @@ function createSpwan({ args, processPath, name }, options) {
7082
7069
  return createChildProcess({ childProcess: child, name }, options);
7083
7070
  }
7084
7071
  function createChildProcess({ childProcess, name }, options) {
7085
- const debug13 = Debug9(`mobbdev:${name}`);
7072
+ const debug15 = Debug11(`mobbdev:${name}`);
7086
7073
  const { display } = options;
7087
7074
  return new Promise((resolve, reject) => {
7088
7075
  let out = "";
7089
7076
  const onData = (chunk) => {
7090
- debug13(`chunk received from ${name} std ${chunk}`);
7077
+ debug15(`chunk received from ${name} std ${chunk}`);
7091
7078
  out += chunk;
7092
7079
  };
7093
7080
  if (!childProcess || !childProcess?.stdout || !childProcess?.stderr) {
7094
- debug13(`unable to fork ${name}`);
7081
+ debug15(`unable to fork ${name}`);
7095
7082
  reject(new Error(`unable to fork ${name}`));
7096
7083
  }
7097
7084
  childProcess.stdout?.on("data", onData);
@@ -7101,11 +7088,11 @@ function createChildProcess({ childProcess, name }, options) {
7101
7088
  childProcess.stderr?.pipe(process2.stderr);
7102
7089
  }
7103
7090
  childProcess.on("exit", (code) => {
7104
- debug13(`${name} exit code ${code}`);
7091
+ debug15(`${name} exit code ${code}`);
7105
7092
  resolve({ message: out, code });
7106
7093
  });
7107
7094
  childProcess.on("error", (err) => {
7108
- debug13(`${name} error %o`, err);
7095
+ debug15(`${name} error %o`, err);
7109
7096
  reject(err);
7110
7097
  });
7111
7098
  });
@@ -7113,12 +7100,12 @@ function createChildProcess({ childProcess, name }, options) {
7113
7100
 
7114
7101
  // src/features/analysis/scanners/checkmarx.ts
7115
7102
  import chalk2 from "chalk";
7116
- import Debug10 from "debug";
7103
+ import Debug12 from "debug";
7117
7104
  import { existsSync } from "fs";
7118
7105
  import { createSpinner as createSpinner2 } from "nanospinner";
7119
7106
  import { type } from "os";
7120
7107
  import path5 from "path";
7121
- var debug9 = Debug10("mobbdev:checkmarx");
7108
+ var debug11 = Debug12("mobbdev:checkmarx");
7122
7109
  var require2 = createRequire(import.meta.url);
7123
7110
  var getCheckmarxPath = () => {
7124
7111
  const os2 = type();
@@ -7159,14 +7146,14 @@ function validateCheckmarxInstallation() {
7159
7146
  existsSync(getCheckmarxPath());
7160
7147
  }
7161
7148
  async function forkCheckmarx(args, { display }) {
7162
- debug9("fork checkmarx with args %o %s", args.join(" "), display);
7149
+ debug11("fork checkmarx with args %o %s", args.join(" "), display);
7163
7150
  return createSpwan(
7164
7151
  { args, processPath: getCheckmarxPath(), name: "checkmarx" },
7165
7152
  { display }
7166
7153
  );
7167
7154
  }
7168
7155
  async function getCheckmarxReport({ reportPath, repositoryRoot, branch, projectName }, { skipPrompts = false }) {
7169
- debug9("get checkmarx report start %s %s", reportPath, repositoryRoot);
7156
+ debug11("get checkmarx report start %s %s", reportPath, repositoryRoot);
7170
7157
  const { code: loginCode } = await forkCheckmarx(VALIDATE_COMMAND, {
7171
7158
  display: false
7172
7159
  });
@@ -7234,20 +7221,20 @@ async function validateCheckamxCredentials() {
7234
7221
  // src/features/analysis/scanners/snyk.ts
7235
7222
  import { createRequire as createRequire2 } from "node:module";
7236
7223
  import chalk3 from "chalk";
7237
- import Debug11 from "debug";
7224
+ import Debug13 from "debug";
7238
7225
  import { createSpinner as createSpinner3 } from "nanospinner";
7239
7226
  import open from "open";
7240
- var debug10 = Debug11("mobbdev:snyk");
7227
+ var debug12 = Debug13("mobbdev:snyk");
7241
7228
  var require3 = createRequire2(import.meta.url);
7242
7229
  var SNYK_PATH = require3.resolve("snyk/bin/snyk");
7243
7230
  var SNYK_ARTICLE_URL = "https://docs.snyk.io/scan-using-snyk/snyk-code/configure-snyk-code#enable-snyk-code";
7244
- debug10("snyk executable path %s", SNYK_PATH);
7231
+ debug12("snyk executable path %s", SNYK_PATH);
7245
7232
  async function forkSnyk(args, { display }) {
7246
- debug10("fork snyk with args %o %s", args, display);
7233
+ debug12("fork snyk with args %o %s", args, display);
7247
7234
  return createFork({ args, processPath: SNYK_PATH, name: "snyk" }, { display });
7248
7235
  }
7249
7236
  async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7250
- debug10("get snyk report start %s %s", reportPath, repoRoot);
7237
+ debug12("get snyk report start %s %s", reportPath, repoRoot);
7251
7238
  const config4 = await forkSnyk(["config"], { display: false });
7252
7239
  const { message: configMessage } = config4;
7253
7240
  if (!configMessage.includes("api: ")) {
@@ -7261,7 +7248,7 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7261
7248
  snykLoginSpinner.update({
7262
7249
  text: "\u{1F513} Waiting for Snyk login to complete"
7263
7250
  });
7264
- debug10("no token in the config %s", config4);
7251
+ debug12("no token in the config %s", config4);
7265
7252
  await forkSnyk(["auth"], { display: true });
7266
7253
  snykLoginSpinner.success({ text: "\u{1F513} Login to Snyk Successful" });
7267
7254
  }
@@ -7271,12 +7258,12 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7271
7258
  { display: true }
7272
7259
  );
7273
7260
  if (scanOutput.includes("Snyk Code is not supported for org")) {
7274
- debug10("snyk code is not enabled %s", scanOutput);
7261
+ debug12("snyk code is not enabled %s", scanOutput);
7275
7262
  snykSpinner.error({ text: "\u{1F50D} Snyk configuration needed" });
7276
7263
  const answer = await snykArticlePrompt();
7277
- debug10("answer %s", answer);
7264
+ debug12("answer %s", answer);
7278
7265
  if (answer) {
7279
- debug10("opening the browser");
7266
+ debug12("opening the browser");
7280
7267
  await open(SNYK_ARTICLE_URL);
7281
7268
  }
7282
7269
  console.log(
@@ -7291,18 +7278,18 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7291
7278
  }
7292
7279
 
7293
7280
  // src/features/analysis/upload-file.ts
7294
- import Debug12 from "debug";
7281
+ import Debug14 from "debug";
7295
7282
  import fetch3, { File, fileFrom, FormData } from "node-fetch";
7296
- var debug11 = Debug12("mobbdev:upload-file");
7283
+ var debug13 = Debug14("mobbdev:upload-file");
7297
7284
  async function uploadFile({
7298
7285
  file,
7299
7286
  url,
7300
7287
  uploadKey,
7301
7288
  uploadFields
7302
7289
  }) {
7303
- debug11("upload file start %s", url);
7304
- debug11("upload fields %o", uploadFields);
7305
- debug11("upload key %s", uploadKey);
7290
+ debug13("upload file start %s", url);
7291
+ debug13("upload fields %o", uploadFields);
7292
+ debug13("upload key %s", uploadKey);
7306
7293
  const form = new FormData();
7307
7294
  Object.entries(uploadFields).forEach(([key, value]) => {
7308
7295
  form.append(key, value);
@@ -7311,10 +7298,10 @@ async function uploadFile({
7311
7298
  form.append("key", uploadKey);
7312
7299
  }
7313
7300
  if (typeof file === "string") {
7314
- debug11("upload file from path %s", file);
7301
+ debug13("upload file from path %s", file);
7315
7302
  form.append("file", await fileFrom(file));
7316
7303
  } else {
7317
- debug11("upload file from buffer");
7304
+ debug13("upload file from buffer");
7318
7305
  form.append("file", new File([file], "file"));
7319
7306
  }
7320
7307
  const response = await fetch3(url, {
@@ -7322,10 +7309,10 @@ async function uploadFile({
7322
7309
  body: form
7323
7310
  });
7324
7311
  if (!response.ok) {
7325
- debug11("error from S3 %s %s", response.body, response.status);
7312
+ debug13("error from S3 %s %s", response.body, response.status);
7326
7313
  throw new Error(`Failed to upload the file: ${response.status}`);
7327
7314
  }
7328
- debug11("upload file done");
7315
+ debug13("upload file done");
7329
7316
  }
7330
7317
 
7331
7318
  // src/features/analysis/index.ts
@@ -7345,9 +7332,9 @@ async function downloadRepo({
7345
7332
  }) {
7346
7333
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
7347
7334
  const repoSpinner = createSpinner4("\u{1F4BE} Downloading Repo").start();
7348
- debug12("download repo %s %s %s", repoUrl, dirname);
7335
+ debug14("download repo %s %s %s", repoUrl, dirname);
7349
7336
  const zipFilePath = path6.join(dirname, "repo.zip");
7350
- debug12("download URL: %s auth headers: %o", downloadUrl, authHeaders);
7337
+ debug14("download URL: %s auth headers: %o", downloadUrl, authHeaders);
7351
7338
  const response = await fetch4(downloadUrl, {
7352
7339
  method: "GET",
7353
7340
  headers: {
@@ -7355,7 +7342,7 @@ async function downloadRepo({
7355
7342
  }
7356
7343
  });
7357
7344
  if (!response.ok) {
7358
- debug12("SCM zipball request failed %s %s", response.body, response.status);
7345
+ debug14("SCM zipball request failed %s %s", response.body, response.status);
7359
7346
  repoSpinner.error({ text: "\u{1F4BE} Repo download failed" });
7360
7347
  throw new Error(`Can't access ${chalk4.bold(repoUrl)}`);
7361
7348
  }
@@ -7369,7 +7356,7 @@ async function downloadRepo({
7369
7356
  if (!repoRoot) {
7370
7357
  throw new Error("Repo root not found");
7371
7358
  }
7372
- debug12("repo root %s", repoRoot);
7359
+ debug14("repo root %s", repoRoot);
7373
7360
  repoSpinner.success({ text: "\u{1F4BE} Repo downloaded successfully" });
7374
7361
  return path6.join(dirname, repoRoot);
7375
7362
  }
@@ -7383,7 +7370,7 @@ var getReportUrl = ({
7383
7370
  projectId,
7384
7371
  fixReportId
7385
7372
  }) => `${WEB_APP_URL}/organization/${organizationId}/project/${projectId}/report/${fixReportId}`;
7386
- var debug12 = Debug13("mobbdev:index");
7373
+ var debug14 = Debug15("mobbdev:index");
7387
7374
  var packageJson = JSON.parse(
7388
7375
  fs3.readFileSync(path6.join(getDirName(), "../package.json"), "utf8")
7389
7376
  );
@@ -7393,7 +7380,7 @@ if (!semver.satisfies(process.version, packageJson.engines.node)) {
7393
7380
  );
7394
7381
  }
7395
7382
  var config2 = new Configstore(packageJson.name, { apiToken: "" });
7396
- debug12("config %o", config2);
7383
+ debug14("config %o", config2);
7397
7384
  async function runAnalysis(params, options) {
7398
7385
  const tmpObj = tmp2.dirSync({
7399
7386
  unsafeCleanup: true
@@ -7535,7 +7522,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7535
7522
  organizationId: userOrganizationId,
7536
7523
  autoPr
7537
7524
  } = params;
7538
- debug12("start %s %s", dirname, repo);
7525
+ debug14("start %s %s", dirname, repo);
7539
7526
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
7540
7527
  skipPrompts = skipPrompts || ci;
7541
7528
  let gqlClient = new GQLClient({
@@ -7602,8 +7589,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
7602
7589
  );
7603
7590
  }
7604
7591
  const { sha } = getReferenceDataRes.gitReference;
7605
- debug12("project id %s", projectId);
7606
- debug12("default branch %s", reference);
7592
+ debug14("project id %s", projectId);
7593
+ debug14("default branch %s", reference);
7607
7594
  if (command === "scan") {
7608
7595
  reportPath = await getReport(
7609
7596
  {
@@ -7641,7 +7628,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7641
7628
  spinner: mobbSpinner,
7642
7629
  submitVulnerabilityReportVariables: {
7643
7630
  fixReportId: reportUploadInfo.fixReportId,
7644
- repoUrl: z19.string().parse(repo),
7631
+ repoUrl: z20.string().parse(repo),
7645
7632
  reference,
7646
7633
  projectId,
7647
7634
  vulnerabilityReportFileName: "report.json",
@@ -7722,9 +7709,9 @@ async function _scan(params, { skipPrompts = false } = {}) {
7722
7709
  });
7723
7710
  loginSpinner.spin();
7724
7711
  if (encryptedApiToken) {
7725
- debug12("encrypted API token received %s", encryptedApiToken);
7712
+ debug14("encrypted API token received %s", encryptedApiToken);
7726
7713
  newApiToken = crypto.privateDecrypt(privateKey, Buffer.from(encryptedApiToken, "base64")).toString("utf-8");
7727
- debug12("API token decrypted");
7714
+ debug14("API token decrypted");
7728
7715
  break;
7729
7716
  }
7730
7717
  await sleep(LOGIN_CHECK_DELAY);
@@ -7737,7 +7724,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7737
7724
  }
7738
7725
  gqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
7739
7726
  if (await gqlClient.verifyToken()) {
7740
- debug12("set api token %s", newApiToken);
7727
+ debug14("set api token %s", newApiToken);
7741
7728
  config2.set("apiToken", newApiToken);
7742
7729
  loginSpinner.success({ text: "\u{1F513} Login to Mobb successful!" });
7743
7730
  } else {
@@ -7880,9 +7867,9 @@ async function _scan(params, { skipPrompts = false } = {}) {
7880
7867
  }
7881
7868
  });
7882
7869
  if (command === "review") {
7883
- const params2 = z19.object({
7884
- repo: z19.string().url(),
7885
- githubActionToken: z19.string()
7870
+ const params2 = z20.object({
7871
+ repo: z20.string().url(),
7872
+ githubActionToken: z20.string()
7886
7873
  }).parse({ repo, githubActionToken });
7887
7874
  const scm = await SCMLib.init(
7888
7875
  {
@@ -7904,7 +7891,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7904
7891
  analysisId,
7905
7892
  gqlClient,
7906
7893
  scm,
7907
- scanner: z19.nativeEnum(SCANNERS).parse(scanner)
7894
+ scanner: z20.nativeEnum(SCANNERS).parse(scanner)
7908
7895
  });
7909
7896
  },
7910
7897
  callbackStates: ["Finished" /* Finished */]
@@ -8131,7 +8118,7 @@ var scmTokenOption = {
8131
8118
  // src/args/validation.ts
8132
8119
  import chalk6 from "chalk";
8133
8120
  import path8 from "path";
8134
- import { z as z20 } from "zod";
8121
+ import { z as z21 } from "zod";
8135
8122
  function throwRepoUrlErrorMessage({
8136
8123
  error,
8137
8124
  repoUrl,
@@ -8148,13 +8135,13 @@ Example:
8148
8135
  )}`;
8149
8136
  throw new CliError(formattedErrorMessage);
8150
8137
  }
8151
- var UrlZ = z20.string({
8138
+ var UrlZ = z21.string({
8152
8139
  invalid_type_error: `is not a valid ${Object.values(ScmType).join("/ ")} URL`
8153
8140
  }).refine((data) => !!sanityRepoURL(data), {
8154
8141
  message: `is not a valid ${Object.values(ScmType).join(" / ")} URL`
8155
8142
  });
8156
8143
  function validateOrganizationId(organizationId) {
8157
- const orgIdValidation = z20.string().uuid().nullish().safeParse(organizationId);
8144
+ const orgIdValidation = z21.string().uuid().nullish().safeParse(organizationId);
8158
8145
  if (!orgIdValidation.success) {
8159
8146
  throw new CliError(`organizationId: ${organizationId} is not a valid UUID`);
8160
8147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.165",
3
+ "version": "0.0.167",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "@octokit/plugin-rest-endpoint-methods": "7.2.3",
34
34
  "@octokit/request-error": "3.0.3",
35
35
  "@types/libsodium-wrappers": "0.7.13",
36
- "adm-zip": "0.5.15",
36
+ "adm-zip": "0.5.16",
37
37
  "axios": "1.7.7",
38
38
  "azure-devops-node-api": "12.1.0",
39
39
  "bitbucket": "2.11.0",
@@ -58,8 +58,8 @@
58
58
  "open": "8.4.2",
59
59
  "parse-diff": "0.11.1",
60
60
  "semver": "7.6.3",
61
- "simple-git": "3.26.0",
62
- "snyk": "1.1293.0",
61
+ "simple-git": "3.27.0",
62
+ "snyk": "1.1293.1",
63
63
  "supports-color": "9.4.0",
64
64
  "tar": "6.2.1",
65
65
  "tmp": "0.2.3",
@@ -71,11 +71,11 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@graphql-codegen/cli": "5.0.2",
74
- "@graphql-codegen/typescript": "3.0.4",
74
+ "@graphql-codegen/typescript": "4.0.9",
75
75
  "@graphql-codegen/typescript-graphql-request": "6.2.0",
76
- "@graphql-codegen/typescript-operations": "3.0.4",
76
+ "@graphql-codegen/typescript-operations": "4.2.3",
77
77
  "@octokit/request-error": "3.0.3",
78
- "@octokit/types": "13.5.0",
78
+ "@octokit/types": "13.6.0",
79
79
  "@types/adm-zip": "0.5.5",
80
80
  "@types/chalk-animation": "1.6.3",
81
81
  "@types/configstore": "6.0.2",