mobbdev 0.0.169 → 0.0.170

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 +64 -31
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -188,14 +188,14 @@ var Project_Role_Type_Enum = /* @__PURE__ */ ((Project_Role_Type_Enum2) => {
188
188
  Project_Role_Type_Enum2["Writer"] = "writer";
189
189
  return Project_Role_Type_Enum2;
190
190
  })(Project_Role_Type_Enum || {});
191
- var Vulnerability_Report_Vendor_Enum = /* @__PURE__ */ ((Vulnerability_Report_Vendor_Enum3) => {
192
- Vulnerability_Report_Vendor_Enum3["Checkmarx"] = "checkmarx";
193
- Vulnerability_Report_Vendor_Enum3["CheckmarxXml"] = "checkmarxXml";
194
- Vulnerability_Report_Vendor_Enum3["Codeql"] = "codeql";
195
- Vulnerability_Report_Vendor_Enum3["Fortify"] = "fortify";
196
- Vulnerability_Report_Vendor_Enum3["Snyk"] = "snyk";
197
- Vulnerability_Report_Vendor_Enum3["Sonarqube"] = "sonarqube";
198
- return Vulnerability_Report_Vendor_Enum3;
191
+ var Vulnerability_Report_Vendor_Enum = /* @__PURE__ */ ((Vulnerability_Report_Vendor_Enum4) => {
192
+ Vulnerability_Report_Vendor_Enum4["Checkmarx"] = "checkmarx";
193
+ Vulnerability_Report_Vendor_Enum4["CheckmarxXml"] = "checkmarxXml";
194
+ Vulnerability_Report_Vendor_Enum4["Codeql"] = "codeql";
195
+ Vulnerability_Report_Vendor_Enum4["Fortify"] = "fortify";
196
+ Vulnerability_Report_Vendor_Enum4["Snyk"] = "snyk";
197
+ Vulnerability_Report_Vendor_Enum4["Sonarqube"] = "sonarqube";
198
+ return Vulnerability_Report_Vendor_Enum4;
199
199
  })(Vulnerability_Report_Vendor_Enum || {});
200
200
  var Vulnerability_Severity_Enum = /* @__PURE__ */ ((Vulnerability_Severity_Enum2) => {
201
201
  Vulnerability_Severity_Enum2["Critical"] = "critical";
@@ -308,7 +308,7 @@ var GetAnalsyisDocument = `
308
308
  var GetFixesDocument = `
309
309
  query getFixes($filters: fix_bool_exp!) {
310
310
  fixes: fix(where: $filters) {
311
- issueType
311
+ safeIssueType
312
312
  id
313
313
  vulnerabilitySeverity
314
314
  issueLanguage
@@ -738,7 +738,7 @@ var ReportQueryResultZ = z.object({
738
738
  z.object({
739
739
  id: z.string().uuid(),
740
740
  issueLanguage: z.nativeEnum(IssueLanguage_Enum).nullable(),
741
- issueType: z.nativeEnum(IssueType_Enum).nullable(),
741
+ safeIssueType: z.string(),
742
742
  confidence: z.number(),
743
743
  effortToApplyFix: z.nativeEnum(Effort_To_Apply_Fix_Enum).nullable(),
744
744
  modifiedBy: z.string().nullable(),
@@ -833,7 +833,7 @@ var ReportFixesQueryZ = z.array(
833
833
  gitBlameLogin: z.string().nullable(),
834
834
  effortToApplyFix: z.nativeEnum(Effort_To_Apply_Fix_Enum).nullable(),
835
835
  issueLanguage: z.nativeEnum(IssueLanguage_Enum).nullable(),
836
- issueType: z.nativeEnum(IssueType_Enum).nullable(),
836
+ safeIssueType: z.string(),
837
837
  vulnerabilitySeverity: z.nativeEnum(Vulnerability_Severity_Enum).nullable().transform((i) => i ?? "low" /* Low */),
838
838
  fixReportId: z.string().uuid(),
839
839
  filePaths: z.array(
@@ -903,7 +903,8 @@ var FixQueryZ = z.object({
903
903
  modifiedBy: z.string().nullable(),
904
904
  gitBlameLogin: z.string().nullable(),
905
905
  issueLanguage: z.nativeEnum(IssueLanguage_Enum).nullable(),
906
- issueType: z.nativeEnum(IssueType_Enum).nullable(),
906
+ safeIssueType: z.string(),
907
+ // issueType: z.nativeEnum(IssueType_Enum).nullable(),
907
908
  confidence: z.number(),
908
909
  fixReportId: z.string().uuid(),
909
910
  isExpired: z.boolean().default(false),
@@ -919,7 +920,6 @@ var FixQueryZ = z.object({
919
920
  vulnerabilityReportIssues: z.array(
920
921
  z.object({
921
922
  vendorIssueId: z.string(),
922
- issueType: z.string(),
923
923
  issueLanguage: z.string()
924
924
  })
925
925
  ),
@@ -990,7 +990,17 @@ var FixScreenQueryResultZ = z.object({
990
990
  }).array()
991
991
  })
992
992
  }),
993
- fix_by_pk: FixQueryZ,
993
+ fix_by_pk: FixQueryZ.merge(
994
+ z.object({
995
+ vulnerabilityReportIssues: z.array(
996
+ z.object({
997
+ vendorIssueId: z.string(),
998
+ issueType: z.string(),
999
+ issueLanguage: z.string()
1000
+ })
1001
+ )
1002
+ })
1003
+ ),
994
1004
  fixesWithSameIssueType: z.object({
995
1005
  fix: z.array(z.object({ id: z.string().uuid() }))
996
1006
  })
@@ -1608,7 +1618,7 @@ var issueTypeMap = {
1608
1618
  ["AUTO_ESCAPE_FALSE" /* AutoEscapeFalse */]: "Auto-escape False"
1609
1619
  };
1610
1620
  var issueTypeZ = z4.nativeEnum(IssueType_Enum);
1611
- var getIssueType = (issueType) => {
1621
+ var getIssueTypeFriendlyString = (issueType) => {
1612
1622
  const issueTypeZParseRes = issueTypeZ.safeParse(issueType);
1613
1623
  if (!issueTypeZParseRes.success) {
1614
1624
  return issueType ? issueType.replaceAll("_", " ") : "Other";
@@ -1643,7 +1653,7 @@ var getCommitDescription = ({
1643
1653
  if (!staticData) {
1644
1654
  return "";
1645
1655
  }
1646
- const issueTypeString = getIssueType(issueType);
1656
+ const issueTypeString = getIssueTypeFriendlyString(issueType);
1647
1657
  let description = `This change fixes a **${severity} severity** (${severityToEmoji[severity]}) **${issueTypeString}** issue reported by **${capitalizeFirstLetter(
1648
1658
  vendor
1649
1659
  )}**.
@@ -2941,12 +2951,20 @@ function getFixGuidances({
2941
2951
  const fixGuidance = storeFixResult.success ? [storeFixResult.data.guidance({ questions, ...extraContext })] : [];
2942
2952
  return libGuidances.concat(fixGuidance).filter((guidance) => !!guidance);
2943
2953
  }
2944
- function getGuidances({
2945
- questions,
2946
- issueType,
2947
- issueLanguage,
2948
- fixExtraContext
2949
- }) {
2954
+ var IssueTypeAndLanguageZ = z8.object({
2955
+ issueType: z8.nativeEnum(IssueType_Enum),
2956
+ issueLanguage: z8.nativeEnum(IssueLanguage_Enum)
2957
+ });
2958
+ function getGuidances(args) {
2959
+ const safeIssueTypeAndLanguage = IssueTypeAndLanguageZ.safeParse({
2960
+ issueType: args.issueType,
2961
+ issueLanguage: args.issueLanguage
2962
+ });
2963
+ if (!safeIssueTypeAndLanguage.success) {
2964
+ return [];
2965
+ }
2966
+ const { questions, fixExtraContext } = args;
2967
+ const { issueType, issueLanguage } = safeIssueTypeAndLanguage.data;
2950
2968
  const fixGuidances = getFixGuidances({
2951
2969
  issueType,
2952
2970
  issueLanguage,
@@ -2957,8 +2975,8 @@ function getGuidances({
2957
2975
  let questionGuidance = question.guidance;
2958
2976
  if (!questionGuidance && issueType && issueLanguage) {
2959
2977
  const getFixInformation = curriedQuestionInformationByQuestion({
2960
- issueType: z8.nativeEnum(IssueType_Enum).parse(issueType),
2961
- language: z8.nativeEnum(IssueLanguage_Enum).parse(issueLanguage)
2978
+ issueType,
2979
+ language: issueLanguage
2962
2980
  });
2963
2981
  const { guidance } = getFixInformation(question);
2964
2982
  questionGuidance = guidance({
@@ -5819,10 +5837,12 @@ async function getAdoSdk(params) {
5819
5837
  try {
5820
5838
  const branchStatus = await git.getBranch(repo, branch, projectName);
5821
5839
  if (!branchStatus || !branchStatus.commit) {
5840
+ console.log(`no branch status: ${JSON.stringify(branchStatus)}`);
5822
5841
  throw new InvalidRepoUrlError("no branch status");
5823
5842
  }
5824
5843
  return branchStatus.name === branch;
5825
5844
  } catch (e) {
5845
+ console.error(`error in getAdoIsRemoteBranch: ${JSON.stringify(e)}`);
5826
5846
  return false;
5827
5847
  }
5828
5848
  },
@@ -6252,20 +6272,33 @@ Refresh the page in order to see the changes.`,
6252
6272
  redirectUrl: commentRes.data.html_url,
6253
6273
  commentId
6254
6274
  });
6255
- const issueType = getIssueType(fix.issueType ?? null);
6275
+ const issueType = getIssueTypeFriendlyString(fix.safeIssueType);
6256
6276
  const title = `# ${MobbIconMarkdown} ${issueType} fix is ready`;
6257
6277
  const patchAndQuestions = await PatchAndQuestionsZ.parseAsync(
6258
6278
  fix.patchAndQuestions
6259
6279
  );
6280
+ const validFixParseRes = z18.object({
6281
+ vulnerabilitySeverity: z18.nativeEnum(Vulnerability_Severity_Enum),
6282
+ issueLanguage: z18.nativeEnum(IssueLanguage_Enum),
6283
+ safeIssueType: z18.nativeEnum(IssueType_Enum)
6284
+ }).safeParse(fix);
6285
+ if (!validFixParseRes.success) {
6286
+ debug5(
6287
+ `fix ${fixId} does not have all the required fields to create a comment`,
6288
+ validFixParseRes.error
6289
+ );
6290
+ return;
6291
+ }
6292
+ const validFix = validFixParseRes.data;
6260
6293
  const subTitle = getCommitDescription({
6261
- issueType: fix.issueType,
6294
+ issueType: validFix.safeIssueType,
6262
6295
  vendor: scanner,
6263
- severity: fix.vulnerabilitySeverity,
6264
- issueLanguage: fix.issueLanguage,
6296
+ severity: validFix.vulnerabilitySeverity,
6297
+ issueLanguage: validFix.issueLanguage,
6265
6298
  guidances: getGuidances({
6266
6299
  questions: patchAndQuestions.questions.map(toQuestion),
6267
- issueType: fix.issueType,
6268
- issueLanguage: fix.issueLanguage,
6300
+ issueType: validFix.safeIssueType,
6301
+ issueLanguage: validFix.issueLanguage,
6269
6302
  fixExtraContext: patchAndQuestions.extraContext
6270
6303
  })
6271
6304
  });
@@ -6297,7 +6330,7 @@ function buildAnalysisSummaryComment(params) {
6297
6330
  if (!fix) {
6298
6331
  throw new Error(`fix ${vulnerabilityReportIssue.fixId} not found`);
6299
6332
  }
6300
- const issueType = getIssueType(fix.issueType ?? null);
6333
+ const issueType = getIssueTypeFriendlyString(fix.safeIssueType);
6301
6334
  const vulnerabilityReportIssueCount = (result[issueType] || 0) + 1;
6302
6335
  return {
6303
6336
  ...result,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.169",
3
+ "version": "0.0.170",
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",