@cbnventures/nova 0.37.2 → 0.39.0
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/build/package.json +1 -1
- package/build/scaffold-versions.json +20 -0
- package/build/src/api/app-store-connect.d.ts +17 -2
- package/build/src/api/app-store-connect.d.ts.map +1 -1
- package/build/src/api/app-store-connect.js +654 -171
- package/build/src/api/app-store-connect.js.map +1 -1
- package/build/src/api/github-runner-images.d.ts +13 -0
- package/build/src/api/github-runner-images.d.ts.map +1 -0
- package/build/src/api/github-runner-images.js +238 -0
- package/build/src/api/github-runner-images.js.map +1 -0
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +2 -2
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint-validate.js +226 -3
- package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.d.ts +6 -4
- package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.js +804 -124
- package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.js +1 -0
- package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
- package/build/src/cli/index.js +13 -1
- package/build/src/cli/index.js.map +1 -1
- package/build/src/cli/integration/app-store-connect.d.ts +10 -0
- package/build/src/cli/integration/app-store-connect.d.ts.map +1 -1
- package/build/src/cli/integration/app-store-connect.js +701 -80
- package/build/src/cli/integration/app-store-connect.js.map +1 -1
- package/build/src/cli/scaffold/app/astro.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/astro.js +8 -0
- package/build/src/cli/scaffold/app/astro.js.map +1 -1
- package/build/src/cli/scaffold/app/discord-bot.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/discord-bot.js +28 -0
- package/build/src/cli/scaffold/app/discord-bot.js.map +1 -1
- package/build/src/cli/scaffold/app/expressjs.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/expressjs.js +28 -0
- package/build/src/cli/scaffold/app/expressjs.js.map +1 -1
- package/build/src/cli/scaffold/app/nextjs.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/nextjs.js +22 -0
- package/build/src/cli/scaffold/app/nextjs.js.map +1 -1
- package/build/src/cli/scaffold/app/vite.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/vite.js +8 -0
- package/build/src/cli/scaffold/app/vite.js.map +1 -1
- package/build/src/cli/scaffold/docs/docusaurus.d.ts.map +1 -1
- package/build/src/cli/scaffold/docs/docusaurus.js +8 -0
- package/build/src/cli/scaffold/docs/docusaurus.js.map +1 -1
- package/build/src/cli/scaffold/package/github-action.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/github-action.js +14 -0
- package/build/src/cli/scaffold/package/github-action.js.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.js +22 -0
- package/build/src/cli/scaffold/package/homebridge.js.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.d.ts +3 -0
- package/build/src/cli/scaffold/package/pfsense.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.js +148 -6
- package/build/src/cli/scaffold/package/pfsense.js.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.d.ts +2 -0
- package/build/src/cli/scaffold/tool/serverless.d.ts.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.js +86 -1
- package/build/src/cli/scaffold/tool/serverless.js.map +1 -1
- package/build/src/cli/utility/changelog.d.ts +7 -0
- package/build/src/cli/utility/changelog.d.ts.map +1 -1
- package/build/src/cli/utility/changelog.js +802 -7
- package/build/src/cli/utility/changelog.js.map +1 -1
- package/build/src/cli/utility/configure.d.ts +6 -1
- package/build/src/cli/utility/configure.d.ts.map +1 -1
- package/build/src/cli/utility/configure.js +278 -20
- package/build/src/cli/utility/configure.js.map +1 -1
- package/build/src/cli/utility/run-workspaces.d.ts.map +1 -1
- package/build/src/cli/utility/run-workspaces.js +1 -0
- package/build/src/cli/utility/run-workspaces.js.map +1 -1
- package/build/src/lib/artifact-assembly.d.ts +7 -0
- package/build/src/lib/artifact-assembly.d.ts.map +1 -0
- package/build/src/lib/artifact-assembly.js +122 -0
- package/build/src/lib/artifact-assembly.js.map +1 -0
- package/build/src/lib/docker-packaging.d.ts +3 -1
- package/build/src/lib/docker-packaging.d.ts.map +1 -1
- package/build/src/lib/docker-packaging.js +83 -2
- package/build/src/lib/docker-packaging.js.map +1 -1
- package/build/src/lib/env-namespace.d.ts.map +1 -1
- package/build/src/lib/env-namespace.js +2 -1
- package/build/src/lib/env-namespace.js.map +1 -1
- package/build/src/lib/item.d.ts +2 -1
- package/build/src/lib/item.d.ts.map +1 -1
- package/build/src/lib/item.js +18 -0
- package/build/src/lib/item.js.map +1 -1
- package/build/src/lib/nova-config-order.d.ts.map +1 -1
- package/build/src/lib/nova-config-order.js +1 -0
- package/build/src/lib/nova-config-order.js.map +1 -1
- package/build/src/lib/nova-config.d.ts +1 -0
- package/build/src/lib/nova-config.d.ts.map +1 -1
- package/build/src/lib/nova-config.js +150 -4
- package/build/src/lib/nova-config.js.map +1 -1
- package/build/src/lib/regex.d.ts +14 -0
- package/build/src/lib/regex.d.ts.map +1 -1
- package/build/src/lib/regex.js +14 -0
- package/build/src/lib/regex.js.map +1 -1
- package/build/src/lib/run-workspaces.d.ts.map +1 -1
- package/build/src/lib/run-workspaces.js +79 -8
- package/build/src/lib/run-workspaces.js.map +1 -1
- package/build/src/lib/scaffold.d.ts +3 -3
- package/build/src/lib/scaffold.d.ts.map +1 -1
- package/build/src/lib/scaffold.js +140 -8
- package/build/src/lib/scaffold.js.map +1 -1
- package/build/src/lib/workflow-templates.d.ts +4 -1
- package/build/src/lib/workflow-templates.d.ts.map +1 -1
- package/build/src/lib/workflow-templates.js +60 -2
- package/build/src/lib/workflow-templates.js.map +1 -1
- package/build/src/types/api/app-store-connect.d.ts +476 -33
- package/build/src/types/api/github-runner-images.d.ts +199 -0
- package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +76 -8
- package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +178 -11
- package/build/src/types/cli/integration/app-store-connect.d.ts +470 -6
- package/build/src/types/cli/scaffold/package/pfsense.d.ts +83 -0
- package/build/src/types/cli/scaffold/tool/serverless.d.ts +30 -0
- package/build/src/types/cli/utility/changelog.d.ts +327 -1
- package/build/src/types/cli/utility/configure.d.ts +150 -4
- package/build/src/types/lib/artifact-assembly.d.ts +102 -0
- package/build/src/types/lib/docker-packaging.d.ts +54 -1
- package/build/src/types/lib/env-namespace.d.ts +4 -1
- package/build/src/types/lib/item.d.ts +7 -0
- package/build/src/types/lib/nova-config.d.ts +91 -2
- package/build/src/types/lib/regex.d.ts +91 -0
- package/build/src/types/lib/run-workspaces.d.ts +30 -0
- package/build/src/types/lib/scaffold.d.ts +67 -4
- package/build/src/types/lib/workflow-templates.d.ts +26 -0
- package/build/src/types/shared.d.ts +315 -3
- package/build/src/types/tests/api/app-store-connect.test.d.ts +162 -0
- package/build/src/types/tests/api/github-runner-images.test.d.ts +113 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-generate.test.d.ts +19 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-parity.test.d.ts +0 -9
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +109 -26
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +146 -30
- package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +61 -0
- package/build/src/types/tests/cli/generate/github/workflows-version-contract.test.d.ts +2 -2
- package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +2 -0
- package/build/src/types/tests/cli/integration/app-store-connect.test.d.ts +876 -0
- package/build/src/types/tests/cli/scaffold/app/nextjs.test.d.ts +6 -0
- package/build/src/types/tests/cli/scaffold/tool/serverless.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-android.test.d.ts +14 -0
- package/build/src/types/tests/cli/utility/changelog-apple.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-fold.test.d.ts +350 -0
- package/build/src/types/tests/cli/utility/changelog.test.d.ts +50 -0
- package/build/src/types/tests/cli/utility/configure.test.d.ts +56 -0
- package/build/src/types/tests/cli/utility/run-workspaces.test.d.ts +29 -2
- package/build/src/types/tests/lib/artifact-assembly.test.d.ts +45 -0
- package/build/src/types/tests/lib/docker-packaging.test.d.ts +12 -0
- package/build/src/types/tests/lib/nova-config-artifacts.test.d.ts +40 -0
- package/build/src/types/tests/lib/nova-config.test.d.ts +28 -0
- package/build/src/types/tests/lib/scaffold.test.d.ts +59 -2
- package/build/src/types/tests/scaffold-output-contract.test.d.ts +79 -0
- package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/conventions/nova.md +7 -1
- package/build/templates/generators/must-haves/agent-conventions/conventions/pfsense.md +311 -0
- package/build/templates/scaffold/app/android/package.json +1 -1
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-1024.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512@2x.png +0 -0
- package/build/templates/scaffold/app/apple/package.json +1 -1
- package/build/templates/scaffold/app/astro/package.json +1 -1
- package/build/templates/scaffold/app/discord-bot/package.json +1 -1
- package/build/templates/scaffold/app/express/package.json +1 -1
- package/build/templates/scaffold/app/nextjs/package.json +1 -1
- package/build/templates/scaffold/app/vite/package.json +1 -1
- package/build/templates/scaffold/docs/docusaurus/package.json +2 -2
- package/build/templates/scaffold/package/github-action/package.json +1 -1
- package/build/templates/scaffold/package/homebridge/package.json +1 -1
- package/build/templates/scaffold/package/pfsense/package.json +1 -1
- package/build/templates/scaffold/package/pfsense/port/Makefile.template +16 -1
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/FileLock.php +93 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/PackagePaths.php +40 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/UpdateManager.php +1667 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].inc +161 -13
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].xml +37 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/sbin/[__WORKSPACE_NAME__] +203 -8
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/logo.svg +12 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/release-signing.pub +9 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/www/[__WORKSPACE_NAME__]-about.php +437 -0
- package/build/templates/scaffold/package/pfsense/port/pkg-plist +6 -0
- package/build/templates/scaffold/package/pfsense/scripts/build-package.sh +54 -0
- package/build/templates/scaffold/package/pfsense/scripts/check-package.mjs +114 -1
- package/build/templates/scaffold/package/pfsense/scripts/regex.mjs +10 -0
- package/build/templates/scaffold/package/pfsense/tests/updates.php +695 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/drawable/ic_launcher_background.xml +1 -1
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/docker-image/common/Dockerfile +7 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +1 -1
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.test.ts +119 -4
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.ts +25 -3
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.test.ts +121 -6
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.ts +49 -12
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/function/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.d.ts +17 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/function/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/tsconfig.functions.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/vercel.json +7 -1
- package/package.json +1 -1
- package/build/templates/scaffold/package/pfsense-root/.github/workflows/pfsense-[__WORKSPACE_NAME__].yml +0 -62
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
use PfSense\[__WORKSPACE_IDENTIFIER__]\Runtime\UpdateManager;
|
|
6
|
+
|
|
7
|
+
require_once(__DIR__ . '/../port/files/usr/local/pkg/[__WORKSPACE_NAME__]/UpdateManager.php');
|
|
8
|
+
|
|
9
|
+
if (UpdateManager::isAvailable() === false) {
|
|
10
|
+
fwrite(STDOUT, "Update checks are unavailable for this generated repository.\n");
|
|
11
|
+
|
|
12
|
+
exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @var list<array> Captured pfSense notices. */
|
|
16
|
+
$updateTestNotices = [];
|
|
17
|
+
|
|
18
|
+
/** @var list<string> Captured closed pfSense notice identifiers. */
|
|
19
|
+
$updateTestClosedNotices = [];
|
|
20
|
+
|
|
21
|
+
if (function_exists('file_notice') === false) {
|
|
22
|
+
/**
|
|
23
|
+
* Captures one pfSense notice for update tests.
|
|
24
|
+
*
|
|
25
|
+
* @param string $id - Notice identifier.
|
|
26
|
+
* @param string $notice - Notice text.
|
|
27
|
+
* @param string $category - Notice category.
|
|
28
|
+
* @param string $url - Notice link.
|
|
29
|
+
* @param int $priority - Notice priority.
|
|
30
|
+
* @param bool $localOnly - Whether remote channels are suppressed.
|
|
31
|
+
*
|
|
32
|
+
* @return void
|
|
33
|
+
*
|
|
34
|
+
* @since UNRELEASED
|
|
35
|
+
*/
|
|
36
|
+
function file_notice(
|
|
37
|
+
string $id,
|
|
38
|
+
string $notice,
|
|
39
|
+
string $category = 'General',
|
|
40
|
+
string $url = '',
|
|
41
|
+
int $priority = 1,
|
|
42
|
+
bool $localOnly = false,
|
|
43
|
+
): void {
|
|
44
|
+
global $updateTestNotices;
|
|
45
|
+
|
|
46
|
+
$updateTestNotices[] = compact('id', 'notice', 'category', 'url', 'priority', 'localOnly');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (function_exists('close_notice') === false) {
|
|
51
|
+
/**
|
|
52
|
+
* Captures one closed pfSense notice identifier.
|
|
53
|
+
*
|
|
54
|
+
* @param string $id - Notice identifier.
|
|
55
|
+
*
|
|
56
|
+
* @return void
|
|
57
|
+
*
|
|
58
|
+
* @since UNRELEASED
|
|
59
|
+
*/
|
|
60
|
+
function close_notice(string $id): void
|
|
61
|
+
{
|
|
62
|
+
global $updateTestClosedNotices;
|
|
63
|
+
|
|
64
|
+
$updateTestClosedNotices[] = $id;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Asserts strict equality for update regression checks.
|
|
70
|
+
*
|
|
71
|
+
* @param mixed $expected - Expected value.
|
|
72
|
+
* @param mixed $actual - Actual value.
|
|
73
|
+
* @param string $message - Failure context.
|
|
74
|
+
*
|
|
75
|
+
* @return void
|
|
76
|
+
*
|
|
77
|
+
* @throws RuntimeException When values differ.
|
|
78
|
+
*
|
|
79
|
+
* @since UNRELEASED
|
|
80
|
+
*/
|
|
81
|
+
function assertUpdateSame(mixed $expected, mixed $actual, string $message): void
|
|
82
|
+
{
|
|
83
|
+
if ($expected !== $actual) {
|
|
84
|
+
throw new RuntimeException(sprintf(
|
|
85
|
+
"%s\nExpected: %s\nActual: %s",
|
|
86
|
+
$message,
|
|
87
|
+
var_export($expected, true),
|
|
88
|
+
var_export($actual, true),
|
|
89
|
+
));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Requires one callback to throw a RuntimeException with an exact message.
|
|
95
|
+
*
|
|
96
|
+
* @param callable $callback - Operation expected to fail.
|
|
97
|
+
* @param string $message - Expected exception message.
|
|
98
|
+
*
|
|
99
|
+
* @return void
|
|
100
|
+
*
|
|
101
|
+
* @throws RuntimeException When the callback does not fail as expected.
|
|
102
|
+
*
|
|
103
|
+
* @since UNRELEASED
|
|
104
|
+
*/
|
|
105
|
+
function assertUpdateFailure(callable $callback, string $message): void
|
|
106
|
+
{
|
|
107
|
+
try {
|
|
108
|
+
$callback();
|
|
109
|
+
} catch (RuntimeException $runtimeException) {
|
|
110
|
+
assertUpdateSame($message, $runtimeException->getMessage(), 'The update failure message must be actionable.');
|
|
111
|
+
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
throw new RuntimeException('The update operation was expected to fail.');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates one private directory for update signing tests.
|
|
120
|
+
*
|
|
121
|
+
* The generated directory contains only test-owned files and can be removed
|
|
122
|
+
* without affecting package state or another concurrent test process.
|
|
123
|
+
*
|
|
124
|
+
* @return string
|
|
125
|
+
*
|
|
126
|
+
* @throws RuntimeException When the directory cannot be created.
|
|
127
|
+
*
|
|
128
|
+
* @since UNRELEASED
|
|
129
|
+
*/
|
|
130
|
+
function makeUpdateTestDirectory(): string
|
|
131
|
+
{
|
|
132
|
+
$directory = sys_get_temp_dir() . '/[__WORKSPACE_NAME__]-signing-' . bin2hex(random_bytes(16));
|
|
133
|
+
|
|
134
|
+
if (mkdir($directory, 0700) === false) {
|
|
135
|
+
throw new RuntimeException('Could not create the update signing test directory.');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return $directory;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Removes files from one update signing test directory.
|
|
143
|
+
*
|
|
144
|
+
* Test fixtures remain in the repository while generated key files, stubs,
|
|
145
|
+
* recordings, and tampered package copies are deleted after every test run.
|
|
146
|
+
*
|
|
147
|
+
* @param string $directory - Test-owned directory.
|
|
148
|
+
*
|
|
149
|
+
* @return void
|
|
150
|
+
*
|
|
151
|
+
* @since UNRELEASED
|
|
152
|
+
*/
|
|
153
|
+
function removeUpdateTestDirectory(string $directory): void
|
|
154
|
+
{
|
|
155
|
+
$entries = @scandir($directory);
|
|
156
|
+
|
|
157
|
+
foreach ((is_array($entries) ? $entries : []) as $entry) {
|
|
158
|
+
if ($entry === '.' || $entry === '..') {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
$entryPath = $directory . '/' . $entry;
|
|
163
|
+
|
|
164
|
+
if (is_file($entryPath) || is_link($entryPath)) {
|
|
165
|
+
@unlink($entryPath);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@rmdir($directory);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Writes one ssh-keygen stub that records arguments and standard input.
|
|
174
|
+
*
|
|
175
|
+
* The executable simulates both successful and failed verification without
|
|
176
|
+
* requiring OpenSSH for the process-boundary regression test.
|
|
177
|
+
*
|
|
178
|
+
* @param string $directory - Test-owned directory.
|
|
179
|
+
* @param string $name - Stub and recording file prefix.
|
|
180
|
+
* @param int $exitCode - Stub exit code.
|
|
181
|
+
*
|
|
182
|
+
* @return array{command: string, arguments: string, stdin: string}
|
|
183
|
+
*
|
|
184
|
+
* @throws RuntimeException When the stub cannot be written or made executable.
|
|
185
|
+
*
|
|
186
|
+
* @since UNRELEASED
|
|
187
|
+
*/
|
|
188
|
+
function writeUpdateSshKeygenStub(string $directory, string $name, int $exitCode): array
|
|
189
|
+
{
|
|
190
|
+
$commandPath = $directory . '/' . $name;
|
|
191
|
+
$argumentsPath = $directory . '/' . $name . '.arguments';
|
|
192
|
+
$standardInputPath = $directory . '/' . $name . '.stdin';
|
|
193
|
+
$stubLines = [
|
|
194
|
+
'#!/bin/sh',
|
|
195
|
+
'printf \'%s\\n\' "$@" > ' . escapeshellarg($argumentsPath),
|
|
196
|
+
'cat > ' . escapeshellarg($standardInputPath),
|
|
197
|
+
'exit ' . $exitCode,
|
|
198
|
+
'',
|
|
199
|
+
];
|
|
200
|
+
$stubContents = implode("\n", $stubLines);
|
|
201
|
+
|
|
202
|
+
if (
|
|
203
|
+
file_put_contents($commandPath, $stubContents) === false
|
|
204
|
+
|| chmod($commandPath, 0700) === false
|
|
205
|
+
) {
|
|
206
|
+
throw new RuntimeException('Could not create the ssh-keygen test stub.');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return [
|
|
210
|
+
'command' => $commandPath,
|
|
211
|
+
'arguments' => $argumentsPath,
|
|
212
|
+
'stdin' => $standardInputPath,
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Finds a real ssh-keygen executable for fixture verification.
|
|
218
|
+
*
|
|
219
|
+
* The fixed pfSense path is preferred, with PATH lookup allowing the same tests
|
|
220
|
+
* to run on contributor workstations and continuous-integration hosts.
|
|
221
|
+
*
|
|
222
|
+
* @return string|null
|
|
223
|
+
*
|
|
224
|
+
* @since UNRELEASED
|
|
225
|
+
*/
|
|
226
|
+
function findUpdateSshKeygen(): ?string
|
|
227
|
+
{
|
|
228
|
+
if (is_file('/usr/bin/ssh-keygen') && is_executable('/usr/bin/ssh-keygen')) {
|
|
229
|
+
return '/usr/bin/ssh-keygen';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
$path = getenv('PATH');
|
|
233
|
+
|
|
234
|
+
foreach ((is_string($path) ? explode(PATH_SEPARATOR, $path) : []) as $directory) {
|
|
235
|
+
if ($directory === '') {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
$candidate = $directory . '/ssh-keygen';
|
|
240
|
+
|
|
241
|
+
if (is_file($candidate) && is_executable($candidate)) {
|
|
242
|
+
return $candidate;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
assertUpdateSame(true, UpdateManager::isNewerVersion('2.0.1', 'v2.1.0'), 'A leading v must be ignored.');
|
|
250
|
+
assertUpdateSame(false, UpdateManager::isNewerVersion('v2.1.0', '2.1.0'), 'Equal normalized versions are current.');
|
|
251
|
+
assertUpdateSame(false, UpdateManager::isNewerVersion('2.2.0', 'v2.1.9'), 'An older release is not an update.');
|
|
252
|
+
|
|
253
|
+
$releaseJson = json_encode([
|
|
254
|
+
'tag_name' => 'v2.1.0',
|
|
255
|
+
'html_url' => substr(UpdateManager::DOWNLOAD_PREFIX, 0, -strlen('download/')) . 'tag/v2.1.0',
|
|
256
|
+
'published_at' => '2026-11-06T12:00:00Z',
|
|
257
|
+
'assets' => [
|
|
258
|
+
[
|
|
259
|
+
'name' => 'pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg',
|
|
260
|
+
'browser_download_url' => UpdateManager::DOWNLOAD_PREFIX . 'v2.1.0/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg',
|
|
261
|
+
'digest' => 'sha256:' . str_repeat('a', 64),
|
|
262
|
+
],
|
|
263
|
+
[
|
|
264
|
+
'name' => 'pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg.sig',
|
|
265
|
+
'browser_download_url' => UpdateManager::DOWNLOAD_PREFIX . 'v2.1.0/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg.sig',
|
|
266
|
+
'digest' => null,
|
|
267
|
+
],
|
|
268
|
+
],
|
|
269
|
+
], JSON_THROW_ON_ERROR);
|
|
270
|
+
$release = UpdateManager::parseReleaseJson($releaseJson);
|
|
271
|
+
|
|
272
|
+
assertUpdateSame('2.1.0', $release['version'], 'Release parsing must normalize the Git tag.');
|
|
273
|
+
assertUpdateSame(2, count($release['assets']), 'Release parsing must retain valid assets.');
|
|
274
|
+
assertUpdateSame(
|
|
275
|
+
true,
|
|
276
|
+
UpdateManager::isAllowedAssetUrl($release['assets'][0]['url']),
|
|
277
|
+
'Repository release assets must be accepted.',
|
|
278
|
+
);
|
|
279
|
+
assertUpdateSame(
|
|
280
|
+
false,
|
|
281
|
+
UpdateManager::isAllowedAssetUrl('https://example.com/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg'),
|
|
282
|
+
'Assets outside the configured repository must be rejected.',
|
|
283
|
+
);
|
|
284
|
+
assertUpdateSame(
|
|
285
|
+
true,
|
|
286
|
+
UpdateManager::isAllowedAssetUrl('http://vm.test/releases/package.pkg', 'http://vm.test/releases/'),
|
|
287
|
+
'The explicit CLI test prefix must support a local VM endpoint.',
|
|
288
|
+
);
|
|
289
|
+
$apiDigestAssets = UpdateManager::selectUpdateAssets($release);
|
|
290
|
+
|
|
291
|
+
assertUpdateSame(
|
|
292
|
+
'sha256:' . str_repeat('a', 64),
|
|
293
|
+
$apiDigestAssets['digest'],
|
|
294
|
+
'The GitHub API digest must be the preferred SHA-256 source.',
|
|
295
|
+
);
|
|
296
|
+
assertUpdateSame(null, $apiDigestAssets['checksum'], 'An API digest must not require a checksum asset.');
|
|
297
|
+
assertUpdateSame(
|
|
298
|
+
'pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg.sig',
|
|
299
|
+
$apiDigestAssets['signature']['name'],
|
|
300
|
+
'The matching detached signature asset must be selected.',
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
$unsignedRelease = $release;
|
|
304
|
+
$unsignedRelease['assets'] = [$release['assets'][0]];
|
|
305
|
+
$unsignedAssets = UpdateManager::selectUpdateAssets($unsignedRelease);
|
|
306
|
+
|
|
307
|
+
assertUpdateSame(null, $unsignedAssets['signature'], 'A release without a signature must report no signature asset.');
|
|
308
|
+
|
|
309
|
+
$outsidePrefixRelease = $release;
|
|
310
|
+
$outsidePrefixRelease['assets'][1]['url'] = 'https://example.com/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg.sig';
|
|
311
|
+
|
|
312
|
+
assertUpdateFailure(
|
|
313
|
+
static fn (): array => UpdateManager::selectUpdateAssets($outsidePrefixRelease),
|
|
314
|
+
'The release contains an asset URL outside the trusted repository path.',
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
$randomValues = [17, 4, 2, 23];
|
|
318
|
+
$randomCalls = 0;
|
|
319
|
+
$randomInteger = static function (int $minimum, int $maximum) use (&$randomValues, &$randomCalls): int {
|
|
320
|
+
$value = $randomValues[$randomCalls] ?? $minimum;
|
|
321
|
+
$randomCalls++;
|
|
322
|
+
|
|
323
|
+
if ($value < $minimum || $value > $maximum) {
|
|
324
|
+
throw new RuntimeException('The deterministic random value is outside the requested range.');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return $value;
|
|
328
|
+
};
|
|
329
|
+
$schedule = UpdateManager::stableCronSchedule([], $randomInteger);
|
|
330
|
+
|
|
331
|
+
assertUpdateSame(
|
|
332
|
+
['minute' => 17, 'hour' => 4, 'weekday' => 2, 'monthday' => 23],
|
|
333
|
+
$schedule,
|
|
334
|
+
'A complete random schedule must be generated once.',
|
|
335
|
+
);
|
|
336
|
+
assertUpdateSame(4, $randomCalls, 'Every stable schedule component must be initialized.');
|
|
337
|
+
|
|
338
|
+
$reusedSchedule = UpdateManager::stableCronSchedule(
|
|
339
|
+
array_map(static fn (int $value): string => (string) $value, $schedule),
|
|
340
|
+
static function (): never {
|
|
341
|
+
throw new RuntimeException('A valid stored schedule must not be randomized again.');
|
|
342
|
+
},
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
assertUpdateSame($schedule, $reusedSchedule, 'A valid stored schedule must stay stable.');
|
|
346
|
+
assertUpdateSame(['17', '4', '*', '*', '*'], UpdateManager::cronFields('daily', $schedule), 'Daily mapping must use minute and hour.');
|
|
347
|
+
assertUpdateSame(['17', '4', '*', '*', '2'], UpdateManager::cronFields('weekly', $schedule), 'Weekly mapping must use the weekday.');
|
|
348
|
+
assertUpdateSame(['17', '4', '23', '*', '*'], UpdateManager::cronFields('monthly', $schedule), 'Monthly mapping must use the month day.');
|
|
349
|
+
assertUpdateSame(null, UpdateManager::cronFields('never', $schedule), 'Never must remove the cron schedule.');
|
|
350
|
+
|
|
351
|
+
$noticeState = [
|
|
352
|
+
'notified_version' => null,
|
|
353
|
+
];
|
|
354
|
+
$noticeState = UpdateManager::synchronizeNotice($noticeState, '2.0.1', '2.1.0', false);
|
|
355
|
+
|
|
356
|
+
assertUpdateSame('2.1.0', $noticeState['notified_version'], 'The noticed version must be persisted.');
|
|
357
|
+
assertUpdateSame(1, count($updateTestNotices), 'A new version must create one notice.');
|
|
358
|
+
assertUpdateSame(
|
|
359
|
+
'[__WORKSPACE_TITLE__] 2.1.0 is available.',
|
|
360
|
+
$updateTestNotices[0]['notice'],
|
|
361
|
+
'The bell notice must use plain localized package and version text.',
|
|
362
|
+
);
|
|
363
|
+
assertUpdateSame('[__WORKSPACE_TITLE__]', $updateTestNotices[0]['category'], 'The notice category must be the package name.');
|
|
364
|
+
assertUpdateSame(true, $updateTestNotices[0]['localOnly'], 'Remote notifications must be off by default.');
|
|
365
|
+
assertUpdateSame(UpdateManager::ABOUT_PAGE, $updateTestNotices[0]['url'], 'The notice must link to the About tab.');
|
|
366
|
+
|
|
367
|
+
$noticeState = UpdateManager::synchronizeNotice($noticeState, '2.0.1', '2.1.0', true);
|
|
368
|
+
assertUpdateSame(1, count($updateTestNotices), 'The same version must not create a duplicate notice.');
|
|
369
|
+
|
|
370
|
+
$noticeState = UpdateManager::synchronizeNotice($noticeState, '2.0.1', '2.2.0', true);
|
|
371
|
+
assertUpdateSame(2, count($updateTestNotices), 'A later version must create one new notice.');
|
|
372
|
+
assertUpdateSame(false, $updateTestNotices[1]['localOnly'], 'The opt-in must allow pfSense remote notifications.');
|
|
373
|
+
|
|
374
|
+
UpdateManager::synchronizeNotice($noticeState, '2.2.0', '2.2.0', true);
|
|
375
|
+
assertUpdateSame(
|
|
376
|
+
UpdateManager::NOTICE_ID,
|
|
377
|
+
$updateTestClosedNotices[array_key_last($updateTestClosedNotices)],
|
|
378
|
+
'The notice must close when the installed version is current.',
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
$digestPath = tempnam(sys_get_temp_dir(), '[__WORKSPACE_NAME__]-digest-');
|
|
382
|
+
|
|
383
|
+
if ($digestPath === false) {
|
|
384
|
+
throw new RuntimeException('Could not create the digest test file.');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
file_put_contents($digestPath, 'package payload');
|
|
388
|
+
$digest = 'sha256:' . hash_file('sha256', $digestPath);
|
|
389
|
+
|
|
390
|
+
assertUpdateSame(true, UpdateManager::verifyDigest($digestPath, $digest), 'A matching SHA-256 digest must pass.');
|
|
391
|
+
assertUpdateSame(
|
|
392
|
+
false,
|
|
393
|
+
UpdateManager::verifyDigest($digestPath, 'sha256:' . str_repeat('0', 64)),
|
|
394
|
+
'A package with a mismatched SHA-256 digest must be refused.',
|
|
395
|
+
);
|
|
396
|
+
$checksumAssetName = 'pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg.sha256';
|
|
397
|
+
$checksumRelease = [
|
|
398
|
+
'version' => '2.1.0',
|
|
399
|
+
'assets' => [
|
|
400
|
+
[
|
|
401
|
+
'name' => 'pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg',
|
|
402
|
+
'url' => UpdateManager::DOWNLOAD_PREFIX . 'v2.1.0/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]-2.1.0.pkg',
|
|
403
|
+
'digest' => null,
|
|
404
|
+
],
|
|
405
|
+
[
|
|
406
|
+
'name' => $checksumAssetName,
|
|
407
|
+
'url' => UpdateManager::DOWNLOAD_PREFIX . 'v2.1.0/' . $checksumAssetName,
|
|
408
|
+
'digest' => null,
|
|
409
|
+
],
|
|
410
|
+
],
|
|
411
|
+
];
|
|
412
|
+
$checksumAssets = UpdateManager::selectUpdateAssets($checksumRelease);
|
|
413
|
+
$checksumHash = hash_file('sha256', $digestPath);
|
|
414
|
+
|
|
415
|
+
assertUpdateSame(null, $checksumAssets['digest'], 'A release without an API digest must use the checksum fallback.');
|
|
416
|
+
assertUpdateSame(
|
|
417
|
+
$checksumAssetName,
|
|
418
|
+
$checksumAssets['checksum']['name'],
|
|
419
|
+
'The fallback must select the same-release package checksum asset.',
|
|
420
|
+
);
|
|
421
|
+
assertUpdateSame(
|
|
422
|
+
'sha256:' . $checksumHash,
|
|
423
|
+
UpdateManager::checksumDigest($checksumHash . PHP_EOL),
|
|
424
|
+
'A hash-only .sha256 file must produce the expected digest.',
|
|
425
|
+
);
|
|
426
|
+
assertUpdateSame(
|
|
427
|
+
true,
|
|
428
|
+
UpdateManager::verifyDigest($digestPath, (string) UpdateManager::checksumDigest($checksumHash . PHP_EOL)),
|
|
429
|
+
'The .sha256 fallback digest must verify the package.',
|
|
430
|
+
);
|
|
431
|
+
assertUpdateSame(
|
|
432
|
+
null,
|
|
433
|
+
UpdateManager::checksumDigest($checksumHash . ' package.pkg'),
|
|
434
|
+
'A checksum file with extra fields must fail closed.',
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
$keyA = 'AAAAC3NzaC1lZDI1NTE5AAAAIEcEuM8O7kQQkKHAgao93cat1D9++Xd8gX4JXKEza6HH';
|
|
439
|
+
$keyB = 'AAAAC3NzaC1lZDI1NTE5AAAAIMNV3G6CQ4eHbujtIxgdDPgCOnbMkK9YIYmRI35AWzQx';
|
|
440
|
+
$signingTestDirectory = makeUpdateTestDirectory();
|
|
441
|
+
$packageFixturePath = $signingTestDirectory . '/' . UpdateManager::PACKAGE_NAME . '-9.9.9.pkg';
|
|
442
|
+
$signatureFixturePath = $packageFixturePath . '.sig';
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
file_put_contents($packageFixturePath, 'signed package fixture');
|
|
446
|
+
file_put_contents($signatureFixturePath, 'detached signature fixture');
|
|
447
|
+
|
|
448
|
+
assertUpdateSame(
|
|
449
|
+
[],
|
|
450
|
+
UpdateManager::readSigningKeys($signingTestDirectory . '/missing.pub'),
|
|
451
|
+
'A missing release signing key file must keep unsigned updates compatible.',
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
$commentOnlyPath = $signingTestDirectory . '/comments.pub';
|
|
455
|
+
|
|
456
|
+
file_put_contents($commentOnlyPath, "# Comment\n\n # Indented comment\n");
|
|
457
|
+
|
|
458
|
+
assertUpdateSame(
|
|
459
|
+
[],
|
|
460
|
+
UpdateManager::readSigningKeys($commentOnlyPath),
|
|
461
|
+
'A comment-only release signing key file must contain no trusted keys.',
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
$twoKeysPath = $signingTestDirectory . '/two-keys.pub';
|
|
465
|
+
$twoKeysContents = "# First key\r\n\r\n"
|
|
466
|
+
. "ssh-ed25519 $keyA first key\r\n"
|
|
467
|
+
. " # Between keys\r\n"
|
|
468
|
+
. "ssh-ed25519 $keyB second key\r\n";
|
|
469
|
+
|
|
470
|
+
file_put_contents($twoKeysPath, $twoKeysContents);
|
|
471
|
+
|
|
472
|
+
assertUpdateSame(
|
|
473
|
+
[$keyA, $keyB],
|
|
474
|
+
UpdateManager::readSigningKeys($twoKeysPath),
|
|
475
|
+
'CRLF, comments, and two valid release signing keys must be accepted.',
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
$malformedKeyPath = $signingTestDirectory . '/malformed.pub';
|
|
479
|
+
|
|
480
|
+
file_put_contents($malformedKeyPath, 'ssh-rsa invalid' . PHP_EOL);
|
|
481
|
+
|
|
482
|
+
assertUpdateFailure(
|
|
483
|
+
static fn (): array => UpdateManager::readSigningKeys($malformedKeyPath),
|
|
484
|
+
'The installed release signing key file is unreadable or malformed, so the update was not installed.',
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
$expectedAllowedSigners = UpdateManager::PACKAGE_NAME
|
|
488
|
+
. ' namespaces="'
|
|
489
|
+
. UpdateManager::PACKAGE_NAME
|
|
490
|
+
. '" ssh-ed25519 '
|
|
491
|
+
. $keyA
|
|
492
|
+
. "\n"
|
|
493
|
+
. UpdateManager::PACKAGE_NAME
|
|
494
|
+
. ' namespaces="'
|
|
495
|
+
. UpdateManager::PACKAGE_NAME
|
|
496
|
+
. '" ssh-ed25519 '
|
|
497
|
+
. $keyB
|
|
498
|
+
. "\n";
|
|
499
|
+
|
|
500
|
+
assertUpdateSame(
|
|
501
|
+
$expectedAllowedSigners,
|
|
502
|
+
UpdateManager::allowedSignersContent([$keyA, $keyB]),
|
|
503
|
+
'Allowed signers content must restrict every key to the package namespace.',
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
$successfulStub = writeUpdateSshKeygenStub($signingTestDirectory, 'ssh-keygen-success', 0);
|
|
507
|
+
$stubManager = new UpdateManager(
|
|
508
|
+
installedVersion: '9.9.8',
|
|
509
|
+
signingKeysFile: $twoKeysPath,
|
|
510
|
+
sshKeygenCommand: $successfulStub['command'],
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
$stubManager->verifyReleaseSignature(
|
|
514
|
+
$packageFixturePath,
|
|
515
|
+
$signatureFixturePath,
|
|
516
|
+
[$keyA],
|
|
517
|
+
$signingTestDirectory,
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
$expectedStubArguments = implode(PHP_EOL, [
|
|
521
|
+
'-Y',
|
|
522
|
+
'verify',
|
|
523
|
+
'-f',
|
|
524
|
+
$signingTestDirectory . '/allowed_signers',
|
|
525
|
+
'-I',
|
|
526
|
+
UpdateManager::PACKAGE_NAME,
|
|
527
|
+
'-n',
|
|
528
|
+
UpdateManager::PACKAGE_NAME,
|
|
529
|
+
'-s',
|
|
530
|
+
$signatureFixturePath,
|
|
531
|
+
]) . PHP_EOL;
|
|
532
|
+
|
|
533
|
+
assertUpdateSame(
|
|
534
|
+
$expectedStubArguments,
|
|
535
|
+
file_get_contents($successfulStub['arguments']),
|
|
536
|
+
'Signature verification must pass the exact ssh-keygen argument vector.',
|
|
537
|
+
);
|
|
538
|
+
assertUpdateSame(
|
|
539
|
+
file_get_contents($packageFixturePath),
|
|
540
|
+
file_get_contents($successfulStub['stdin']),
|
|
541
|
+
'Signature verification must stream the downloaded package bytes to ssh-keygen.',
|
|
542
|
+
);
|
|
543
|
+
assertUpdateSame(
|
|
544
|
+
0600,
|
|
545
|
+
fileperms($signingTestDirectory . '/allowed_signers') & 0777,
|
|
546
|
+
'The generated allowed-signers file must use private permissions.',
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
$failingStub = writeUpdateSshKeygenStub($signingTestDirectory, 'ssh-keygen-failure', 1);
|
|
550
|
+
$failingStubManager = new UpdateManager(
|
|
551
|
+
installedVersion: '9.9.8',
|
|
552
|
+
signingKeysFile: $twoKeysPath,
|
|
553
|
+
sshKeygenCommand: $failingStub['command'],
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
assertUpdateFailure(
|
|
557
|
+
static function () use (
|
|
558
|
+
$failingStubManager,
|
|
559
|
+
$packageFixturePath,
|
|
560
|
+
$signatureFixturePath,
|
|
561
|
+
$keyA,
|
|
562
|
+
$signingTestDirectory,
|
|
563
|
+
): void {
|
|
564
|
+
$failingStubManager->verifyReleaseSignature(
|
|
565
|
+
$packageFixturePath,
|
|
566
|
+
$signatureFixturePath,
|
|
567
|
+
[$keyA],
|
|
568
|
+
$signingTestDirectory,
|
|
569
|
+
);
|
|
570
|
+
},
|
|
571
|
+
'The release signature does not match this package\'s signing key, so the update was not installed.',
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
$missingToolManager = new UpdateManager(
|
|
575
|
+
installedVersion: '9.9.8',
|
|
576
|
+
signingKeysFile: $twoKeysPath,
|
|
577
|
+
sshKeygenCommand: $signingTestDirectory . '/missing-ssh-keygen',
|
|
578
|
+
);
|
|
579
|
+
|
|
580
|
+
assertUpdateFailure(
|
|
581
|
+
static function () use (
|
|
582
|
+
$missingToolManager,
|
|
583
|
+
$packageFixturePath,
|
|
584
|
+
$signatureFixturePath,
|
|
585
|
+
$keyA,
|
|
586
|
+
$signingTestDirectory,
|
|
587
|
+
): void {
|
|
588
|
+
$missingToolManager->verifyReleaseSignature(
|
|
589
|
+
$packageFixturePath,
|
|
590
|
+
$signatureFixturePath,
|
|
591
|
+
[$keyA],
|
|
592
|
+
$signingTestDirectory,
|
|
593
|
+
);
|
|
594
|
+
},
|
|
595
|
+
'The required ssh-keygen signature verification tool is unavailable, so the update was not installed.',
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
$realSshKeygen = findUpdateSshKeygen();
|
|
599
|
+
|
|
600
|
+
if ($realSshKeygen === null) {
|
|
601
|
+
fwrite(STDOUT, "SKIP: ssh-keygen is unavailable; a real release signature was not verified.\n");
|
|
602
|
+
} else {
|
|
603
|
+
$privateKeyPath = $signingTestDirectory . '/release-key';
|
|
604
|
+
$generateCommand = sprintf(
|
|
605
|
+
'%s -q -t ed25519 -N %s -f %s',
|
|
606
|
+
escapeshellarg($realSshKeygen),
|
|
607
|
+
escapeshellarg(''),
|
|
608
|
+
escapeshellarg($privateKeyPath),
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
exec($generateCommand, $generateOutput, $generateExitCode);
|
|
612
|
+
|
|
613
|
+
if ($generateExitCode !== 0) {
|
|
614
|
+
throw new RuntimeException('Could not generate the release signing test key.');
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
$generatedKeys = UpdateManager::readSigningKeys($privateKeyPath . '.pub');
|
|
618
|
+
$generatedKey = $generatedKeys[0] ?? null;
|
|
619
|
+
|
|
620
|
+
if (!is_string($generatedKey)) {
|
|
621
|
+
throw new RuntimeException('The generated release signing test key is invalid.');
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
$signCommand = sprintf(
|
|
625
|
+
'%s -Y sign -f %s -n %s %s',
|
|
626
|
+
escapeshellarg($realSshKeygen),
|
|
627
|
+
escapeshellarg($privateKeyPath),
|
|
628
|
+
escapeshellarg(UpdateManager::PACKAGE_NAME),
|
|
629
|
+
escapeshellarg($packageFixturePath),
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
@unlink($signatureFixturePath);
|
|
633
|
+
exec($signCommand, $signOutput, $signExitCode);
|
|
634
|
+
|
|
635
|
+
if ($signExitCode !== 0) {
|
|
636
|
+
throw new RuntimeException('Could not sign the release package fixture.');
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
$realSignatureManager = new UpdateManager(
|
|
640
|
+
installedVersion: '9.9.8',
|
|
641
|
+
signingKeysFile: $privateKeyPath . '.pub',
|
|
642
|
+
sshKeygenCommand: $realSshKeygen,
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
$realSignatureManager->verifyReleaseSignature(
|
|
646
|
+
$packageFixturePath,
|
|
647
|
+
$signatureFixturePath,
|
|
648
|
+
[$generatedKey],
|
|
649
|
+
$signingTestDirectory,
|
|
650
|
+
);
|
|
651
|
+
|
|
652
|
+
$tamperedPackagePath = $signingTestDirectory . '/tampered.pkg';
|
|
653
|
+
|
|
654
|
+
file_put_contents(
|
|
655
|
+
$tamperedPackagePath,
|
|
656
|
+
(string) file_get_contents($packageFixturePath) . 'tampered',
|
|
657
|
+
);
|
|
658
|
+
|
|
659
|
+
assertUpdateFailure(
|
|
660
|
+
static function () use (
|
|
661
|
+
$realSignatureManager,
|
|
662
|
+
$tamperedPackagePath,
|
|
663
|
+
$signatureFixturePath,
|
|
664
|
+
$generatedKey,
|
|
665
|
+
$signingTestDirectory,
|
|
666
|
+
): void {
|
|
667
|
+
$realSignatureManager->verifyReleaseSignature(
|
|
668
|
+
$tamperedPackagePath,
|
|
669
|
+
$signatureFixturePath,
|
|
670
|
+
[$generatedKey],
|
|
671
|
+
$signingTestDirectory,
|
|
672
|
+
);
|
|
673
|
+
},
|
|
674
|
+
'The release signature does not match this package\'s signing key, so the update was not installed.',
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
} finally {
|
|
678
|
+
removeUpdateTestDirectory($signingTestDirectory);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
$missingChecksumRelease = $checksumRelease;
|
|
682
|
+
$missingChecksumRelease['assets'] = [$checksumRelease['assets'][0]];
|
|
683
|
+
|
|
684
|
+
assertUpdateFailure(
|
|
685
|
+
static fn (): array => UpdateManager::selectUpdateAssets($missingChecksumRelease),
|
|
686
|
+
'The release provides neither a GitHub SHA-256 digest nor the required checksum asset '
|
|
687
|
+
. $checksumAssetName
|
|
688
|
+
. '. The installed version was kept.',
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
@unlink($digestPath);
|
|
692
|
+
|
|
693
|
+
fwrite(STDOUT, "Update checks, notices, schedules, checksums, and signatures passed.\n");
|
|
694
|
+
|
|
695
|
+
exit(0);
|