mobbdev 0.0.166 → 0.0.168

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 +301 -278
  2. package/package.json +1 -1
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);
@@ -4057,17 +4042,24 @@ function getGithubSdk(parmas = {}) {
4057
4042
 
4058
4043
  // src/features/analysis/scm/gitlab/gitlab.ts
4059
4044
  import querystring2 from "node:querystring";
4045
+ import { setTimeout as setTimeout2 } from "node:timers/promises";
4046
+ import {
4047
+ createRequesterFn
4048
+ } from "@gitbeaker/requester-utils";
4060
4049
  import {
4061
4050
  Gitlab
4062
4051
  } from "@gitbeaker/rest";
4063
- import { ProxyAgent as ProxyAgent2 } from "undici";
4052
+ import {
4053
+ fetch as undiciFetch,
4054
+ ProxyAgent as ProxyAgent2
4055
+ } from "undici";
4064
4056
 
4065
4057
  // 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()
4058
+ import { z as z12 } from "zod";
4059
+ var GitlabAuthResultZ = z12.object({
4060
+ access_token: z12.string(),
4061
+ token_type: z12.string(),
4062
+ refresh_token: z12.string()
4071
4063
  });
4072
4064
 
4073
4065
  // src/features/analysis/scm/gitlab/gitlab.ts
@@ -4075,13 +4067,28 @@ function removeTrailingSlash(str) {
4075
4067
  return str.trim().replace(/\/+$/, "");
4076
4068
  }
4077
4069
  function getGitBeaker(options) {
4070
+ console.log("getGitBeaker starting");
4078
4071
  const token = options?.gitlabAuthToken ?? GITLAB_API_TOKEN ?? "";
4079
4072
  const url = options.url;
4080
4073
  const host = url ? new URL(url).origin : "https://gitlab.com";
4081
4074
  if (token?.startsWith("glpat-") || token === "") {
4082
- return new Gitlab({ token, host });
4075
+ return new Gitlab({
4076
+ token,
4077
+ host,
4078
+ requesterFn: createRequesterFn(
4079
+ (_, reqo) => Promise.resolve(reqo),
4080
+ brokerRequestHandler
4081
+ )
4082
+ });
4083
4083
  }
4084
- return new Gitlab({ oauthToken: token, host });
4084
+ return new Gitlab({
4085
+ oauthToken: token,
4086
+ host,
4087
+ requesterFn: createRequesterFn(
4088
+ (_, reqo) => Promise.resolve(reqo),
4089
+ brokerRequestHandler
4090
+ )
4091
+ });
4085
4092
  }
4086
4093
  async function gitlabValidateParams({
4087
4094
  url,
@@ -4331,31 +4338,56 @@ async function getGitlabBlameRanges({ ref, gitlabUrl, path: path9 }, options) {
4331
4338
  };
4332
4339
  });
4333
4340
  }
