Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
43e2819
feat(versioniq): build install-manual-upload [skip ci]
rubenvdlinde Nov 14, 2026
76d3576
Merge development into quality/build-install-manual-upload [skip ci]
rubenvdlinde Nov 16, 2026
c48c85e
feat(versioniq): build install-manual-upload [skip ci]
rubenvdlinde Nov 16, 2026
fc17a36
feat(versioniq): build install-manual-upload [skip ci]
rubenvdlinde Nov 16, 2026
bc2d7a7
feat(versioniq): build install-manual-upload [skip ci]
rubenvdlinde Nov 16, 2026
37497a7
Merge origin/development into quality/build-install-manual-upload [sk…
rubenvdlinde Nov 16, 2026
f78bf6e
Merge development into quality/build-install-manual-upload [skip ci]
rubenvdlinde Nov 17, 2026
7524886
refactor(versioniq): narrow the upload install's parameter lists [ski…
rubenvdlinde Nov 17, 2026
86063e0
refactor(versioniq): split the store signature check and pass upload …
rubenvdlinde Nov 17, 2026
8750f02
refactor(versioniq): split the upload archive's tar scan into small s…
rubenvdlinde Nov 17, 2026
f3d2179
refactor(versioniq): move the upload branches of the external install…
rubenvdlinde Nov 17, 2026
be384eb
fix(versioniq): type the download token helper as the stored token [s…
rubenvdlinde Nov 17, 2026
160a3e8
refactor(versioniq): pass the release and install target as values to…
rubenvdlinde Nov 17, 2026
4657c9d
Merge development into quality/build-install-manual-upload [skip ci]
rubenvdlinde Nov 17, 2026
c85ebc5
Merge development into PR #715 branch
rubenvdlinde Nov 20, 2026
552f0cd
fix(versioniq): name the upload's pasted-SHA check uploadShaRefusal
rubenvdlinde Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/openapi-design-rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
'forge' => 'The self-hosted Forgejo or Gitea host that app sources are read from',
'open_api' => 'The OpenAPI document that describes this API',
'settings' => 'Instance settings of Versioniq',
'upload' => 'Installing an app from an uploaded archive',
];
ksort($tags);
$document->tags = [];
Expand Down
22 changes: 21 additions & 1 deletion l10n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,27 @@ OC.L10N.register(
"{appId} {version} is installed, promoted from {name}.": "{appId} {version} is installed, promoted from {name}.",
"_Read {count} day ago_::_Read {count} days ago_": ["Read {count} day ago","Read {count} days ago"],
"_It is not known since when {name} runs {version}, so the waiting period of {count} day is not met._::_It is not known since when {name} runs {version}, so the waiting period of {count} days is not met._": ["It is not known since when {name} runs {version}, so the waiting period of {count} day is not met.","It is not known since when {name} runs {version}, so the waiting period of {count} days is not met."],
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": ["{version} has not run on {name} long enough: {count} day of the waiting period is left.","{version} has not run on {name} long enough: {count} days of the waiting period are left."]
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": ["{version} has not run on {name} long enough: {count} day of the waiting period is left.","{version} has not run on {name} long enough: {count} days of the waiting period are left."],
"Installing from a file": "Installing from a file",
"Allow unsigned uploads": "Allow unsigned uploads",
"An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.": "An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.",
"Install from a file": "Install from a file",
"Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.": "Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.",
"App archive": "App archive",
"Read archive": "Read archive",
"Install {appId} {version}": "Install {appId} {version}",
"Version": "Version",
"SHA-256": "SHA-256",
"Signature": "Signature",
"Signed by the App Store": "Signed by the App Store",
"Not signed by the App Store": "Not signed by the App Store",
"This archive is {archiveApp}, not {app}.": "This archive is {archiveApp}, not {app}.",
"An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.": "An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.",
"Expected SHA-256": "Expected SHA-256",
"Paste the checksum the supplier gave you.": "Paste the checksum the supplier gave you.",
"I accept the SHA-256 shown above": "I accept the SHA-256 shown above",
"Could not read the archive.": "Could not read the archive.",
"Could not install the archive.": "Could not install the archive."
},
"nplurals=2; plural=(n != 1);"
)
22 changes: 21 additions & 1 deletion l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,26 @@
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": [
"{version} has not run on {name} long enough: {count} day of the waiting period is left.",
"{version} has not run on {name} long enough: {count} days of the waiting period are left."
]
],
"Installing from a file": "Installing from a file",
"Allow unsigned uploads": "Allow unsigned uploads",
"An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.": "An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.",
"Install from a file": "Install from a file",
"Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.": "Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.",
"App archive": "App archive",
"Read archive": "Read archive",
"Install {appId} {version}": "Install {appId} {version}",
"Version": "Version",
"SHA-256": "SHA-256",
"Signature": "Signature",
"Signed by the App Store": "Signed by the App Store",
"Not signed by the App Store": "Not signed by the App Store",
"This archive is {archiveApp}, not {app}.": "This archive is {archiveApp}, not {app}.",
"An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.": "An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.",
"Expected SHA-256": "Expected SHA-256",
"Paste the checksum the supplier gave you.": "Paste the checksum the supplier gave you.",
"I accept the SHA-256 shown above": "I accept the SHA-256 shown above",
"Could not read the archive.": "Could not read the archive.",
"Could not install the archive.": "Could not install the archive."
}
}
22 changes: 21 additions & 1 deletion l10n/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,27 @@ OC.L10N.register(
"{appId} {version} is installed, promoted from {name}.": "{appId} {version} is geïnstalleerd, gepromoveerd vanaf {name}.",
"_Read {count} day ago_::_Read {count} days ago_": ["{count} dag geleden gelezen","{count} dagen geleden gelezen"],
"_It is not known since when {name} runs {version}, so the waiting period of {count} day is not met._::_It is not known since when {name} runs {version}, so the waiting period of {count} days is not met._": ["Het is niet bekend sinds wanneer {name} {version} draait, dus aan de wachttijd van {count} dag is niet voldaan.","Het is niet bekend sinds wanneer {name} {version} draait, dus aan de wachttijd van {count} dagen is niet voldaan."],
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": ["{version} draait nog niet lang genoeg op {name}: er is nog {count} dag van de wachttijd over.","{version} draait nog niet lang genoeg op {name}: er zijn nog {count} dagen van de wachttijd over."]
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": ["{version} draait nog niet lang genoeg op {name}: er is nog {count} dag van de wachttijd over.","{version} draait nog niet lang genoeg op {name}: er zijn nog {count} dagen van de wachttijd over."],
"Installing from a file": "Installeren vanuit een bestand",
"Allow unsigned uploads": "Niet-ondertekende uploads toestaan",
"An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.": "Een archief dat de App Store niet ondertekent, voert alle code uit die erin zit. Laat dit uit, tenzij je zulke archieven installeert en ze zelf controleert.",
"Install from a file": "Installeren vanuit een bestand",
"Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.": "Kies een .tar.gz-app-archief. Versioniq leest de app-id, de versie en de SHA-256 ervan en toont die voordat er iets wordt geïnstalleerd.",
"App archive": "App-archief",
"Read archive": "Archief lezen",
"Install {appId} {version}": "{appId} {version} installeren",
"Version": "Versie",
"SHA-256": "SHA-256",
"Signature": "Handtekening",
"Signed by the App Store": "Ondertekend door de App Store",
"Not signed by the App Store": "Niet ondertekend door de App Store",
"This archive is {archiveApp}, not {app}.": "Dit archief is {archiveApp}, niet {app}.",
"An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.": "Een archief dat de App Store niet ondertekent, voert alle code uit die erin zit. Het wordt alleen geïnstalleerd als \"Niet-ondertekende uploads toestaan\" aan staat op het tabblad Instellingen.",
"Expected SHA-256": "Verwachte SHA-256",
"Paste the checksum the supplier gave you.": "Plak de controlesom die je van de leverancier hebt gekregen.",
"I accept the SHA-256 shown above": "Ik accepteer de SHA-256 hierboven",
"Could not read the archive.": "Het archief kon niet worden gelezen.",
"Could not install the archive.": "Het archief kon niet worden geïnstalleerd."
},
"nplurals=2; plural=(n != 1);"
)
22 changes: 21 additions & 1 deletion l10n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,27 @@
"_{version} has not run on {name} long enough: {count} day of the waiting period is left._::_{version} has not run on {name} long enough: {count} days of the waiting period are left._": [
"{version} draait nog niet lang genoeg op {name}: er is nog {count} dag van de wachttijd over.",
"{version} draait nog niet lang genoeg op {name}: er zijn nog {count} dagen van de wachttijd over."
]
],
"Installing from a file": "Installeren vanuit een bestand",
"Allow unsigned uploads": "Niet-ondertekende uploads toestaan",
"An archive the App Store does not sign runs whatever code it contains. Leave this off unless you install such archives and check them yourself.": "Een archief dat de App Store niet ondertekent, voert alle code uit die erin zit. Laat dit uit, tenzij je zulke archieven installeert en ze zelf controleert.",
"Install from a file": "Installeren vanuit een bestand",
"Pick a .tar.gz app archive. Versioniq reads its app id, version and SHA-256 and shows them before anything is installed.": "Kies een .tar.gz-app-archief. Versioniq leest de app-id, de versie en de SHA-256 ervan en toont die voordat er iets wordt geïnstalleerd.",
"App archive": "App-archief",
"Read archive": "Archief lezen",
"Install {appId} {version}": "{appId} {version} installeren",
"Version": "Versie",
"SHA-256": "SHA-256",
"Signature": "Handtekening",
"Signed by the App Store": "Ondertekend door de App Store",
"Not signed by the App Store": "Niet ondertekend door de App Store",
"This archive is {archiveApp}, not {app}.": "Dit archief is {archiveApp}, niet {app}.",
"An archive the App Store does not sign runs whatever code it contains. It installs only when \"Allow unsigned uploads\" is on in the Settings tab.": "Een archief dat de App Store niet ondertekent, voert alle code uit die erin zit. Het wordt alleen geïnstalleerd als \"Niet-ondertekende uploads toestaan\" aan staat op het tabblad Instellingen.",
"Expected SHA-256": "Verwachte SHA-256",
"Paste the checksum the supplier gave you.": "Plak de controlesom die je van de leverancier hebt gekregen.",
"I accept the SHA-256 shown above": "Ik accepteer de SHA-256 hierboven",
"Could not read the archive.": "Het archief kon niet worden gelezen.",
"Could not install the archive.": "Het archief kon niet worden geïnstalleerd."
},
"pluralForm": "nplurals=2; plural=(n != 1);",
"plurals": null
Expand Down
154 changes: 154 additions & 0 deletions lib/Controller/UploadController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php

