yaver-cli 1.99.445 → 1.99.447
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/package.json +1 -1
- package/src/agent-runtime.js +35 -32
package/package.json
CHANGED
package/src/agent-runtime.js
CHANGED
|
@@ -237,23 +237,17 @@ async function downloadAndCacheAgent(asset, { quiet }) {
|
|
|
237
237
|
if (process.platform !== 'win32') {
|
|
238
238
|
fs.chmodSync(binaryPath, 0o755);
|
|
239
239
|
}
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
// signature error 2"). codesign --force --sign - rebuilds a
|
|
247
|
-
// valid adhoc signature against the current bytes.
|
|
248
|
-
// Doing both here means the happy path never sees SIGKILL in the
|
|
249
|
-
// first place.
|
|
240
|
+
// Strip quarantine, but preserve a valid release signature. Since CLI
|
|
241
|
+
// 1.99.446 the macOS artifacts are Developer ID signed and notarized in
|
|
242
|
+
// release-cli.yml. The old unconditional `codesign --sign -` below erased
|
|
243
|
+
// that identity after every download and silently downgraded the installed
|
|
244
|
+
// binary to ad-hoc. Only repair the signature when verification proves the
|
|
245
|
+
// archive produced an invalid Mach-O.
|
|
250
246
|
if (process.platform === 'darwin') {
|
|
251
247
|
try {
|
|
252
248
|
spawnSync('xattr', ['-dr', 'com.apple.quarantine', binaryPath], { stdio: 'ignore' });
|
|
253
249
|
} catch (_err) {}
|
|
254
|
-
|
|
255
|
-
spawnSync('codesign', ['--force', '--sign', '-', binaryPath], { stdio: 'ignore' });
|
|
256
|
-
} catch (_err) {}
|
|
250
|
+
ensureValidMacSignature(binaryPath);
|
|
257
251
|
}
|
|
258
252
|
// Sanity-check the extracted binary. A truncated tarball or an
|
|
259
253
|
// HTML error page saved as ".tar.gz" can leave us with a file that
|
|
@@ -402,25 +396,14 @@ async function attemptSigkillRecovery(binaryPath, { quiet = false } = {}) {
|
|
|
402
396
|
} catch (_err) {}
|
|
403
397
|
try { fs.chmodSync(binaryPath, 0o755); } catch (_err) {}
|
|
404
398
|
|
|
405
|
-
// 3.
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
414
|
-
encoding: 'utf8',
|
|
415
|
-
});
|
|
416
|
-
if (result.status === 0) {
|
|
417
|
-
// Verify the resigned binary actually passes the kernel check
|
|
418
|
-
// now. If codesign succeeded we're done — the retry will work.
|
|
419
|
-
return 'resign-macos-adhoc';
|
|
420
|
-
}
|
|
421
|
-
// If codesign failed (e.g. missing developer tools), fall through
|
|
422
|
-
// to the quarantine-only return below.
|
|
423
|
-
} catch (_err) {}
|
|
399
|
+
// 3. Preserve a valid Developer ID signature. Only an actually invalid
|
|
400
|
+
// signature is replaced with an ad-hoc one. This keeps notarized release
|
|
401
|
+
// identity intact while retaining the self-heal for interrupted updates.
|
|
402
|
+
const signatureAction = ensureValidMacSignature(binaryPath);
|
|
403
|
+
if (signatureAction === 'preserve-valid-signature') {
|
|
404
|
+
return 'strip-macos-quarantine-preserve-signature';
|
|
405
|
+
}
|
|
406
|
+
if (signatureAction === 'resign-macos-adhoc') return signatureAction;
|
|
424
407
|
|
|
425
408
|
return 'strip-macos-quarantine';
|
|
426
409
|
}
|
|
@@ -746,10 +729,30 @@ async function extractTarball(archivePath, destDir) {
|
|
|
746
729
|
|
|
747
730
|
module.exports = {
|
|
748
731
|
ensureAgentBinary,
|
|
732
|
+
ensureValidMacSignature,
|
|
749
733
|
resolveAgentInfo,
|
|
750
734
|
runAgentCommand,
|
|
751
735
|
};
|
|
752
736
|
|
|
737
|
+
function ensureValidMacSignature(binaryPath, spawnImpl = spawnSync) {
|
|
738
|
+
try {
|
|
739
|
+
const verified = spawnImpl('codesign', ['--verify', '--strict', binaryPath], {
|
|
740
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
741
|
+
encoding: 'utf8',
|
|
742
|
+
});
|
|
743
|
+
if (verified.status === 0) return 'preserve-valid-signature';
|
|
744
|
+
} catch (_err) {}
|
|
745
|
+
|
|
746
|
+
try {
|
|
747
|
+
const repaired = spawnImpl('codesign', ['--force', '--sign', '-', binaryPath], {
|
|
748
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
749
|
+
encoding: 'utf8',
|
|
750
|
+
});
|
|
751
|
+
if (repaired.status === 0) return 'resign-macos-adhoc';
|
|
752
|
+
} catch (_err) {}
|
|
753
|
+
return 'signature-repair-failed';
|
|
754
|
+
}
|
|
755
|
+
|
|
753
756
|
function repoRoot() {
|
|
754
757
|
return path.resolve(__dirname, '..', '..');
|
|
755
758
|
}
|