mobbdev 1.0.44 → 1.0.46
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 +62 -45
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -837,16 +837,6 @@ var FixPageFixReportZ = z3.object({
|
|
|
837
837
|
expirationOn: z3.string(),
|
|
838
838
|
createdOn: z3.string(),
|
|
839
839
|
state: z3.nativeEnum(Fix_Report_State_Enum),
|
|
840
|
-
fixes_aggregate: z3.object({
|
|
841
|
-
aggregate: z3.object({
|
|
842
|
-
count: z3.number()
|
|
843
|
-
})
|
|
844
|
-
}),
|
|
845
|
-
fixableIssuesCount: z3.object({
|
|
846
|
-
aggregate: z3.object({
|
|
847
|
-
count: z3.number()
|
|
848
|
-
})
|
|
849
|
-
}),
|
|
850
840
|
repo: z3.object({
|
|
851
841
|
name: z3.string().nullable(),
|
|
852
842
|
originalUrl: z3.string(),
|
|
@@ -1156,9 +1146,6 @@ var AnalysisReportDigestedZ = z7.object({
|
|
|
1156
1146
|
});
|
|
1157
1147
|
var ReportQueryResultZ = z7.object({
|
|
1158
1148
|
fixReport_by_pk: z7.object({
|
|
1159
|
-
fixableIssuesCount: z7.object({
|
|
1160
|
-
aggregate: z7.object({ count: z7.number() })
|
|
1161
|
-
}),
|
|
1162
1149
|
id: z7.string().uuid(),
|
|
1163
1150
|
analysisUrl: z7.string(),
|
|
1164
1151
|
fixesCommitted: z7.object({
|
|
@@ -1177,11 +1164,6 @@ var ReportQueryResultZ = z7.object({
|
|
|
1177
1164
|
createdOn: z7.string(),
|
|
1178
1165
|
expirationOn: z7.string().nullable(),
|
|
1179
1166
|
state: z7.nativeEnum(Fix_Report_State_Enum),
|
|
1180
|
-
fixes_aggregate: z7.object({
|
|
1181
|
-
aggregate: z7.object({
|
|
1182
|
-
count: z7.number()
|
|
1183
|
-
})
|
|
1184
|
-
}),
|
|
1185
1167
|
fixes: z7.array(
|
|
1186
1168
|
z7.object({
|
|
1187
1169
|
id: z7.string().uuid(),
|
|
@@ -1217,6 +1199,11 @@ var ReportQueryResultZ = z7.object({
|
|
|
1217
1199
|
commitSha: z7.string(),
|
|
1218
1200
|
isKnownBranch: z7.boolean().nullish().default(true)
|
|
1219
1201
|
}),
|
|
1202
|
+
vulnerabilityReportIssuesFixedCount: z7.object({
|
|
1203
|
+
vulnerabilityReportIssues_aggregate: z7.object({
|
|
1204
|
+
aggregate: z7.object({ count: z7.number() })
|
|
1205
|
+
})
|
|
1206
|
+
}),
|
|
1220
1207
|
vulnerabilityReport: z7.object({
|
|
1221
1208
|
id: z7.string().uuid(),
|
|
1222
1209
|
reportSummaryUrl: z7.string().url().nullish(),
|
|
@@ -1369,13 +1356,7 @@ var FixPageQueryZ = z7.object({
|
|
|
1369
1356
|
var GetReportFixesQueryZ = z7.object({
|
|
1370
1357
|
fixReport: z7.array(
|
|
1371
1358
|
z7.object({
|
|
1372
|
-
fixableIssuesCount: z7.object({
|
|
1373
|
-
aggregate: z7.object({ count: z7.number() })
|
|
1374
|
-
}),
|
|
1375
1359
|
fixes: z7.array(ReportFixesQueryFixZ),
|
|
1376
|
-
fixes_aggregate: z7.object({
|
|
1377
|
-
aggregate: z7.object({ count: z7.number() })
|
|
1378
|
-
}),
|
|
1379
1360
|
vulnerabilityReportIssuesTotalCount: z7.object({
|
|
1380
1361
|
vulnerabilityReportIssues_aggregate: z7.object({
|
|
1381
1362
|
aggregate: z7.object({ count: z7.number() })
|
|
@@ -1406,9 +1387,9 @@ var ProjectVulnerabilityReport = z7.object({
|
|
|
1406
1387
|
fixReport: z7.object({
|
|
1407
1388
|
id: z7.string().uuid(),
|
|
1408
1389
|
createdOn: z7.string(),
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
count: z7.number()
|
|
1390
|
+
vulnerabilityReportIssuesFixedCount: z7.object({
|
|
1391
|
+
vulnerabilityReportIssues_aggregate: z7.object({
|
|
1392
|
+
aggregate: z7.object({ count: z7.number() })
|
|
1412
1393
|
})
|
|
1413
1394
|
}),
|
|
1414
1395
|
issueTypes: z7.record(z7.string(), z7.number()).nullable(),
|
|
@@ -1438,11 +1419,6 @@ var ProjectGetProjectZ = z7.object({
|
|
|
1438
1419
|
fixReport: z7.object({
|
|
1439
1420
|
issueLanguages: z7.record(z7.nativeEnum(IssueLanguage_Enum), z7.number()).nullable(),
|
|
1440
1421
|
state: z7.nativeEnum(Fix_Report_State_Enum),
|
|
1441
|
-
fixes_aggregate: z7.object({
|
|
1442
|
-
aggregate: z7.object({
|
|
1443
|
-
count: z7.number()
|
|
1444
|
-
})
|
|
1445
|
-
}),
|
|
1446
1422
|
repo: z7.object({
|
|
1447
1423
|
originalUrl: z7.string(),
|
|
1448
1424
|
reference: z7.string()
|
|
@@ -1593,6 +1569,7 @@ var VUL_REPORT_DIGEST_TIMEOUT_MS = 1e3 * 60 * 30;
|
|
|
1593
1569
|
|
|
1594
1570
|
// src/features/analysis/index.ts
|
|
1595
1571
|
import fs4 from "node:fs";
|
|
1572
|
+
import fsPromises from "node:fs/promises";
|
|
1596
1573
|
import path7 from "node:path";
|
|
1597
1574
|
import { env as env2 } from "node:process";
|
|
1598
1575
|
import { pipeline } from "node:stream/promises";
|
|
@@ -1708,7 +1685,7 @@ import { createSpinner as createSpinner4 } from "nanospinner";
|
|
|
1708
1685
|
import fetch4 from "node-fetch";
|
|
1709
1686
|
import open2 from "open";
|
|
1710
1687
|
import tmp2 from "tmp";
|
|
1711
|
-
import { z as
|
|
1688
|
+
import { z as z31 } from "zod";
|
|
1712
1689
|
|
|
1713
1690
|
// src/features/analysis/add_fix_comments_for_pr/add_fix_comments_for_pr.ts
|
|
1714
1691
|
import Debug8 from "debug";
|
|
@@ -7822,15 +7799,29 @@ import Debug12 from "debug";
|
|
|
7822
7799
|
import { globby } from "globby";
|
|
7823
7800
|
import { isBinary } from "istextorbinary";
|
|
7824
7801
|
import { simpleGit as simpleGit3 } from "simple-git";
|
|
7802
|
+
import { parseStringPromise } from "xml2js";
|
|
7803
|
+
import { z as z30 } from "zod";
|
|
7825
7804
|
var debug12 = Debug12("mobbdev:pack");
|
|
7826
7805
|
var MAX_FILE_SIZE = 1024 * 1024 * 5;
|
|
7806
|
+
var FPR_SOURCE_CODE_FILE_MAPPING_SCHEMA = z30.object({
|
|
7807
|
+
properties: z30.object({
|
|
7808
|
+
entry: z30.array(
|
|
7809
|
+
z30.object({
|
|
7810
|
+
_: z30.string(),
|
|
7811
|
+
$: z30.object({
|
|
7812
|
+
key: z30.string()
|
|
7813
|
+
})
|
|
7814
|
+
})
|
|
7815
|
+
)
|
|
7816
|
+
})
|
|
7817
|
+
});
|
|
7827
7818
|
function endsWithAny(str, suffixes) {
|
|
7828
7819
|
return suffixes.some(function(suffix) {
|
|
7829
7820
|
return str.endsWith(suffix);
|
|
7830
7821
|
});
|
|
7831
7822
|
}
|
|
7832
7823
|
function _get_manifest_files_suffixes() {
|
|
7833
|
-
return ["package.json"];
|
|
7824
|
+
return ["package.json", "pom.xml"];
|
|
7834
7825
|
}
|
|
7835
7826
|
async function pack(srcDirPath, vulnFiles) {
|
|
7836
7827
|
debug12("pack folder %s", srcDirPath);
|
|
@@ -7891,6 +7882,25 @@ async function pack(srcDirPath, vulnFiles) {
|
|
|
7891
7882
|
debug12("get zip file buffer");
|
|
7892
7883
|
return zip.toBuffer();
|
|
7893
7884
|
}
|
|
7885
|
+
async function repackFpr(fprPath) {
|
|
7886
|
+
debug12("repack fpr file %s", fprPath);
|
|
7887
|
+
const zipIn = new AdmZip(fprPath);
|
|
7888
|
+
const zipOut = new AdmZip();
|
|
7889
|
+
const mappingXML = zipIn.readAsText("src-archive/index.xml", "utf-8");
|
|
7890
|
+
const filesMapping = FPR_SOURCE_CODE_FILE_MAPPING_SCHEMA.parse(
|
|
7891
|
+
await parseStringPromise(mappingXML)
|
|
7892
|
+
);
|
|
7893
|
+
for (const fileMapping of filesMapping.properties.entry) {
|
|
7894
|
+
const zipPath = fileMapping._;
|
|
7895
|
+
const realPath = fileMapping.$.key;
|
|
7896
|
+
const buf = zipIn.readFile(zipPath);
|
|
7897
|
+
if (buf) {
|
|
7898
|
+
zipOut.addFile(realPath, buf);
|
|
7899
|
+
}
|
|
7900
|
+
}
|
|
7901
|
+
debug12("get repacked zip file buffer");
|
|
7902
|
+
return zipOut.toBuffer();
|
|
7903
|
+
}
|
|
7894
7904
|
|
|
7895
7905
|
// src/features/analysis/prompts.ts
|
|
7896
7906
|
import inquirer from "inquirer";
|
|
@@ -8553,7 +8563,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8553
8563
|
spinner: mobbSpinner,
|
|
8554
8564
|
submitVulnerabilityReportVariables: {
|
|
8555
8565
|
fixReportId: reportUploadInfo.fixReportId,
|
|
8556
|
-
repoUrl:
|
|
8566
|
+
repoUrl: z31.string().parse(repo),
|
|
8557
8567
|
reference,
|
|
8558
8568
|
projectId,
|
|
8559
8569
|
vulnerabilityReportFileName: "report.json",
|
|
@@ -8666,9 +8676,16 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8666
8676
|
projectId,
|
|
8667
8677
|
command
|
|
8668
8678
|
});
|
|
8669
|
-
const
|
|
8679
|
+
const srcFileStatus = await fsPromises.lstat(srcPath);
|
|
8670
8680
|
const zippingSpinner = createSpinner5("\u{1F4E6} Zipping repo").start();
|
|
8671
|
-
|
|
8681
|
+
let zipBuffer;
|
|
8682
|
+
let gitInfo = { success: false };
|
|
8683
|
+
if (srcFileStatus.isFile() && path7.extname(srcPath).toLowerCase() === ".fpr") {
|
|
8684
|
+
zipBuffer = await repackFpr(srcPath);
|
|
8685
|
+
} else {
|
|
8686
|
+
gitInfo = await getGitInfo(srcPath);
|
|
8687
|
+
zipBuffer = await pack(srcPath, vulnFiles);
|
|
8688
|
+
}
|
|
8672
8689
|
zippingSpinner.success({ text: "\u{1F4E6} Zipping repo successful!" });
|
|
8673
8690
|
const uploadRepoSpinner = createSpinner5("\u{1F4C1} Uploading Repo").start();
|
|
8674
8691
|
try {
|
|
@@ -8699,9 +8716,9 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8699
8716
|
}
|
|
8700
8717
|
});
|
|
8701
8718
|
if (command === "review") {
|
|
8702
|
-
const params2 =
|
|
8703
|
-
repo:
|
|
8704
|
-
githubActionToken:
|
|
8719
|
+
const params2 = z31.object({
|
|
8720
|
+
repo: z31.string().url(),
|
|
8721
|
+
githubActionToken: z31.string()
|
|
8705
8722
|
}).parse({ repo, githubActionToken });
|
|
8706
8723
|
const scm = await createScmLib(
|
|
8707
8724
|
{
|
|
@@ -8723,7 +8740,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8723
8740
|
analysisId,
|
|
8724
8741
|
gqlClient,
|
|
8725
8742
|
scm,
|
|
8726
|
-
scanner:
|
|
8743
|
+
scanner: z31.nativeEnum(SCANNERS).parse(scanner)
|
|
8727
8744
|
});
|
|
8728
8745
|
},
|
|
8729
8746
|
callbackStates: ["Finished" /* Finished */]
|
|
@@ -9106,7 +9123,7 @@ var scmTokenOption = {
|
|
|
9106
9123
|
// src/args/validation.ts
|
|
9107
9124
|
import chalk7 from "chalk";
|
|
9108
9125
|
import path8 from "path";
|
|
9109
|
-
import { z as
|
|
9126
|
+
import { z as z32 } from "zod";
|
|
9110
9127
|
function throwRepoUrlErrorMessage({
|
|
9111
9128
|
error,
|
|
9112
9129
|
repoUrl,
|
|
@@ -9123,11 +9140,11 @@ Example:
|
|
|
9123
9140
|
)}`;
|
|
9124
9141
|
throw new CliError(formattedErrorMessage);
|
|
9125
9142
|
}
|
|
9126
|
-
var UrlZ =
|
|
9143
|
+
var UrlZ = z32.string({
|
|
9127
9144
|
invalid_type_error: `is not a valid ${Object.values(ScmType).join("/ ")} URL`
|
|
9128
9145
|
});
|
|
9129
9146
|
function validateOrganizationId(organizationId) {
|
|
9130
|
-
const orgIdValidation =
|
|
9147
|
+
const orgIdValidation = z32.string().uuid().nullish().safeParse(organizationId);
|
|
9131
9148
|
if (!orgIdValidation.success) {
|
|
9132
9149
|
throw new CliError(`organizationId: ${organizationId} is not a valid UUID`);
|
|
9133
9150
|
}
|
|
@@ -9174,7 +9191,7 @@ function analyzeBuilder(yargs2) {
|
|
|
9174
9191
|
}).option("repo", repoOption).option("p", {
|
|
9175
9192
|
alias: "src-path",
|
|
9176
9193
|
describe: chalk8.bold(
|
|
9177
|
-
"Path to the repository folder with the source code"
|
|
9194
|
+
"Path to the repository folder with the source code; alternatively, you can specify the Fortify FPR file to extract source code out of it"
|
|
9178
9195
|
),
|
|
9179
9196
|
type: "string"
|
|
9180
9197
|
}).option("ref", refOption).option("ch", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobbdev",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "Automated secure code remediation tool",
|
|
5
5
|
"repository": "git+https://github.com/mobb-dev/bugsy.git",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"undici": "6.21.1",
|
|
71
71
|
"uuid": "11.1.0",
|
|
72
72
|
"ws": "8.18.0",
|
|
73
|
+
"xml2js": "0.6.2",
|
|
73
74
|
"yargs": "17.7.2",
|
|
74
75
|
"zod": "3.24.2"
|
|
75
76
|
},
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
"@types/tmp": "0.2.6",
|
|
90
91
|
"@types/uuid": "10.0.0",
|
|
91
92
|
"@types/ws": "8.5.14",
|
|
93
|
+
"@types/xml2js": "0.4.14",
|
|
92
94
|
"@types/yargs": "17.0.33",
|
|
93
95
|
"@typescript-eslint/eslint-plugin": "7.17.0",
|
|
94
96
|
"@typescript-eslint/parser": "7.17.0",
|