mobbdev 1.0.185 → 1.0.188

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 +103 -37
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1692,6 +1692,7 @@ var IssueType_Enum = /* @__PURE__ */ ((IssueType_Enum2) => {
1692
1692
  IssueType_Enum2["DeclareVariableExplicitly"] = "DECLARE_VARIABLE_EXPLICITLY";
1693
1693
  IssueType_Enum2["DefaultRightsInObjDefinition"] = "DEFAULT_RIGHTS_IN_OBJ_DEFINITION";
1694
1694
  IssueType_Enum2["DeprecatedFunction"] = "DEPRECATED_FUNCTION";
1695
+ IssueType_Enum2["DjangoBlankFieldNeedsNullOrDefault"] = "DJANGO_BLANK_FIELD_NEEDS_NULL_OR_DEFAULT";
1695
1696
  IssueType_Enum2["DosStringBuilder"] = "DOS_STRING_BUILDER";
1696
1697
  IssueType_Enum2["DoNotRaiseException"] = "DO_NOT_RAISE_EXCEPTION";
1697
1698
  IssueType_Enum2["DoNotThrowGenericException"] = "DO_NOT_THROW_GENERIC_EXCEPTION";
@@ -1765,6 +1766,7 @@ var IssueType_Enum = /* @__PURE__ */ ((IssueType_Enum2) => {
1765
1766
  IssueType_Enum2["Pt"] = "PT";
1766
1767
  IssueType_Enum2["RaceConditionFormatFlaw"] = "RACE_CONDITION_FORMAT_FLAW";
1767
1768
  IssueType_Enum2["Redos"] = "REDOS";
1769
+ IssueType_Enum2["RedundantNilErrorCheck"] = "REDUNDANT_NIL_ERROR_CHECK";
1768
1770
  IssueType_Enum2["RegexInjection"] = "REGEX_INJECTION";
1769
1771
  IssueType_Enum2["RegexMissingTimeout"] = "REGEX_MISSING_TIMEOUT";
1770
1772
  IssueType_Enum2["RequestParametersBoundViaInput"] = "REQUEST_PARAMETERS_BOUND_VIA_INPUT";
@@ -2916,7 +2918,9 @@ var fixDetailsData = {
2916
2918
  ["FUNCTION_CALL_WITHOUT_PARENTHESES" /* FunctionCallWithoutParentheses */]: void 0,
2917
2919
  ["SPRING_DEFAULT_PERMIT" /* SpringDefaultPermit */]: void 0,
2918
2920
  ["RETURN_IN_INIT" /* ReturnInInit */]: void 0,
2919
- ["ACTION_NOT_PINNED_TO_COMMIT_SHA" /* ActionNotPinnedToCommitSha */]: void 0
2921
+ ["ACTION_NOT_PINNED_TO_COMMIT_SHA" /* ActionNotPinnedToCommitSha */]: void 0,
2922
+ ["DJANGO_BLANK_FIELD_NEEDS_NULL_OR_DEFAULT" /* DjangoBlankFieldNeedsNullOrDefault */]: void 0,
2923
+ ["REDUNDANT_NIL_ERROR_CHECK" /* RedundantNilErrorCheck */]: void 0
2920
2924
  };
2921
2925
 
2922
2926
  // src/features/analysis/scm/shared/src/getIssueType.ts
@@ -3054,7 +3058,9 @@ var issueTypeMap = {
3054
3058
  ["FUNCTION_CALL_WITHOUT_PARENTHESES" /* FunctionCallWithoutParentheses */]: "Function Call Without Parentheses",
3055
3059
  ["SPRING_DEFAULT_PERMIT" /* SpringDefaultPermit */]: "Spring Default Permit",
3056
3060
  ["RETURN_IN_INIT" /* ReturnInInit */]: "Return in Init",
3057
- ["ACTION_NOT_PINNED_TO_COMMIT_SHA" /* ActionNotPinnedToCommitSha */]: "Action Not Pinned to Commit Sha"
3061
+ ["ACTION_NOT_PINNED_TO_COMMIT_SHA" /* ActionNotPinnedToCommitSha */]: "Action Not Pinned to Commit Sha",
3062
+ ["DJANGO_BLANK_FIELD_NEEDS_NULL_OR_DEFAULT" /* DjangoBlankFieldNeedsNullOrDefault */]: "Django Blank Field Needs Null or Default",
3063
+ ["REDUNDANT_NIL_ERROR_CHECK" /* RedundantNilErrorCheck */]: "Redundant Nil Error Check"
3058
3064
  };
3059
3065
  var issueTypeZ = z.nativeEnum(IssueType_Enum);
3060
3066
  var getIssueTypeFriendlyString = (issueType) => {
@@ -5409,9 +5415,7 @@ var VulnerabilityReportIssueZ = BaseVulnerabilityReportIssueZ.merge(
5409
5415
  );
5410
5416
  var VulnerabilityReportIssueWithCodeFilePathZ = BaseVulnerabilityReportIssueZ.merge(
5411
5417
  z11.object({
5412
- codeFilePath: z11.string().nullable(),
5413
- //TODO: REMOVE THIS once we flush out all the reports that don't have codeFilePath
5414
- codeNodes: z11.array(z11.object({ path: z11.string() }))
5418
+ codeFilePath: z11.string().nullable()
5415
5419
  })
5416
5420
  );
5417
5421
  var GetReportIssuesQueryZ = z11.object({
@@ -7619,14 +7623,38 @@ function getOctoKit(options) {
7619
7623
  //to debug the performance of these API calls.
7620
7624
  log: GITHUB_API_TOKEN ? console : void 0,
7621
7625
  request: {
7622
- fetch: getFetch(baseUrl)
7623
- },
7624
- retry: {
7625
- enabled: false
7626
+ fetch: getFetch(baseUrl),
7627
+ timeout: 1e4
7628
+ // 10 second timeout
7626
7629
  },
7627
- throttle: {
7628
- enabled: false
7629
- }
7630
+ retry: options?.isEnableRetries ? {
7631
+ doNotRetry: [400, 401, 403, 404, 422],
7632
+ // Don't retry on these status codes
7633
+ retries: 3
7634
+ // Retry up to 3 times
7635
+ } : { enabled: false },
7636
+ throttle: options?.isEnableRetries ? {
7637
+ onRateLimit: (retryAfter, options2, octokit, retryCount) => {
7638
+ octokit.log.warn(
7639
+ `Request quota exhausted for request ${options2.method} ${options2.url}`
7640
+ );
7641
+ if (retryCount === 0) {
7642
+ octokit.log.info(`Retrying after ${retryAfter} seconds!`);
7643
+ return true;
7644
+ }
7645
+ return false;
7646
+ },
7647
+ onSecondaryRateLimit: (retryAfter, options2, octokit, retryCount) => {
7648
+ octokit.log.warn(
7649
+ `SecondaryRateLimit detected for request ${options2.method} ${options2.url}`
7650
+ );
7651
+ if (retryCount === 0) {
7652
+ octokit.log.info(`Retrying after ${retryAfter} seconds!`);
7653
+ return true;
7654
+ }
7655
+ return false;
7656
+ }
7657
+ } : { enabled: false }
7630
7658
  });
7631
7659
  }
7632
7660
  function isGithubActionActionToken(token) {
@@ -12373,6 +12401,12 @@ var WorkspaceService = class {
12373
12401
  static getKnownWorkspacePath() {
12374
12402
  return this.knownWorkspacePath;
12375
12403
  }
12404
+ /**
12405
+ * Clears the known workspace path cache
12406
+ */
12407
+ static clearKnownWorkspacePath() {
12408
+ this.knownWorkspacePath = void 0;
12409
+ }
12376
12410
  /**
12377
12411
  * Gets the workspace folder path from known path or environment variables
12378
12412
  * @returns The workspace folder path or undefined if none found
@@ -13883,6 +13917,7 @@ var McpServer = class {
13883
13917
  __publicField(this, "eventHandlers", /* @__PURE__ */ new Map());
13884
13918
  __publicField(this, "parentProcessCheckInterval");
13885
13919
  __publicField(this, "parentPid");
13920
+ __publicField(this, "socketEventHandlers", /* @__PURE__ */ new Map());
13886
13921
  __publicField(this, "mcpUsageService");
13887
13922
  this.parentPid = process.ppid;
13888
13923
  this.mcpUsageService = govOrgId ? new McpUsageService(govOrgId) : null;
@@ -14003,31 +14038,43 @@ var McpServer = class {
14003
14038
  logInfo("Setting up parent process monitoring", {
14004
14039
  parentPid: this.parentPid
14005
14040
  });
14006
- process.stdin.on("close", async () => {
14041
+ const stdinCloseHandler = async () => {
14007
14042
  logDebug("stdin closed - parent likely terminated");
14008
14043
  await this.handleParentProcessDeath("stdin-close");
14009
- });
14010
- process.stdin.on("end", async () => {
14044
+ };
14045
+ const stdinEndHandler = async () => {
14011
14046
  logDebug("stdin ended - parent likely terminated");
14012
14047
  await this.handleParentProcessDeath("stdin-end");
14013
- });
14014
- process.stdout.on("error", async (error) => {
14048
+ };
14049
+ const stdoutErrorHandler = async (...args) => {
14050
+ const error = args[0];
14015
14051
  logWarn("stdout error - parent may have terminated", { error });
14016
14052
  if (error.message.includes("EPIPE") || error.message.includes("ECONNRESET")) {
14017
14053
  await this.handleParentProcessDeath("stdout-error");
14018
14054
  }
14019
- });
14020
- process.stderr.on("error", async (error) => {
14055
+ };
14056
+ const stderrErrorHandler = async (...args) => {
14057
+ const error = args[0];
14021
14058
  logWarn("stderr error - parent may have terminated", { error });
14022
14059
  if (error.message.includes("EPIPE") || error.message.includes("ECONNRESET")) {
14023
14060
  await this.handleParentProcessDeath("stderr-error");
14024
14061
  }
14025
- });
14062
+ };
14063
+ const disconnectHandler = async () => {
14064
+ logDebug("IPC disconnected - parent terminated");
14065
+ await this.handleParentProcessDeath("ipc-disconnect");
14066
+ };
14067
+ this.socketEventHandlers.set("stdin-close", stdinCloseHandler);
14068
+ this.socketEventHandlers.set("stdin-end", stdinEndHandler);
14069
+ this.socketEventHandlers.set("stdout-error", stdoutErrorHandler);
14070
+ this.socketEventHandlers.set("stderr-error", stderrErrorHandler);
14071
+ this.socketEventHandlers.set("disconnect", disconnectHandler);
14072
+ process.stdin.on("close", stdinCloseHandler);
14073
+ process.stdin.on("end", stdinEndHandler);
14074
+ process.stdout.on("error", stdoutErrorHandler);
14075
+ process.stderr.on("error", stderrErrorHandler);
14026
14076
  if (process.send) {
14027
- process.on("disconnect", async () => {
14028
- logDebug("IPC disconnected - parent terminated");
14029
- await this.handleParentProcessDeath("ipc-disconnect");
14030
- });
14077
+ process.on("disconnect", disconnectHandler);
14031
14078
  logDebug("IPC monitoring enabled");
14032
14079
  } else {
14033
14080
  logDebug("IPC not available - skipping IPC monitoring");
@@ -14094,6 +14141,7 @@ var McpServer = class {
14094
14141
  logError("Failed to connect to the API, skipping background scan");
14095
14142
  return;
14096
14143
  }
14144
+ WorkspaceService.clearKnownWorkspacePath();
14097
14145
  const workspacePath = WorkspaceService.getWorkspaceFolderPath();
14098
14146
  if (workspacePath) {
14099
14147
  try {
@@ -14250,6 +14298,31 @@ var McpServer = class {
14250
14298
  this.parentProcessCheckInterval = void 0;
14251
14299
  logDebug("Parent process check interval cleared");
14252
14300
  }
14301
+ this.socketEventHandlers.forEach((handler, eventType) => {
14302
+ try {
14303
+ switch (eventType) {
14304
+ case "stdin-close":
14305
+ process.stdin.removeListener("close", handler);
14306
+ break;
14307
+ case "stdin-end":
14308
+ process.stdin.removeListener("end", handler);
14309
+ break;
14310
+ case "stdout-error":
14311
+ process.stdout.removeListener("error", handler);
14312
+ break;
14313
+ case "stderr-error":
14314
+ process.stderr.removeListener("error", handler);
14315
+ break;
14316
+ case "disconnect":
14317
+ process.removeListener("disconnect", handler);
14318
+ break;
14319
+ }
14320
+ } catch (error) {
14321
+ logWarn(`Failed to remove ${eventType} listener`, { error });
14322
+ }
14323
+ });
14324
+ this.socketEventHandlers.clear();
14325
+ logDebug("Socket event handlers cleaned up");
14253
14326
  this.eventHandlers.forEach((handler, signal) => {
14254
14327
  process.removeListener(signal, handler);
14255
14328
  });
@@ -15968,28 +16041,21 @@ var PatchApplicationService = class {
15968
16041
  let finalContent = content;
15969
16042
  if (MCP_AUTO_FIX_DEBUG_MODE) {
15970
16043
  const fixType = fix.safeIssueType || "Security Issue";
15971
- let fixLink;
15972
- if (fix.fixUrl) {
15973
- fixLink = fix.fixUrl;
15974
- } else {
15975
- const apiUrl = process.env["API_URL"] || MCP_DEFAULT_API_URL;
15976
- const appBaseUrl = apiUrl.replace("/v1/graphql", "").replace("api.", "");
15977
- fixLink = `${appBaseUrl}/fixes/${fix.id}`;
15978
- }
15979
16044
  const commentPrefix = this.getCommentSyntax(filePath);
15980
16045
  const lines = content.split("\n");
15981
16046
  const lastLine = lines[lines.length - 1]?.trim() || "";
15982
16047
  const isMobbComment = lastLine.includes("Mobb security fix applied:");
15983
16048
  const spacing = isMobbComment ? "\n" : "\n\n";
16049
+ const fixComment = `Mobb security fix applied: ${fixType} ${fix.fixUrl || ""}`;
15984
16050
  let comment;
15985
16051
  if (commentPrefix === "<!--") {
15986
- comment = `${spacing}<!-- Mobb security fix applied: ${fixType} ${fixLink} -->`;
16052
+ comment = `${spacing}<!-- ${fixComment} -->`;
15987
16053
  } else if (commentPrefix === "/*") {
15988
- comment = `${spacing}/* Mobb security fix applied: ${fixType} ${fixLink} */`;
16054
+ comment = `${spacing}/* ${fixComment} */`;
15989
16055
  } else if (commentPrefix === "(*") {
15990
- comment = `${spacing}(* Mobb security fix applied: ${fixType} ${fixLink} *)`;
16056
+ comment = `${spacing}(* ${fixComment} *)`;
15991
16057
  } else {
15992
- comment = `${spacing}${commentPrefix} Mobb security fix applied: ${fixType} ${fixLink}`;
16058
+ comment = `${spacing}${commentPrefix} ${fixComment}`;
15993
16059
  }
15994
16060
  finalContent = content + comment;
15995
16061
  logInfo(
@@ -15997,7 +16063,7 @@ var PatchApplicationService = class {
15997
16063
  {
15998
16064
  fixId: fix.id,
15999
16065
  fixType,
16000
- fixLink,
16066
+ fixLink: fix.fixUrl,
16001
16067
  commentSyntax: commentPrefix,
16002
16068
  spacing: isMobbComment ? "single line" : "empty line above"
16003
16069
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.0.185",
3
+ "version": "1.0.188",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.mjs",