isomorphic-git 1.38.7 → 1.38.8

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/index.cjs CHANGED
@@ -6890,23 +6890,11 @@ async function branch({
6890
6890
  }
6891
6891
  }
6892
6892
 
6893
- const worthWalking = (filepath, root) => {
6894
- if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6895
- return true
6896
- }
6897
- if (root.length >= filepath.length) {
6898
- return root.startsWith(filepath)
6899
- } else {
6900
- return filepath.startsWith(root)
6901
- }
6902
- };
6903
-
6904
- // @ts-check
6905
-
6906
6893
  /**
6907
- * Throw if any leading directory component of `fullpath` (relative to `dir`) is a symbolic
6908
- * link. git does not follow symlinks in the leading path when writing working-tree files;
6909
- * matching that avoids writing through a symlinked parent into a location outside `dir`.
6894
+ * Refuse to materialize a working-tree entry whose parent path traverses a
6895
+ * symbolic link. A leading component that is a symlink could otherwise redirect
6896
+ * a write or mkdir outside the working tree. git applies the same check: it does
6897
+ * not follow symlinks in the leading path when writing working-tree files.
6910
6898
  *
6911
6899
  * @param {import('../models/FileSystem.js').FileSystem} fs
6912
6900
  * @param {string} dir
@@ -6927,6 +6915,19 @@ async function assertNoSymlinkInLeadingPath(fs, dir, fullpath) {
6927
6915
  }
6928
6916
  }
6929
6917
 
6918
+ const worthWalking = (filepath, root) => {
6919
+ if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6920
+ return true
6921
+ }
6922
+ if (root.length >= filepath.length) {
6923
+ return root.startsWith(filepath)
6924
+ } else {
6925
+ return filepath.startsWith(root)
6926
+ }
6927
+ };
6928
+
6929
+ // @ts-check
6930
+
6930
6931
  /**
6931
6932
  * @param {object} args
6932
6933
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -8468,6 +8469,11 @@ async function applyTreeChanges({
8468
8469
  await fs.rmdir(currentFilepath);
8469
8470
  break
8470
8471
  case 'mkdir':
8472
+ // Don't mkdir through a symlinked leading path: a parent component that
8473
+ // is a symlink could otherwise redirect the directory creation outside
8474
+ // the working tree. git applies the same check (it does not follow
8475
+ // symlinks here) — see checkout.
8476
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8471
8477
  await fs.mkdir(currentFilepath);
8472
8478
  break
8473
8479
  case 'rm':
@@ -8480,6 +8486,10 @@ async function applyTreeChanges({
8480
8486
  currentFilepath.startsWith(removedDir)
8481
8487
  )
8482
8488
  ) {
8489
+ // Don't write through a symlinked leading path (see checkout): a
8490
+ // parent component that is a symlink could redirect the write to a
8491
+ // location outside the working tree.
8492
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8483
8493
  const { object } = await _readObject({
8484
8494
  fs,
8485
8495
  cache: {},
@@ -9488,8 +9498,8 @@ function filterCapabilities(server, client) {
9488
9498
 
9489
9499
  const pkg = {
9490
9500
  name: 'isomorphic-git',
9491
- version: '1.38.7',
9492
- agent: 'git/isomorphic-git@1.38.7',
9501
+ version: '1.38.8',
9502
+ agent: 'git/isomorphic-git@1.38.8',
9493
9503
  };
9494
9504
 
9495
9505
  class FIFO {
package/index.js CHANGED
@@ -6877,23 +6877,11 @@ async function branch({
6877
6877
  }
6878
6878
  }
6879
6879
 
6880
- const worthWalking = (filepath, root) => {
6881
- if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6882
- return true
6883
- }
6884
- if (root.length >= filepath.length) {
6885
- return root.startsWith(filepath)
6886
- } else {
6887
- return filepath.startsWith(root)
6888
- }
6889
- };
6890
-
6891
- // @ts-check
6892
-
6893
6880
  /**
6894
- * Throw if any leading directory component of `fullpath` (relative to `dir`) is a symbolic
6895
- * link. git does not follow symlinks in the leading path when writing working-tree files;
6896
- * matching that avoids writing through a symlinked parent into a location outside `dir`.
6881
+ * Refuse to materialize a working-tree entry whose parent path traverses a
6882
+ * symbolic link. A leading component that is a symlink could otherwise redirect
6883
+ * a write or mkdir outside the working tree. git applies the same check: it does
6884
+ * not follow symlinks in the leading path when writing working-tree files.
6897
6885
  *
6898
6886
  * @param {import('../models/FileSystem.js').FileSystem} fs
6899
6887
  * @param {string} dir
@@ -6914,6 +6902,19 @@ async function assertNoSymlinkInLeadingPath(fs, dir, fullpath) {
6914
6902
  }
6915
6903
  }
6916
6904
 
6905
+ const worthWalking = (filepath, root) => {
6906
+ if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6907
+ return true
6908
+ }
6909
+ if (root.length >= filepath.length) {
6910
+ return root.startsWith(filepath)
6911
+ } else {
6912
+ return filepath.startsWith(root)
6913
+ }
6914
+ };
6915
+
6916
+ // @ts-check
6917
+
6917
6918
  /**
6918
6919
  * @param {object} args
6919
6920
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -8455,6 +8456,11 @@ async function applyTreeChanges({
8455
8456
  await fs.rmdir(currentFilepath);
8456
8457
  break
8457
8458
  case 'mkdir':
8459
+ // Don't mkdir through a symlinked leading path: a parent component that
8460
+ // is a symlink could otherwise redirect the directory creation outside
8461
+ // the working tree. git applies the same check (it does not follow
8462
+ // symlinks here) — see checkout.
8463
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8458
8464
  await fs.mkdir(currentFilepath);
8459
8465
  break
8460
8466
  case 'rm':
@@ -8467,6 +8473,10 @@ async function applyTreeChanges({
8467
8473
  currentFilepath.startsWith(removedDir)
8468
8474
  )
8469
8475
  ) {
8476
+ // Don't write through a symlinked leading path (see checkout): a
8477
+ // parent component that is a symlink could redirect the write to a
8478
+ // location outside the working tree.
8479
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8470
8480
  const { object } = await _readObject({
8471
8481
  fs,
8472
8482
  cache: {},
@@ -9475,8 +9485,8 @@ function filterCapabilities(server, client) {
9475
9485
 
9476
9486
  const pkg = {
9477
9487
  name: 'isomorphic-git',
9478
- version: '1.38.7',
9479
- agent: 'git/isomorphic-git@1.38.7',
9488
+ version: '1.38.8',
9489
+ agent: 'git/isomorphic-git@1.38.8',
9480
9490
  };
9481
9491
 
9482
9492
  class FIFO {