mobbdev 0.0.57 → 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.
- package/dist/index.mjs +50 -26
- 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
|
|
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:
|
|
500
|
+
projectId: project.id
|
|
497
501
|
};
|
|
498
502
|
}
|
|
499
503
|
async getEncryptedApiToken(variables) {
|
|
@@ -2060,7 +2064,9 @@ async function uploadFile({
|
|
|
2060
2064
|
Object.entries(uploadFields).forEach(([key, value]) => {
|
|
2061
2065
|
form.append(key, value);
|
|
2062
2066
|
});
|
|
2063
|
-
form.
|
|
2067
|
+
if (!form.has("key")) {
|
|
2068
|
+
form.append("key", uploadKey);
|
|
2069
|
+
}
|
|
2064
2070
|
if (typeof file === "string") {
|
|
2065
2071
|
debug7("upload file from path %s", file);
|
|
2066
2072
|
form.append("file", await fileFrom(file));
|
|
@@ -2167,7 +2173,8 @@ async function _scan({
|
|
|
2167
2173
|
commitHash,
|
|
2168
2174
|
ref,
|
|
2169
2175
|
scanner,
|
|
2170
|
-
cxProjectName
|
|
2176
|
+
cxProjectName,
|
|
2177
|
+
mobbProjectName
|
|
2171
2178
|
}, { skipPrompts = false } = {}) {
|
|
2172
2179
|
debug8("start %s %s", dirname, repo);
|
|
2173
2180
|
const { createSpinner: createSpinner4 } = Spinner2({ ci });
|
|
@@ -2176,7 +2183,9 @@ async function _scan({
|
|
|
2176
2183
|
apiKey: apiKey || config2.get("apiToken")
|
|
2177
2184
|
});
|
|
2178
2185
|
await handleMobbLogin();
|
|
2179
|
-
const { projectId, organizationId } = await gqlClient.getOrgAndProjectId(
|
|
2186
|
+
const { projectId, organizationId } = await gqlClient.getOrgAndProjectId(
|
|
2187
|
+
mobbProjectName
|
|
2188
|
+
);
|
|
2180
2189
|
const {
|
|
2181
2190
|
uploadS3BucketInfo: { repoUploadInfo, reportUploadInfo }
|
|
2182
2191
|
} = await gqlClient.uploadS3BucketInfo();
|
|
@@ -2481,7 +2490,16 @@ async function _scan({
|
|
|
2481
2490
|
|
|
2482
2491
|
// src/commands/index.ts
|
|
2483
2492
|
import chalkAnimation from "chalk-animation";
|
|
2484
|
-
async function analyze({
|
|
2493
|
+
async function analyze({
|
|
2494
|
+
repo,
|
|
2495
|
+
f: scanFile,
|
|
2496
|
+
ref,
|
|
2497
|
+
apiKey,
|
|
2498
|
+
ci,
|
|
2499
|
+
commitHash,
|
|
2500
|
+
srcPath,
|
|
2501
|
+
mobbProjectName
|
|
2502
|
+
}, { skipPrompts = false } = {}) {
|
|
2485
2503
|
!ci && await showWelcomeMessage(skipPrompts);
|
|
2486
2504
|
await runAnalysis(
|
|
2487
2505
|
{
|
|
@@ -2491,6 +2509,7 @@ async function analyze({ repo, f: scanFile, ref, apiKey, ci, commitHash, srcPath
|
|
|
2491
2509
|
apiKey,
|
|
2492
2510
|
ci,
|
|
2493
2511
|
commitHash,
|
|
2512
|
+
mobbProjectName,
|
|
2494
2513
|
srcPath
|
|
2495
2514
|
},
|
|
2496
2515
|
{ skipPrompts }
|
|
@@ -2546,6 +2565,16 @@ var refOption = {
|
|
|
2546
2565
|
type: "string",
|
|
2547
2566
|
demandOption: false
|
|
2548
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
|
+
};
|
|
2549
2578
|
var ciOption = {
|
|
2550
2579
|
describe: chalk5.bold(
|
|
2551
2580
|
"Run in CI mode, prompts and browser will not be opened"
|
|
@@ -2638,7 +2667,7 @@ function analyzeBuilder(yargs2) {
|
|
|
2638
2667
|
alias: "commit-hash",
|
|
2639
2668
|
describe: chalk7.bold("Hash of the commit"),
|
|
2640
2669
|
type: "string"
|
|
2641
|
-
}).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(
|
|
2642
2671
|
"$0 analyze -r https://github.com/WebGoat/WebGoat -f <your_vulirabitliy_report_path>",
|
|
2643
2672
|
"analyze an existing repository"
|
|
2644
2673
|
).help();
|
|
@@ -2665,13 +2694,8 @@ async function analyzeHandler(args) {
|
|
|
2665
2694
|
}
|
|
2666
2695
|
|
|
2667
2696
|
// src/args/commands/scan.ts
|
|
2668
|
-
import chalk8 from "chalk";
|
|
2669
2697
|
function scanBuilder(args) {
|
|
2670
|
-
return args.coerce("scanner", (arg) => arg.toLowerCase()).option("repo", repoOption).option("ref", refOption).option("
|
|
2671
|
-
alias: "scanner",
|
|
2672
|
-
choices: Object.values(SCANNERS),
|
|
2673
|
-
describe: chalk8.bold("Select the scanner to use")
|
|
2674
|
-
}).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(
|
|
2675
2699
|
"$0 scan -r https://github.com/WebGoat/WebGoat",
|
|
2676
2700
|
"Scan an existing repository"
|
|
2677
2701
|
).help();
|
|
@@ -2697,28 +2721,28 @@ async function scanHandler(args) {
|
|
|
2697
2721
|
var parseArgs = async (args) => {
|
|
2698
2722
|
const yargsInstance = yargs(args);
|
|
2699
2723
|
return yargsInstance.updateStrings({
|
|
2700
|
-
"Commands:":
|
|
2701
|
-
"Options:":
|
|
2702
|
-
"Examples:":
|
|
2703
|
-
"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")
|
|
2704
2728
|
}).usage(
|
|
2705
|
-
`${
|
|
2729
|
+
`${chalk8.bold(
|
|
2706
2730
|
"\n Bugsy - Trusted, Automatic Vulnerability Fixer \u{1F575}\uFE0F\u200D\u2642\uFE0F\n\n"
|
|
2707
|
-
)} ${
|
|
2708
|
-
$0 ${
|
|
2731
|
+
)} ${chalk8.yellow.underline.bold("Usage:")}
|
|
2732
|
+
$0 ${chalk8.green(
|
|
2709
2733
|
"<command>"
|
|
2710
|
-
)} ${
|
|
2734
|
+
)} ${chalk8.dim("[options]")}
|
|
2711
2735
|
`
|
|
2712
2736
|
).version(false).command(
|
|
2713
2737
|
"scan",
|
|
2714
|
-
|
|
2738
|
+
chalk8.bold(
|
|
2715
2739
|
"Scan your code for vulnerabilities, get automated fixes right away."
|
|
2716
2740
|
),
|
|
2717
2741
|
scanBuilder,
|
|
2718
2742
|
scanHandler
|
|
2719
2743
|
).command(
|
|
2720
2744
|
"analyze",
|
|
2721
|
-
|
|
2745
|
+
chalk8.bold(
|
|
2722
2746
|
"Provide a vulnerability report and relevant code repository, get automated fixes right away."
|
|
2723
2747
|
),
|
|
2724
2748
|
analyzeBuilder,
|
|
@@ -2731,7 +2755,7 @@ var parseArgs = async (args) => {
|
|
|
2731
2755
|
handler() {
|
|
2732
2756
|
yargsInstance.showHelp();
|
|
2733
2757
|
}
|
|
2734
|
-
}).strictOptions().help("h").alias("h", "help").epilog(
|
|
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();
|
|
2735
2759
|
};
|
|
2736
2760
|
|
|
2737
2761
|
// src/index.ts
|