git-workspace-service 0.4.1 → 0.4.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.
package/dist/index.js CHANGED
@@ -617,7 +617,13 @@ var WorkspaceService = class {
617
617
  });
618
618
  }
619
619
  try {
620
- await fs3.rm(workspace.path, { recursive: true, force: true });
620
+ const realPath = await fs3.realpath(workspace.path);
621
+ const realBase = await fs3.realpath(this.baseDir);
622
+ if (!realPath.startsWith(realBase + path.sep) && realPath !== realBase) {
623
+ this.log("error", { workspaceId, realPath, realBase }, "Workspace path resolves outside baseDir \u2014 refusing to delete");
624
+ } else {
625
+ await fs3.rm(workspace.path, { recursive: true, force: true });
626
+ }
621
627
  } catch (error) {
622
628
  const errorMessage = error instanceof Error ? error.message : String(error);
623
629
  this.log("warn", { workspaceId, error: errorMessage }, "Failed to remove workspace directory");
@@ -650,6 +656,7 @@ var WorkspaceService = class {
650
656
  if (cloneUrl.startsWith("git@github.com:")) {
651
657
  cloneUrl = cloneUrl.replace("git@github.com:", "https://github.com/");
652
658
  }
659
+ cloneUrl = cloneUrl.replace(/\/+$/, "");
653
660
  if (!cloneUrl.endsWith(".git")) {
654
661
  cloneUrl = `${cloneUrl}.git`;
655
662
  }
@@ -784,6 +791,7 @@ var WorkspaceService = class {
784
791
  if (url.startsWith("git@github.com:")) {
785
792
  url = url.replace("git@github.com:", "https://github.com/");
786
793
  }
794
+ url = url.replace(/\/+$/, "");
787
795
  if (!url.endsWith(".git")) {
788
796
  url = `${url}.git`;
789
797
  }