mobbdev 0.0.59 → 0.0.61

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 +33 -41
  2. package/package.json +3 -1
package/dist/index.mjs CHANGED
@@ -202,6 +202,7 @@ async function getGitInfo(srcDirPath) {
202
202
  // src/features/analysis/graphql/gql.ts
203
203
  import Debug3 from "debug";
204
204
  import { GraphQLClient } from "graphql-request";
205
+ import { v4 as uuidv4 } from "uuid";
205
206
 
206
207
  // src/features/analysis/graphql/mutations.ts
207
208
  import { gql } from "graphql-request";
@@ -230,17 +231,11 @@ var DIGEST_VULNERABILITY_REPORT = gql`
230
231
  $vulnerabilityReportFileName: String!
231
232
  $fixReportId: String!
232
233
  $projectId: String!
233
- $repoUrl: String!
234
- $reference: String!
235
- $sha: String
236
234
  ) {
237
235
  digestVulnerabilityReport(
238
236
  fixReportId: $fixReportId
239
237
  vulnerabilityReportFileName: $vulnerabilityReportFileName
240
238
  projectId: $projectId
241
- repoUrl: $repoUrl
242
- reference: $reference
243
- sha: $sha
244
239
  ) {
245
240
  __typename
246
241
  ... on VulnerabilityReport {
@@ -262,29 +257,22 @@ var DIGEST_VULNERABILITY_REPORT = gql`
262
257
  }
263
258
  }
264
259
  `;
265
- var INITIALIZE_VULNERABILITY_REPORT = gql`
266
- mutation InitializeVulnerabilityReport($fixReportId: String!) {
267
- initializeVulnerabilityReport(fixReportId: $fixReportId) {
268
- __typename
269
- }
270
- }
271
- `;
272
260
  var SUBMIT_VULNERABILITY_REPORT = gql`