declare(strict_types=1);
/**
* @license EUPL-1.2
* @copyright Copyright (c) 2026, Conduction B.V. <info@conduction.nl>
*
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
* SPDX-License-Identifier: EUPL-1.2
*/


namespace OCA\Versioniq\Controller;

use InvalidArgumentException;
use OCA\Versioniq\Service\Installer\InstallTarget;
use OCA\Versioniq\Service\Installer\StoreSignatureCheck;
use OCA\Versioniq\Service\Installer\UploadedArchive;
use OCA\Versioniq\Service\InstallerService;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUserSession;

/**
* Install from a file: read an uploaded app archive and show what it is before
* anything is installed (install-manual-upload D1), then install it by the
* token that step returned (D2).
*
* Admin-only twice over, like SettingsController: no NoAdminRequired
* attribute, and the explicit isAdmin() guard. Uploading code is a strict
* password-confirmed action.
*
* @psalm-suppress UnusedClass
*/
class UploadController extends OCSController {
use ChecksAdmin;

/** The multipart field that carries the archive. */
public const FIELD = 'archive';

public function __construct(
string $appName,
IRequest $request,
private UploadedArchive $uploads,
private IGroupManager $groupManager,
private IUserSession $userSession,
private StoreSignatureCheck $signatures,
private InstallerService $installer,
) {
parent::__construct($appName, $request);
}

/**
* Reads an uploaded app archive (multipart field `archive`, a `.tar.gz` of at most 256 MB) and keeps it for an hour; installs nothing
*
* @return DataResponse<Http::STATUS_OK, array{token: string, appId: string, version: string, sha256: string, signedByStore: bool}, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_UNPROCESSABLE_ENTITY, array{message: string}, array{}>
*
* 200: The app id and version the archive's info.xml declares, its SHA-256, whether the App Store's signature verifies it, and the token to install it with
* 400: No archive was uploaded, or the upload failed
* 403: Caller is not an administrator
* 422: The archive is too large, not a .tar.gz, or has no usable appinfo/info.xml
*
* @spec openspec/changes/install-manual-upload/tasks.md#task-1.1
* @spec openspec/changes/install-manual-upload/tasks.md#task-1.2
*/
#[PasswordConfirmationRequired(strict: true)]
#[ApiRoute(verb: 'POST', url: '/api/upload/inspect')]
#[ApiRoute(verb: 'POST', url: '/api/v1/upload/inspect', postfix: 'v1')]
public function inspect(): DataResponse {
if (!$this->isAdmin()) {
return new DataResponse(['message' => 'Forbidden'], Http::STATUS_FORBIDDEN);
}

$file = $this->request->getUploadedFile(self::FIELD);
$path = $this->uploadedPath($file);
if ($path === null) {
return new DataResponse(['message' => 'Upload a .tar.gz app archive in the field "archive".'], Http::STATUS_BAD_REQUEST);
}

try {
$inspected = $this->uploads->store($path);
} catch (InvalidArgumentException $error) {
return new DataResponse(['message' => $error->getMessage()], Http::STATUS_UNPROCESSABLE_ENTITY);
}

$inspected['signedByStore'] = $this->signatures->storeRelease(new InstallTarget($inspected['appId'], $inspected['version'], null), $path) !== null;

return new DataResponse($inspected);
}

/**
* Installs an inspected upload: the guards of a normal install, then the App Store's signature, or for an unsigned archive the setting and the SHA-256 the admin pasted or accepted
*
* @param string $token The token the inspect step returned
* @param string $expectedSha256 The SHA-256 the admin expects; blank when none was pasted
* @param bool $acceptShown Whether the admin accepts the SHA-256 shown for an unsigned archive
* @param bool $allowDowngrade Acknowledges installing a version older than the installed one
* @param string|null $overridePin `repin` or `unpin` to install over a pinned version
* @return DataResponse<Http::STATUS_OK, array<string, mixed>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{message: string}, array{}>
*
* 200: The installer's outcome with source `upload`, the SHA-256 and whether the App Store signed the archive. The status is the outcome's own: 400 for an unsigned archive without a pasted or accepted SHA-256, 403 when unsigned uploads are off, 404 for an unknown or expired upload, 409 for a pin, an unacknowledged downgrade or a SHA-256 that is not the expected one, 4xx or 5xx for a failed install
* 403: Caller is not an administrator
*
* As for installVersion(), the @return above is the documented contract; the
* runtime status is the installer's, which psalm cannot narrow.
*
* @psalm-suppress InvalidReturnType
*
* @spec openspec/changes/install-manual-upload/tasks.md#task-2.1
*/
#[PasswordConfirmationRequired(strict: true)]
#[ApiRoute(verb: 'POST', url: '/api/upload/{token}/install')]
#[ApiRoute(verb: 'POST', url: '/api/v1/upload/{token}/install', postfix: 'v1')]
public function install(string $token, string $expectedSha256 = '', bool $acceptShown = false, bool $allowDowngrade = false, ?string $overridePin = null): DataResponse {
if (!$this->isAdmin()) {
return new DataResponse(['message' => 'Forbidden'], Http::STATUS_FORBIDDEN);
}

$outcome = $this->installer->installUploadedArchive($token, $expectedSha256, $acceptShown, $allowDowngrade, $overridePin);

/** @psalm-suppress InvalidReturnStatement, ArgumentTypeCoercion Status passthrough, see the docblock. */
return new DataResponse($outcome['payload'], $outcome['statusCode']);
}

/**
* The temporary path of a successful upload, or null.
*
* @param mixed $file What IRequest::getUploadedFile() returned.
*/
private function uploadedPath(mixed $file): ?string {
if (!is_array($file) || ($file['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
return null;
}

$path = $file['tmp_name'] ?? null;
if (!is_string($path) || $path === '' || !$this->isUpload($path)) {
return null;
}

return $path;
}

/**
* Whether a path is a file PHP received in this request's upload.
*/
protected function isUpload(string $path): bool {
return is_uploaded_file($path);
}
}
3 changes: 3 additions & 0 deletions lib/Http/InstanceSettingsFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ final class InstanceSettingsFields extends RequestFields {
/** @var string|null Where advisories are read from: remote (the feed address) or local (the imported copy) */
public ?string $advisoryFeedSource = null;

/** @var string|null Whether an archive upload the App Store does not sign may be installed: true or false */
public ?string $allowUnsignedUpload = null;

/** @var string|null Days a version runs on the earlier stage before it may be promoted, 0 to 90; 0 turns the check off */
public ?string $promotionMinDays = null;

Expand Down
Loading
Loading