isomorphic-git 1.37.4 → 1.37.5

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
@@ -8,6 +8,7 @@ var AsyncLock = _interopDefault(require('async-lock'));
8
8
  var Hash = _interopDefault(require('sha.js/sha1.js'));
9
9
  var crc32 = _interopDefault(require('crc-32'));
10
10
  var pako = _interopDefault(require('pako'));
11
+ var crypto$1 = require('crypto');
11
12
  var pify = _interopDefault(require('pify'));
12
13
  var ignore = _interopDefault(require('ignore'));
13
14
  var cleanGitRef = _interopDefault(require('clean-git-ref'));
@@ -3368,6 +3369,19 @@ function readPackIndex({
3368
3369
  return p
3369
3370
  }
3370
3371
 
3372
+ const SHA1_CHUNK_SIZE = 8 * 1024 * 1024;
3373
+
3374
+ async function shasumRange(
3375
+ buffer,
3376
+ { start = 0, end = buffer.length } = {}
3377
+ ) {
3378
+ const hash = crypto$1.createHash('sha1');
3379
+ for (let i = start; i < end; i += SHA1_CHUNK_SIZE) {
3380
+ hash.update(buffer.subarray(i, Math.min(i + SHA1_CHUNK_SIZE, end)));
3381
+ }
3382
+ return hash.digest('hex')
3383
+ }
3384
+
3371
3385
  async function readObjectPacked({
3372
3386
  fs,
3373
3387
  cache,
@@ -3421,11 +3435,12 @@ async function readObjectPacked({
3421
3435
  )
3422
3436
  }
3423
3437
 
3424
- // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload
3425
- // This ensures true data integrity by verifying the entire packfile content
3426
- // Use subarray for zero-copy reading of large files
3427
- const payload = pack.subarray(0, -20);
3428
- const actualPayloadSha = await shasum(payload);
3438
+ // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3439
+ // The Node package build swaps in a chunked implementation for large packs.
3440
+ const actualPayloadSha = await shasumRange(pack, {
3441
+ start: 0,
3442
+ end: pack.length - 20,
3443
+ });
3429
3444
  if (actualPayloadSha !== expectedShaFromIndex) {
3430
3445
  throw new InternalError(
3431
3446
  `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
@@ -9311,8 +9326,8 @@ function filterCapabilities(server, client) {
9311
9326
 
9312
9327
  const pkg = {
9313
9328
  name: 'isomorphic-git',
9314
- version: '1.37.4',
9315
- agent: 'git/isomorphic-git@1.37.4',
9329
+ version: '1.37.5',
9330
+ agent: 'git/isomorphic-git@1.37.5',
9316
9331
  };
9317
9332
 
9318
9333
  class FIFO {
package/index.js CHANGED
@@ -3362,6 +3362,13 @@ function readPackIndex({
3362
3362
  return p
3363
3363
  }
3364
3364
 
3365
+ async function shasumRange(
3366
+ buffer,
3367
+ { start = 0, end = buffer.length } = {}
3368
+ ) {
3369
+ return shasum(buffer.subarray(start, end))
3370
+ }
3371
+
3365
3372
  async function readObjectPacked({
3366
3373
  fs,
3367
3374
  cache,
@@ -3415,11 +3422,12 @@ async function readObjectPacked({
3415
3422
  )
3416
3423
  }
3417
3424
 
3418
- // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload
3419
- // This ensures true data integrity by verifying the entire packfile content
3420
- // Use subarray for zero-copy reading of large files
3421
- const payload = pack.subarray(0, -20);
3422
- const actualPayloadSha = await shasum(payload);
3425
+ // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3426
+ // The Node package build swaps in a chunked implementation for large packs.
3427
+ const actualPayloadSha = await shasumRange(pack, {
3428
+ start: 0,
3429
+ end: pack.length - 20,
3430
+ });
3423
3431
  if (actualPayloadSha !== expectedShaFromIndex) {
3424
3432
  throw new InternalError(
3425
3433
  `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
@@ -9305,8 +9313,8 @@ function filterCapabilities(server, client) {
9305
9313
 
9306
9314
  const pkg = {
9307
9315
  name: 'isomorphic-git',
9308
- version: '1.37.4',
9309
- agent: 'git/isomorphic-git@1.37.4',
9316
+ version: '1.37.5',
9317
+ agent: 'git/isomorphic-git@1.37.5',
9310
9318
  };
9311
9319
 
9312
9320
  class FIFO {