273
261
  mutation SubmitVulnerabilityReport(
274
- $vulnerabilityReportFileName: String!
275
262
  $fixReportId: String!
276
263
  $repoUrl: String!
277
264
  $reference: String!
278
265
  $projectId: String!
279
266
  $sha: String
267
+ $vulnerabilityReportFileName: String
280
268
  ) {
281
269
  submitVulnerabilityReport(
282
270
  fixReportId: $fixReportId
283
271
  repoUrl: $repoUrl
284
272
  reference: $reference
285
273
  sha: $sha
286
- vulnerabilityReportFileName: $vulnerabilityReportFileName
287
274
  projectId: $projectId
275
+ vulnerabilityReportFileName: $vulnerabilityReportFileName
288
276
  ) {
289
277
  __typename
290
278
  }
@@ -456,7 +444,20 @@ var GQLClient = class {
456
444
  const { apiKey } = args;
457
445
  debug3(`init with apiKey ${apiKey}`);
458
446
  this._client = new GraphQLClient(API_URL, {
459
- headers: { [API_KEY_HEADER_NAME]: apiKey || "" }
447
+ headers: { [API_KEY_HEADER_NAME]: apiKey || "" },
448
+ requestMiddleware: (request) => {
449
+ const requestId = uuidv4();
450
+ debug3(
451
+ `sending API request with id: ${requestId} and with request: ${request.body}`
452
+ );
453
+ return {
454
+ ...request,
455
+ headers: {
456
+ ...request.headers,
457
+ "x-hasura-request-id": requestId
458
+ }
459
+ };
460
+ }
460
461
  });
461
462
  }
462
463
  async getUserInfo() {
@@ -526,43 +527,31 @@ var GQLClient = class {
526
527
  }
527
528
  async digestVulnerabilityReport({
528
529
  fixReportId,
529
- projectId,
530
- repoUrl,
531
- reference,
532
- sha
530
+ projectId
533
531
  }) {
534
532
  const res = await this._client.request(
535
533
  DIGEST_VULNERABILITY_REPORT,
536
534
  {
537
535
  fixReportId,
538
536
  vulnerabilityReportFileName: "report.json",
539
- projectId,
540
- repoUrl,
541
- reference,
542
- sha
537
+ projectId
543
538
  }
544
539
  );
545
540
  return DigestVulnerabilityReportZ.parse(res).digestVulnerabilityReport;
546
541
  }
547
- async initializeVulnerabilityReport({
548
- fixReportId
549
- }) {
550
- await this._client.request(INITIALIZE_VULNERABILITY_REPORT, {
551
- fixReportId
552
- });
553
- }
554
542
  async submitVulnerabilityReport({
555
543
  fixReportId,
556
544
  repoUrl,
557
545
  reference,
558
546
  projectId,
559
- sha
547
+ sha,
548
+ vulnerabilityReportFileName
560
549
  }) {
561
550
  await this._client.request(SUBMIT_VULNERABILITY_REPORT, {
562
551
  fixReportId,
563
552
  repoUrl,
564
553
  reference,
565
- vulnerabilityReportFileName: "report.json",
554
+ vulnerabilityReportFileName,
566
555
  projectId,
567
556
  sha: sha || ""
568
557
  });
@@ -2267,7 +2256,9 @@ async function _scan({
2267
2256
  fixReportId: reportUploadInfo.fixReportId,
2268
2257
  repoUrl: repo,
2269
2258
  reference,
2270
- projectId
2259
+ projectId,
2260
+ vulnerabilityReportFileName: "report.json",
2261
+ sha
2271
2262
  });
2272
2263
  } catch (e) {
2273
2264
  mobbSpinner.error({ text: "\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed" });
@@ -2430,14 +2421,11 @@ async function _scan({
2430
2421
  });
2431
2422
  const digestSpinner = createSpinner4("\u{1F575}\uFE0F\u200D\u2642\uFE0F Digesting report").start();
2432
2423
  let vulnFiles = [];
2424
+ const gitInfo = await getGitInfo(srcPath);
2433
2425
  try {
2434
- const gitInfo = await getGitInfo(srcPath);
2435
2426
  const { vulnerabilityReportId } = await gqlClient.digestVulnerabilityReport({
2436
2427
  fixReportId: reportUploadInfo.fixReportId,
2437
- projectId,
2438
- repoUrl: repo || gitInfo.repoUrl,
2439
- reference: gitInfo.reference,
2440
- sha: commitHash || gitInfo.hash
2428
+ projectId
2441
2429
  });
2442
2430
  const finalState = await gqlClient.waitFixReportInit(
2443
2431
  reportUploadInfo.fixReportId,
@@ -2474,8 +2462,12 @@ async function _scan({
2474
2462
  uploadRepoSpinner.success({ text: "\u{1F4C1} Uploading Repo successful!" });
2475
2463
  const mobbSpinner2 = createSpinner4("\u{1F575}\uFE0F\u200D\u2642\uFE0F Initiating Mobb analysis").start();
2476
2464
  try {
2477
- await gqlClient.initializeVulnerabilityReport({
2478
- fixReportId: reportUploadInfo.fixReportId
2465
+ await gqlClient.submitVulnerabilityReport({
2466
+ fixReportId: reportUploadInfo.fixReportId,
2467
+ projectId,
2468
+ repoUrl: repo || gitInfo.repoUrl,
2469
+ reference: gitInfo.reference,
2470
+ sha: commitHash || gitInfo.hash
2479
2471
  });
2480
2472
  } catch (e) {
2481
2473
  mobbSpinner2.error({ text: "\u{1F575}\uFE0F\u200D\u2642\uFE0F Mobb analysis failed" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",
@@ -49,6 +49,7 @@
49
49
  "supports-color": "9.4.0",
50
50
  "tar": "6.2.0",
51
51
  "tmp": "0.2.1",
52
+ "uuid": "9.0.0",
52
53
  "yargs": "17.7.2",
53
54
  "zod": "3.22.3"
54
55
  },
@@ -63,6 +64,7 @@
63
64
  "@types/semver": "7.5.0",
64
65
  "@types/tar": "^6.1.6",
65
66
  "@types/tmp": "0.2.3",
67
+ "@types/uuid": "9.0.1",
66
68
  "@types/yargs": "17.0.24",
67
69
  "@typescript-eslint/eslint-plugin": "5.44.0",
68
70
  "@typescript-eslint/parser": "5.44.0",