API / Minn\Ops / EngineChecksums

EngineChecksums final readonly class

Minn\Ops\EngineChecksums · public/minn/src/Minn/Ops/EngineChecksums.php · 157 lines

Checks a Minn install's files against the release they claim to be, the way `wp core verify-checksums` checks WordPress's against wordpress.org: the update service describes the running version's release, its minn.zip is downloaded from the service alone and must match its published sha256 and carry a signature from a key this engine trusts (EngineUpdate), and then every file of the engine is compared with the archive's, as are the shape files at the webroot with the archive's layout templates. A file that differs, one the archive has and the install lacks, and one the install has beyond the archive are all named. The install record (.install.json) is the site's own and is not compared.

Constants and properties

constSOURCE = 'https://updates.minn.run/v1/minn/releases/'

Where a version's release record is asked for.

privateMAX_DOWNLOAD = 67108864
privateOWN = array ( 0 => '.install.json', )
privatereadonly string $engineDir

Promoted from the constructor.

privatereadonly array $keys

Promoted from the constructor.

privatereadonly Minn\Http $http

Promoted from the constructor.

Public

new__construct(string $engineDir, array $keys = Minn\Ops\EngineUpdate::KEYS, Minn\Http $http = \Minn\Http::__set_state(array( 'within' => array ( ), 'fake' => NULL, 'refusal' => NULL, )))#
$keyslist<string>the release keys to trust (tests pass their own)
methodcheck(string $webroot): array#

The comparison: the version checked, and the paths (under minn/, or at the webroot for shape files) that differ, are missing, or are extra.

@return array{version: string, changed: list<string>, missing: list<string>, extra: list<string>}

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privaterelease(string $version): Minn\Ops\Release#

The release the service describes for a version; it must be one Minn offers, of that version.

privatearchiveHashes(string $zip): array#

The sha256 of every file in the archive's engine folder, by its path inside that folder.

@return array<string, string>
privatetreeHashes(string $dir): array#

The sha256 of every file under the engine folder, by its path inside it; the install record left out.

@return array<string, string>
privatelayoutOf(array $released): array#

The archive's layout templates by the webroot path each shapes.

$releasedarray<string, string>
@return array<string, string>
privateshapeHashes(string $webroot, array $paths): array#

The sha256 of the webroot's shape files that exist.

$pathslist<string>
@return array<string, string>
privatecompare(array $expected, array $found, string $prefix): array#

Expected against found: the paths that differ, are missing, and are extra, prefixed.

$expectedarray<string, string>
$foundarray<string, string>
@return array{changed: list<string>, missing: list<string>, extra: list<string>}