mobbdev 1.1.2 → 1.1.3

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 +38 -17
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -19141,10 +19141,15 @@ var PatchApplicationService = class {
19141
19141
  */
19142
19142
  static writeFileWithFixComment({
19143
19143
  filePath,
19144
+ repositoryPath,
19144
19145
  content,
19145
19146
  fix,
19146
19147
  scanContext
19147
19148
  }) {
19149
+ const { normalizedPath: normalizedFilePath } = this.resolvePathWithinRepo({
19150
+ repositoryPath,
19151
+ targetPath: filePath
19152
+ });
19148
19153
  let finalContent = content;
19149
19154
  if (MCP_AUTO_FIX_DEBUG_MODE) {
19150
19155
  const fixType = fix.safeIssueType || "Security Issue";
@@ -19176,10 +19181,28 @@ var PatchApplicationService = class {
19176
19181
  }
19177
19182
  );
19178
19183
  }
19179
- const dirPath = path20.dirname(filePath);
19184
+ const dirPath = path20.dirname(normalizedFilePath);
19180
19185
  mkdirSync(dirPath, { recursive: true });
19181
- writeFileSync(filePath, finalContent, "utf8");
19182
- return filePath;
19186
+ writeFileSync(normalizedFilePath, finalContent, "utf8");
19187
+ return normalizedFilePath;
19188
+ }
19189
+ static resolvePathWithinRepo({
19190
+ repositoryPath,
19191
+ targetPath
19192
+ }) {
19193
+ const repoRoot = path20.resolve(repositoryPath);
19194
+ const normalizedPath = path20.resolve(repoRoot, targetPath);
19195
+ const repoRootWithSep = repoRoot.endsWith(path20.sep) ? repoRoot : `${repoRoot}${path20.sep}`;
19196
+ if (normalizedPath !== repoRoot && !normalizedPath.startsWith(repoRootWithSep)) {
19197
+ throw new Error(
19198
+ `Security violation: target path ${targetPath} resolves outside repository`
19199
+ );
19200
+ }
19201
+ return {
19202
+ repoRoot,
19203
+ normalizedPath,
19204
+ relativePath: path20.relative(repoRoot, normalizedPath)
19205
+ };
19183
19206
  }
19184
19207
  /**
19185
19208
  * Extracts target file path from a fix
@@ -19649,21 +19672,17 @@ var PatchApplicationService = class {
19649
19672
  repositoryPath,
19650
19673
  scanContext
19651
19674
  }) {
19652
- const sanitizedRepoPath = String(repositoryPath || "").replace("\0", "").replace(/^(\.\.(\/|\\))+/, "");
19653
- const sanitizedTargetFile = String(targetFile || "").replace("\0", "").replace(/^(\.\.(\/|\\))+/, "");
19654
- const absoluteFilePath = path20.resolve(
19655
- sanitizedRepoPath,
19656
- sanitizedTargetFile
19657
- );
19658
- const relativePath = path20.relative(sanitizedRepoPath, absoluteFilePath);
19659
- if (relativePath.startsWith("..")) {
19660
- throw new Error(
19661
- `Security violation: target file ${targetFile} resolves outside repository`
19662
- );
19663
- }
19675
+ const {
19676
+ repoRoot,
19677
+ normalizedPath: absoluteFilePath,
19678
+ relativePath
19679
+ } = this.resolvePathWithinRepo({
19680
+ repositoryPath,
19681
+ targetPath: targetFile
19682
+ });
19664
19683
  logDebug(`[${scanContext}] Resolving file path for ${targetFile}`, {
19665
- repositoryPath: sanitizedRepoPath,
19666
- targetFile: sanitizedTargetFile,
19684
+ repositoryPath: repoRoot,
19685
+ targetFile,
19667
19686
  absoluteFilePath,
19668
19687
  relativePath,
19669
19688
  exists: existsSync6(absoluteFilePath)
@@ -19685,6 +19704,7 @@ var PatchApplicationService = class {
19685
19704
  const newContent = this.applyHunksToEmptyFile(fileDiff.chunks);
19686
19705
  const actualPath = this.writeFileWithFixComment({
19687
19706
  filePath: absoluteFilePath,
19707
+ repositoryPath,
19688
19708
  content: newContent,
19689
19709
  fix,
19690
19710
  scanContext
@@ -19733,6 +19753,7 @@ var PatchApplicationService = class {
19733
19753
  if (modifiedContent !== originalContent) {
19734
19754
  const actualPath = this.writeFileWithFixComment({
19735
19755
  filePath: absoluteFilePath,
19756
+ repositoryPath,
19736
19757
  content: modifiedContent,
19737
19758
  fix,
19738
19759
  scanContext
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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",
@@ -75,7 +75,7 @@
75
75
  "http-proxy-agent": "7.0.2",
76
76
  "https-proxy-agent": "7.0.6",
77
77
  "ignore": "7.0.5",
78
- "inquirer": "9.3.7",
78
+ "inquirer": "9.3.8",
79
79
  "isomorphic-ws": "5.0.0",
80
80
  "istextorbinary": "9.5.0",
81
81
  "libsodium-wrappers": "0.7.15",