4334
- function initGitlabFetchMock() {
4335
- const globalFetch = global.fetch;
4336
- function myFetch(input, init) {
4337
- let urlParsed = null;
4338
- try {
4339
- urlParsed = input?.url ? new URL(input?.url) : null;
4340
- } catch (err) {
4341
- console.log(
4342
- `this block is used for unit tests only. URL ${input?.url} starts from local directory`
4343
- );
4344
- }
4345
- if (urlParsed && isBrokerUrl(urlParsed.href)) {
4346
- const dispatcher = new ProxyAgent2({
4347
- uri: GIT_PROXY_HOST,
4348
- requestTls: {
4349
- rejectUnauthorized: false
4350
- }
4351
- });
4352
- return globalFetch(input, { dispatcher });
4353
- }
4354
- return globalFetch(input, init);
4341
+ async function processBody(response) {
4342
+ const headers = response.headers;
4343
+ const type2 = headers.get("content-type")?.split(";")[0]?.trim();
4344
+ if (type2 === "application/json") {
4345
+ return await response.json();
4346
+ }
4347
+ return await response.text();
4348
+ }
4349
+ async function brokerRequestHandler(endpoint, options) {
4350
+ const retryCodes = [429, 502];
4351
+ const maxRetries = 10;
4352
+ const { prefixUrl, searchParams } = options || {};
4353
+ let baseUrl;
4354
+ if (prefixUrl)
4355
+ baseUrl = prefixUrl.endsWith("/") ? prefixUrl : `${prefixUrl}/`;
4356
+ const url = new URL(endpoint, baseUrl);
4357
+ url.search = searchParams || "";
4358
+ const dispatcher = url && isBrokerUrl(url.href) ? new ProxyAgent2({
4359
+ uri: GIT_PROXY_HOST,
4360
+ requestTls: {
4361
+ rejectUnauthorized: false
4362
+ }
4363
+ }) : void 0;
4364
+ for (let i = 0; i < maxRetries; i += 1) {
4365
+ const response = await undiciFetch(url, {
4366
+ headers: options?.headers,
4367
+ method: options?.method,
4368
+ body: options?.body ? String(options?.body) : void 0,
4369
+ dispatcher
4370
+ }).catch((e) => {
4371
+ if (e.name === "TimeoutError" || e.name === "AbortError") {
4372
+ throw new Error("Query timeout was reached");
4373
+ }
4374
+ throw e;
4375
+ });
4376
+ if (response.ok)
4377
+ return {
4378
+ body: await processBody(response),
4379
+ headers: Object.fromEntries(response.headers.entries()),
4380
+ status: response.status
4381
+ };
4382
+ if (!retryCodes.includes(response.status))
4383
+ throw new Error(`gitbeaker: ${response.statusText}`);
4384
+ await setTimeout2(2 ** i * 0.25);
4385
+ continue;
4355
4386
  }
4356
- global.fetch = myFetch;
4387
+ throw new Error(
4388
+ `Could not successfully complete this request due to Error 429. Check the applicable rate limits for this endpoint.`
4389
+ );
4357
4390
  }
4358
- initGitlabFetchMock();
4359
4391
 
4360
4392
  // src/features/analysis/scm/scmSubmit/index.ts
4361
4393
  import fs from "node:fs/promises";
@@ -4363,80 +4395,80 @@ import parseDiff from "parse-diff";
4363
4395
  import path3 from "path";
4364
4396
  import { simpleGit } from "simple-git";
4365
4397
  import tmp from "tmp";
4366
- import { z as z13 } from "zod";
4398
+ import { z as z14 } from "zod";
4367
4399
 
4368
4400
  // 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())
4401
+ import { z as z13 } from "zod";
4402
+ var BaseSubmitToScmMessageZ = z13.object({
4403
+ submitFixRequestId: z13.string().uuid(),
4404
+ fixes: z13.array(
4405
+ z13.object({
4406
+ fixId: z13.string().uuid(),
4407
+ patches: z13.array(z13.string())
4376
4408
  })
4377
4409
  ),
4378
- commitHash: z12.string(),
4379
- repoUrl: z12.string(),
4380
- mobbUserEmail: z12.string(),
4381
- extraHeaders: z12.record(z12.string(), z12.string()).default({})
4410
+ commitHash: z13.string(),
4411
+ repoUrl: z13.string(),
4412
+ mobbUserEmail: z13.string(),
4413
+ extraHeaders: z13.record(z13.string(), z13.string()).default({})
4382
4414
  });
4383
4415
  var submitToScmMessageType = {
4384
4416
  commitToSameBranch: "commitToSameBranch",
4385
4417
  submitFixesForDifferentBranch: "submitFixesForDifferentBranch"
4386
4418
  };
4387
4419
  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()
4420
+ z13.object({
4421
+ type: z13.literal(submitToScmMessageType.commitToSameBranch),
4422
+ branch: z13.string(),
4423
+ commitMessage: z13.string(),
4424
+ commitDescription: z13.string().nullish(),
4425
+ githubCommentId: z13.number().nullish()
4394
4426
  })
4395
4427
  );
4396
- var SubmitFixesToDifferentBranchParamsZ = z12.object({
4397
- type: z12.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4398
- submitBranch: z12.string(),
4399
- baseBranch: z12.string()
4428
+ var SubmitFixesToDifferentBranchParamsZ = z13.object({
4429
+ type: z13.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4430
+ submitBranch: z13.string(),
4431
+ baseBranch: z13.string()
4400
4432
  }).merge(BaseSubmitToScmMessageZ);
4401
- var SubmitFixesMessageZ = z12.union([
4433
+ var SubmitFixesMessageZ = z13.union([
4402
4434
  CommitToSameBranchParamsZ,
4403
4435
  SubmitFixesToDifferentBranchParamsZ
4404
4436
  ]);
4405
- var FixResponseArrayZ = z12.array(
4406
- z12.object({
4407
- fixId: z12.string().uuid()
4437
+ var FixResponseArrayZ = z13.array(
4438
+ z13.object({
4439
+ fixId: z13.string().uuid()
4408
4440
  })
4409
4441
  );
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(),
4442
+ var SubmitFixesBaseResponseMessageZ = z13.object({
4443
+ mobbUserEmail: z13.string(),
4444
+ submitFixRequestId: z13.string().uuid(),
4445
+ submitBranches: z13.array(
4446
+ z13.object({
4447
+ branchName: z13.string(),
4416
4448
  fixes: FixResponseArrayZ
4417
4449
  })
4418
4450
  ),
4419
- error: z12.object({
4420
- type: z12.enum([
4451
+ error: z13.object({
4452
+ type: z13.enum([
4421
4453
  "InitialRepoAccessError",
4422
4454
  "PushBranchError",
4423
4455
  "UnknownError"
4424
4456
  ]),
4425
- info: z12.object({
4426
- message: z12.string(),
4427
- pushBranchName: z12.string().optional()
4457
+ info: z13.object({
4458
+ message: z13.string(),
4459
+ pushBranchName: z13.string().optional()
4428
4460
  })
4429
4461
  }).optional()
4430
4462
  });
4431
- var SubmitFixesToSameBranchResponseMessageZ = z12.object({
4432
- type: z12.literal(submitToScmMessageType.commitToSameBranch),
4433
- githubCommentId: z12.number().nullish()
4463
+ var SubmitFixesToSameBranchResponseMessageZ = z13.object({
4464
+ type: z13.literal(submitToScmMessageType.commitToSameBranch),
4465
+ githubCommentId: z13.number().nullish()
4434
4466
  }).merge(SubmitFixesBaseResponseMessageZ);
4435
- var SubmitFixesToDifferentBranchResponseMessageZ = z12.object({
4436
- type: z12.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4437
- githubCommentId: z12.number().optional()
4467
+ var SubmitFixesToDifferentBranchResponseMessageZ = z13.object({
4468
+ type: z13.literal(submitToScmMessageType.submitFixesForDifferentBranch),
4469
+ githubCommentId: z13.number().optional()
4438
4470
  }).merge(SubmitFixesBaseResponseMessageZ);
4439
- var SubmitFixesResponseMessageZ = z12.discriminatedUnion("type", [
4471
+ var SubmitFixesResponseMessageZ = z13.discriminatedUnion("type", [
4440
4472
  SubmitFixesToSameBranchResponseMessageZ,
4441
4473
  SubmitFixesToDifferentBranchResponseMessageZ
4442
4474
  ]);
@@ -4454,21 +4486,21 @@ var isValidBranchName = async (branchName) => {
4454
4486
  return false;
4455
4487
  }
4456
4488
  };
4457
- var FixesZ = z13.array(
4458
- z13.object({
4459
- fixId: z13.string(),
4460
- patches: z13.array(z13.string())
4489
+ var FixesZ = z14.array(
4490
+ z14.object({
4491
+ fixId: z14.string(),
4492
+ patches: z14.array(z14.string())
4461
4493
  })
4462
4494
  ).nonempty();
4463
4495
 
4464
4496
  // src/features/analysis/scm/scm.ts
4465
4497
  function isBrokerUrl(url) {
4466
- return z14.string().uuid().safeParse(new URL(url).host).success;
4498
+ return z15.string().uuid().safeParse(new URL(url).host).success;
4467
4499
  }
4468
- var GetRefererenceResultZ = z14.object({
4469
- date: z14.date().optional(),
4470
- sha: z14.string(),
4471
- type: z14.nativeEnum(ReferenceType)
4500
+ var GetRefererenceResultZ = z15.object({
4501
+ date: z15.date().optional(),
4502
+ sha: z15.string(),
4503
+ type: z15.nativeEnum(ReferenceType)
4472
4504
  });
4473
4505
  function getCloudScmLibTypeFromUrl(url) {
4474
4506
  if (!url) {
@@ -4509,7 +4541,7 @@ var scmTypeToScmLibScmType = {
4509
4541
  ["Bitbucket" /* Bitbucket */]: "BITBUCKET" /* BITBUCKET */
4510
4542
  };
4511
4543
  function getScmLibTypeFromScmType(scmType) {
4512
- const parsedScmType = z14.nativeEnum(ScmType).parse(scmType);
4544
+ const parsedScmType = z15.nativeEnum(ScmType).parse(scmType);
4513
4545
  return scmTypeToScmLibScmType[parsedScmType];
4514
4546
  }
4515
4547
  function getScmConfig({
@@ -4723,7 +4755,7 @@ var SCMLib = class {
4723
4755
  if (e instanceof InvalidRepoUrlError && url) {
4724
4756
  throw new RepoNoTokenAccessError(
4725
4757
  "no access to repo",
4726
- scmLibScmTypeToScmType[z14.nativeEnum(ScmLibScmType).parse(scmType)]
4758
+ scmLibScmTypeToScmType[z15.nativeEnum(ScmLibScmType).parse(scmType)]
4727
4759
  );
4728
4760
  }
4729
4761
  console.error(`error validating scm: ${scmType} `, e);
@@ -5134,7 +5166,7 @@ var GithubSCMLib = class extends SCMLib {
5134
5166
  owner,
5135
5167
  repo
5136
5168
  });
5137
- return z14.string().parse(prRes.data);
5169
+ return z15.string().parse(prRes.data);
5138
5170
  }
5139
5171
  async getRepoList(_scmOrg) {
5140
5172
  this._validateAccessToken();
@@ -5325,7 +5357,7 @@ var StubSCMLib = class extends SCMLib {
5325
5357
  };
5326
5358
  function getUserAndPassword(token) {
5327
5359
  const [username, password] = token.split(":");
5328
- const safePasswordAndUsername = z14.object({ username: z14.string(), password: z14.string() }).parse({ username, password });
5360
+ const safePasswordAndUsername = z15.object({ username: z15.string(), password: z15.string() }).parse({ username, password });
5329
5361
  return {
5330
5362
  username: safePasswordAndUsername.username,
5331
5363
  password: safePasswordAndUsername.password
@@ -5361,7 +5393,7 @@ var BitbucketSCMLib = class extends SCMLib {
5361
5393
  return { username, password, authType };
5362
5394
  }
5363
5395
  case "token": {
5364
- return { authType, token: z14.string().parse(this.accessToken) };
5396
+ return { authType, token: z15.string().parse(this.accessToken) };
5365
5397
  }
5366
5398
  case "public":
5367
5399
  return { authType };
@@ -5373,7 +5405,7 @@ var BitbucketSCMLib = class extends SCMLib {
5373
5405
  ...params,
5374
5406
  repoUrl: this.url
5375
5407
  });
5376
- return String(z14.number().parse(pullRequestRes.id));
5408
+ return String(z15.number().parse(pullRequestRes.id));
5377
5409
  }
5378
5410
  async validateParams() {
5379
5411
  return validateBitbucketParams({
@@ -5445,7 +5477,7 @@ var BitbucketSCMLib = class extends SCMLib {
5445
5477
  async getUsername() {
5446
5478
  this._validateAccessToken();
5447
5479
  const res = await this.bitbucketSdk.getUser();
5448
- return z14.string().parse(res.username);
5480
+ return z15.string().parse(res.username);
5449
5481
  }
5450
5482
  async getSubmitRequestStatus(_scmSubmitRequestId) {
5451
5483
  this._validateAccessTokenAndUrl();
@@ -5474,7 +5506,7 @@ var BitbucketSCMLib = class extends SCMLib {
5474
5506
  async getRepoDefaultBranch() {
5475
5507
  this._validateUrl();
5476
5508
  const repoRes = await this.bitbucketSdk.getRepo({ repoUrl: this.url });
5477
- return z14.string().parse(repoRes.mainbranch?.name);
5509
+ return z15.string().parse(repoRes.mainbranch?.name);
5478
5510
  }
5479
5511
  getPrUrl(prNumber) {
5480
5512
  this._validateUrl();
@@ -5483,51 +5515,42 @@ var BitbucketSCMLib = class extends SCMLib {
5483
5515
  `https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/${prNumber}`
5484
5516
  );
5485
5517
  }
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
5518
  };
5497
5519
 
5498
5520
  // 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 */)
5521
+ import { z as z16 } from "zod";
5522
+ var ValidPullRequestStatusZ = z16.union([
5523
+ z16.literal(1 /* Active */),
5524
+ z16.literal(2 /* Abandoned */),
5525
+ z16.literal(3 /* Completed */)
5504
5526
  ]);
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)
5527
+ var AdoAuthResultZ = z16.object({
5528
+ access_token: z16.string().min(1),
5529
+ token_type: z16.string().min(1),
5530
+ refresh_token: z16.string().min(1)
5509
5531
  });
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()
5532
+ var profileZ = z16.object({
5533
+ displayName: z16.string(),
5534
+ publicAlias: z16.string().min(1),
5535
+ emailAddress: z16.string(),
5536
+ coreRevision: z16.number(),
5537
+ timeStamp: z16.string(),
5538
+ id: z16.string(),
5539
+ revision: z16.number()
5518
5540
  });
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()
5541
+ var accountsZ = z16.object({
5542
+ count: z16.number(),
5543
+ value: z16.array(
5544
+ z16.object({
5545
+ accountId: z16.string(),
5546
+ accountUri: z16.string(),
5547
+ accountName: z16.string()
5526
5548
  })
5527
5549
  )
5528
5550
  });
5529
5551
 
5530
5552
  // src/features/analysis/scm/ado/utils.ts
5553
+ var debug3 = Debug3("mobbdev:scm:ado");
5531
5554
  function _getPublicAdoClient({
5532
5555
  orgName,
5533
5556
  origin: origin2
@@ -5595,7 +5618,7 @@ async function getAdoConnectData({
5595
5618
  oauthToken: adoTokenInfo.accessToken
5596
5619
  });
5597
5620
  return {
5598
- org: z16.string().parse(org),
5621
+ org: z17.string().parse(org),
5599
5622
  origin: DEFUALT_ADO_ORIGIN
5600
5623
  };
5601
5624
  }
@@ -5681,7 +5704,7 @@ async function getAdoClientParams(params) {
5681
5704
  return {
5682
5705
  tokenType: "PAT" /* PAT */,
5683
5706
  accessToken: adoTokenInfo.accessToken,
5684
- patTokenOrg: z16.string().parse(tokenOrg).toLowerCase(),
5707
+ patTokenOrg: z17.string().parse(tokenOrg).toLowerCase(),
5685
5708
  origin: origin2,
5686
5709
  orgName: org.toLowerCase()
5687
5710
  };
@@ -6036,9 +6059,9 @@ async function getAdoRepoList({
6036
6059
  var MOBB_ICON_IMG = "https://app.mobb.ai/gh-action/Logo_Rounded_Icon.svg";
6037
6060
 
6038
6061
  // src/features/analysis/add_fix_comments_for_pr/utils.ts
6039
- import Debug3 from "debug";
6062
+ import Debug5 from "debug";
6040
6063
  import parseDiff2 from "parse-diff";
6041
- import { z as z17 } from "zod";
6064
+ import { z as z18 } from "zod";
6042
6065
 
6043
6066
  // src/features/analysis/utils/by_key.ts
6044
6067
  function keyBy(array, keyBy2) {
@@ -6048,8 +6071,8 @@ function keyBy(array, keyBy2) {
6048
6071
  }
6049
6072
 
6050
6073
  // src/features/analysis/utils/send_report.ts
6051
- import Debug2 from "debug";
6052
- var debug2 = Debug2("mobbdev:index");
6074
+ import Debug4 from "debug";
6075
+ var debug4 = Debug4("mobbdev:index");
6053
6076
  async function sendReport({
6054
6077
  spinner,
6055
6078
  submitVulnerabilityReportVariables,
@@ -6060,7 +6083,7 @@ async function sendReport({
6060
6083
  submitVulnerabilityReportVariables
6061
6084
  );
6062
6085
  if (submitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
6063
- debug2("error submit vul report %s", submitRes);
6086
+ debug4("error submit vul report %s", submitRes);
6064
6087
  throw new Error("\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed");
6065
6088
  }
6066
6089
  spinner.update({ text: progressMassages.processingVulnerabilityReport });
@@ -6108,7 +6131,7 @@ var scannerToFriendlyString = {
6108
6131
  };
6109
6132
 
6110
6133
  // src/features/analysis/add_fix_comments_for_pr/utils.ts
6111
- var debug3 = Debug3("mobbdev:handle-finished-analysis");
6134
+ var debug5 = Debug5("mobbdev:handle-finished-analysis");
6112
6135
  var getCommitFixButton = (commitUrl) => `<a href="${commitUrl}"><img src=${COMMIT_FIX_SVG}></a>`;
6113
6136
  function calculateRanges(integers) {
6114
6137
  if (integers.length === 0) {
@@ -6143,7 +6166,7 @@ function deleteAllPreviousComments({
6143
6166
  try {
6144
6167
  return scm.deleteComment({ comment_id: comment.id });
6145
6168
  } catch (e) {
6146
- debug3("delete comment failed %s", e);
6169
+ debug5("delete comment failed %s", e);
6147
6170
  return Promise.resolve();
6148
6171
  }
6149
6172
  });
@@ -6159,7 +6182,7 @@ function deleteAllPreviousGeneralPrComments(params) {
6159
6182
  try {
6160
6183
  return scm.deleteGeneralPrComment({ commentId: comment.id });
6161
6184
  } catch (e) {
6162
- debug3("delete comment failed %s", e);
6185
+ debug5("delete comment failed %s", e);
6163
6186
  return Promise.resolve();
6164
6187
  }
6165
6188
  });
@@ -6283,7 +6306,7 @@ async function getRelevantVulenrabilitiesFromDiff(params) {
6283
6306
  });
6284
6307
  const lineAddedRanges = calculateRanges(fileNumbers);
6285
6308
  const fileFilter = {
6286
- path: z17.string().parse(file.to),
6309
+ path: z18.string().parse(file.to),
6287
6310
  ranges: lineAddedRanges.map(([startLine, endLine]) => ({
6288
6311
  endLine,
6289
6312
  startLine
@@ -6324,7 +6347,7 @@ async function postAnalysisInsightComment(params) {
6324
6347
  fixablePrVuls,
6325
6348
  nonFixablePrVuls
6326
6349
  } = prVulenrabilities;
6327
- debug3({
6350
+ debug5({
6328
6351
  fixablePrVuls,
6329
6352
  nonFixablePrVuls,
6330
6353
  vulnerabilitiesOutsidePr,
@@ -6379,7 +6402,7 @@ ${contactUsMarkdown}`;
6379
6402
  }
6380
6403
 
6381
6404
  // src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
6382
- var debug4 = Debug4("mobbdev:handle-finished-analysis");
6405
+ var debug6 = Debug6("mobbdev:handle-finished-analysis");
6383
6406
  async function addFixCommentsForPr({
6384
6407
  analysisId,
6385
6408
  scm: _scm,
@@ -6391,7 +6414,7 @@ async function addFixCommentsForPr({
6391
6414
  }
6392
6415
  const scm = _scm;
6393
6416
  const getAnalysisRes = await gqlClient.getAnalysis(analysisId);
6394
- debug4("getAnalysis %o", getAnalysisRes);
6417
+ debug6("getAnalysis %o", getAnalysisRes);
6395
6418
  const {
6396
6419
  vulnerabilityReport: {
6397
6420
  projectId,
@@ -6453,8 +6476,8 @@ async function addFixCommentsForPr({
6453
6476
  }
6454
6477
 
6455
6478
  // src/features/analysis/auto_pr_handler.ts
6456
- import Debug5 from "debug";
6457
- var debug5 = Debug5("mobbdev:handleAutoPr");
6479
+ import Debug7 from "debug";
6480
+ var debug7 = Debug7("mobbdev:handleAutoPr");
6458
6481
  async function handleAutoPr(params) {
6459
6482
  const { gqlClient, analysisId, createSpinner: createSpinner4 } = params;
6460
6483
  const createAutoPrSpinner = createSpinner4(
@@ -6466,7 +6489,7 @@ async function handleAutoPr(params) {
6466
6489
  },
6467
6490
  callback: async (analysisId2) => {
6468
6491
  const autoPrAnalysisRes = await gqlClient.autoPrAnalysis(analysisId2);
6469
- debug5("auto pr analysis res %o", autoPrAnalysisRes);
6492
+ debug7("auto pr analysis res %o", autoPrAnalysisRes);
6470
6493
  if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
6471
6494
  createAutoPrSpinner.error({
6472
6495
  text: `\u{1F504} Automatic pull request failed - ${autoPrAnalysisRes.autoPrAnalysis.error}`
@@ -6491,12 +6514,12 @@ async function handleAutoPr(params) {
6491
6514
  }
6492
6515
 
6493
6516
  // src/features/analysis/git.ts
6494
- import Debug6 from "debug";
6517
+ import Debug8 from "debug";
6495
6518
  import { simpleGit as simpleGit2 } from "simple-git";
6496
- var debug6 = Debug6("mobbdev:git");
6519
+ var debug8 = Debug8("mobbdev:git");
6497
6520
  var GIT_NOT_INITIALIZED_ERROR_MESSAGE = "not a git repository";
6498
6521
  async function getGitInfo(srcDirPath) {
6499
- debug6("getting git info for %s", srcDirPath);
6522
+ debug8("getting git info for %s", srcDirPath);
6500
6523
  const git = simpleGit2({
6501
6524
  baseDir: srcDirPath,
6502
6525
  maxConcurrentProcesses: 1,
@@ -6511,11 +6534,11 @@ async function getGitInfo(srcDirPath) {
6511
6534
  reference = await git.revparse(["--abbrev-ref", "HEAD"]) || "";
6512
6535
  } catch (e) {
6513
6536
  if (e instanceof Error) {
6514
- debug6("failed to run git %o", e);
6537
+ debug8("failed to run git %o", e);
6515
6538
  if (e.message.includes(" spawn ")) {
6516
- debug6("git cli not installed");
6539
+ debug8("git cli not installed");
6517
6540
  } else if (e.message.includes(GIT_NOT_INITIALIZED_ERROR_MESSAGE)) {
6518
- debug6("folder is not a git repo");
6541
+ debug8("folder is not a git repo");
6519
6542
  return {
6520
6543
  success: false,
6521
6544
  hash: void 0,
@@ -6543,7 +6566,7 @@ async function getGitInfo(srcDirPath) {
6543
6566
  }
6544
6567
 
6545
6568
  // src/features/analysis/graphql/gql.ts
6546
- import Debug7 from "debug";
6569
+ import Debug9 from "debug";
6547
6570
  import { GraphQLClient } from "graphql-request";
6548
6571
  import { v4 as uuidv4 } from "uuid";
6549
6572
 
@@ -6628,36 +6651,36 @@ function subscribe(query, variables, callback, wsClientOptions) {
6628
6651
  }
6629
6652
 
6630
6653
  // 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()
6654
+ import { z as z19 } from "zod";
6655
+ var VulnerabilityReportIssueCodeNodeZ = z19.object({
6656
+ vulnerabilityReportIssueId: z19.string(),
6657
+ path: z19.string(),
6658
+ startLine: z19.number(),
6659
+ vulnerabilityReportIssue: z19.object({
6660
+ fixId: z19.string()
6638
6661
  })
6639
6662
  });
6640
- var GetVulByNodesMetadataZ = z18.object({
6641
- vulnerabilityReportIssueCodeNodes: z18.array(VulnerabilityReportIssueCodeNodeZ),
6642
- nonFixablePrVuls: z18.object({
6643
- aggregate: z18.object({
6644
- count: z18.number()
6663
+ var GetVulByNodesMetadataZ = z19.object({
6664
+ vulnerabilityReportIssueCodeNodes: z19.array(VulnerabilityReportIssueCodeNodeZ),
6665
+ nonFixablePrVuls: z19.object({
6666
+ aggregate: z19.object({
6667
+ count: z19.number()
6645
6668
  })
6646
6669
  }),
6647
- fixablePrVuls: z18.object({
6648
- aggregate: z18.object({
6649
- count: z18.number()
6670
+ fixablePrVuls: z19.object({
6671
+ aggregate: z19.object({
6672
+ count: z19.number()
6650
6673
  })
6651
6674
  }),
6652
- totalScanVulnerabilities: z18.object({
6653
- aggregate: z18.object({
6654
- count: z18.number()
6675
+ totalScanVulnerabilities: z19.object({
6676
+ aggregate: z19.object({
6677
+ count: z19.number()
6655
6678
  })
6656
6679
  })
6657
6680
  });
6658
6681
 
6659
6682
  // src/features/analysis/graphql/gql.ts
6660
- var debug7 = Debug7("mobbdev:gql");
6683
+ var debug9 = Debug9("mobbdev:gql");
6661
6684
  var API_KEY_HEADER_NAME = "x-mobb-key";
6662
6685
  var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
6663
6686
  var GQLClient = class {
@@ -6665,7 +6688,7 @@ var GQLClient = class {
6665
6688
  __publicField(this, "_client");
6666
6689
  __publicField(this, "_clientSdk");
6667
6690
  __publicField(this, "_auth");
6668
- debug7(`init with ${args}`);
6691
+ debug9(`init with ${args}`);
6669
6692
  this._auth = args;
6670
6693
  this._client = new GraphQLClient(API_URL, {
6671
6694
  headers: args.type === "apiKey" ? { [API_KEY_HEADER_NAME]: args.apiKey || "" } : {
@@ -6673,7 +6696,7 @@ var GQLClient = class {
6673
6696
  },
6674
6697
  requestMiddleware: (request) => {
6675
6698
  const requestId = uuidv4();
6676
- debug7(
6699
+ debug9(
6677
6700
  `sending API request with id: ${requestId} and with request: ${request.body}`
6678
6701
  );
6679
6702
  return {
@@ -6703,7 +6726,7 @@ var GQLClient = class {
6703
6726
  try {
6704
6727
  await this.getUserInfo();
6705
6728
  } catch (e) {
6706
- debug7("verify token failed %o", e);
6729
+ debug9("verify token failed %o", e);
6707
6730
  return false;
6708
6731
  }
6709
6732
  return true;
@@ -6747,7 +6770,7 @@ var GQLClient = class {
6747
6770
  try {
6748
6771
  await this._clientSdk.CreateCommunityUser();
6749
6772
  } catch (e) {
6750
- debug7("create community user failed %o", e);
6773
+ debug9("create community user failed %o", e);
6751
6774
  }
6752
6775
  }
6753
6776
  async updateScmToken(args) {
@@ -6941,10 +6964,10 @@ var GQLClient = class {
6941
6964
  import fs2 from "node:fs";
6942
6965
  import path4 from "node:path";
6943
6966
  import AdmZip from "adm-zip";
6944
- import Debug8 from "debug";
6967
+ import Debug10 from "debug";
6945
6968
  import { globby } from "globby";
6946
6969
  import { isBinary } from "istextorbinary";
6947
- var debug8 = Debug8("mobbdev:pack");
6970
+ var debug10 = Debug10("mobbdev:pack");
6948
6971
  var MAX_FILE_SIZE = 1024 * 1024 * 5;
6949
6972
  function endsWithAny(str, suffixes) {
6950
6973
  return suffixes.some(function(suffix) {
@@ -6955,7 +6978,7 @@ function _get_manifest_files_suffixes() {
6955
6978
  return ["package.json"];
6956
6979
  }
6957
6980
  async function pack(srcDirPath, vulnFiles) {
6958
- debug8("pack folder %s", srcDirPath);
6981
+ debug10("pack folder %s", srcDirPath);
6959
6982
  const filepaths = await globby("**", {
6960
6983
  gitignore: true,
6961
6984
  onlyFiles: true,
@@ -6963,9 +6986,9 @@ async function pack(srcDirPath, vulnFiles) {
6963
6986
  followSymbolicLinks: false,
6964
6987
  dot: true
6965
6988
  });
6966
- debug8("files found %d", filepaths.length);
6989
+ debug10("files found %d", filepaths.length);
6967
6990
  const zip = new AdmZip();
6968
- debug8("compressing files");
6991
+ debug10("compressing files");
6969
6992
  for (const filepath of filepaths) {
6970
6993
  const absFilepath = path4.join(srcDirPath, filepath.toString());
6971
6994
  vulnFiles = vulnFiles.concat(_get_manifest_files_suffixes());
@@ -6973,21 +6996,21 @@ async function pack(srcDirPath, vulnFiles) {
6973
6996
  absFilepath.toString().replaceAll(path4.win32.sep, path4.posix.sep),
6974
6997
  vulnFiles
6975
6998
  )) {
6976
- debug8("ignoring %s because it is not a vulnerability file", filepath);
6999
+ debug10("ignoring %s because it is not a vulnerability file", filepath);
6977
7000
  continue;
6978
7001
  }
6979
7002
  if (fs2.lstatSync(absFilepath).size > MAX_FILE_SIZE) {
6980
- debug8("ignoring %s because the size is > 5MB", filepath);
7003
+ debug10("ignoring %s because the size is > 5MB", filepath);
6981
7004
  continue;
6982
7005
  }
6983
7006
  const data = fs2.readFileSync(absFilepath);
6984
7007
  if (isBinary(null, data)) {
6985
- debug8("ignoring %s because is seems to be a binary file", filepath);
7008
+ debug10("ignoring %s because is seems to be a binary file", filepath);
6986
7009
  continue;
6987
7010
  }
6988
7011
  zip.addFile(filepath.toString(), data);
6989
7012
  }
6990
- debug8("get zip file buffer");
7013
+ debug10("get zip file buffer");
6991
7014
  return zip.toBuffer();
6992
7015
  }
6993
7016
 
@@ -7063,7 +7086,7 @@ var cxOperatingSystemSupportMessage = `Your operating system does not support ch
7063
7086
 
7064
7087
  // src/utils/child_process.ts
7065
7088
  import cp from "node:child_process";
7066
- import Debug9 from "debug";
7089
+ import Debug11 from "debug";
7067
7090
  import * as process2 from "process";
7068
7091
  import supportsColor from "supports-color";
7069
7092
  var { stdout: stdout2 } = supportsColor;
@@ -7082,16 +7105,16 @@ function createSpwan({ args, processPath, name }, options) {
7082
7105
  return createChildProcess({ childProcess: child, name }, options);
7083
7106
  }
7084
7107
  function createChildProcess({ childProcess, name }, options) {
7085
- const debug13 = Debug9(`mobbdev:${name}`);
7108
+ const debug15 = Debug11(`mobbdev:${name}`);
7086
7109
  const { display } = options;
7087
7110
  return new Promise((resolve, reject) => {
7088
7111
  let out = "";
7089
7112
  const onData = (chunk) => {
7090
- debug13(`chunk received from ${name} std ${chunk}`);
7113
+ debug15(`chunk received from ${name} std ${chunk}`);
7091
7114
  out += chunk;
7092
7115
  };
7093
7116
  if (!childProcess || !childProcess?.stdout || !childProcess?.stderr) {
7094
- debug13(`unable to fork ${name}`);
7117
+ debug15(`unable to fork ${name}`);
7095
7118
  reject(new Error(`unable to fork ${name}`));
7096
7119
  }
7097
7120
  childProcess.stdout?.on("data", onData);
@@ -7101,11 +7124,11 @@ function createChildProcess({ childProcess, name }, options) {
7101
7124
  childProcess.stderr?.pipe(process2.stderr);
7102
7125
  }
7103
7126
  childProcess.on("exit", (code) => {
7104
- debug13(`${name} exit code ${code}`);
7127
+ debug15(`${name} exit code ${code}`);
7105
7128
  resolve({ message: out, code });
7106
7129
  });
7107
7130
  childProcess.on("error", (err) => {
7108
- debug13(`${name} error %o`, err);
7131
+ debug15(`${name} error %o`, err);
7109
7132
  reject(err);
7110
7133
  });
7111
7134
  });
@@ -7113,12 +7136,12 @@ function createChildProcess({ childProcess, name }, options) {
7113
7136
 
7114
7137
  // src/features/analysis/scanners/checkmarx.ts
7115
7138
  import chalk2 from "chalk";
7116
- import Debug10 from "debug";
7139
+ import Debug12 from "debug";
7117
7140
  import { existsSync } from "fs";
7118
7141
  import { createSpinner as createSpinner2 } from "nanospinner";
7119
7142
  import { type } from "os";
7120
7143
  import path5 from "path";
7121
- var debug9 = Debug10("mobbdev:checkmarx");
7144
+ var debug11 = Debug12("mobbdev:checkmarx");
7122
7145
  var require2 = createRequire(import.meta.url);
7123
7146
  var getCheckmarxPath = () => {
7124
7147
  const os2 = type();
@@ -7159,14 +7182,14 @@ function validateCheckmarxInstallation() {
7159
7182
  existsSync(getCheckmarxPath());
7160
7183
  }
7161
7184
  async function forkCheckmarx(args, { display }) {
7162
- debug9("fork checkmarx with args %o %s", args.join(" "), display);
7185
+ debug11("fork checkmarx with args %o %s", args.join(" "), display);
7163
7186
  return createSpwan(
7164
7187
  { args, processPath: getCheckmarxPath(), name: "checkmarx" },
7165
7188
  { display }
7166
7189
  );
7167
7190
  }
7168
7191
  async function getCheckmarxReport({ reportPath, repositoryRoot, branch, projectName }, { skipPrompts = false }) {
7169
- debug9("get checkmarx report start %s %s", reportPath, repositoryRoot);
7192
+ debug11("get checkmarx report start %s %s", reportPath, repositoryRoot);
7170
7193
  const { code: loginCode } = await forkCheckmarx(VALIDATE_COMMAND, {
7171
7194
  display: false
7172
7195
  });
@@ -7234,20 +7257,20 @@ async function validateCheckamxCredentials() {
7234
7257
  // src/features/analysis/scanners/snyk.ts
7235
7258
  import { createRequire as createRequire2 } from "node:module";
7236
7259
  import chalk3 from "chalk";
7237
- import Debug11 from "debug";
7260
+ import Debug13 from "debug";
7238
7261
  import { createSpinner as createSpinner3 } from "nanospinner";
7239
7262
  import open from "open";
7240
- var debug10 = Debug11("mobbdev:snyk");
7263
+ var debug12 = Debug13("mobbdev:snyk");
7241
7264
  var require3 = createRequire2(import.meta.url);
7242
7265
  var SNYK_PATH = require3.resolve("snyk/bin/snyk");
7243
7266
  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);
7267
+ debug12("snyk executable path %s", SNYK_PATH);
7245
7268
  async function forkSnyk(args, { display }) {
7246
- debug10("fork snyk with args %o %s", args, display);
7269
+ debug12("fork snyk with args %o %s", args, display);
7247
7270
  return createFork({ args, processPath: SNYK_PATH, name: "snyk" }, { display });
7248
7271
  }
7249
7272
  async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7250
- debug10("get snyk report start %s %s", reportPath, repoRoot);
7273
+ debug12("get snyk report start %s %s", reportPath, repoRoot);
7251
7274
  const config4 = await forkSnyk(["config"], { display: false });
7252
7275
  const { message: configMessage } = config4;
7253
7276
  if (!configMessage.includes("api: ")) {
@@ -7261,7 +7284,7 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7261
7284
  snykLoginSpinner.update({
7262
7285
  text: "\u{1F513} Waiting for Snyk login to complete"
7263
7286
  });
7264
- debug10("no token in the config %s", config4);
7287
+ debug12("no token in the config %s", config4);
7265
7288
  await forkSnyk(["auth"], { display: true });
7266
7289
  snykLoginSpinner.success({ text: "\u{1F513} Login to Snyk Successful" });
7267
7290
  }
@@ -7271,12 +7294,12 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7271
7294
  { display: true }
7272
7295
  );
7273
7296
  if (scanOutput.includes("Snyk Code is not supported for org")) {
7274
- debug10("snyk code is not enabled %s", scanOutput);
7297
+ debug12("snyk code is not enabled %s", scanOutput);
7275
7298
  snykSpinner.error({ text: "\u{1F50D} Snyk configuration needed" });
7276
7299
  const answer = await snykArticlePrompt();
7277
- debug10("answer %s", answer);
7300
+ debug12("answer %s", answer);
7278
7301
  if (answer) {
7279
- debug10("opening the browser");
7302
+ debug12("opening the browser");
7280
7303
  await open(SNYK_ARTICLE_URL);
7281
7304
  }
7282
7305
  console.log(
@@ -7291,18 +7314,18 @@ async function getSnykReport(reportPath, repoRoot, { skipPrompts = false }) {
7291
7314
  }
7292
7315
 
7293
7316
  // src/features/analysis/upload-file.ts
7294
- import Debug12 from "debug";
7317
+ import Debug14 from "debug";
7295
7318
  import fetch3, { File, fileFrom, FormData } from "node-fetch";
7296
- var debug11 = Debug12("mobbdev:upload-file");
7319
+ var debug13 = Debug14("mobbdev:upload-file");
7297
7320
  async function uploadFile({
7298
7321
  file,
7299
7322
  url,
7300
7323
  uploadKey,
7301
7324
  uploadFields
7302
7325
  }) {
7303
- debug11("upload file start %s", url);
7304
- debug11("upload fields %o", uploadFields);
7305
- debug11("upload key %s", uploadKey);
7326
+ debug13("upload file start %s", url);
7327
+ debug13("upload fields %o", uploadFields);
7328
+ debug13("upload key %s", uploadKey);
7306
7329
  const form = new FormData();
7307
7330
  Object.entries(uploadFields).forEach(([key, value]) => {
7308
7331
  form.append(key, value);
@@ -7311,10 +7334,10 @@ async function uploadFile({
7311
7334
  form.append("key", uploadKey);
7312
7335
  }
7313
7336
  if (typeof file === "string") {
7314
- debug11("upload file from path %s", file);
7337
+ debug13("upload file from path %s", file);
7315
7338
  form.append("file", await fileFrom(file));
7316
7339
  } else {
7317
- debug11("upload file from buffer");
7340
+ debug13("upload file from buffer");
7318
7341
  form.append("file", new File([file], "file"));
7319
7342
  }
7320
7343
  const response = await fetch3(url, {
@@ -7322,10 +7345,10 @@ async function uploadFile({
7322
7345
  body: form
7323
7346
  });
7324
7347
  if (!response.ok) {
7325
- debug11("error from S3 %s %s", response.body, response.status);
7348
+ debug13("error from S3 %s %s", response.body, response.status);
7326
7349
  throw new Error(`Failed to upload the file: ${response.status}`);
7327
7350
  }
7328
- debug11("upload file done");
7351
+ debug13("upload file done");
7329
7352
  }
7330
7353
 
7331
7354
  // src/features/analysis/index.ts
@@ -7345,9 +7368,9 @@ async function downloadRepo({
7345
7368
  }) {
7346
7369
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
7347
7370
  const repoSpinner = createSpinner4("\u{1F4BE} Downloading Repo").start();
7348
- debug12("download repo %s %s %s", repoUrl, dirname);
7371
+ debug14("download repo %s %s %s", repoUrl, dirname);
7349
7372
  const zipFilePath = path6.join(dirname, "repo.zip");
7350
- debug12("download URL: %s auth headers: %o", downloadUrl, authHeaders);
7373
+ debug14("download URL: %s auth headers: %o", downloadUrl, authHeaders);
7351
7374
  const response = await fetch4(downloadUrl, {
7352
7375
  method: "GET",
7353
7376
  headers: {
@@ -7355,7 +7378,7 @@ async function downloadRepo({
7355
7378
  }
7356
7379
  });
7357
7380
  if (!response.ok) {
7358
- debug12("SCM zipball request failed %s %s", response.body, response.status);
7381
+ debug14("SCM zipball request failed %s %s", response.body, response.status);
7359
7382
  repoSpinner.error({ text: "\u{1F4BE} Repo download failed" });
7360
7383
  throw new Error(`Can't access ${chalk4.bold(repoUrl)}`);
7361
7384
  }
@@ -7369,7 +7392,7 @@ async function downloadRepo({
7369
7392
  if (!repoRoot) {
7370
7393
  throw new Error("Repo root not found");
7371
7394
  }
7372
- debug12("repo root %s", repoRoot);
7395
+ debug14("repo root %s", repoRoot);
7373
7396
  repoSpinner.success({ text: "\u{1F4BE} Repo downloaded successfully" });
7374
7397
  return path6.join(dirname, repoRoot);
7375
7398
  }
@@ -7383,7 +7406,7 @@ var getReportUrl = ({
7383
7406
  projectId,
7384
7407
  fixReportId
7385
7408
  }) => `${WEB_APP_URL}/organization/${organizationId}/project/${projectId}/report/${fixReportId}`;
7386
- var debug12 = Debug13("mobbdev:index");
7409
+ var debug14 = Debug15("mobbdev:index");
7387
7410
  var packageJson = JSON.parse(
7388
7411
  fs3.readFileSync(path6.join(getDirName(), "../package.json"), "utf8")
7389
7412
  );
@@ -7393,7 +7416,7 @@ if (!semver.satisfies(process.version, packageJson.engines.node)) {
7393
7416
  );
7394
7417
  }
7395
7418
  var config2 = new Configstore(packageJson.name, { apiToken: "" });
7396
- debug12("config %o", config2);
7419
+ debug14("config %o", config2);
7397
7420
  async function runAnalysis(params, options) {
7398
7421
  const tmpObj = tmp2.dirSync({
7399
7422
  unsafeCleanup: true
@@ -7535,7 +7558,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7535
7558
  organizationId: userOrganizationId,
7536
7559
  autoPr
7537
7560
  } = params;
7538
- debug12("start %s %s", dirname, repo);
7561
+ debug14("start %s %s", dirname, repo);
7539
7562
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
7540
7563
  skipPrompts = skipPrompts || ci;
7541
7564
  let gqlClient = new GQLClient({
@@ -7602,8 +7625,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
7602
7625
  );
7603
7626
  }
7604
7627
  const { sha } = getReferenceDataRes.gitReference;
7605
- debug12("project id %s", projectId);
7606
- debug12("default branch %s", reference);
7628
+ debug14("project id %s", projectId);
7629
+ debug14("default branch %s", reference);
7607
7630
  if (command === "scan") {
7608
7631
  reportPath = await getReport(
7609
7632
  {
@@ -7641,7 +7664,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7641
7664
  spinner: mobbSpinner,
7642
7665
  submitVulnerabilityReportVariables: {
7643
7666
  fixReportId: reportUploadInfo.fixReportId,
7644
- repoUrl: z19.string().parse(repo),
7667
+ repoUrl: z20.string().parse(repo),
7645
7668
  reference,
7646
7669
  projectId,
7647
7670
  vulnerabilityReportFileName: "report.json",
@@ -7722,9 +7745,9 @@ async function _scan(params, { skipPrompts = false } = {}) {
7722
7745
  });
7723
7746
  loginSpinner.spin();
7724
7747
  if (encryptedApiToken) {
7725
- debug12("encrypted API token received %s", encryptedApiToken);
7748
+ debug14("encrypted API token received %s", encryptedApiToken);
7726
7749
  newApiToken = crypto.privateDecrypt(privateKey, Buffer.from(encryptedApiToken, "base64")).toString("utf-8");
7727
- debug12("API token decrypted");
7750
+ debug14("API token decrypted");
7728
7751
  break;
7729
7752
  }
7730
7753
  await sleep(LOGIN_CHECK_DELAY);
@@ -7737,7 +7760,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7737
7760
  }
7738
7761
  gqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
7739
7762
  if (await gqlClient.verifyToken()) {
7740
- debug12("set api token %s", newApiToken);
7763
+ debug14("set api token %s", newApiToken);
7741
7764
  config2.set("apiToken", newApiToken);
7742
7765
  loginSpinner.success({ text: "\u{1F513} Login to Mobb successful!" });
7743
7766
  } else {
@@ -7880,9 +7903,9 @@ async function _scan(params, { skipPrompts = false } = {}) {
7880
7903
  }
7881
7904
  });
7882
7905
  if (command === "review") {
7883
- const params2 = z19.object({
7884
- repo: z19.string().url(),
7885
- githubActionToken: z19.string()
7906
+ const params2 = z20.object({
7907
+ repo: z20.string().url(),
7908
+ githubActionToken: z20.string()
7886
7909
  }).parse({ repo, githubActionToken });
7887
7910
  const scm = await SCMLib.init(
7888
7911
  {
@@ -7904,7 +7927,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
7904
7927
  analysisId,
7905
7928
  gqlClient,
7906
7929
  scm,
7907
- scanner: z19.nativeEnum(SCANNERS).parse(scanner)
7930
+ scanner: z20.nativeEnum(SCANNERS).parse(scanner)
7908
7931
  });
7909
7932
  },
7910
7933
  callbackStates: ["Finished" /* Finished */]
@@ -8131,7 +8154,7 @@ var scmTokenOption = {
8131
8154
  // src/args/validation.ts
8132
8155
  import chalk6 from "chalk";
8133
8156
  import path8 from "path";
8134
- import { z as z20 } from "zod";
8157
+ import { z as z21 } from "zod";
8135
8158
  function throwRepoUrlErrorMessage({
8136
8159
  error,
8137
8160
  repoUrl,
@@ -8148,13 +8171,13 @@ Example:
8148
8171
  )}`;
8149
8172
  throw new CliError(formattedErrorMessage);
8150
8173
  }
8151
- var UrlZ = z20.string({
8174
+ var UrlZ = z21.string({
8152
8175
  invalid_type_error: `is not a valid ${Object.values(ScmType).join("/ ")} URL`
8153
8176
  }).refine((data) => !!sanityRepoURL(data), {
8154
8177
  message: `is not a valid ${Object.values(ScmType).join(" / ")} URL`
8155
8178
  });
8156
8179
  function validateOrganizationId(organizationId) {
8157
- const orgIdValidation = z20.string().uuid().nullish().safeParse(organizationId);
8180
+ const orgIdValidation = z21.string().uuid().nullish().safeParse(organizationId);
8158
8181
  if (!orgIdValidation.success) {
8159
8182
  throw new CliError(`organizationId: ${organizationId} is not a valid UUID`);
8160
8183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.166",
3
+ "version": "0.0.168",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",