isomorphic-git 1.43.1 → 1.43.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/README.md +4 -0
- package/index.cjs +36 -34
- package/index.js +36 -34
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +34 -32
- package/managers/index.js +34 -32
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/managers/index.cjs
CHANGED
|
@@ -403,8 +403,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
|
|
|
403
403
|
// variable name is alphanumeric (ASCII) with -
|
|
404
404
|
// variable name starts with an alphabetic character
|
|
405
405
|
// variable name is case insensitive
|
|
406
|
-
|
|
407
|
-
const
|
|
406
|
+
// whitespace (spaces or tabs) around the equal sign is ignored
|
|
407
|
+
const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
|
|
408
|
+
const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
408
409
|
|
|
409
410
|
// Comments start with either # or ; and extend to the end of line
|
|
410
411
|
const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
|
|
@@ -4527,37 +4528,12 @@ async function readObjectPacked({
|
|
|
4527
4528
|
}
|
|
4528
4529
|
|
|
4529
4530
|
// === Packfile Integrity Verification ===
|
|
4530
|
-
// Performance optimization:
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
// 1. Fast Check: Verify packfile trailer matches index record
|
|
4535
|
-
// Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
|
|
4536
|
-
const packTrailer = pack.subarray(-20);
|
|
4537
|
-
const packTrailerSha = Array.from(packTrailer)
|
|
4538
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
4539
|
-
.join('');
|
|
4540
|
-
if (packTrailerSha !== expectedShaFromIndex) {
|
|
4541
|
-
throw new InternalError(
|
|
4542
|
-
`Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
|
|
4543
|
-
)
|
|
4544
|
-
}
|
|
4545
|
-
|
|
4546
|
-
// 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
|
|
4547
|
-
// The Node package build swaps in a chunked implementation for large packs.
|
|
4548
|
-
const actualPayloadSha = await shasumRange(pack, {
|
|
4549
|
-
start: 0,
|
|
4550
|
-
end: pack.length - 20,
|
|
4551
|
-
});
|
|
4552
|
-
if (actualPayloadSha !== expectedShaFromIndex) {
|
|
4553
|
-
throw new InternalError(
|
|
4554
|
-
`Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
|
|
4555
|
-
)
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
// Mark as verified to prevent performance regression on subsequent reads
|
|
4559
|
-
p._checksumVerified = true;
|
|
4531
|
+
// Performance optimization: verify only once per packfile.
|
|
4532
|
+
// Concurrent reads share the same verification promise.
|
|
4533
|
+
if (!p._checksumVerification) {
|
|
4534
|
+
p._checksumVerification = verifyPackfile(pack, p.packfileSha);
|
|
4560
4535
|
}
|
|
4536
|
+
await p._checksumVerification;
|
|
4561
4537
|
|
|
4562
4538
|
const result = await p.read({ oid, getExternalRefDelta });
|
|
4563
4539
|
result.format = 'content';
|
|
@@ -4569,6 +4545,32 @@ async function readObjectPacked({
|
|
|
4569
4545
|
return null
|
|
4570
4546
|
}
|
|
4571
4547
|
|
|
4548
|
+
async function verifyPackfile(pack, expectedShaFromIndex) {
|
|
4549
|
+
// 1. Fast Check: Verify packfile trailer matches index record
|
|
4550
|
+
// Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
|
|
4551
|
+
const packTrailer = pack.subarray(-20);
|
|
4552
|
+
const packTrailerSha = Array.from(packTrailer)
|
|
4553
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
4554
|
+
.join('');
|
|
4555
|
+
if (packTrailerSha !== expectedShaFromIndex) {
|
|
4556
|
+
throw new InternalError(
|
|
4557
|
+
`Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
|
|
4558
|
+
)
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4561
|
+
// 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
|
|
4562
|
+
// The Node package build swaps in a chunked implementation for large packs.
|
|
4563
|
+
const actualPayloadSha = await shasumRange(pack, {
|
|
4564
|
+
start: 0,
|
|
4565
|
+
end: pack.length - 20,
|
|
4566
|
+
});
|
|
4567
|
+
if (actualPayloadSha !== expectedShaFromIndex) {
|
|
4568
|
+
throw new InternalError(
|
|
4569
|
+
`Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
|
|
4570
|
+
)
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
|
|
4572
4574
|
/**
|
|
4573
4575
|
* @param {object} args
|
|
4574
4576
|
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
package/managers/index.js
CHANGED
|
@@ -396,8 +396,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
|
|
|
396
396
|
// variable name is alphanumeric (ASCII) with -
|
|
397
397
|
// variable name starts with an alphabetic character
|
|
398
398
|
// variable name is case insensitive
|
|
399
|
-
|
|
400
|
-
const
|
|
399
|
+
// whitespace (spaces or tabs) around the equal sign is ignored
|
|
400
|
+
const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
|
|
401
|
+
const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
401
402
|
|
|
402
403
|
// Comments start with either # or ; and extend to the end of line
|
|
403
404
|
const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
|
|
@@ -4514,37 +4515,12 @@ async function readObjectPacked({
|
|
|
4514
4515
|
}
|
|
4515
4516
|
|
|
4516
4517
|
// === Packfile Integrity Verification ===
|
|
4517
|
-
// Performance optimization:
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
// 1. Fast Check: Verify packfile trailer matches index record
|
|
4522
|
-
// Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
|
|
4523
|
-
const packTrailer = pack.subarray(-20);
|
|
4524
|
-
const packTrailerSha = Array.from(packTrailer)
|
|
4525
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
4526
|
-
.join('');
|
|
4527
|
-
if (packTrailerSha !== expectedShaFromIndex) {
|
|
4528
|
-
throw new InternalError(
|
|
4529
|
-
`Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
|
|
4530
|
-
)
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
|
-
// 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
|
|
4534
|
-
// The Node package build swaps in a chunked implementation for large packs.
|
|
4535
|
-
const actualPayloadSha = await shasumRange(pack, {
|
|
4536
|
-
start: 0,
|
|
4537
|
-
end: pack.length - 20,
|
|
4538
|
-
});
|
|
4539
|
-
if (actualPayloadSha !== expectedShaFromIndex) {
|
|
4540
|
-
throw new InternalError(
|
|
4541
|
-
`Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
|
|
4542
|
-
)
|
|
4543
|
-
}
|
|
4544
|
-
|
|
4545
|
-
// Mark as verified to prevent performance regression on subsequent reads
|
|
4546
|
-
p._checksumVerified = true;
|
|
4518
|
+
// Performance optimization: verify only once per packfile.
|
|
4519
|
+
// Concurrent reads share the same verification promise.
|
|
4520
|
+
if (!p._checksumVerification) {
|
|
4521
|
+
p._checksumVerification = verifyPackfile(pack, p.packfileSha);
|
|
4547
4522
|
}
|
|
4523
|
+
await p._checksumVerification;
|
|
4548
4524
|
|
|
4549
4525
|
const result = await p.read({ oid, getExternalRefDelta });
|
|
4550
4526
|
result.format = 'content';
|
|
@@ -4556,6 +4532,32 @@ async function readObjectPacked({
|
|
|
4556
4532
|
return null
|
|
4557
4533
|
}
|
|
4558
4534
|
|
|
4535
|
+
async function verifyPackfile(pack, expectedShaFromIndex) {
|
|
4536
|
+
// 1. Fast Check: Verify packfile trailer matches index record
|
|
4537
|
+
// Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
|
|
4538
|
+
const packTrailer = pack.subarray(-20);
|
|
4539
|
+
const packTrailerSha = Array.from(packTrailer)
|
|
4540
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
4541
|
+
.join('');
|
|
4542
|
+
if (packTrailerSha !== expectedShaFromIndex) {
|
|
4543
|
+
throw new InternalError(
|
|
4544
|
+
`Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
|
|
4545
|
+
)
|
|
4546
|
+
}
|
|
4547
|
+
|
|
4548
|
+
// 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
|
|
4549
|
+
// The Node package build swaps in a chunked implementation for large packs.
|
|
4550
|
+
const actualPayloadSha = await shasumRange(pack, {
|
|
4551
|
+
start: 0,
|
|
4552
|
+
end: pack.length - 20,
|
|
4553
|
+
});
|
|
4554
|
+
if (actualPayloadSha !== expectedShaFromIndex) {
|
|
4555
|
+
throw new InternalError(
|
|
4556
|
+
`Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
|
|
4557
|
+
)
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4559
4561
|
/**
|
|
4560
4562
|
* @param {object} args
|
|
4561
4563
|
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|