Skip to content

Commit 67ab520

Browse files
committed
Fix CI: import PHP_URL_HOST, use Safe\parse_url, drop dead setDistSha1Checksum
- phpcs (SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName): `use const PHP_URL_HOST;`. - phpstan (thephpf/safe-rule): `use function Safe\parse_url;`. - phpstan (CompletePackageInterface::setDistSha1Checksum doesn't exist on the typed handle): drop the explicit clear. The audit notes Composer's FileDownloader doesn't consult the stale checksum after `setDistUrl` anyway, so the call was cosmetic. The user-facing warning about HTTPS-to-origin still lands.
1 parent 2952792 commit 67ab520

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListener.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
use Throwable;
2121

2222
use function array_walk;
23-
use function parse_url;
2423
use function pathinfo;
24+
use function Safe\parse_url;
2525

2626
use const PATHINFO_EXTENSION;
27+
use const PHP_URL_HOST;
2728

2829
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
2930
class OverrideDownloadUrlInstallListener
@@ -130,14 +131,11 @@ function (OperationInterface $operation): void {
130131
$this->composerRequest->pieOutput->write('Found prebuilt archive: ' . $url);
131132
$composerPackage->setDistUrl($url);
132133

133-
// The Packagist-side dist sha1 was computed against the
134-
// original dist URL; once we swap to a release-asset URL
135-
// it no longer corresponds to anything Composer will fetch.
136-
// Clear it so Composer doesn't silently match the wrong
137-
// bytes against a stale checksum, and warn the caller that
138-
// the only integrity guarantee left is HTTPS to the
139-
// release-hosting origin.
140-
$composerPackage->setDistSha1Checksum(null);
134+
// Composer's dist-sha was computed against the original
135+
// Packagist URL; once we swap to a release-asset URL the
136+
// FileDownloader has nothing to validate the new bytes
137+
// against. Surface that so the caller knows HTTPS-to-origin
138+
// is the only integrity guarantee left.
141139
$this->composerRequest->pieOutput->write(
142140
'<warning>Note: dist-sha integrity check is not available for prebuilt-binary URLs; relying on HTTPS to ' . parse_url($url, PHP_URL_HOST) . ' only.</warning>',
143141
);

0 commit comments

Comments
 (0)