Compare commits

..
Author SHA1 Message Date
James MaesandClaude Fable 5.2 478bd4363b feat(encryption): client-side encryption works, from the plan to the restore
build / maven (push) Successful in 2m2s
maven / build (push) Successful in 2m2s
A plan could ask for CLIENT_AES256_GCM and was refused: the transform
plumbing was there, but nothing installed a cipher and nothing handed one
to a run.

- BackupsQBitConfig.withKeyProvider installs the streaming cipher of the
  QQQ crypto package (StreamingCipherTransform: Tink streaming AEAD, a
  fresh data key per object, wrapped by the referenced key)
- a run of a plan that asks for encryption gets the cipher for the plan's
  key reference; with no key for it the run is refused and nothing is
  written in the clear
- a plan is not saved when the provider has no key for its reference
- verification and restore read through the same provider; a rotated key
  still reads what its older version wrote
- a run records the key reference and a fingerprint (v<version>:<16 hex
  of a labelled hash), never the key

Fixed on the way: the file index of an encrypted run was written in the
clear while the catalog recorded it as encrypted, and a restore from an
encrypted run could not read it. It is encrypted like every other object
of the run. No release could encrypt before this, so no stored run is
affected.

Tests: StreamingCipherTransformTest (6: round trip, tampering and
truncation refused, another key refused, no key gives no transform,
rotation, the fingerprint is not the key); an encrypted run from the plan
(objects are ciphertext, verified by content and by test restore, rotated,
refused without the key with nothing written); a restore from an encrypted
backup, rows and a file, and its refusal without the key; plan validation
with a key provider. ./mvnw verify: 225 tests, guardrails and coverage
pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 04:38:25 -06:00
james.maes 4ef8a6293f Merge pull request 'build(deps): align with Gitea registry (parent 2.2.1, QQQ 4.1.0-RC.26)' (#53) from deps/align-gitea into develop
build / maven (push) Successful in 1m50s
maven / build (push) Successful in 1m50s
2026-11-07 18:06:38 +00:00
james.maesandClaude Opus 5.5 c58324bccf build(deps): align with Gitea registry (parent 2.2.1, QQQ 4.1.0-RC.26)
build / maven (push) Successful in 3m28s
maven / build (push) Successful in 3m28s
pom.xml: parent -> 2.2.1
pom.xml: qqq.snapshot.version: 4.1.0-RC.14 -> 4.1.0-RC.26
pom.xml: qbit-object-storage: 0.1.0-RC.2 -> 0.1.0-RC.10
pom.xml: qqq-frontend-next: 1.0.0-RC.14 -> 1.0.0-RC.38
pom.xml: added qqq.version=4.1.0-RC.26 (parent BOM import)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 17:55:30 +00:00
james.maes 06b766d516 Merge pull request 'ci: pin shared workflow to v1' (#52) from ci/pin-v1-develop into develop
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1e25bb5a243dfdcd95d4b9a4f780200ff8c8778a] (push) Successful in 20s
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 16s
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Successful in 11s
build / maven (push) Successful in 3m59s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (push) Skipped
maven / build (push) Successful in 3m59s
2026-11-06 16:03:45 +00:00
james.maesandClaude Opus 5.5 5c32e3c5f3 ci: pin shared workflow to v1
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1e25bb5a243dfdcd95d4b9a4f780200ff8c8778a] (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 6s
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-business (pull_request) Skipped
QRun-IO/ci-policy: ci / original-mcp (pull_request) Skipped
QRun-IO/ci-policy: ci / original-voyage (pull_request) Skipped
QRun-IO/ci-policy: ci / original-cli (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: ci / ci-result (pull_request) Waiting to run
build / maven (push) Successful in 3m27s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (pull_request) Skipped
maven / build (push) Successful in 3m27s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 14:04:43 +00:00
james.maes 1de785328e Merge pull request 'ci: use shared ci-workflows Maven workflow' (#51) from ci/ci-workflows into develop
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 6s
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Successful in 7s
build / maven (push) Successful in 2m49s
QRun-IO/ci-policy: ci / Scoped workflow [workflow d20a578c7d818bc7ca32a2ac2c675da4e4f27385] (push) Successful in 8s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (push) Skipped
maven / build (push) Successful in 2m48s
2026-11-05 23:14:34 +00:00
james.maesandClaude Opus 5.5 dbcfd85da8 ci: use shared ci-workflows Maven workflow
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1b3648d9421543350067e95e54959dfb471b26d5] (pull_request) Successful in 7s
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / original-business (pull_request) Skipped
QRun-IO/ci-policy: ci / original-mcp (pull_request) Skipped
QRun-IO/ci-policy: ci / original-voyage (pull_request) Skipped
QRun-IO/ci-policy: ci / original-cli (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
build / maven (push) Successful in 2m32s
QRun-IO/ci-policy: ci / ci-result (pull_request) Failing after 2s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (pull_request) Skipped
maven / build (push) Successful in 2m33s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (pull_request) Successful in 2m3s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (pull_request) Successful in 16s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (pull_request) Failing after 2s
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Failing after 19m29s
Replace the platform-ci release callers with one caller of
KofTwentyTwo/ci-workflows maven.yaml (qqq-orb port).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:02:21 +00:00
forge-recovery ff76412d80 ci: enroll shared Gitea lifecycle
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
Shared Java Maven CI with Docker / secrets (push) Successful in 27s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (push) Successful in 24s
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 10s
QRun-IO/ci-policy: ci / java-docker-3 (push) Successful in 11m52s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 6s
Shared Java Maven CI with Docker / verify (push) Successful in 2m38s
qrun-release / postpublish (push) Failing after 10m40s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (push) Successful in 1m52s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (push) Successful in 13s
Shared Java Maven CI with Docker / gate (push) Successful in 11s
qrun-release / release (push) Successful in 12m25s
Shared QRun source version / version (push) Failing after 10m40s
2026-11-02 22:10:12 +00:00
forge-recovery 76ac13c14f ci: enroll shared Gitea lifecycle
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 7s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (push) Successful in 22s
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Successful in 7m24s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 11s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (push) Successful in 2m6s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (push) Successful in 20s
2026-11-02 21:30:25 +00:00
forge-recoveryandCodex 7ba2740283 ci: enroll shared Gitea release-candidate lifecycle
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 6s
Release candidate / release-rc (pull_request) Skipped
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (pull_request) Successful in 12s
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (pull_request) Successful in 2m7s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (pull_request) Successful in 16s
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Successful in 55m33s
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 20:13:41 +00:00
c82c847b35 ci: add the isolated postpublish job to the QRun release caller
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
Shared Java Maven CI with Docker / secrets (push) Successful in 15s
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 4s
Shared Java Maven CI with Docker / verify (push) Successful in 1m35s
qrun-release / postpublish (push) Skipped
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 5s
Release candidate / release-rc (pull_request) Skipped
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (pull_request) Successful in 14s
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
Shared Java Maven CI with Docker / gate (push) Successful in 10s
qrun-release / release (push) Successful in 2h25m44s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (pull_request) Successful in 1m31s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (pull_request) Successful in 9s
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Successful in 2h27m8s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 15:45:49 +00:00
dc69ffe245 ci: move the QRun release caller to the thin v2 contract
QRun-IO/ci-policy: ci / java-frontend-browser-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-9 (pull_request) Skipped
Shared Java Maven CI with Docker / secrets (push) Failing after 17s
QRun-IO/ci-policy: ci / java-docker-2 (pull_request) Canceled after 1h25m12s
Shared Java Maven CI with Docker / verify (push) Canceled after 0s
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 6s
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / java-maven-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-7 (pull_request) Skipped
Shared Java Maven CI with Docker / gate (push) Canceled after 0s
qrun-release / release (push) Canceled after 1h25m16s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (pull_request) Successful in 21s
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (pull_request) Successful in 1m39s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (pull_request) Successful in 11s
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Successful in 1h41m21s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 06:16:09 +00:00
forge-recoveryandCodex 66fd64e1c4 ci: add the identical QRun release caller
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-2 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-1 (pull_request) Failing after 14m1s
QRun-IO/ci-policy: ci / ci-result (pull_request) Failing after 5s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / secrets (pull_request) Failing after 16s
QRun-IO/ci-policy: ci / gradle-0 (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI with Docker / verify (pull_request) Successful in 1m46s
QRun-IO/ci-policy: Shared Java Maven CI with Docker / gate (pull_request) Failing after 15s
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 03:25:46 +00:00
james.maesandCodex 895727acbb ci: adopt managed orb 0.8 patch track (#45)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 15:28:38 -05:00
james.maesandCodex 886e76b333 ci: adopt shared orb 0.7.18 (#44)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 14:48:47 -05:00
james.maesandCodex 603f0c9d82 ci: adopt shared orb 0.7.17 (#43)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 14:16:17 -05:00
james.maesandCodex bdf79eae09 ci: centralize QBit source scanning (#40)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 10:43:14 -05:00
james.maesandCodex ec5fef94bc ci: adopt central orb 0.7.12 and stable gates (#39)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 08:56:47 -05:00
james.maesandCodex b21db17a9f ci: centralize rc release completion in qqq orb (#38)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 02:25:46 -05:00
james.maesandCodex 7fa71bbaa6 ci: adopt shared orb 0.7.11 (#37)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 00:59:34 -05:00
james.maes 84f030d048 Merge pull request #36 from QRun-IO/feature/central-ci
ci: adopt shared QQQ orb standard
2026-10-20 18:57:40 -05:00
james.maesandCodex 9cb78190d8 ci: adopt verified central QQQ orb 0.7.3
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 18:52:23 -05:00
18 changed files with 653 additions and 25 deletions

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
version: 2.1
setup: true
orbs:
qqq-orb: kingsrook/qqq-orb@0.7.15
qqq-orb: kingsrook/qqq-orb@0.8
workflows:
setup:
jobs:
- qqq-orb/generate_pipeline:
orb_version: 0.7.15
orb_version: '0.8'
filters:
branches:
ignore: automation/qbit-rc-pending
+7
View File
@@ -0,0 +1,7 @@
name: build
on:
push:
jobs:
maven:
uses: self:KofTwentyTwo/ci-workflows/.gitea/workflows/maven.yaml@v1
secrets: inherit
+2 -1
View File
@@ -1,5 +1,5 @@
profile: qbit
orb_version: 0.7.15
orb_version: '0.8'
default_branch: develop
java_version: '21'
browsers: true
@@ -13,3 +13,4 @@ publish:
release_candidate: true
release: true
asciidoc: false
release_completion: true
+3
View File
@@ -5,6 +5,7 @@ All notable changes to this project are documented here. The format follows Keep
## [0.1.0] - Unreleased
### Added
- Client-side encryption (`CLIENT_AES256_GCM`, spec 11.2) works. `BackupsQBitConfig.withKeyProvider(QKeyProviderInterface)` installs the streaming cipher of the QQQ crypto package (`StreamingCipherTransform`: Tink streaming AEAD, a fresh data key per object, wrapped by the referenced key). A plan that asks for encryption is encrypted by its run without the host handing it a cipher, a plan is refused when the provider has no key for its reference, verification and restore read through the same provider, and a rotated key still reads what its older version wrote. A run records the key reference and a fingerprint (`v<version>:<16 hex>`), never the key. Without a key a run is refused and nothing is written in the clear.
- Central `backups.sla` and per-active-plan `backups.destination.<planId>` health checks, with bounded read-only destination diagnostics and secret-free status details.
- Always-durable backup, resume, scheduled backup, restore and verify processes with conservative `NONE` idempotency and stable backup identities on explicit job retry.
- Weighted backup phases, table/file counts, stored bytes, safe per-table/artifact logs, warnings, failures and resume notices through QQQ `JobProgress`.
@@ -16,6 +17,8 @@ All notable changes to this project are documented here. The format follows Keep
- Repository scaffold: `BackupsQBitConfig` and `BackupsQBitProducer` (table prefix `backups_`, permissions `backups.*`), build, CI and repository standard files.
### Changed
- The file index of an encrypted run (`files/index-00001.jsonl.gz`: tables, record keys and where each file came from) is encrypted like every other object of the run. It was written in the clear while the catalog recorded it as encrypted, and a restore from an encrypted run could not read it. No release could encrypt before this one, so no stored run is affected.
- A plan that asks for encryption without a key provider is refused with "no key provider is configured" (was "not available in this version"); a refused run names the key reference.
- Tables whose backend module has no query interface (storage-only modules such as qbit-edi `edi_preview_download`) are classified EXTERNAL and always left out of a backup with the reason `NOT_QUERYABLE`, even when selected by name or role; the Run backup review lists them. Before, such a table was read as DATA and the whole run FAILED with "Query is not implemented in this module".
- Failed runs persist an actionable `error_message` ("Backup failed: Class: message") and fill `error_detail` with the exception class, the cause chain and the top root-cause frames (bounded to 8 KB). Both go through `FailureText.sanitize`, which redacts URL user-info, presigned query parameters, key=value secrets, Authorization/Bearer values, AWS access key ids, PEM blocks and Postgres row values while keeping object keys and bucket names.
- Multi-node deployments: the cached Prometheus text (`BackupsMetrics`) is registered with QQQ `ClusterCaches` as `qbit-backups.metrics` and cleared on every node when a run finishes or a plan is inserted, updated or deleted; the 60 s TTL remains the safety net. `SlaChecker`'s manifest-head and bucket-audit throttles and `BackupsRuntime`'s process-permission map are registered as node-local, with reasons. `BackupsClusterCachesTest` audits the package for unregistered static caches and covers a remote invalidation.
+16
View File
@@ -62,6 +62,22 @@ checks empty-state, widget and possible-value-source coverage. Run it with
Always use the Maven wrapper (Maven 3.9.11); Maven 3.10 cannot read the parent POM.
## Encryption
Backup objects are encrypted before they leave the application when a plan's encryption mode is `CLIENT_AES256_GCM` and the host has given the qbit a key provider:
```java
new BackupsQBitProducer().withQBitConfig(config.withKeyProvider(new EnvKeyProvider())).produce(qInstance);
```
- The plan's **encryption key reference** names a key of the provider. For `EnvKeyProvider` it is the name of an environment variable that holds 32 random bytes as base64, which is how a secret manager hands a key to a process. `AwsSecretsManagerKeyProvider` reads the same from AWS Secrets Manager. The key is never in a table, a log, a manifest or a message; a run records the reference and a fingerprint.
- Table parts, the file index and the copies of referenced files are encrypted (Tink streaming AEAD, a fresh data key per object). The manifest and the checksum list stay readable without the key: they hold table names, row counts and checksums (of the stored bytes, and of each part before it was encrypted, which is how a verification knows it read the right content), and no row.
- A plan cannot be saved, and a run does not start, when the provider has no key for the reference. Nothing is written in the clear instead.
- **Rotation** (the convention of the QQQ key providers, for a reference `NAME`): keep the old key as `NAME_V<old version>`, put the new key in `NAME`, set `NAME_VERSION` to the new version. New runs are written under the new version; older runs are read with the version in each object's header for as long as that version is kept.
- **Losing the key loses every backup it wrote.** Keep it where the application's database is not, and keep an old version until every run written under it has been pruned.
- The sensitive field policy `INCLUDE_ENCRYPTED_ONLY` needs this mode.
## Durable jobs and progress
Run backup now, Resume, scheduled backups, both Restore actions, and Verify backup
+6 -5
View File
@@ -18,9 +18,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<qqq.version>4.1.0-RC.26</qqq.version> <!-- feeds qbit-build-parent's qqq-bom-pom import -->
<qbit.guardrails.enforce>true</qbit.guardrails.enforce>
<qbit.guardrails.strictUiApiRoutes>true</qbit.guardrails.strictUiApiRoutes>
<revision>0.1.0-RC.11</revision>
<revision>0.1.0-SNAPSHOT</revision>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<jacoco.version>0.8.15</jacoco.version>
@@ -29,7 +30,7 @@
<parent>
<groupId>com.kingsrook</groupId>
<artifactId>qbit-build-parent</artifactId>
<version>2.1.0</version>
<version>2.2.1</version>
</parent>
<groupId>com.kingsrook.qbits</groupId>
@@ -86,7 +87,7 @@
<dependency>
<groupId>com.kingsrook.qbits</groupId>
<artifactId>qbit-object-storage</artifactId>
<version>0.1.0-RC.2</version>
<version>0.1.0-RC.10</version>
<optional>true</optional>
</dependency>
@@ -106,7 +107,7 @@
<dependency>
<groupId>com.kingsrook.qqq</groupId>
<artifactId>qqq-frontend-next</artifactId>
<version>1.0.0-RC.14</version>
<version>1.0.0-RC.38</version>
<scope>test</scope>
</dependency>
@@ -216,7 +217,7 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<qqq.snapshot.version>4.1.0-RC.14</qqq.snapshot.version>
<qqq.snapshot.version>4.1.0-RC.26</qqq.snapshot.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -21,8 +21,10 @@ import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import com.kingsrook.qbits.backups.codec.ArtifactTransform;
import com.kingsrook.qbits.backups.codec.StreamingCipherTransform;
import com.kingsrook.qbits.backups.verify.ScratchTarget;
import com.kingsrook.qbits.backups.storage.BackupStorage;
import com.kingsrook.qqq.backend.core.crypto.QKeyProviderInterface;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitConfig;
import com.kingsrook.qqq.backend.core.utils.StringUtils;
@@ -417,7 +419,23 @@ public class BackupsQBitConfig implements QBitConfig
/*******************************************************************************
** Getter for artifactTransformResolver (the decrypt hook for verify)
** Turn client-side encryption on: plans may ask for CLIENT_AES256_GCM with an
** encryption key reference, which names a key of this provider (for the
** environment provider, the variable that holds it). The same provider reads
** what it wrote, for verification and restore. Losing the key loses the
** backups it wrote: the provider's store is what has to be kept safe.
*******************************************************************************/
public BackupsQBitConfig withKeyProvider(QKeyProviderInterface keyProvider)
{
this.artifactTransformResolver = keyProvider == null ? null : keyRef -> StreamingCipherTransform.forKey(keyProvider, keyRef);
return (this);
}
/*******************************************************************************
** Getter for artifactTransformResolver: the cipher for an encryption key
** reference, for writing, verifying and restoring (null: no encryption)
*******************************************************************************/
public Function<String, ArtifactTransform> getArtifactTransformResolver()
{
@@ -428,7 +446,9 @@ public class BackupsQBitConfig implements QBitConfig
/*******************************************************************************
** Fluent setter for artifactTransformResolver: encryption key reference (the name
** of a key in a key provider) to the transform that decrypts what that key wrote.
** of a key in a key provider) to the transform that encrypts with that key and
** decrypts what it wrote, or null when there is no such key. withKeyProvider
** sets the one built on the QQQ crypto package; this is for a host with its own.
*******************************************************************************/
public BackupsQBitConfig withArtifactTransformResolver(Function<String, ArtifactTransform> artifactTransformResolver)
{
@@ -83,4 +83,15 @@ public interface ArtifactTransform
{
return ("");
}
/***************************************************************************
** What a run records to say which key wrote its objects (never the key),
** or null for a transform that has no key.
***************************************************************************/
default String keyFingerprint()
{
return (null);
}
}
@@ -0,0 +1,197 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.backups.codec;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
import com.kingsrook.qqq.backend.core.crypto.QKeyMaterial;
import com.kingsrook.qqq.backend.core.crypto.QKeyProviderInterface;
import com.kingsrook.qqq.backend.core.crypto.StreamingArtifactCipher;
import com.kingsrook.qqq.backend.core.exceptions.QException;
/*******************************************************************************
** Client-side encryption of a backup's objects (the plan's CLIENT_AES256_GCM,
** spec 11.2): the streaming cipher of the QQQ crypto package, keyed by a
** reference into a key provider.
**
** Every object gets a fresh data key, wrapped by the current version of the
** referenced key; the object's own header names the key and the version that
** wrapped it, so an object written before a rotation is read with the version
** it was written under for as long as the provider still has it.
**
** The key never leaves the provider and the cipher: it is in no table, log,
** manifest or message. What is recorded is the reference and a fingerprint.
*******************************************************************************/
public final class StreamingCipherTransform implements ArtifactTransform
{
/** The scheme a manifest records for objects this transform wrote. */
public static final String SCHEME = "tink-streaming-aead-AES256_GCM_HKDF_1MB";
private static final String FINGERPRINT_DOMAIN = "qbit-backups key fingerprint v1";
private static final int FINGERPRINT_HEX = 16;
private final StreamingArtifactCipher cipher;
private final String keyRef;
private final String fingerprint;
/*******************************************************************************
**
*******************************************************************************/
private StreamingCipherTransform(QKeyProviderInterface keyProvider, String keyRef, String fingerprint)
{
this.cipher = new StreamingArtifactCipher(keyProvider);
this.keyRef = keyRef;
this.fingerprint = fingerprint;
}
/*******************************************************************************
** The transform for a key reference, or null when the provider has no usable
** key of that name (so that a plan, a run, a verification and a restore each
** say "no key for this reference" in their own words, and nothing is written
** or read in the clear instead).
*******************************************************************************/
public static StreamingCipherTransform forKey(QKeyProviderInterface keyProvider, String keyRef)
{
if(keyProvider == null || keyRef == null || keyRef.isBlank())
{
return (null);
}
try
{
QKeyMaterial current = keyProvider.getKey(keyRef);
return (current == null ? null : new StreamingCipherTransform(keyProvider, keyRef, fingerprint(current)));
}
catch(QException e)
{
////////////////////////////////////////////////////////////////////////////
// the provider's message names the setting, never the key; the callers //
// say which reference has no key, so nothing of it is carried further //
////////////////////////////////////////////////////////////////////////////
return (null);
}
}
/*******************************************************************************
** What a run records to say which key (and which version of it) wrote its
** objects: the version, and the start of a hash over the key under a label of
** this qbit's own. Two keys do not share one, and the key cannot be had from it.
*******************************************************************************/
static String fingerprint(QKeyMaterial key)
{
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.update(FINGERPRINT_DOMAIN.getBytes(StandardCharsets.UTF_8));
byte[] keyBytes = key.getKeyBytes();
try
{
digest.update(keyBytes);
}
finally
{
java.util.Arrays.fill(keyBytes, (byte) 0);
}
return ("v" + key.getVersion() + ":" + HexFormat.of().formatHex(digest.digest()).substring(0, FINGERPRINT_HEX));
}
catch(NoSuchAlgorithmException e)
{
throw (new IllegalStateException("SHA-256 is not available", e));
}
}
/*******************************************************************************
** {@inheritDoc}
*******************************************************************************/
@Override
public OutputStream wrap(OutputStream out) throws IOException
{
try
{
return (cipher.newEncryptingStream(keyRef, out));
}
catch(QException e)
{
throw (new IOException("An object could not be encrypted with the key " + keyRef + ": the key provider did not supply it"));
}
}
/*******************************************************************************
** {@inheritDoc}
*******************************************************************************/
@Override
public InputStream unwrap(InputStream in) throws IOException
{
try
{
return (cipher.newDecryptingStream(in));
}
catch(QException e)
{
throw (new IOException("An object could not be decrypted: it is not an encrypted backup object, or the key provider has no key of the version that wrote it (key " + keyRef + ")"));
}
}
/*******************************************************************************
** {@inheritDoc}
*******************************************************************************/
@Override
public boolean encrypts()
{
return (true);
}
/*******************************************************************************
** {@inheritDoc}
*******************************************************************************/
@Override
public String keySuffix()
{
return (".tink");
}
/*******************************************************************************
** {@inheritDoc}
*******************************************************************************/
@Override
public String keyFingerprint()
{
return (fingerprint);
}
}
@@ -54,7 +54,7 @@ public final class BackupPlanValidator
private static final Set<String> COMPRESSIONS = Set.of("GZIP", "NONE");
private static final Set<String> LOCK_MODES = Set.of("NONE", "GOVERNANCE", "COMPLIANCE");
/** Replace with the real check when client-side encryption ships (spec 11.2). */
/** For a host that installs a cipher of its own outside the config; a configured key provider needs no switch. */
private static volatile boolean encryptionAvailable = false;
@@ -69,8 +69,9 @@ public final class BackupPlanValidator
/*******************************************************************************
** Tell the validator that client-side encryption is available (the encryption
** work calls this when it installs a cipher).
** Tell the validator that client-side encryption is available although the
** config has no key provider (a host with a cipher of its own). With a key
** provider on the config it is available, and a plan's key is checked too.
*******************************************************************************/
public static void setEncryptionAvailable(boolean available)
{
@@ -193,14 +194,21 @@ public final class BackupPlanValidator
String policy = settings.string("sensitiveFieldPolicy", "EXCLUDE");
if("CLIENT_AES256_GCM".equals(mode))
{
if(!encryptionAvailable)
var config = BackupsRuntime.getConfig();
var resolver = config == null ? null : config.getArtifactTransformResolver();
String keyRef = settings.string("encryptionKeyRef", null);
if(!encryptionAvailable && resolver == null)
{
errors.add("Client-side encryption is not available in this version. Use NONE (and keep the sensitive field policy at EXCLUDE).");
errors.add("Client-side encryption is not set up for this application: no key provider is configured. Use NONE (and keep the sensitive field policy at EXCLUDE).");
}
else if(settings.string("encryptionKeyRef", null) == null)
else if(keyRef == null)
{
errors.add("Client-side encryption needs an encryption key reference (the name of the key, never the key itself).");
}
else if(resolver != null && resolver.apply(keyRef) == null)
{
errors.add("No key is available for the encryption key reference " + keyRef + ": the key provider has no usable key of that name. Nothing could be encrypted, so the plan was not saved.");
}
}
if("INCLUDE_ENCRYPTED_ONLY".equals(policy) && !"CLIENT_AES256_GCM".equals(mode))
{
@@ -153,6 +153,14 @@ public final class BackupSource
}
Function<BackupManifest.EncryptionInfo, ArtifactTransform> resolver = transformResolver;
ArtifactTransform resolved = resolver == null ? null : resolver.apply(encryption);
if(resolver == null && BackupsRuntime.getConfig() != null && BackupsRuntime.getConfig().getArtifactTransformResolver() != null)
{
///////////////////////////////////////////////////////////////////////////
// the configured key provider reads what it wrote; a resolver set here //
// (by a host with a cipher of its own) takes its place //
///////////////////////////////////////////////////////////////////////////
resolved = BackupsRuntime.getConfig().getArtifactTransformResolver().apply(encryption.keyRef());
}
if(resolved == null)
{
throw (new QException("This backup is encrypted (key " + encryption.keyRef() + "), and no key provider is available to restore it"));
@@ -41,6 +41,8 @@ import com.kingsrook.qbits.backups.BackupsRuntime;
import com.kingsrook.qbits.backups.alerts.BackupAlertSink;
import com.kingsrook.qbits.backups.codec.HashingOutputStream;
import com.kingsrook.qbits.backups.codec.TableArtifactWriter;
import com.kingsrook.qbits.backups.codec.ArtifactTransform;
import com.kingsrook.qbits.backups.codec.StreamingCipherTransform;
import com.kingsrook.qbits.backups.events.BackupEvents;
import com.kingsrook.qbits.backups.files.FileCopier;
import com.kingsrook.qbits.backups.files.FileReference;
@@ -454,7 +456,7 @@ public class BackupEngine
checkJob();
if(indexWriter == null)
{
indexWriter = new FileIndexWriter(storage, runPrefix + "files/index-00001.jsonl.gz", result.getRunKey(), fileLockMode, fileRetainUntil);
indexWriter = new FileIndexWriter(storage, runPrefix + "files/index-00001.jsonl.gz", result.getRunKey(), fileLockMode, fileRetainUntil, request.getTransform());
}
FileCopier.IndexEntry entry = copier.process(ref);
indexWriter.write(entry);
@@ -530,7 +532,7 @@ public class BackupEngine
started.toString(), finished.toString(), request.getRequestedBy(), request.getSecurityScope(),
new BackupManifest.ConsistencyInfo(result.getConsistencyAchieved(), List.of()),
request.getTransform().encrypts()
? new BackupManifest.EncryptionInfo("CLIENT_AES256_GCM", "tink-streaming-aead-AES256_GCM_HKDF_1MB", request.getEncryptionKeyRef(), request.getEncryptionKeyFingerprint())
? new BackupManifest.EncryptionInfo("CLIENT_AES256_GCM", StreamingCipherTransform.SCHEME, request.getEncryptionKeyRef(), request.getEncryptionKeyFingerprint())
: new BackupManifest.EncryptionInfo("NONE", null, null, null),
manifestTables, order,
new BackupManifest.FilesInfo(settings.fileObjectPolicy(), indexKeys, copied + deduplicated, fileBytes + fileBytesRef, missing),
@@ -1085,9 +1087,11 @@ public class BackupEngine
/*******************************************************************************
** Constructor.
** Constructor. The index names tables, record keys and where each file came
** from, so in an encrypted run it is encrypted like the rows are: compressed,
** then through the run's transform, then stored.
*******************************************************************************/
FileIndexWriter(BackupStorage storage, String key, String runKey, String lockMode, Instant retainUntil) throws IOException
FileIndexWriter(BackupStorage storage, String key, String runKey, String lockMode, Instant retainUntil, ArtifactTransform transform) throws IOException
{
WriteOptions options = WriteOptions.create().withMetadata("qqq-backup-run", runKey);
if(lockMode != null)
@@ -1095,7 +1099,7 @@ public class BackupEngine
options.withObjectLock(lockMode, retainUntil);
}
stored = new HashingOutputStream(storage.openWrite(key, options));
raw = new HashingOutputStream(new GZIPOutputStream(stored));
raw = new HashingOutputStream(new GZIPOutputStream((transform == null ? ArtifactTransform.IDENTITY : transform).wrap(stored)));
}
@@ -448,7 +448,8 @@ public class BackupRunCoordinator
String mode = plan.getValueString("encryptionMode");
if(mode != null && !"NONE".equals(mode) && !request.getTransform().encrypts())
{
return ("The plan asks for " + mode + " encryption, but no cipher is available in this version. Nothing was written.");
return ("The plan asks for " + mode + " encryption, but no key is available for its encryption key reference"
+ (plan.getValueString("encryptionKeyRef") == null ? "" : " " + plan.getValueString("encryptionKeyRef")) + " (no key provider is configured, or it has no key of that name). Nothing was written.");
}
return (null);
}
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import com.kingsrook.qbits.backups.BackupsQBitConfig;
import com.kingsrook.qbits.backups.BackupsRuntime;
import com.kingsrook.qbits.backups.codec.ArtifactTransform;
import com.kingsrook.qbits.backups.model.BackupsTables;
import com.kingsrook.qbits.backups.scope.PlanSettings;
import com.kingsrook.qbits.backups.scope.ScopeResolver;
@@ -82,7 +83,7 @@ public final class BackupRunFactory
QSession session = QContext.getQSession();
String user = session == null || session.getUser() == null ? "system:scheduler" : session.getUser().getIdReference();
return (new BackupRunRequest()
BackupRunRequest request = new BackupRunRequest()
.withSettings(settings)
.withScope(resolveScope(plan))
.withTrigger(trigger)
@@ -93,6 +94,23 @@ public final class BackupRunFactory
.withSourceResolver(BackupsRuntime::storageFor)
.withInstanceName(config.getInstanceName() != null ? config.getInstanceName() : "qqq")
.withPlanName(plan.getValueString("name"))
.withClock(BackupsRuntime.getClock()));
.withClock(BackupsRuntime.getClock());
////////////////////////////////////////////////////////////////////////////////
// a plan that asks for client-side encryption gets the cipher for its key //
// reference. When there is none (no key provider, or no key of that name), //
// the request stays without one and the coordinator refuses the run: nothing //
// is ever written in the clear for a plan that asked for encryption //
////////////////////////////////////////////////////////////////////////////////
String keyRef = settings.string("encryptionKeyRef", null);
if("CLIENT_AES256_GCM".equals(settings.string("encryptionMode", "NONE")) && keyRef != null && config.getArtifactTransformResolver() != null)
{
ArtifactTransform transform = config.getArtifactTransformResolver().apply(keyRef);
if(transform != null && transform.encrypts())
{
request.withTransform(transform, keyRef, transform.keyFingerprint());
}
}
return (request);
}
}
@@ -0,0 +1,215 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.backups.codec;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import com.kingsrook.qqq.backend.core.crypto.EnvKeyProvider;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** The transform that encrypts a backup's objects: what it writes can be read
** back with the key and with nothing else, a changed or cut-off object is
** refused, a rotated key still reads what its older version wrote, and what a
** run records about the key is not the key.
**
** Every key here is random and made for the test.
*******************************************************************************/
class StreamingCipherTransformTest
{
private static final String KEY_REF = "BACKUPS_TEST_KEK";
private static final byte[] PLAIN = ("{\"id\":1,\"title\":\"a row of a backup\"}\n".repeat(4000)).getBytes(StandardCharsets.UTF_8);
/*******************************************************************************
** A new random key, as the text an environment variable would hold.
*******************************************************************************/
private static String newKey()
{
byte[] key = new byte[32];
new SecureRandom().nextBytes(key);
return (Base64.getEncoder().encodeToString(key));
}
/*******************************************************************************
**
*******************************************************************************/
private static byte[] encrypt(ArtifactTransform transform, byte[] plain) throws IOException
{
ByteArrayOutputStream stored = new ByteArrayOutputStream();
try(OutputStream out = transform.wrap(stored))
{
out.write(plain);
}
return (stored.toByteArray());
}
/*******************************************************************************
**
*******************************************************************************/
private static byte[] decrypt(ArtifactTransform transform, byte[] stored) throws IOException
{
try(InputStream in = transform.unwrap(new ByteArrayInputStream(stored)))
{
return (in.readAllBytes());
}
}
/*******************************************************************************
** What is stored is not what was written, and the key reads it back exactly.
*******************************************************************************/
@Test
void testWhatIsStoredIsCiphertextAndTheKeyReadsItBack() throws Exception
{
Map<String, String> env = new HashMap<>(Map.of(KEY_REF, newKey()));
ArtifactTransform transform = StreamingCipherTransform.forKey(new EnvKeyProvider(env::get), KEY_REF);
assertThat(transform).isNotNull();
assertThat(transform.encrypts()).isTrue();
assertThat(transform.keySuffix()).isEqualTo(".tink");
byte[] stored = encrypt(transform, PLAIN);
assertThat(new String(stored, StandardCharsets.ISO_8859_1)).doesNotContain("a row of a backup");
assertThat(stored.length).isGreaterThan(PLAIN.length);
assertThat(decrypt(transform, stored)).isEqualTo(PLAIN);
assertThat(encrypt(transform, PLAIN)).as("a fresh data key for every object").isNotEqualTo(stored);
}
/*******************************************************************************
** A flipped byte, and an object cut short, are refused: nothing altered is
** ever handed back as if it were the backup.
*******************************************************************************/
@Test
void testAChangedOrCutOffObjectIsRefused() throws Exception
{
Map<String, String> env = new HashMap<>(Map.of(KEY_REF, newKey()));
ArtifactTransform transform = StreamingCipherTransform.forKey(new EnvKeyProvider(env::get), KEY_REF);
byte[] stored = encrypt(transform, PLAIN);
byte[] flipped = stored.clone();
flipped[flipped.length / 2] ^= 0x01;
assertThatThrownBy(() -> decrypt(transform, flipped)).isInstanceOf(IOException.class);
byte[] cut = java.util.Arrays.copyOf(stored, stored.length - 100);
assertThatThrownBy(() -> decrypt(transform, cut)).isInstanceOf(IOException.class);
assertThatThrownBy(() -> decrypt(transform, PLAIN)).as("an object that was never encrypted").isInstanceOf(IOException.class);
}
/*******************************************************************************
** Another key does not read it, and its message says nothing of either key.
*******************************************************************************/
@Test
void testAnotherKeyDoesNotReadIt() throws Exception
{
String rightKey = newKey();
String wrongKey = newKey();
byte[] stored = encrypt(StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, rightKey)::get), KEY_REF), PLAIN);
ArtifactTransform wrong = StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, wrongKey)::get), KEY_REF);
assertThatThrownBy(() -> decrypt(wrong, stored)).isInstanceOf(IOException.class)
.satisfies(e -> assertThat(String.valueOf(e.getMessage())).doesNotContain(rightKey).doesNotContain(wrongKey));
}
/*******************************************************************************
** A reference with no key, or a key that is not a key, gives no transform: the
** caller then refuses, and nothing is written in the clear instead.
*******************************************************************************/
@Test
void testNoKeyGivesNoTransform()
{
assertThat(StreamingCipherTransform.forKey(new EnvKeyProvider(Map.<String, String>of()::get), KEY_REF)).isNull();
assertThat(StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, "not-a-key")::get), KEY_REF)).isNull();
assertThat(StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, newKey())::get), " ")).isNull();
assertThat(StreamingCipherTransform.forKey(null, KEY_REF)).isNull();
}
/*******************************************************************************
** After a rotation the new version writes, and what the old version wrote is
** still read for as long as the provider keeps that version; without it, it is
** refused.
*******************************************************************************/
@Test
void testARotatedKeyStillReadsWhatItsOlderVersionWrote() throws Exception
{
Map<String, String> env = new HashMap<>();
String first = newKey();
env.put(KEY_REF, first);
ArtifactTransform before = StreamingCipherTransform.forKey(new EnvKeyProvider(env::get), KEY_REF);
byte[] oldObject = encrypt(before, PLAIN);
env.put(KEY_REF + "_V1", first);
env.put(KEY_REF, newKey());
env.put(KEY_REF + "_VERSION", "2");
ArtifactTransform after = StreamingCipherTransform.forKey(new EnvKeyProvider(env::get), KEY_REF);
assertThat(after.keyFingerprint()).startsWith("v2:").isNotEqualTo(before.keyFingerprint());
assertThat(decrypt(after, oldObject)).as("written under version 1, read after the rotation").isEqualTo(PLAIN);
assertThat(decrypt(after, encrypt(after, PLAIN))).isEqualTo(PLAIN);
env.remove(KEY_REF + "_V1");
ArtifactTransform withoutTheOldVersion = StreamingCipherTransform.forKey(new EnvKeyProvider(env::get), KEY_REF);
assertThatThrownBy(() -> decrypt(withoutTheOldVersion, oldObject)).isInstanceOf(IOException.class);
}
/*******************************************************************************
** The fingerprint a run records names the version, is the same every time for
** one key, differs between keys, and holds nothing of the key.
*******************************************************************************/
@Test
void testTheFingerprintIsNotTheKey()
{
String keyText = newKey();
String one = StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, keyText)::get), KEY_REF).keyFingerprint();
String again = StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, keyText)::get), KEY_REF).keyFingerprint();
String another = StreamingCipherTransform.forKey(new EnvKeyProvider(Map.of(KEY_REF, newKey())::get), KEY_REF).keyFingerprint();
String keyAsHex = java.util.HexFormat.of().formatHex(Base64.getDecoder().decode(keyText));
assertThat(one).matches("v1:[0-9a-f]{16}").isEqualTo(again).isNotEqualTo(another);
assertThat(keyAsHex).doesNotContain(one.substring(3));
assertThat(keyText).doesNotContain(one.substring(3));
}
}
@@ -160,17 +160,35 @@ class BackupPlanValidationTest
/*******************************************************************************
** Including sensitive fields only encrypted needs encryption; client-side
** encryption is refused until a cipher is installed, and then needs a key name.
** With a key provider on the config the key must be one the provider has.
*******************************************************************************/
@Test
void testEncryptionRules() throws Exception
{
assertThat(errors(save(Map.of("sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY")))).singleElement().asString().contains("requires client-side encryption");
assertThat(errors(save(Map.of("encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "kek")))).singleElement().asString().contains("not available in this version");
assertThat(errors(save(Map.of("encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "kek")))).singleElement().asString().contains("no key provider is configured");
assertThat(errors(save(Map.of("sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY", "encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "kek")))).hasSize(1);
BackupPlanValidator.setEncryptionAvailable(true);
assertThat(errors(save(Map.of("sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY", "encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "kek")))).isEmpty();
assertThat(errors(save(Map.of("encryptionMode", "CLIENT_AES256_GCM")))).singleElement().asString().contains("encryption key reference");
BackupPlanValidator.setEncryptionAvailable(false);
byte[] key = new byte[32];
new java.security.SecureRandom().nextBytes(key);
Map<String, String> env = Map.of("PLAN_TEST_KEK", java.util.Base64.getEncoder().encodeToString(key));
com.kingsrook.qbits.backups.BackupsRuntime.getConfig().withKeyProvider(new com.kingsrook.qqq.backend.core.crypto.EnvKeyProvider(env::get));
try
{
assertThat(errors(save(Map.of("planKey", "with-a-key", "sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY", "encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "PLAN_TEST_KEK"))))
.as("the provider has this key").isEmpty();
assertThat(errors(save(Map.of("planKey", "without-a-key", "encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "NO_SUCH_KEK")))).singleElement().asString()
.contains("No key is available for the encryption key reference NO_SUCH_KEK");
}
finally
{
com.kingsrook.qbits.backups.BackupsRuntime.getConfig().withKeyProvider(null);
}
}
@@ -175,6 +175,47 @@ class RestoreModesTest
/*******************************************************************************
** A restore from an encrypted backup, with the key provider of the config and
** nothing else set up: the edited rows are rolled back, and the file that was
** removed comes back as it was although its copy in the backup is ciphertext.
** Without the key the restore is refused before anything is read or written.
*******************************************************************************/
@Test
void testRestoreFromAnEncryptedBackup() throws Exception
{
java.util.Map<String, String> env = new java.util.HashMap<>();
byte[] key = new byte[32];
new java.security.SecureRandom().nextBytes(key);
env.put("RESTORE_TEST_KEK", java.util.Base64.getEncoder().encodeToString(key));
com.kingsrook.qbits.backups.BackupsRuntime.getConfig().withKeyProvider(new com.kingsrook.qqq.backend.core.crypto.EnvKeyProvider(env::get));
BackupRunResult run = RestoreTestSupport.backup(Map.of("encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "RESTORE_TEST_KEK", "sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY"));
assertThat(RestoreTestSupport.manifest(run).encryption().mode()).isEqualTo("CLIENT_AES256_GCM");
assertThat(RestoreTestSupport.manifest(run).encryption().keyFingerprint()).startsWith("v1:");
assertThat(BackupsTestUtils.BACKUPS.list("").stream().filter(o -> o.key().contains("_files/sha256/")).map(o -> new String(BackupsTestUtils.BACKUPS.getBytes(o.key()))))
.as("the copies of the files are ciphertext too").isNotEmpty().noneMatch(content -> content.contains("photo bytes"));
byte[] index = BackupsTestUtils.BACKUPS.list("").stream().filter(o -> o.key().endsWith("files/index-00001.jsonl.gz")).map(o -> BackupsTestUtils.BACKUPS.getBytes(o.key())).findFirst().orElseThrow();
assertThat(new String(index, 0, 4, java.nio.charset.StandardCharsets.US_ASCII)).as("the file index names record keys and where files came from: it is encrypted too").isEqualTo("QSC1");
RestoreTestSupport.mutate();
BackupsTestUtils.MEDIA.removeIgnoringLock("media/photo-1.jpg");
RestoreOutcome outcome = new RestoreEngine().execute(RestoreTestSupport.request(run, RestoreRequest.MODE_UPSERT, "blogPost"));
assertThat(outcome.getErrors()).isEmpty();
assertThat(outcome.getTables().get("blogPost").getUpdated()).isEqualTo(10);
assertThat(outcome.getTables().get("blogPost").getFilesRestored()).isEqualTo(1);
assertThat(RestoreTestSupport.rows("blogPost").stream().filter(r -> r.getValueInteger("id") == 15).findFirst().orElseThrow().getValueString("title")).isEqualTo("Post 15");
assertThat(new String(BackupsTestUtils.MEDIA.getBytes("media/photo-1.jpg"))).isEqualTo("photo bytes 1");
env.clear();
RestoreOutcome refused = new RestoreEngine().review(RestoreTestSupport.request(run, RestoreRequest.MODE_UPSERT, "blogPost"));
assertThat(refused.getErrors()).singleElement().asString().contains("This backup is encrypted (key RESTORE_TEST_KEK), and no key provider is available to restore it");
assertThat(refused.getTables()).as("nothing was read").isEmpty();
}
/*******************************************************************************
** REPLACE needs the typed confirmation, deletes what is not in the backup, takes a
** pre-restore backup first, brings the table back to exactly the backed up rows
@@ -323,6 +323,65 @@ class BackupVerifierTest
/*******************************************************************************
** The real thing, from the plan: a key provider on the config, a plan that asks
** for client-side encryption with a key reference. Its run is encrypted without
** anybody handing it a cipher: the objects are ciphertext, the run and its
** manifest record the reference and a fingerprint (never the key), and it
** passes verification by content and a test restore. After a rotation the old
** run still verifies and a new run is written under the new version. When the
** key is gone the old run cannot be verified, and a new run is refused with
** nothing written.
*******************************************************************************/
@Test
void testAPlanThatAsksForEncryptionIsEncryptedByTheKeyProvider() throws Exception
{
java.util.Map<String, String> env = new java.util.HashMap<>();
byte[] first = new byte[32];
new java.security.SecureRandom().nextBytes(first);
env.put("RUN_TEST_KEK", java.util.Base64.getEncoder().encodeToString(first));
BackupsRuntime.getConfig().withKeyProvider(new com.kingsrook.qqq.backend.core.crypto.EnvKeyProvider(env::get));
QRecord plan = plan(Map.of("encryptionMode", "CLIENT_AES256_GCM", "encryptionKeyRef", "RUN_TEST_KEK", "sensitiveFieldPolicy", "INCLUDE_ENCRYPTED_ONLY"));
BackupRunResult result = new com.kingsrook.qbits.backups.run.BackupRunCoordinator().runPlan(plan, "MANUAL");
assertThat(result.isUsable()).as(String.valueOf(result.getErrorMessage())).isTrue();
QRecord stored = run(result.getRunId());
assertThat(stored.getValueString("encryptionKeyRef")).isEqualTo("RUN_TEST_KEK");
assertThat(stored.getValueString("encryptionKeyFingerprint")).matches("v1:[0-9a-f]{16}");
String key = VerifyTestSupport.firstPartKey(result, "blogPost");
assertThat(key).endsWith(".tink");
byte[] object = BackupsTestUtils.BACKUPS.getBytes(key);
assertThat(new String(object, 0, 4, java.nio.charset.StandardCharsets.US_ASCII)).as("the cipher's header, not a gzip stream").isEqualTo("QSC1");
assertThat(new BackupCatalog().where(BackupsTables.ARTIFACT, "backupRunId", result.getRunId()).stream().filter(a -> "TABLE_DATA".equals(a.getValueString("artifactType"))))
.isNotEmpty().allSatisfy(a -> assertThat(a.getValueBoolean("encrypted")).isTrue());
List<VerificationOutcome> good = new BackupVerifier().verifyThrough(result.getRunId(), BackupVerifier.TEST_RESTORE, "MANUAL", "t");
assertThat(good).extracting(VerificationOutcome::status).containsExactly("PASSED", "PASSED", "PASSED");
env.put("RUN_TEST_KEK_V1", env.get("RUN_TEST_KEK"));
byte[] second = new byte[32];
new java.security.SecureRandom().nextBytes(second);
env.put("RUN_TEST_KEK", java.util.Base64.getEncoder().encodeToString(second));
env.put("RUN_TEST_KEK_VERSION", "2");
assertThat(new BackupVerifier().verify(result.getRunId(), BackupVerifier.CONTENT, "MANUAL", "t").status()).as("written under version 1, verified after the rotation").isEqualTo("PASSED");
VerifyTestSupport.clock.advance(java.time.Duration.ofHours(1));
BackupRunResult rotated = new com.kingsrook.qbits.backups.run.BackupRunCoordinator().runPlan(reload(plan), "MANUAL");
assertThat(rotated.isUsable()).as(String.valueOf(rotated.getErrorMessage())).isTrue();
assertThat(run(rotated.getRunId()).getValueString("encryptionKeyFingerprint")).startsWith("v2:");
env.clear();
assertThat(new BackupVerifier().verify(result.getRunId(), BackupVerifier.CONTENT, "MANUAL", "t").messages()).anyMatch(m -> m.contains("No key is available for the key reference RUN_TEST_KEK"));
int objects = BackupsTestUtils.BACKUPS.list("").size();
BackupRunResult refused = new com.kingsrook.qbits.backups.run.BackupRunCoordinator().runPlan(reload(plan), "MANUAL");
assertThat(refused.getStatus()).isEqualTo("FAILED");
assertThat(refused.getErrorMessage()).contains("no key is available for its encryption key reference RUN_TEST_KEK").contains("Nothing was written");
assertThat(BackupsTestUtils.BACKUPS.list("")).as("nothing was written in the clear instead").hasSize(objects);
}
/*******************************************************************************
** Encrypted runs verify through the decrypt hook; a wrong key fails clearly; no
** hook at all is an ERROR that says what to configure.