mobbdev 0.0.58 → 0.0.59

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 +47 -25
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => {
13
13
  import { hideBin } from "yargs/helpers";
14
14
 
15
15
  // src/args/yargs.ts
16
- import chalk9 from "chalk";
16
+ import chalk8 from "chalk";
17
17
  import yargs from "yargs/yargs";
18
18
 
19
19
  // src/args/commands/analyze.ts
@@ -69,6 +69,7 @@ var mobbAscii = `
69
69
  ...............................
70
70
  .................
71
71
  `;
72
+ var PROJECT_DEFAULT_NAME = "My first project";
72
73
  var WEB_APP_URL = envVariables.WEB_APP_URL;
73
74
  var API_URL = envVariables.API_URL;
74
75
  var errorMessages = {
@@ -333,6 +334,7 @@ var GET_ORG_AND_PROJECT_ID = gql2`
333
334
  id
334
335
  projects(order_by: { updatedAt: desc }) {
335
336
  id
337
+ name
336
338
  }
337
339
  }
338
340
  }
@@ -406,7 +408,8 @@ var GetOrgAndProjectIdQueryZ = z2.object({
406
408
  id: z2.string(),
407
409
  projects: z2.array(
408
410
  z2.object({
409
- id: z2.string()
411
+ id: z2.string(),
412
+ name: z2.string()
410
413
  })
411
414
  ).nonempty()
412
415
  })
@@ -483,7 +486,7 @@ var GQLClient = class {
483
486
  }
484
487
  return true;
485
488
  }
486
- async getOrgAndProjectId() {
489
+ async getOrgAndProjectId(projectName) {
487
490
  const getOrgAndProjectIdResult = await this._client.request(
488
491
  GET_ORG_AND_PROJECT_ID
489
492
  );
@@ -491,9 +494,10 @@ var GQLClient = class {
491
494
  getOrgAndProjectIdResult
492
495
  ).users;
493
496
  const org = user.userOrganizationsAndUserOrganizationRoles[0].organization;
497
+ const project = projectName ? org.projects.find((project2) => project2.name === projectName) ?? org.projects[0] : org.projects[0];
494
498
  return {
495
499
  organizationId: org.id,
496
- projectId: org.projects[0].id
500
+ projectId: project.id
497
501
  };
498
502
  }
499
503
  async getEncryptedApiToken(variables) {
@@ -2169,7 +2173,8 @@ async function _scan({
2169
2173
  commitHash,
2170
2174
  ref,
2171
2175
  scanner,
2172
- cxProjectName
2176
+ cxProjectName,
2177
+ mobbProjectName
2173
2178
  }, { skipPrompts = false } = {}) {
2174
2179
  debug8("start %s %s", dirname, repo);
2175
2180
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
@@ -2178,7 +2183,9 @@ async function _scan({
2178
2183
  apiKey: apiKey || config2.get("apiToken")
2179
2184
  });
2180
2185
  await handleMobbLogin();
2181
- const { projectId, organizationId } = await gqlClient.getOrgAndProjectId();
2186
+ const { projectId, organizationId } = await gqlClient.getOrgAndProjectId(
2187
+ mobbProjectName
2188
+ );
2182
2189
  const {
2183
2190
  uploadS3BucketInfo: { repoUploadInfo, reportUploadInfo }
2184
2191
  } = await gqlClient.uploadS3BucketInfo();
@@ -2483,7 +2490,16 @@ async function _scan({
2483
2490
 
2484
2491
  // src/commands/index.ts
2485
2492
  import chalkAnimation from "chalk-animation";
2486
- async function analyze({ repo, f: scanFile, ref, apiKey, ci, commitHash, srcPath }, { skipPrompts = false } = {}) {
2493
+ async function analyze({
2494
+ repo,
2495
+ f: scanFile,
2496
+ ref,
2497
+ apiKey,
2498
+ ci,
2499
+ commitHash,
2500
+ srcPath,
2501
+ mobbProjectName
2502
+ }, { skipPrompts = false } = {}) {
2487
2503
  !ci && await showWelcomeMessage(skipPrompts);
2488
2504
  await runAnalysis(
2489
2505
  {
@@ -2493,6 +2509,7 @@ async function analyze({ repo, f: scanFile, ref, apiKey, ci, commitHash, srcPath
2493
2509
  apiKey,
2494
2510
  ci,
2495
2511
  commitHash,
2512
+ mobbProjectName,
2496
2513
  srcPath
2497
2514
  },
2498
2515
  { skipPrompts }
@@ -2548,6 +2565,16 @@ var refOption = {
2548
2565
  type: "string",
2549
2566
  demandOption: false
2550
2567
  };
2568
+ var scannerOptions = {
2569
+ alias: "s",
2570
+ choices: Object.values(SCANNERS),
2571
+ describe: chalk5.bold("Select the scanner to use")
2572
+ };
2573
+ var mobbProjectNameOption = {
2574
+ type: "string",
2575
+ describe: chalk5.bold("Mobb project name"),
2576
+ default: PROJECT_DEFAULT_NAME
2577
+ };
2551
2578
  var ciOption = {
2552
2579
  describe: chalk5.bold(
2553
2580
  "Run in CI mode, prompts and browser will not be opened"
@@ -2640,7 +2667,7 @@ function analyzeBuilder(yargs2) {
2640
2667
  alias: "commit-hash",
2641
2668
  describe: chalk7.bold("Hash of the commit"),
2642
2669
  type: "string"
2643
- }).option("y", yesOption).option("ci", ciOption).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).example(
2670
+ }).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).example(
2644
2671
  "$0 analyze -r https://github.com/WebGoat/WebGoat -f <your_vulirabitliy_report_path>",
2645
2672
  "analyze an existing repository"
2646
2673
  ).help();
@@ -2667,13 +2694,8 @@ async function analyzeHandler(args) {
2667
2694
  }
2668
2695
 
2669
2696
  // src/args/commands/scan.ts
2670
- import chalk8 from "chalk";
2671
2697
  function scanBuilder(args) {
2672
- return args.coerce("scanner", (arg) => arg.toLowerCase()).option("repo", repoOption).option("ref", refOption).option("s", {
2673
- alias: "scanner",
2674
- choices: Object.values(SCANNERS),
2675
- describe: chalk8.bold("Select the scanner to use")
2676
- }).option("y", yesOption).option("ci", ciOption).option("api-key", apiKeyOption).option("cx-project-name", projectNameOption).example(
2698
+ return args.coerce("scanner", (arg) => arg.toLowerCase()).option("repo", repoOption).option("ref", refOption).option("scanner", scannerOptions).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("api-key", apiKeyOption).option("cx-project-name", projectNameOption).example(
2677
2699
  "$0 scan -r https://github.com/WebGoat/WebGoat",
2678
2700
  "Scan an existing repository"
2679
2701
  ).help();
@@ -2699,28 +2721,28 @@ async function scanHandler(args) {
2699
2721
  var parseArgs = async (args) => {
2700
2722
  const yargsInstance = yargs(args);
2701
2723
  return yargsInstance.updateStrings({
2702
- "Commands:": chalk9.yellow.underline.bold("Commands:"),
2703
- "Options:": chalk9.yellow.underline.bold("Options:"),
2704
- "Examples:": chalk9.yellow.underline.bold("Examples:"),
2705
- "Show help": chalk9.bold("Show help")
2724
+ "Commands:": chalk8.yellow.underline.bold("Commands:"),
2725
+ "Options:": chalk8.yellow.underline.bold("Options:"),
2726
+ "Examples:": chalk8.yellow.underline.bold("Examples:"),
2727
+ "Show help": chalk8.bold("Show help")
2706
2728
  }).usage(
2707
- `${chalk9.bold(
2729
+ `${chalk8.bold(
2708
2730
  "\n Bugsy - Trusted, Automatic Vulnerability Fixer \u{1F575}\uFE0F\u200D\u2642\uFE0F\n\n"
2709
- )} ${chalk9.yellow.underline.bold("Usage:")}
2710
- $0 ${chalk9.green(
2731
+ )} ${chalk8.yellow.underline.bold("Usage:")}
2732
+ $0 ${chalk8.green(
2711
2733
  "<command>"
2712
- )} ${chalk9.dim("[options]")}
2734
+ )} ${chalk8.dim("[options]")}
2713
2735
  `
2714
2736
  ).version(false).command(
2715
2737
  "scan",
2716
- chalk9.bold(
2738
+ chalk8.bold(
2717
2739
  "Scan your code for vulnerabilities, get automated fixes right away."
2718
2740
  ),
2719
2741
  scanBuilder,
2720
2742
  scanHandler
2721
2743
  ).command(
2722
2744
  "analyze",
2723
- chalk9.bold(
2745
+ chalk8.bold(
2724
2746
  "Provide a vulnerability report and relevant code repository, get automated fixes right away."
2725
2747
  ),
2726
2748
  analyzeBuilder,
@@ -2733,7 +2755,7 @@ var parseArgs = async (args) => {
2733
2755
  handler() {
2734
2756
  yargsInstance.showHelp();
2735
2757
  }
2736
- }).strictOptions().help("h").alias("h", "help").epilog(chalk9.bgBlue("Made with \u2764\uFE0F by Mobb")).showHelpOnFail(true).wrap(Math.min(120, yargsInstance.terminalWidth())).parse();
2758
+ }).strictOptions().help("h").alias("h", "help").epilog(chalk8.bgBlue("Made with \u2764\uFE0F by Mobb")).showHelpOnFail(true).wrap(Math.min(120, yargsInstance.terminalWidth())).parse();
2737
2759
  };
2738
2760
 
2739
2761
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",