From 0eede240cb8ec3b30d711bd1657457a937f341c8 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:13:23 +0000 Subject: [PATCH 01/18] update(images): update Docker image versions (web-app-gitlab) --- roles/web-app-gitlab/meta/services.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/web-app-gitlab/meta/services.yml b/roles/web-app-gitlab/meta/services.yml index b4cb1d6d72..cf4fc8fa72 100644 --- a/roles/web-app-gitlab/meta/services.yml +++ b/roles/web-app-gitlab/meta/services.yml @@ -78,7 +78,7 @@ webservice: backup: stop_required: false image: registry.gitlab.com/gitlab-org/build/cng/gitlab-webservice-ce - version: v19.6.0 + version: v19.6.1 name: gitlab-webservice healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -99,7 +99,7 @@ sidekiq: flavor: tcp path: liveness image: registry.gitlab.com/gitlab-org/build/cng/gitlab-sidekiq-ce - version: v19.6.0 + version: v19.6.1 name: gitlab-sidekiq cpus: "1.0" mem_reservation: 2g @@ -112,7 +112,7 @@ workhorse: backup: stop_required: false image: registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ce - version: v19.6.0 + version: v19.6.1 name: gitlab-workhorse healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -128,7 +128,7 @@ gitaly: # nocheck: default-placement-manager the repositories live on a node-local volume (meta/volumes.yml nfs: false, gitaly does not support NFS), which a reschedule leaves behind on the old node placement: manager image: registry.gitlab.com/gitlab-org/build/cng/gitaly - version: v19.6.0 + version: v19.6.1 healthcheck: test: ["CMD", "/scripts/healthcheck"] name: gitlab-gitaly @@ -143,7 +143,7 @@ shell: backup: stop_required: false image: registry.gitlab.com/gitlab-org/build/cng/gitlab-shell - version: v19.6.0 + version: v19.6.1 name: gitlab-shell ports: internal: @@ -158,7 +158,7 @@ migrations: # nocheck: single-replica replicas: 1 image: registry.gitlab.com/gitlab-org/build/cng/gitlab-rails-ce - version: v19.6.0 + version: v19.6.1 name: gitlab-migrations cpus: "1.0" mem_reservation: 1g From 345a015a16560c81a380b6ed0f21e69e173ee1a2 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:13:34 +0000 Subject: [PATCH 02/18] update(versions): update pins with a declared source (web-app-pretix) --- roles/web-app-pretix/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-pretix/meta/services.yml b/roles/web-app-pretix/meta/services.yml index 158ec18ba7..8986698c27 100644 --- a/roles/web-app-pretix/meta/services.yml +++ b/roles/web-app-pretix/meta/services.yml @@ -56,7 +56,7 @@ pretix: # nocheck: docker-version runtime base of the source build, not the served application version: "3.13" source_repository: https://github.com/pretix/pretix.git - source_version: v2026.9.2 + source_version: v2026.9.3 update: - key: source_version type: git_tags From a3b7af619bde6be4b76f000e6a64505a0f8868be Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 12:40:08 +0000 Subject: [PATCH 03/18] fix(ci): skip the runtime vulnerability sync when no deploy chunk ran MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A main push whose selection deploys nothing (all four deploy chunks skipped) uploads no rescue-diagnostics artifact, so gh run download in the runtime vulnerability sync step exited 1 and turned the report job and the whole pipeline red (run 44683997608 on a29d4bf8fe). The step now runs only when at least one deploy chunk succeeded, failed or was cancelled; with nothing scanned there is nothing to open, update or close. 🎯 Fix: 95 % 💥 Break: 1 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 94 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .github/workflows/call-orchestrator.yml | 2 +- .../meta/ci/test_runtime_vulnerabilities.py | 35 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/call-orchestrator.yml b/.github/workflows/call-orchestrator.yml index 04da142767..cc1ac3fff9 100644 --- a/.github/workflows/call-orchestrator.yml +++ b/.github/workflows/call-orchestrator.yml @@ -398,7 +398,7 @@ jobs: if: ${{ !cancelled() }} run: grep '^INFINITO_GHCR_MIRROR_PREFIX=' default.env >> "$GITHUB_ENV" - name: 🛡️ Open, update and close the runtime vulnerability issues - if: ${{ !cancelled() }} + if: ${{ !cancelled() && (contains(needs.*.result, 'success') || contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: python3 -m cli.meta.ci.runtime_vulnerabilities --run-id "${{ github.run_id }}" --repo "${{ github.repository }}" --ref "${GITHUB_REF}" --dir "${RUNNER_TEMP}/rescue-diagnostics" diff --git a/tests/unit/python/cli/meta/ci/test_runtime_vulnerabilities.py b/tests/unit/python/cli/meta/ci/test_runtime_vulnerabilities.py index 7299a44aaf..fbb5d54ea4 100644 --- a/tests/unit/python/cli/meta/ci/test_runtime_vulnerabilities.py +++ b/tests/unit/python/cli/meta/ci/test_runtime_vulnerabilities.py @@ -2,6 +2,7 @@ from __future__ import annotations import datetime as dt import json +import re import tempfile import unittest from pathlib import Path @@ -370,23 +371,47 @@ class TestMainGuard(unittest.TestCase): self.assertEqual(gh.calls[0][:2], ["run", "download"]) self.assertIn(f"opened {NGINX_TITLE}", actions) - def guarded(self, job): - step = next( + @staticmethod + def report_job(): + workflow = PROJECT_ROOT / ".github" / "workflows" / "call-orchestrator.yml" + return load_yaml(str(workflow))["jobs"]["report-main-failures"] + + @staticmethod + def sync_step(job): + return next( step for step in job["steps"] if "runtime_vulnerabilities" in step.get("run", "") ) + + def guarded(self, job): return ( "github.ref == 'refs/heads/main'" in job["if"] - and '--ref "${GITHUB_REF}"' in step["run"] + and '--ref "${GITHUB_REF}"' in self.sync_step(job)["run"] ) def test_the_workflow_job_runs_only_on_main_and_hands_the_ref_on(self): - workflow = PROJECT_ROOT / ".github" / "workflows" / "call-orchestrator.yml" - job = load_yaml(str(workflow))["jobs"]["report-main-failures"] + job = self.report_job() self.assertTrue(self.guarded(job)) self.assertFalse(self.guarded({**job, "if": "${{ always() }}"})) + @staticmethod + def sync_runs(condition, results): + wanted = re.findall(r"contains\(needs\.\*\.result, '(\w+)'\)", condition) + return not wanted or any(result in wanted for result in results) + + def test_the_sync_runs_only_after_a_deploy_chunk_ran(self): + job = self.report_job() + condition = self.sync_step(job)["if"] + skipped = ["skipped"] * len(job["needs"]) + self.assertFalse(self.sync_runs(condition, skipped)) + for result in ("success", "failure", "cancelled"): + self.assertTrue(self.sync_runs(condition, [result, *skipped[1:]])) + + def test_negative_control_an_unguarded_sync_runs_without_any_deploy(self): + skipped = ["skipped"] * len(self.report_job()["needs"]) + self.assertTrue(self.sync_runs("${{ !cancelled() }}", skipped)) + if __name__ == "__main__": unittest.main() From 8da606919b66041b8031f4d11d82be1f7df8797e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 13:03:39 +0000 Subject: [PATCH 04/18] fix(web-app-shopware): build the vendor tree without ext-mbstring in composer:2.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The composer:2.11 image (digest 919efe8e) moved to PHP 8.5 without mbstring, so composer install in the builder stage refuses shopware/core v6.7.13.0 (requires ext-mbstring, and shopware/core replaces symfony/polyfill-mbstring); Shopware#0 failed in docker compose build on main run 44593266731. The builder only resolves and downloads the vendor tree; the runtime image ghcr.io/shopware/docker-base:8.3.36-caddy ships mbstring, as it ships gd, intl, pdo_mysql and redis, which the builder already ignores. Verified: the builder stage now installs shopware/core v6.7.13.0; the origin/main builder stage still fails with the CI error. MEDUSA reports 4 findings in this Dockerfile, all on unchanged runtime-stage lines (DKR001 USER root, DL3018 unpinned apk, DS-0026 no HEALTHCHECK, SC2016); the operator accepted committing the hotfix with them left for a separate change. 🎯 Fix: 96 % 💥 Break: 1 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 76 % 🏆 Score: 72 🚦 Gate: ⚠️ security 76 % < 100: ask the operator before the commit Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- roles/web-app-shopware/files/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/web-app-shopware/files/Dockerfile b/roles/web-app-shopware/files/Dockerfile index 092232bc4f..55ccd9f9dc 100644 --- a/roles/web-app-shopware/files/Dockerfile +++ b/roles/web-app-shopware/files/Dockerfile @@ -26,6 +26,7 @@ RUN set -eux; \ --no-scripts \ --ignore-platform-req=ext-gd \ --ignore-platform-req=ext-intl \ + --ignore-platform-req=ext-mbstring \ --ignore-platform-req=ext-pdo_mysql; \ composer require symfony/redis-messenger:^7.4 league/flysystem-async-aws-s3:^3.0 \ heptacom/shopware-platform-admin-open-auth:^9.0 \ @@ -35,6 +36,7 @@ RUN set -eux; \ --update-no-dev \ --ignore-platform-req=ext-gd \ --ignore-platform-req=ext-intl \ + --ignore-platform-req=ext-mbstring \ --ignore-platform-req=ext-pdo_mysql \ --ignore-platform-req=ext-redis From cdafcc98eeb647c9a140deb23ed9151409c5fb1c Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 13:14:29 +0000 Subject: [PATCH 05/18] fix(sys-ctl-hlth-runtime): bound every Trivy run by the job timeout, not Trivy's 5 minute default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit script.py bounds each engine run by JOB_TIMEOUT_SECONDS (4 h) but passed no --timeout to Trivy, so Trivy's built-in 5 minute deadline applied. On a busy swarm node the image scan of local_discourse/discourse (4.52 GB) hit it: 'analyze error: pipeline error: context deadline exceeded' after 300.4 s, the report counted errors 1 with fail 0, and sys-service-terminator failed to start hlth-runtime (Discourse#2, PR 2309 run 44683973433). TRIVY_COMMON now passes --timeout JOB_TIMEOUT_SECONDS, which covers image, rootfs, sbom and both database downloads, the same bound Syft, Grype and OSV already have. 🎯 Fix: 90 % 💥 Break: 4 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 86 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- roles/sys-ctl-hlth-runtime/README.md | 1 + roles/sys-ctl-hlth-runtime/files/python/script.py | 2 ++ .../sys-ctl-hlth-runtime/files/test_script.py | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/roles/sys-ctl-hlth-runtime/README.md b/roles/sys-ctl-hlth-runtime/README.md index 6b8c6a393f..b8c0a520c8 100644 --- a/roles/sys-ctl-hlth-runtime/README.md +++ b/roles/sys-ctl-hlth-runtime/README.md @@ -39,6 +39,7 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional ( - **Metrics:** While `web-app-prometheus` is deployed, the check replaces `infinito_hlth_runtime.prom` in `DIR_METRICS_TEXTFILE` atomically with the gauges `infinito_hlth_runtime_findings{target,kind,image,severity,scanner,verdict}`, `infinito_hlth_runtime_last_run_timestamp_seconds`, `infinito_hlth_runtime_last_run_success` and `infinito_hlth_runtime_scanner_errors{scanner}`. No series carries a CVE id. - **Suppressions:** A role accepts findings for its own containers under `.security.suppressions` of its `meta/services.yml`, each entry `id` (one CVE) or `image_tag` (every finding of the image while it runs that tag, which MUST equal the service's `version`) plus `until` below a `# nocheck: cve ` marker, see [suppression.md](../../docs/contributing/actions/testing/suppression.md). Host suppressions are the `id` entries under the engine entries of this role and cover that engine's host findings; an `image_tag` entry there covers the engine's own image. - **Databases:** With `db_update` the engines refresh their databases under `database_dir` before each run, three attempts 30 s apart; without it the databases MUST already be there, and a missing one fails the run. SBOMs of running images are cached under `cache_dir` by image id. +- **Run bound:** Every engine run ends after `JOB_TIMEOUT_SECONDS` of [script.py](./files/python/script.py), 4 h, and then fails the check. Trivy gets the same bound as its `--timeout`, because its own default of 5 minutes failed the scan of the 4.5 GB `local_discourse/discourse` image on a busy swarm node with `context deadline exceeded`. - **Scratch:** Every engine run gets its own temporary directory in the run's work directory under `cache_dir`, removed as soon as the run ends, also when the engine fails, times out or crashes. Engine runs that export an image take turns, whatever `workers` is: each holds a lock on `database_dir` from creating its scratch directory until it has removed it, and on a timeout or crash also its container. The lock spans every scan that reads the same `database_dir`, so the swarm lab nodes and the local stacks of every worktree, which all share the host directory `INFINITO_VULNERABILITY_DB_HOST_PATH` of `default.env`, take turns on their one host disk. The other engine runs keep running in parallel. A run killed mid-scan leaves its work directory to the next run, which removes it first. - **Deploy-time run:** The deploy runs the check once at its end and fails on its first failure, without the retries `sys-service-terminator` gives other units. - **Development and CI deploys:** A CI row pins one engine and restores its databases; a local deploy draws one engine and refreshes the shared host directory `INFINITO_VULNERABILITY_DB_HOST_PATH`. Both run it behind Syft plus the Grype runtime pass and read the databases read-only at `INFINITO_VULNERABILITY_DB_DIR`. Production hosts run every engine. diff --git a/roles/sys-ctl-hlth-runtime/files/python/script.py b/roles/sys-ctl-hlth-runtime/files/python/script.py index 27761cdd63..0be60119ab 100755 --- a/roles/sys-ctl-hlth-runtime/files/python/script.py +++ b/roles/sys-ctl-hlth-runtime/files/python/script.py @@ -1255,6 +1255,8 @@ ENGINE_ENV = { TRIVY_COMMON = ( "--cache-dir", CACHE, + "--timeout", + f"{JOB_TIMEOUT_SECONDS}s", "--disable-telemetry", "--skip-version-check", "--quiet", diff --git a/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py b/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py index 3d9ffff556..1c6c0d4605 100644 --- a/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py +++ b/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py @@ -1944,6 +1944,20 @@ class TestCommands(TestCase): step = SCRIPT.trivy_step(self.layout, "trivy:1", self.container, _config(), []) self.assertIn("/var/run/docker.sock:/var/run/docker.sock:ro", step.argv) + def test_every_trivy_run_ends_only_at_the_job_bound(self): + steps = [ + SCRIPT.trivy_step(self.layout, "trivy:1", self.container, _config(), []), + SCRIPT.trivy_step(self.layout, "trivy:1", self.host, _config(), []), + *SCRIPT.db_steps("trivy", self.layout, "trivy:1"), + ] + for step in steps: + with self.subTest(step=step.label): + self.assertIn("--timeout", step.argv) + self.assertEqual( + step.argv[step.argv.index("--timeout") + 1], + f"{SCRIPT.JOB_TIMEOUT_SECONDS}s", + ) + def test_the_host_scan_skips_the_excluded_paths(self): step = SCRIPT.trivy_step(self.layout, "trivy:1", self.host, _config(), []) self.assertEqual( From 8ed7c40fc56a5bc62088373d4be2aad2e901e074 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 13:50:46 +0000 Subject: [PATCH 06/18] fix(web-app-mediawiki): load OpenIDConnect only once its composer vendor tree exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On the MediaWiki swarm (run 44684132745) replica mediawiki.2 queued OpenIDConnect before composer had written extensions/OpenIDConnect/vendor/ to the shared volume. MediaWiki's ExtensionRegistry caches per replica, for a day, whether an extension's vendor/autoload.php existed when the extension was first queued, so that replica kept failing with 'Class "Jumbojett\OpenIDConnectClient" not found' after composer had finished. oidc.php.j2 now loads PluggableAuth and OpenIDConnect only when vendor/autoload.php exists as well, so the queued set, and with it the registry cache key, changes once the vendor tree appears. test_composer_autoloader_gate.py checks that every extension declaring load_composer_autoloader (OpenIDConnect, AWS, VisualEditorPlus) is loaded behind a file_exists check on its vendor/autoload.php; on origin/main it fails for OpenIDConnect, with the change it passes (1 passed, 3 subtests). MEDUSA could not run in the sandbox (read-only ~/.medusa); the two-file diff was reviewed by hand: a constant path check and a repository-only test, no trust boundary, secret or injection surface. 🎯 Fix: 88 % 💥 Break: 3 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 85 🚦 Gate: ⛔ fix 88 % < 90 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- roles/web-app-mediawiki/templates/oidc.php.j2 | 4 +- .../test_composer_autoloader_gate.py | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/unit/python/roles/web-app-mediawiki/test_composer_autoloader_gate.py diff --git a/roles/web-app-mediawiki/templates/oidc.php.j2 b/roles/web-app-mediawiki/templates/oidc.php.j2 index 7ce2059aa1..73f4ac1ca8 100644 --- a/roles/web-app-mediawiki/templates/oidc.php.j2 +++ b/roles/web-app-mediawiki/templates/oidc.php.j2 @@ -5,8 +5,10 @@ $pa = "$IP/extensions/PluggableAuth/extension.json"; $oidc = "$IP/extensions/OpenIDConnect/extension.json"; +$oidcVendor = "$IP/extensions/OpenIDConnect/vendor/autoload.php"; -if ( file_exists( $pa ) && file_exists( $oidc ) ) { +// Exception: ExtensionRegistry caches per replica, for a day, whether vendor/autoload.php existed when it first saw OpenIDConnect queued. +if ( file_exists( $pa ) && file_exists( $oidc ) && file_exists( $oidcVendor ) ) { {% if 'web-svc-logout' in CURRENT_PLAY_APPLICATIONS %} $wgPasswordAttemptThrottle = []; diff --git a/tests/unit/python/roles/web-app-mediawiki/test_composer_autoloader_gate.py b/tests/unit/python/roles/web-app-mediawiki/test_composer_autoloader_gate.py new file mode 100644 index 0000000000..0eb502c312 --- /dev/null +++ b/tests/unit/python/roles/web-app-mediawiki/test_composer_autoloader_gate.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +import re +import unittest + +from utils.cache.files import PROJECT_ROOT, read_text + +ROLE = PROJECT_ROOT / "roles" / "web-app-mediawiki" +JINJA = re.compile(r"\{%.*?%\}|\{#.*?#\}|\{\{.*?\}\}", re.DOTALL) +ASSIGNMENT = re.compile(r'^\s*(\$\w+)\s*=\s*"([^"]*)";', re.MULTILINE) +SYNTAX = re.compile(r"[{};]|wfLoadExtension\(\s*'([^']+)'\s*\)") +COMPOSER_AUTOLOADED = { + "OpenIDConnect": "oidc.php.j2", + "AWS": "LocalSettings.php.j2", + "VisualEditorPlus": "LocalSettings.php.j2", +} + + +def _guards(template: str) -> dict[str, str]: + """ + Args: + template: file name of a PHP template under the role's templates/. + + Returns: + every extension the template loads, mapped to the conditions of the + blocks around its wfLoadExtension call, with the template's string + variables written out. + """ + php = JINJA.sub("", read_text(str(ROLE / "templates" / template))) + variables = dict(ASSIGNMENT.findall(php)) + loads: dict[str, str] = {} + headers: list[str] = [] + start = 0 + for match in SYNTAX.finditer(php): + symbol = match.group(0) + if match.group(1): + loads[match.group(1)] = " ".join(headers) + continue + if symbol == "{": + headers.append(php[start : match.start()]) + elif symbol == "}": + headers.pop() + start = match.end() + for name, value in variables.items(): + pattern = re.compile(re.escape(name) + r"(?!\w)") + loads = { + ext: pattern.sub(lambda _match, value=value: f'"{value}"', guard) + for ext, guard in loads.items() + } + return loads + + +class TestComposerAutoloaderGate(unittest.TestCase): + def test_composer_autoloaded_extensions_wait_for_their_vendor_tree(self) -> None: + for extension, template in COMPOSER_AUTOLOADED.items(): + with self.subTest(extension=extension): + guard = _guards(template)[extension] + self.assertRegex( + guard, + rf'file_exists\(\s*"\$IP/extensions/{extension}/vendor/autoload\.php"\s*\)', + f"{extension} declares load_composer_autoloader, and MediaWiki's " + "ExtensionRegistry caches per replica for a day whether its " + "vendor/autoload.php existed when the extension was first queued, " + "so loading it before composer finished leaves that replica " + "without the extension's composer classes", + ) + + +if __name__ == "__main__": + unittest.main() From 9683264fe6691d8a5aa68e0d62e214a4e60f2fd9 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:18:02 +0000 Subject: [PATCH 07/18] update(images): update Docker image versions (web-app-espocrm) --- roles/web-app-espocrm/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-espocrm/meta/services.yml b/roles/web-app-espocrm/meta/services.yml index 60f35be54e..f8ee319dad 100644 --- a/roles/web-app-espocrm/meta/services.yml +++ b/roles/web-app-espocrm/meta/services.yml @@ -38,7 +38,7 @@ espocrm: swarm: enabled: true image: espocrm/espocrm - version: "10.1.3" + version: "10.1.4" custom: true name: espocrm min_storage: 470MB From c9539370a64b31f434acf3a19cd84bf258128cb4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 15:31:30 +0100 Subject: [PATCH 08/18] Update roles/web-app-mediawiki/templates/oidc.php.j2 --- roles/web-app-mediawiki/templates/oidc.php.j2 | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/web-app-mediawiki/templates/oidc.php.j2 b/roles/web-app-mediawiki/templates/oidc.php.j2 index 73f4ac1ca8..c4904c4993 100644 --- a/roles/web-app-mediawiki/templates/oidc.php.j2 +++ b/roles/web-app-mediawiki/templates/oidc.php.j2 @@ -7,7 +7,6 @@ $pa = "$IP/extensions/PluggableAuth/extension.json"; $oidc = "$IP/extensions/OpenIDConnect/extension.json"; $oidcVendor = "$IP/extensions/OpenIDConnect/vendor/autoload.php"; -// Exception: ExtensionRegistry caches per replica, for a day, whether vendor/autoload.php existed when it first saw OpenIDConnect queued. if ( file_exists( $pa ) && file_exists( $oidc ) && file_exists( $oidcVendor ) ) { {% if 'web-svc-logout' in CURRENT_PLAY_APPLICATIONS %} From 66da100852b5c07e8fc71058a17aee78c569535b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 14:38:09 +0000 Subject: [PATCH 09/18] fix(ci): cancel a closed pull request's runs only when they belong to it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/github/cancel/pull_request_runs.sh runs privileged under pull_request_target when a pull request closes. It also cancelled every pull_request run whose head_sha equalled the closed pull request's head, whatever pull request or repository the run belonged to. Anyone could therefore open a pull request on another pull request's head commit and close it again, which cancelled the other pull request's CI runs. The head-sha matcher now requires that the run names no other pull request and comes from the same head repository or carries this pull request's number in its run name. When another open pull request shares the head, the head-sha matcher is dropped together with the branch matcher. test_cancel_runs.py covers a rival pull request on another head and on the same head; the old script cancels those runs. 🎯 Fix: 90 % 💥 Break: 2 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 88 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- scripts/github/cancel/pull_request_runs.sh | 14 +++- .../meta/workflows/test_cancel_runs.py | 66 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/scripts/github/cancel/pull_request_runs.sh b/scripts/github/cancel/pull_request_runs.sh index 8abc9d7cc2..35ca10bb86 100755 --- a/scripts/github/cancel/pull_request_runs.sh +++ b/scripts/github/cancel/pull_request_runs.sh @@ -24,7 +24,8 @@ validate_force_cancel_after # A fork PR's runs carry an empty `pull_requests` array, so the branch matcher # is all that is left — and it cannot tell two pull requests apart that share a # head repository and head branch. Rather than cancel the wrong one, drop the -# matcher for as long as the head is ambiguous. +# branch and head-sha matchers for as long as the head is ambiguous: anyone may +# open a pull request from another fork's branch and close it to cancel its runs. disable_ambiguous_branch_fallback() { local rivals local -a query @@ -55,6 +56,7 @@ disable_ambiguous_branch_fallback() { if [[ "${rivals}" != "0" ]]; then echo "Branch fallback disabled: ${rivals} other open pull request(s) share ${PR_HEAD_REPOSITORY%%/*}:${PR_HEAD_REF}" PR_HEAD_REF="" + PR_HEAD_SHA="" fi } @@ -88,7 +90,15 @@ run_ids="$( | select(.event == "pull_request" or .event == "pull_request_target") | select( any(.pull_requests[]?; (.number // -1) == $pr_number) - or ($pr_head_sha != "" and (.head_sha // "") == $pr_head_sha) + or ( + $pr_head_sha != "" + and (.head_sha // "") == $pr_head_sha + and all(.pull_requests[]?; (.number // $pr_number) == $pr_number) + and ( + (.head_repository.full_name // "") == $pr_head_repository + or ((.display_title // "") | test("PR #\($pr_number)( |$)")) + ) + ) or ( $pr_head_ref != "" and all(.pull_requests[]?; (.number // $pr_number) == $pr_number) diff --git a/tests/integration/meta/workflows/test_cancel_runs.py b/tests/integration/meta/workflows/test_cancel_runs.py index 3e9f6a2d5f..d2ea4c875e 100644 --- a/tests/integration/meta/workflows/test_cancel_runs.py +++ b/tests/integration/meta/workflows/test_cancel_runs.py @@ -237,6 +237,7 @@ class TestCancelPullRequestRuns(CancelScriptMixin, unittest.TestCase): { "id": 299, "event": "pull_request_target", + "display_title": "pull_request_target / PR #106 / synchronize / AlejandroRomanIbanez:feature/makefile-wsl2", "head_sha": "deadbeef", "head_branch": "unexpected-branch-name", "head_repository": {"full_name": "base-repo/core"}, @@ -249,6 +250,71 @@ class TestCancelPullRequestRuns(CancelScriptMixin, unittest.TestCase): ) self.assertEqual(cancelled, ["299"]) + def test_head_sha_never_cancels_another_pull_requests_runs(self): + in_progress_runs = """\ +{"workflow_runs":[ + { + "id": 340, + "event": "pull_request", + "head_sha": "deadbeef", + "head_branch": "fix/victim", + "head_repository": {"full_name": "base-repo/core"}, + "pull_requests": [{"number": 107}] + }, + { + "id": 341, + "event": "pull_request_target", + "display_title": "pull_request_target / PR #1061 / synchronize / victim:fix/victim", + "head_sha": "deadbeef", + "head_branch": "main", + "head_repository": {"full_name": "base-repo/core"}, + "pull_requests": [] + }, + { + "id": 342, + "event": "pull_request", + "head_sha": "deadbeef", + "head_branch": "fix/victim", + "head_repository": {"full_name": "victim/core"}, + "pull_requests": [] + }, + { + "id": 343, + "event": "pull_request", + "head_sha": "deadbeef", + "head_branch": "other-branch", + "head_repository": {"full_name": "AlejandroRomanIbanez/core"}, + "pull_requests": [] + } +]} +""" + _, cancelled = self._run_script( + runs_by_status={"in_progress": in_progress_runs} + ) + self.assertEqual(cancelled, ["343"]) + + def test_head_sha_never_cancels_a_rival_pull_request_on_the_same_head(self): + in_progress_runs = """\ +{"workflow_runs":[ + { + "id": 344, + "event": "pull_request", + "head_sha": "deadbeef", + "head_branch": "feature/makefile-wsl2", + "head_repository": {"full_name": "AlejandroRomanIbanez/core"}, + "pull_requests": [] + } +]} +""" + result, cancelled = self._run_script( + runs_by_status={ + "in_progress": in_progress_runs, + "pulls": '[{"number": 107, "head": {"ref": "feature/makefile-wsl2"}}]\n', + }, + ) + self.assertEqual(cancelled, []) + self.assertIn("Branch fallback disabled", result.stdout) + NEWEST_PER_GROUP_RUNS = """\ {"workflow_runs":[ { From b138ca8c8a01f3f332a8c1093ededf5d37a16bdb Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 14:45:20 +0000 Subject: [PATCH 10/18] fix(ci): gate privileged fork image jobs on a maintainer trust label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under pull_request_target, build-ci-images-fork builds a fork's Dockerfile on a runner whose docker config holds a packages:write token and exports the shared build cache that trusted builds read. images-mirror-missing-fork receives the Docker Hub secrets, contrary to pipeline.md, and reads the fork tree with symlinks followed. A new fork-trust-gate job fails both paths for untrusted full-scope fork pull requests until a maintainer adds the label '🛡️ Trusted' (scripts/github/gate/trusted_label.sh). Fork builds no longer export the shared cache (scripts/image/push.sh). The mirror job checks the fork tree out with core.symlinks=false, fails on any symlink (scripts/github/gate/no_symlinks.sh) and does not persist the base checkout's credentials. test_workflow_fork_checkout_gated.py fails on the old workflows and passes on the new ones; actionlint, shellcheck and ruff are clean. Behaviour change: an untrusted full-scope fork pull request turns red at the gate and gets no deploy CI until it is labelled; same-repository pull requests run as before. Open: the label survives later pushes of the fork, and it is untested whether actions/checkout honours a global core.symlinks=false. 🎯 Fix: 88 % 💥 Break: 8 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 81 🚦 Gate: ⛔ fix 88 % < 90, break 8 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .github/workflows/call-images-build-ci.yml | 5 +- .../workflows/call-images-mirror-missing.yml | 12 ++++ .../workflows/entry-pr-change-orchestrate.yml | 25 ++++++- docs/contributing/artefact/git/pipeline.md | 11 +-- scripts/github/gate/no_symlinks.sh | 18 +++++ scripts/github/gate/trusted_label.sh | 16 +++++ scripts/image/push.sh | 10 ++- .../test_workflow_fork_checkout_gated.py | 72 +++++++++++++++++++ 8 files changed, 160 insertions(+), 9 deletions(-) create mode 100755 scripts/github/gate/no_symlinks.sh create mode 100755 scripts/github/gate/trusted_label.sh create mode 100644 tests/lint/repository/test_workflow_fork_checkout_gated.py diff --git a/.github/workflows/call-images-build-ci.yml b/.github/workflows/call-images-build-ci.yml index e375c6af30..a445630d43 100644 --- a/.github/workflows/call-images-build-ci.yml +++ b/.github/workflows/call-images-build-ci.yml @@ -78,6 +78,8 @@ jobs: permissions: contents: read packages: write + env: + FORK_TARGET_BUILD: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository }} steps: - name: ⬇️ Checkout trusted workflow repo (helpers) @@ -158,7 +160,8 @@ jobs: INFINITO_DISTROS: ${{ join(fromJson(needs.pools.outputs.matrix), ' ') }} IMAGE_ARCH: ${{ matrix.architecture }} IMAGE_DIGEST_DIR: build/image-digests - USE_NIX_TOKEN: ${{ !(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) }} + USE_NIX_TOKEN: ${{ env.FORK_TARGET_BUILD != 'true' }} + EXPORT_BUILD_CACHE: ${{ env.FORK_TARGET_BUILD != 'true' }} NIX_GITHUB_TOKEN: ${{ github.token }} MAX_ATTEMPTS: "7" RETRY_DELAY_SECONDS: "20" diff --git a/.github/workflows/call-images-mirror-missing.yml b/.github/workflows/call-images-mirror-missing.yml index 9d95329996..7f70bdec8a 100644 --- a/.github/workflows/call-images-mirror-missing.yml +++ b/.github/workflows/call-images-mirror-missing.yml @@ -91,6 +91,8 @@ jobs: steps: - name: ⬇️ Checkout uses: actions/checkout@v7.0.0 + with: + persist-credentials: false - name: 🔍 Resolve GHCR namespace and repository id: vars @@ -99,6 +101,10 @@ jobs: GHCR_NAMESPACE_INPUT: ${{ inputs.ghcr_namespace || '' }} run: bash scripts/meta/resolve/ghcr/namespace_and_repository.sh + - name: 🔗 Check symlinks out as plain files (optional) + if: ${{ inputs.source_repository != '' && inputs.source_ref != '' }} + run: git config --global core.symlinks false + - name: ⬇️ Checkout source repo for scan (optional) if: ${{ inputs.source_repository != '' && inputs.source_ref != '' }} uses: actions/checkout@v7.0.0 @@ -110,6 +116,12 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.allow_unsafe_checkout }} + - name: 🔗 Refuse symlinks in the scanned source (optional) + if: ${{ inputs.source_repository != '' && inputs.source_ref != '' }} + env: + SOURCE_PATH: ${{ inputs.source_path }} + run: bash scripts/github/gate/no_symlinks.sh "${SOURCE_PATH}" + - name: 🔧 Setup Python uses: actions/setup-python@v6 with: diff --git a/.github/workflows/entry-pr-change-orchestrate.yml b/.github/workflows/entry-pr-change-orchestrate.yml index 0a3c46f036..4f2921e911 100644 --- a/.github/workflows/entry-pr-change-orchestrate.yml +++ b/.github/workflows/entry-pr-change-orchestrate.yml @@ -140,8 +140,27 @@ jobs: PR_MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha || '' }} run: ./scripts/meta/resolve/pr/merge_ref.sh - build-ci-images-fork: + fork-trust-gate: + name: 🛡️ Gate fork trust needs: prepare-fork-merge-ref + runs-on: ubuntu-26.04 + steps: + - name: ⬇️ Checkout + uses: actions/checkout@v7.0.0 + with: + persist-credentials: false + + - name: 🛡️ Require the maintainer Trusted label + shell: bash + env: + TRUSTED: ${{ needs.prepare-fork-merge-ref.outputs.trusted }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: bash scripts/github/gate/trusted_label.sh + + build-ci-images-fork: + needs: + - prepare-fork-merge-ref + - fork-trust-gate permissions: contents: read packages: write @@ -155,7 +174,9 @@ jobs: allow_unsafe_checkout: true images-mirror-missing-fork: - needs: prepare-fork-merge-ref + needs: + - prepare-fork-merge-ref + - fork-trust-gate permissions: contents: read packages: write diff --git a/docs/contributing/artefact/git/pipeline.md b/docs/contributing/artefact/git/pipeline.md index e69ee1385d..1bbe1b25a9 100644 --- a/docs/contributing/artefact/git/pipeline.md +++ b/docs/contributing/artefact/git/pipeline.md @@ -32,7 +32,7 @@ The orchestrator runs the following stages in order: ### 1. Fork Prerequisites ⏳ -For fork PRs, CI waits for privileged images built by the `pull_request_target` event before proceeding. For an untrusted fork that build runs from the safe base merge ref **without organization secrets** (only the per-job `GITHUB_TOKEN`); a maintainer-applied `🛡️ Trusted` label switches the build source to the PR head, unlocks the mirror credentials, and skips the wait — see [Trusted fork PRs](#trusted-fork-prs-). +For fork PRs, CI waits for privileged images built by the `pull_request_target` event before proceeding. That build and the mirror producer run only for a fork PR that carries the maintainer-applied `🛡️ Trusted` label; for an untrusted fork the `🛡️ Gate fork trust` job fails instead, and the waiting `pull_request` run fails fast with it. The label also switches the build source to the PR head and skips the wait — see [Trusted fork PRs](#trusted-fork-prs-). ### 2. Security 🛡️ @@ -62,7 +62,7 @@ The `code-quality-gate` requires linting, code tests, and security checks to all [call-images-mirror-missing.yml](../../../../.github/workflows/call-images-mirror-missing.yml) mirrors any missing upstream images in parallel with the DNS tests so later deploy jobs pull from GHCR instead of Docker Hub, MCR, or other external registries. This shields CI from upstream rate limits, geo-blocking, and transient registry outages. -Fork PRs cannot publish mirror packages directly, so their runs wait for the `pull_request_target` mirror producer before continuing. The producer mirrors with the Docker Hub credentials only for trusted PRs ([🛡️ Trusted](#trusted-fork-prs-)); untrusted forks mirror anonymously (no organization secrets). See [mirror.md](../image/mirror.md) for the mirroring architecture and naming convention. +Fork PRs cannot publish mirror packages directly, so their runs wait for the `pull_request_target` mirror producer before continuing. The producer runs only for trusted PRs ([🛡️ Trusted](#trusted-fork-prs-)) and is the only fork-facing job that receives the Docker Hub credentials. It checks the fork tree out with `core.symlinks=false` and refuses any symlink left in it, so the scan reads the tree's own files and nothing outside it. See [mirror.md](../image/mirror.md) for the mirroring architecture and naming convention. GHCR publication uses the workflow `GITHUB_TOKEN`; optional Docker Hub secrets are used only to reduce source-side Docker Hub rate limits while mirroring. See [authentication.md](../../tools/ghcr/authentication.md). @@ -139,7 +139,7 @@ See [configuration.md](../../tools/github/actions/configuration.md) for all repo Fork PRs run under the `pull_request` event without write permissions. Privileged steps (image builds, package writes) run via `pull_request_target`. The fork CI waits for those privileged images before proceeding. See [pull-request.md](pull-request.md) for the contributor-facing fork workflow. -By default — for an **untrusted** fork PR — the privileged `pull_request_target` build checks out the **base merge ref** (`refs/pull//merge`) from the base repository: the PR's changes merged onto base, with all workflow and build-orchestration scripts coming from base, never from the fork. Because `actions/checkout` otherwise refuses to fetch a PR ref under `pull_request_target`, the source checkout sets `allow-unsafe-pr-checkout: true`. The untrusted build runs **without organization secrets** — `secrets: inherit` is not passed and it authenticates to GHCR with the per-job `GITHUB_TOKEN` only, so a malicious fork cannot read repository/organization secrets. (The `pull_request_target` token still carries `packages: write`, so the `🛡️ Trusted` label remains the real trust boundary for anything beyond image publication.) +For an **untrusted** fork PR the privileged `pull_request_target` jobs stop at the `🛡️ Gate fork trust` job: it fails, so neither the image build nor the mirror producer runs fork content next to the `packages: write` token, and the fork's `pull_request` run fails its prerequisite wait as soon as that run ends. The merge-ref expressions in `build-ci-images-fork` stay as a fallback only. Because `actions/checkout` otherwise refuses to fetch a PR ref under `pull_request_target`, the source checkouts set `allow-unsafe-pr-checkout: true`; the lint `tests/lint/repository/test_workflow_fork_checkout_gated.py` fails any `pull_request_target` job with such a checkout that does not need the gate. ### Trusted fork PRs 🔓 @@ -147,12 +147,13 @@ When a maintainer applies the `🛡️ Trusted` label, the fork PR is treated as - The orchestrator's `wait-fork-prereq-run` job **skips the wait** for the privileged fork images. - The privileged `pull_request_target` build switches its **build source** from the base merge ref to the **raw PR head** (`head.repo.full_name` @ `head.sha`). -- The trusted build additionally receives the Docker Hub mirror credentials (passed only when the label is present); untrusted builds mirror anonymously. +- The trusted mirror producer receives the Docker Hub mirror credentials; untrusted fork PRs get no privileged job at all. +- A fork-sourced build imports the shared `buildcache-` registry cache but never exports to it, so only base-sourced builds write the cache every trusted build reads. - The built image **keeps the merge-SHA tag** (`ci-`) so the `pull_request` orchestrator finds it unchanged — no consumer workflow has to know about the label. Security gates: -- The `🛡️ Trusted` label flips the build source to the PR head and unlocks the Docker Hub credentials; without it the safe base merge ref is built with no organization secrets. Restrict who may set the label via repository label permissions / branch protection so only maintainers can grant it. +- The `🛡️ Trusted` label is the only way a fork PR reaches the privileged build and mirror. Restrict who may set the label via repository label permissions / branch protection so only maintainers can grant it. The label stays on the PR across later pushes, so review every new head before CI uses it, or remove the label first. - Build-orchestration scripts (`scripts/image/push.sh` and the helper checkout) always come from the base repo at `github.sha`; only the Docker build **context** (`_src`) is the fork head. `persist-credentials: false` keeps the token out of the source checkout, and `USE_NIX_TOKEN` stays disabled for fork-sourced builds. - Fork `pull_request` runs always receive a read-only token (GitHub-enforced); the label never grants write tokens or secrets to the untrusted event. diff --git a/scripts/github/gate/no_symlinks.sh b/scripts/github/gate/no_symlinks.sh new file mode 100755 index 0000000000..738e0aa091 --- /dev/null +++ b/scripts/github/gate/no_symlinks.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Usage: no_symlinks.sh +# a directory checked out from an untrusted ref; the script fails +# when it holds a symlink, which would let a later read leave it. + +set -euo pipefail + +tree="${1:?Usage: no_symlinks.sh }" + +mapfile -t links < <(find "${tree}" -type l -print) + +if ((${#links[@]} > 0)); then + echo "Refusing ${tree}: ${#links[@]} symlink(s) survived core.symlinks=false." >&2 + printf ' - %q\n' "${links[@]:0:20}" >&2 + exit 1 +fi +echo "No symlinks under ${tree}." diff --git a/scripts/github/gate/trusted_label.sh b/scripts/github/gate/trusted_label.sh new file mode 100755 index 0000000000..642025c24b --- /dev/null +++ b/scripts/github/gate/trusted_label.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# Inputs via env: +# TRUSTED "true" when the fork PR carries the maintainer '🛡️ Trusted' label. +# PR_NUMBER the pull request number, named in the refusal. + +set -euo pipefail + +: "${TRUSTED:?}" +: "${PR_NUMBER:?}" + +if [[ "${TRUSTED}" != "true" ]]; then + echo "Fork PR #${PR_NUMBER} is not labelled '🛡️ Trusted'. The privileged image build and mirror run fork content with a packages:write token, so they start only after a maintainer reviewed the head and applied the label." >&2 + exit 1 +fi +echo "Fork PR #${PR_NUMBER} carries '🛡️ Trusted'; the privileged image build and mirror may run." diff --git a/scripts/image/push.sh b/scripts/image/push.sh index 4bb1299b7d..f2e54aa88e 100755 --- a/scripts/image/push.sh +++ b/scripts/image/push.sh @@ -17,6 +17,7 @@ export INFINITO_PARENT_IMAGE : "${IMAGE_DIGEST_DIR:?Missing IMAGE_DIGEST_DIR}" : "${GITHUB_REPOSITORY:?Missing GITHUB_REPOSITORY}" : "${USE_NIX_TOKEN:?Missing USE_NIX_TOKEN}" +: "${EXPORT_BUILD_CACHE:?Missing EXPORT_BUILD_CACHE}" : "${INFINITO_PARENT_IMAGE:?Missing INFINITO_PARENT_IMAGE; source scripts/meta/env/load.sh}" : "${INFINITO_SRC_DIR:?Missing INFINITO_SRC_DIR; source scripts/meta/env/load.sh}" : "${INFINITO_VENV_DIR:?Missing INFINITO_VENV_DIR; source scripts/meta/env/load.sh}" @@ -39,6 +40,13 @@ else echo "pull_request_target on fork detected: skipping NIX_CONFIG token build-arg." fi +cache_to_arg=() +if [[ "${EXPORT_BUILD_CACHE}" == "true" ]]; then + cache_to_arg=(--cache-to "type=registry,mode=max,ref=${cache_ref}") +else + echo "Fork-sourced build: importing ${cache_ref} without exporting to it." +fi + while true; do echo "=== Build & push attempt ${attempt}/${max_attempts} ===" @@ -56,7 +64,7 @@ while true; do --build-arg "INFINITO_DOCKER_CLI_INSTALL_SCRIPT=${INFINITO_DOCKER_CLI_INSTALL_SCRIPT:?source scripts/meta/env/load.sh}" \ "${nix_arg[@]}" \ --cache-from "type=registry,ref=${cache_ref}" \ - --cache-to "type=registry,mode=max,ref=${cache_ref}" \ + "${cache_to_arg[@]}" \ "${BUILD_CONTEXT_DIR}"; then echo "Build & push succeeded on attempt ${attempt}/${max_attempts}." break diff --git a/tests/lint/repository/test_workflow_fork_checkout_gated.py b/tests/lint/repository/test_workflow_fork_checkout_gated.py new file mode 100644 index 0000000000..4b386cb56e --- /dev/null +++ b/tests/lint/repository/test_workflow_fork_checkout_gated.py @@ -0,0 +1,72 @@ +from __future__ import annotations + +import re +import unittest + +from utils.cache.yaml import load_yaml_any + +from . import PROJECT_ROOT + +_WORKFLOWS_DIR = PROJECT_ROOT / ".github" / "workflows" +_GATE_JOB = "fork-trust-gate" +_UNSAFE_CALL_INPUT = "allow_unsafe_checkout" +_UNSAFE_STEP_INPUT = "allow-unsafe-pr-checkout" +_GATE_BYPASS = re.compile(r"\b(?:always|cancelled|failure)\(\s*\)") + + +def _listens_to_pull_request_target(document) -> bool: + triggers = document.get("on") or document.get(True) or {} + if isinstance(triggers, str): + return triggers == "pull_request_target" + return "pull_request_target" in triggers + + +def _enabled(value) -> bool: + return value not in (None, False, "false") + + +def _checks_out_pull_request_code(job: dict) -> bool: + if _enabled((job.get("with") or {}).get(_UNSAFE_CALL_INPUT)): + return True + return any( + _enabled((step.get("with") or {}).get(_UNSAFE_STEP_INPUT)) + for step in job.get("steps") or [] + if isinstance(step, dict) + ) + + +def _needs(job: dict) -> list[str]: + needs = job.get("needs") or [] + return [needs] if isinstance(needs, str) else list(needs) + + +class TestWorkflowForkCheckoutGated(unittest.TestCase): + def test_pull_request_checkouts_under_pull_request_target_need_the_gate( + self, + ) -> None: + offenders: list[str] = [] + for path in sorted(_WORKFLOWS_DIR.glob("*.y*ml")): + document = load_yaml_any(str(path), default_if_missing={}) or {} + if not _listens_to_pull_request_target(document): + continue + for job_id, job in (document.get("jobs") or {}).items(): + if not isinstance(job, dict) or not _checks_out_pull_request_code(job): + continue + if _GATE_JOB not in _needs(job): + offenders.append(f"{path.name}: {job_id}: does not need it") + elif _GATE_BYPASS.search(str(job.get("if", ""))): + offenders.append(f"{path.name}: {job_id}: runs past a failed gate") + + if offenders: + self.fail( + f"{len(offenders)} pull_request_target job(s) check out pull " + f"request code without depending on a green '{_GATE_JOB}'. Such " + "a job runs fork content next to a write-scoped token, so it " + "must wait for the gate that refuses fork PRs lacking the " + "maintainer '🛡️ Trusted' label, and its if: must not use " + "always(), cancelled() or failure().\n" + "\n".join(offenders) + ) + + +if __name__ == "__main__": + unittest.main() From e8f788d2cbaf55dd95607e3470d38ea52c02db01 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 14:48:16 +0000 Subject: [PATCH 11/18] fix(web-app-joomla): finish the stock installer's cleanup on an NFS webroot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker Hub re-pushed joomla:6.2.0-php8.3-apache on 2026-11-19 with the docker-joomla entrypoint of official-images 82dbb58597. It skips setup for 'apache2 -v', so the wrapper's leader no longer installed anything. When the installer fails it keeps .joomla-initializing for good. On the swarm's NFS webroot the installer cannot delete installation/ ('[ERROR] Unable to delete installation folder!'), and every replica then exits with 'Initialization did not complete (exit 1); server startup is blocked.' docker-entrypoint-joomla.sh now runs setup through the stock entrypoint with 'apache2 -l'. One leader runs it under a mkdir lock with a heartbeat owner file, and a lock whose heartbeat is older than JOOMLA_INIT_LOCK_STALE_SECONDS (180 s) is taken over atomically. When setup stops only at the delete message, the leader finishes what Joomla's CleanupModel does: it deletes installation/ and joomla.xml and renames robots.txt.dist. It records the pending cleanup in .infinito-init.cleanup, so a failed rm is retried on the next start. A site left stuck by the old wrapper fails with the exact manual step. test_docker_entrypoint_joomla.py has 14 cases. It passes on the fix, fails 12 of 14 on the old wrapper, and fails on a mutant without the grep guard. Two independent skeptic rounds: the first refuted the earlier version, the second found no hole. Draft: no run against the real stock entrypoint on a real NFS volume yet; the fork CI swarm run proves it. 🎯 Fix: 85 % 💥 Break: 6 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 80 🚦 Gate: ⛔ fix 85 % < 90, break 6 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- roles/web-app-joomla/files/Dockerfile | 1 + .../files/shell/docker-entrypoint-joomla.sh | 150 +++++++++-- roles/web-app-joomla/templates/env.j2 | 2 + roles/web-app-joomla/vars/main.yml | 1 + .../roles/web-app-joomla/files/__init__.py | 0 .../web-app-joomla/files/shell/__init__.py | 0 .../shell/test_docker_entrypoint_joomla.py | 255 ++++++++++++++++++ 7 files changed, 384 insertions(+), 25 deletions(-) create mode 100644 tests/unit/python/roles/web-app-joomla/files/__init__.py create mode 100644 tests/unit/python/roles/web-app-joomla/files/shell/__init__.py create mode 100644 tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py diff --git a/roles/web-app-joomla/files/Dockerfile b/roles/web-app-joomla/files/Dockerfile index 73e682fc6b..fb0c128619 100644 --- a/roles/web-app-joomla/files/Dockerfile +++ b/roles/web-app-joomla/files/Dockerfile @@ -16,5 +16,6 @@ COPY ${JOOMLA_ENTRYPOINT_SCRIPT_HOST_REL} ${JOOMLA_ENTRYPOINT_SCRIPT_DOCKER} RUN chmod +x "${JOOMLA_ENTRYPOINT_SCRIPT_DOCKER}" \ && ln -sf "${JOOMLA_ENTRYPOINT_SCRIPT_DOCKER}" /usr/local/bin/entrypoint-joomla +ENV JOOMLA_STOCK_ENTRYPOINT=/entrypoint.sh ENTRYPOINT ["/usr/local/bin/entrypoint-joomla"] CMD ["apache2-foreground"] diff --git a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh index 49a9d03bbb..4f7c27ff07 100644 --- a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh +++ b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh @@ -1,30 +1,130 @@ #!/bin/bash -# Serialize the stock image's first-boot copy+auto-install across replicas that -# share the /var/www/html NFS volume (mkdir is atomic on NFS: one leader runs it, -# the rest block on the ready marker). The setup only runs when $1 is apache2*/ -# php-fpm, so the leader must drive it with `apache2 -v` (returns after setup) — -# a plain `true` skips the whole setup block and copies nothing. - -target="/var/www/html" -lock="${target}/.infinito-init.lock" +webroot="${JOOMLA_WEBROOT:?JOOMLA_WEBROOT must be set}" +stock="${JOOMLA_STOCK_ENTRYPOINT:?JOOMLA_STOCK_ENTRYPOINT must be set}" ready="${JOOMLA_INIT_READY_FILE:?JOOMLA_INIT_READY_FILE must be set}" +stale_after="${JOOMLA_INIT_LOCK_STALE_SECONDS:?JOOMLA_INIT_LOCK_STALE_SECONDS must be set}" +lock="${webroot}/.infinito-init.lock" +owner="${lock}/owner" +marker="${webroot}/.joomla-initializing" +pending="${webroot}/.infinito-init.cleanup" +config="${webroot}/configuration.php" +token="${HOSTNAME}.$$.$(date +%s%N)" +beat=$((stale_after / 4 + 1)) +heartbeat_pid="" -if [ ! -e "${ready}" ] && [ ! -e "${target}/configuration.php" ]; then - if mkdir "${lock}" 2>/dev/null; then - /entrypoint.sh apache2 -v || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error - if [ -e "${target}/configuration.php" ]; then - chown -R www-data:www-data \ - "${target}/administrator/cache" "${target}/administrator/logs" \ - "${target}/cache" "${target}/tmp" 2>/dev/null || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error - touch "${ready}" - fi - else - tries=0 - while [ ! -e "${ready}" ] && [ ! -e "${target}/configuration.php" ] && [ "${tries}" -lt 300 ]; do - sleep 2 - tries=$((tries + 1)) - done +trap 'exit 143' TERM +trap 'exit 130' INT + +log_error() { + printf '[ERROR] %s\n' "$1" >&2 +} + +initialized() { + [ -e "${ready}" ] || { [ -s "${config}" ] && [ ! -e "${marker}" ]; } +} + +stale() { + local stamp + stamp="$(stat -c %Y "$1/owner" 2>/dev/null)" || + stamp="$(stat -c %Y "$1" 2>/dev/null)" || + return 1 + [ $(($(date +%s) - stamp)) -gt "${stale_after}" ] +} + +take_over_stale() { + local moved="${lock}.stale.${token}" + stale "${lock}" || return 1 + mv -T "${lock}" "${moved}" 2>/dev/null || return 1 + if stale "${moved}"; then + rm -rf "${moved}" + return 0 fi -fi + mv -T "${moved}" "${lock}" + return 1 +} -exec /entrypoint.sh "$@" +heartbeat() { + while sleep "${beat}"; do + touch "${owner}" + done +} + +release() { + if [ -n "${heartbeat_pid}" ]; then + kill "${heartbeat_pid}" 2>/dev/null + fi + heartbeat_pid="" + if [ "$(cat "${owner}" 2>/dev/null)" = "${token}" ]; then + rm -rf "${lock}" + fi +} + +run_setup() { + local log + log="$(mktemp)" + # Exception: since docker-joomla 327d05a9f1 the stock entrypoint skips its + # setup for -v/-V/-h/-t/-T; `apache2 -l` still runs it and then returns. + { "${stock}" apache2 -l 2>&1 | tee "${log}"; } & + wait "$!" + # Exception: Joomla's installer deletes installation/ while it still holds + # installation/joomla.php open; NFS keeps that file as a .nfs silly rename, + # so a complete install reports failure and the stock entrypoint keeps its + # marker. The pending note lets any later start finish that cleanup. + if [ -s "${config}" ] && [ -d "${marker}" ] && + grep -q 'Unable to delete installation folder' "${log}" && + ! grep -qE 'Failed to (correct ownership|restore configuration)|Refusing to change permissions' "${log}"; then + touch "${pending}" + fi + rm -f "${log}" +} + +finish_cleanup() { + rm -rf "${webroot}/installation" || return 1 + rm -f "${webroot}/joomla.xml" || return 1 + if [ ! -e "${webroot}/robots.txt" ] && [ -e "${webroot}/robots.txt.dist" ]; then + mv "${webroot}/robots.txt.dist" "${webroot}/robots.txt" || return 1 + fi + rmdir "${marker}" || return 1 + rm -f "${pending}" +} + +recover() { + if [ ! -e "${marker}" ]; then + run_setup + fi + if [ -e "${marker}" ] && [ -e "${pending}" ] && ! finish_cleanup; then + log_error "Finishing Joomla's installer cleanup in ${webroot} failed; ${pending} stays, so the next start retries it." + return 1 + fi + if initialized; then + touch "${ready}" + return 0 + fi + if [ -e "${marker}" ]; then + log_error "${marker} remains from an unfinished Joomla setup. If that setup stopped at 'Unable to delete installation folder!', run 'touch ${pending}' and restart; otherwise restore the site and database, then remove ${marker}." + fi + return 1 +} + +lead() { + local status + printf '%s\n' "${token}" > "${owner}" + trap release EXIT + heartbeat & + heartbeat_pid=$! + recover + status=$? + release + trap - EXIT + return "${status}" +} + +until initialized; do + if mkdir "${lock}" 2>/dev/null; then + lead || exit 1 + elif ! take_over_stale; then + sleep 2 + fi +done + +exec "${stock}" "$@" diff --git a/roles/web-app-joomla/templates/env.j2 b/roles/web-app-joomla/templates/env.j2 index 0fdedc5d0f..14dd382f92 100644 --- a/roles/web-app-joomla/templates/env.j2 +++ b/roles/web-app-joomla/templates/env.j2 @@ -1,6 +1,8 @@ {% include 'roles/sys-svc-container/templates/env.j2' %} +JOOMLA_INIT_LOCK_STALE_SECONDS={{ JOOMLA_INIT_LOCK_STALE_SECONDS }} JOOMLA_INIT_READY_FILE={{ JOOMLA_INIT_READY_FILE }} +JOOMLA_WEBROOT={{ JOOMLA_DOCROOT }} JOOMLA_SITE_NAME={{ JOOMLA_SITE_NAME }} JOOMLA_ADMIN_USER={{ JOOMLA_USER }} JOOMLA_ADMIN_USERNAME={{ JOOMLA_USER_NAME }} diff --git a/roles/web-app-joomla/vars/main.yml b/roles/web-app-joomla/vars/main.yml index fd24e7d44d..c4744ff5c5 100644 --- a/roles/web-app-joomla/vars/main.yml +++ b/roles/web-app-joomla/vars/main.yml @@ -13,6 +13,7 @@ JOOMLA_CONFIG_FILE: "/var/www/html/configuration.php" JOOMLA_INSTALLER_CLI_FILE: "/var/www/html/installation/joomla.php" JOOMLA_CLI_FILE: "/var/www/html/cli/joomla.php" JOOMLA_INIT_READY_FILE: "/var/www/html/.infinito-init.ready" +JOOMLA_INIT_LOCK_STALE_SECONDS: 180 JOOMLA_CLI_EXTENSION_ENABLE_SINCE: "6.1.0" JOOMLA_DOCROOT: "{{ lookup('volume', application_id, 'data').target }}" diff --git a/tests/unit/python/roles/web-app-joomla/files/__init__.py b/tests/unit/python/roles/web-app-joomla/files/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-joomla/files/shell/__init__.py b/tests/unit/python/roles/web-app-joomla/files/shell/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py b/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py new file mode 100644 index 0000000000..1a4b6c9d93 --- /dev/null +++ b/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py @@ -0,0 +1,255 @@ +import contextlib +import os +import signal +import subprocess +import tempfile +import time +import unittest +from pathlib import Path + +from utils import PROJECT_ROOT + +SHELL_DIR = PROJECT_ROOT / "roles/web-app-joomla/files/shell" +ENTRYPOINT = SHELL_DIR / "docker-entrypoint-joomla.sh" +SERVE = "serve apache2-foreground" + +STOCK_STUB = """#!/usr/bin/env bash +printf 'call %s\\n' "$*" >> "${STUB_CALLS}" +case "$1" in apache2*) ;; *) exit 0 ;; esac +case "${2-}" in -v | -V | -h | -t | -T) exit 0 ;; esac +cd "${JOOMLA_WEBROOT}" || exit 9 +if [ -e .joomla-initializing ]; then + echo '[ERROR] Initialization is incomplete or another initializer is active.' >&2 + exit 1 +fi +if [ ! -s configuration.php ]; then + if [ "${STUB_DB}" != up ]; then + echo '[ERROR] Database initialization failed (exit 1).' >&2 + exit 1 + fi + mkdir .joomla-initializing + printf 'init\\n' >> "${STUB_CALLS}" + mkdir -p installation + touch index.php installation/joomla.php joomla.xml robots.txt.dist + sleep "${STUB_SETUP_DELAY}" + if [ "${STUB_INSTALL}" = broken ]; then + echo '[ERROR] Automatic Joomla installation failed (exit 1).' >&2 + exit 1 + fi + echo ' configuration.php + sleep "${STUB_FINISH_DELAY}" + case "${STUB_INSTALL}" in + crash) + echo '[ERROR] Automatic Joomla installation failed (exit 255).' >&2 + exit 1 ;; + nfs) + echo ' [ERROR] Unable to delete installation folder!' + exit 1 ;; + nfs-unowned) + echo ' [ERROR] Unable to delete installation folder!' + echo '[ERROR] Failed to correct ownership after initialization.' >&2 + exit 1 ;; + esac + rm -rf installation joomla.xml + mv robots.txt.dist robots.txt + rmdir .joomla-initializing +fi +printf 'serve %s\\n' "$*" >> "${STUB_CALLS}" +""" + +RM_STUB = """#!/usr/bin/env bash +if [ "${STUB_RM_FAIL}" = 1 ]; then + case "$*" in *installation*) echo 'rm: Device or resource busy' >&2; exit 1 ;; esac +fi +PATH="${STUB_REAL_PATH}" exec rm "$@" +""" + + +class TestJoomlaEntrypoint(unittest.TestCase): + def setUp(self): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + self.root = Path(tmp.name) + self.webroot = self.root / "html" + self.webroot.mkdir() + bin_dir = self.root / "bin" + bin_dir.mkdir() + self.stock = self.root / "entrypoint.sh" + for path, body in {self.stock: STOCK_STUB, bin_dir / "rm": RM_STUB}.items(): + path.write_text(body) + path.chmod(0o755) + self.ready = self.webroot / ".infinito-init.ready" + self.marker = self.webroot / ".joomla-initializing" + self.lock = self.webroot / ".infinito-init.lock" + self.pending = self.webroot / ".infinito-init.cleanup" + self.env = { + **os.environ, + "PATH": f"{bin_dir}{os.pathsep}{os.environ['PATH']}", + "STUB_REAL_PATH": os.environ["PATH"], + "JOOMLA_WEBROOT": str(self.webroot), + "JOOMLA_STOCK_ENTRYPOINT": str(self.stock), + "JOOMLA_INIT_READY_FILE": str(self.ready), + "JOOMLA_INIT_LOCK_STALE_SECONDS": "60", + "STUB_DB": "up", + "STUB_INSTALL": "ok", + "STUB_SETUP_DELAY": "0", + "STUB_FINISH_DELAY": "0", + "STUB_RM_FAIL": "0", + } + + def spawn(self, name="calls", **env): + log = self.root / f"{name}.log" + log.touch() + with (self.root / f"{name}.err").open("a") as err: + process = subprocess.Popen( + ["bash", str(ENTRYPOINT), "apache2-foreground"], + env={**self.env, "STUB_CALLS": str(log), **env}, + stdout=subprocess.DEVNULL, + stderr=err, + start_new_session=True, + ) + self.addCleanup(self.kill_group, process) + return process + + def kill_group(self, process): + with contextlib.suppress(ProcessLookupError, PermissionError): + os.killpg(process.pid, signal.SIGKILL) + process.wait() + + def run_entrypoint(self, **env): + return self.spawn(**env).wait(timeout=60) + + def text(self, name): + path = self.root / name + return path.read_text(encoding="utf-8") # nocheck: cache-read tempdir + + def calls(self, name="calls"): + return self.text(f"{name}.log").splitlines() + + def wait_for(self, path): + deadline = time.monotonic() + 30 + while not path.exists() and time.monotonic() < deadline: + time.sleep(0.1) + self.assertTrue(path.exists()) + + def leave_stuck_volume(self): + for name in ("installation", ".joomla-initializing", ".infinito-init.lock"): + (self.webroot / name).mkdir() + (self.webroot / "configuration.php").write_text(" Date: Fri, 20 Nov 2026 15:05:57 +0000 Subject: [PATCH 12/18] refactor(web-app-joomla): drop a narrating comment and the test helpers' name default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kvb-code-clean pass on PR 2375: the second exception comment in docker-entrypoint-joomla.sh loses its closing sentence, which only restated what the pending note does. The test helpers spawn() and calls() now take the log name as a required argument instead of defaulting to "calls"; every caller passes it. test_docker_entrypoint_joomla.py: 14 passed; ruff check, ruff format and shellcheck clean. 🎯 Fix: 85 % 💥 Break: 6 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 80 🚦 Gate: ⛔ fix 85 % < 90, break 6 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../files/shell/docker-entrypoint-joomla.sh | 2 +- .../shell/test_docker_entrypoint_joomla.py | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh index 4f7c27ff07..65c6de1a49 100644 --- a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh +++ b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh @@ -69,7 +69,7 @@ run_setup() { # Exception: Joomla's installer deletes installation/ while it still holds # installation/joomla.php open; NFS keeps that file as a .nfs silly rename, # so a complete install reports failure and the stock entrypoint keeps its - # marker. The pending note lets any later start finish that cleanup. + # marker. if [ -s "${config}" ] && [ -d "${marker}" ] && grep -q 'Unable to delete installation folder' "${log}" && ! grep -qE 'Failed to (correct ownership|restore configuration)|Refusing to change permissions' "${log}"; then diff --git a/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py b/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py index 1a4b6c9d93..411f8b2ee9 100644 --- a/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py +++ b/tests/unit/python/roles/web-app-joomla/files/shell/test_docker_entrypoint_joomla.py @@ -97,7 +97,7 @@ class TestJoomlaEntrypoint(unittest.TestCase): "STUB_RM_FAIL": "0", } - def spawn(self, name="calls", **env): + def spawn(self, name, **env): log = self.root / f"{name}.log" log.touch() with (self.root / f"{name}.err").open("a") as err: @@ -117,13 +117,13 @@ class TestJoomlaEntrypoint(unittest.TestCase): process.wait() def run_entrypoint(self, **env): - return self.spawn(**env).wait(timeout=60) + return self.spawn("calls", **env).wait(timeout=60) def text(self, name): path = self.root / name return path.read_text(encoding="utf-8") # nocheck: cache-read tempdir - def calls(self, name="calls"): + def calls(self, name): return self.text(f"{name}.log").splitlines() def wait_for(self, path): @@ -143,12 +143,12 @@ class TestJoomlaEntrypoint(unittest.TestCase): def assert_site_down(self): self.assertTrue(self.marker.is_dir()) self.assertFalse(self.ready.exists()) - self.assertNotIn(SERVE, self.calls()) + self.assertNotIn(SERVE, self.calls("calls")) def test_a_fresh_volume_is_set_up_once_before_the_server_starts(self): self.assertEqual(self.run_entrypoint(), 0) - self.assertEqual(self.calls().count("init"), 1) - self.assertEqual(self.calls()[-1], SERVE) + self.assertEqual(self.calls("calls").count("init"), 1) + self.assertEqual(self.calls("calls")[-1], SERVE) self.assertTrue(self.ready.exists()) self.assertFalse(self.lock.exists()) @@ -159,7 +159,7 @@ class TestJoomlaEntrypoint(unittest.TestCase): self.assertTrue((self.webroot / "robots.txt").is_file()) self.assertFalse(self.marker.exists()) self.assertFalse(self.pending.exists()) - self.assertEqual(self.calls()[-1], SERVE) + self.assertEqual(self.calls("calls")[-1], SERVE) def test_an_install_crash_after_the_config_was_written_keeps_the_site_down(self): self.assertNotEqual(self.run_entrypoint(STUB_INSTALL="crash"), 0) @@ -181,14 +181,14 @@ class TestJoomlaEntrypoint(unittest.TestCase): def test_a_restart_after_a_database_outage_sets_the_site_up(self): self.assertNotEqual(self.run_entrypoint(STUB_DB="down"), 0) self.assertEqual(self.run_entrypoint(), 0) - self.assertEqual(self.calls().count("init"), 1) - self.assertEqual(self.calls()[-1], SERVE) + self.assertEqual(self.calls("calls").count("init"), 1) + self.assertEqual(self.calls("calls")[-1], SERVE) def test_an_existing_installation_starts_without_setup(self): (self.webroot / "configuration.php").write_text(" Date: Fri, 20 Nov 2026 15:23:47 +0000 Subject: [PATCH 13/18] refactor(tests): split the fork-gate lint's per-workflow job scan out of the test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kvb-code-clean follow-up to PR 2376: test_pull_request_checkouts_under_pull_request_target_need_the_gate had cyclomatic complexity 11 (limit 10). The job loop moves into _offenders(name, document); the test only walks the workflows. Unchanged behaviour: 1 passed on main's workflows, and against the pre-2376 workflows it still fails on build-ci-images-fork and images-mirror-missing-fork. ruff check and format clean. 🎯 Fix: 95 % 💥 Break: 1 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 94 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../test_workflow_fork_checkout_gated.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/lint/repository/test_workflow_fork_checkout_gated.py b/tests/lint/repository/test_workflow_fork_checkout_gated.py index 4b386cb56e..7e77cb1d7f 100644 --- a/tests/lint/repository/test_workflow_fork_checkout_gated.py +++ b/tests/lint/repository/test_workflow_fork_checkout_gated.py @@ -40,6 +40,18 @@ def _needs(job: dict) -> list[str]: return [needs] if isinstance(needs, str) else list(needs) +def _offenders(name: str, document) -> list[str]: + offenders: list[str] = [] + for job_id, job in (document.get("jobs") or {}).items(): + if not isinstance(job, dict) or not _checks_out_pull_request_code(job): + continue + if _GATE_JOB not in _needs(job): + offenders.append(f"{name}: {job_id}: does not need it") + elif _GATE_BYPASS.search(str(job.get("if", ""))): + offenders.append(f"{name}: {job_id}: runs past a failed gate") + return offenders + + class TestWorkflowForkCheckoutGated(unittest.TestCase): def test_pull_request_checkouts_under_pull_request_target_need_the_gate( self, @@ -47,15 +59,8 @@ class TestWorkflowForkCheckoutGated(unittest.TestCase): offenders: list[str] = [] for path in sorted(_WORKFLOWS_DIR.glob("*.y*ml")): document = load_yaml_any(str(path), default_if_missing={}) or {} - if not _listens_to_pull_request_target(document): - continue - for job_id, job in (document.get("jobs") or {}).items(): - if not isinstance(job, dict) or not _checks_out_pull_request_code(job): - continue - if _GATE_JOB not in _needs(job): - offenders.append(f"{path.name}: {job_id}: does not need it") - elif _GATE_BYPASS.search(str(job.get("if", ""))): - offenders.append(f"{path.name}: {job_id}: runs past a failed gate") + if _listens_to_pull_request_target(document): + offenders.extend(_offenders(path.name, document)) if offenders: self.fail( From 2bcc457be2578b2989cab58bdf70aa1407e6b061 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 15:57:10 +0000 Subject: [PATCH 14/18] refactor(web-app-joomla): drop the narrative exception comments from the entrypoint wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operator review of PR 2375, which merged as 5bd5eeb068 before this commit landed: both exception blocks in docker-entrypoint-joomla.sh narrated why the code is shaped as it is; the commit message of e8f788d2cb already carries that. No code change; shellcheck clean. 🎯 Fix: 85 % 💥 Break: 6 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 80 🚦 Gate: ⛔ fix 85 % < 90, break 6 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../web-app-joomla/files/shell/docker-entrypoint-joomla.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh index 65c6de1a49..ed909dae1f 100644 --- a/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh +++ b/roles/web-app-joomla/files/shell/docker-entrypoint-joomla.sh @@ -62,14 +62,8 @@ release() { run_setup() { local log log="$(mktemp)" - # Exception: since docker-joomla 327d05a9f1 the stock entrypoint skips its - # setup for -v/-V/-h/-t/-T; `apache2 -l` still runs it and then returns. { "${stock}" apache2 -l 2>&1 | tee "${log}"; } & wait "$!" - # Exception: Joomla's installer deletes installation/ while it still holds - # installation/joomla.php open; NFS keeps that file as a .nfs silly rename, - # so a complete install reports failure and the stock entrypoint keeps its - # marker. if [ -s "${config}" ] && [ -d "${marker}" ] && grep -q 'Unable to delete installation folder' "${log}" && ! grep -qE 'Failed to (correct ownership|restore configuration)|Refusing to change permissions' "${log}"; then From 3e92b027df9a64973b0004d63a454ebacc834178 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:00:56 +0000 Subject: [PATCH 15/18] update(images): update Docker image versions (web-app-snipe-it) --- roles/web-app-snipe-it/meta/services.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/roles/web-app-snipe-it/meta/services.yml b/roles/web-app-snipe-it/meta/services.yml index 4ac02548e6..5f6908c819 100644 --- a/roles/web-app-snipe-it/meta/services.yml +++ b/roles/web-app-snipe-it/meta/services.yml @@ -61,7 +61,7 @@ snipe-it: enabled: true swarm: enabled: true - version: v8.8.3-alpine + version: v8.8.4-alpine custom: true name: snipe-it image: snipe/snipe-it @@ -85,11 +85,6 @@ snipe-it: - web-app-stalwart - web-app-mailu lifecycle: beta - security: - suppressions: - # nocheck: cve upstream tag ships fixable CRITICAL CVEs; lift it once a rebuilt tag lands - - image_tag: "v8.8.3-alpine" - until: 2026-11-30 sso: bond: 1 enabled: "{{ 'web-app-keycloak' in group_names }}" From bae46aff2dd7702837dc237af7a9424f08d88d10 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:09:18 +0000 Subject: [PATCH 16/18] update(images): update Docker image versions (web-svc-collabora) --- roles/web-svc-collabora/meta/services.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/roles/web-svc-collabora/meta/services.yml b/roles/web-svc-collabora/meta/services.yml index 3867c2486e..b281a5812e 100644 --- a/roles/web-svc-collabora/meta/services.yml +++ b/roles/web-svc-collabora/meta/services.yml @@ -25,7 +25,7 @@ collabora: enabled: true shared: true image: collabora/code - version: "26.04.6.1.1" + version: "26.04.6.2.1" name: collabora min_storage: 734MB cpus: 2 @@ -40,11 +40,6 @@ collabora: proxy: service_key: collabora lifecycle: beta - security: - suppressions: - # nocheck: cve upstream tag ships fixable CRITICAL CVEs; lift it once a rebuilt tag lands - - image_tag: "26.04.6.1.1" - until: 2026-11-30 # nocheck: dynamic-flag # nocheck: design-off Reason: '/' answers a plain OK, the admin console is off and the editor opens only as a POST from the WOPI host (Nextcloud) design: From 9fab251ffc1c5c57ae77c0372519e05b70f66496 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 19:04:09 +0000 Subject: [PATCH 17/18] fix(web-app-moodle): keep sessions in the database so swarm replicas share them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under swarm, three Moodle PHP replicas served one site from a shared NFS moodledata, and Moodle's default file session handler kept every session under $CFG->dataroot/sessions. CI run 44532889020 (PR 2243, Moodle#0 swarm) logged 'session_start(): Failed to decode session object. Session has been destroyed' nine times across the replicas, each one to two seconds before a failed spec attempt: the browser lost its session, the file picker's repository_ajax call answered requireloginerror and course navigation was sent to the login page (ERR_ABORTED). config.php now selects Moodle's core database session handler, so every replica reads the same session row from the shared MariaDB. Switching handlers signs every user out once. ConfigTest.php runs config.php against a stub setup.php and asserts the handler class; without the line the suite fails exactly that test (negative control). The new test is the mirrored unit test of config.php, so its nocheck: mirrored-unit-test exemption goes. 🎯 Fix: 88 % 💥 Break: 4 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 84 🚦 Gate: ⛔ fix 88 % < 90 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- roles/web-app-moodle/files/build/config.php | 3 +- .../web-app-moodle/files/build/ConfigTest.php | 61 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/unit/php/roles/web-app-moodle/files/build/ConfigTest.php diff --git a/roles/web-app-moodle/files/build/config.php b/roles/web-app-moodle/files/build/config.php index 3ac7ee66a2..a2c2bb9305 100644 --- a/roles/web-app-moodle/files/build/config.php +++ b/roles/web-app-moodle/files/build/config.php @@ -1,5 +1,4 @@ admin = 'admin'; $CFG->directorypermissions = 02770; $CFG->routerconfigured = true; +$CFG->session_handler_class = '\core\session\database'; + $CFG->reverseproxy = moodle_env_bool('MOODLE_REVERSEPROXY'); $CFG->sslproxy = moodle_env_bool('MOODLE_SSLPROXY'); diff --git a/tests/unit/php/roles/web-app-moodle/files/build/ConfigTest.php b/tests/unit/php/roles/web-app-moodle/files/build/ConfigTest.php new file mode 100644 index 0000000000..74c5fca9b8 --- /dev/null +++ b/tests/unit/php/roles/web-app-moodle/files/build/ConfigTest.php @@ -0,0 +1,61 @@ + 'mariadb', + 'MOODLE_DB_HOST' => 'mariadb', + 'MOODLE_DB_NAME' => 'moodle', + 'MOODLE_DB_USER' => 'moodle', + 'MOODLE_DB_PASS' => 'secret', + 'MOODLE_DB_PREFIX' => 'mdl_', + 'MOODLE_DB_PORT' => '3306', + 'MOODLE_WWWROOT' => 'https://academy.example.test', + 'MOODLE_DATAROOT' => '/var/www/moodledata', + 'MOODLE_LOCALCACHEDIR' => '/var/cache/moodle', + 'MOODLE_REVERSEPROXY' => 'false', + 'MOODLE_SSLPROXY' => 'true', + 'MOODLE_EGRESS_BLOCKED_HOSTS' => '10.0.0.0/8', + 'MOODLE_EGRESS_ALLOWED_PORTS' => '443', + 'MOODLE_INTERNAL_HOST' => 'moodle', + 'MOODLE_OBJECTFS_ENABLED' => 'false', + ]; + + private string $root; + + protected function setUp(): void + { + $this->root = sys_get_temp_dir() . '/mdlconfig' . bin2hex(random_bytes(6)); + mkdir($this->root . '/lib', 0700, true); + copy(dirname(__DIR__, 7) . '/roles/web-app-moodle/files/build/config.php', $this->root . '/config.php'); + file_put_contents($this->root . '/lib/setup.php', "root . '/lib/setup.php'); + unlink($this->root . '/config.php'); + rmdir($this->root . '/lib'); + rmdir($this->root); + } + + public function testEveryReplicaReadsSessionsFromTheSharedDatabase(): void + { + $process = proc_open( + [PHP_BINARY, '-r', 'require $argv[1]; echo $CFG->session_handler_class ?? "";', $this->root . '/config.php'], + [1 => ['pipe', 'w'], 2 => ['redirect', 1]], + $pipes, + null, + self::ENV + ['PATH' => (string) getenv('PATH')] + ); + $output = (string) stream_get_contents($pipes[1]); + fclose($pipes[1]); + + $this->assertSame(0, proc_close($process), $output); + $this->assertSame('\core\session\database', $output); + } +} From e2bfa11ac79a6c27ec0fd9c30ff6b2201e7d6f8e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Nov 2026 19:44:27 +0000 Subject: [PATCH 18/18] fix(web-app-erpnext): send mail with the relay's own TLS mode and auth flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit email_account.py hard-coded use_tls = 1 and no_smtp_authentication = 0. In Frappe, use_tls means STARTTLS, but Stalwart serves implicit TLS on smtps 465, so every ERPNext send hung until Stalwart's TLS timeout closed the socket (smtplib.SMTPServerDisconnected, 'Invalid Outgoing Mail Server or Port'); Stage 2.0 proved it in fork run 44617574811 ERPNext#1 (login POST 499 after 59.989 s). A relay without login (port 25, auth false) also got SMTP AUTH forced on it. The script now derives use_ssl_for_outgoing (tls and not start_tls), use_tls (tls and start_tls) and no_smtp_authentication (not auth) from the email lookup's tls, start_tls and auth, which the task passes as SMTP_TLS, SMTP_START_TLS and SMTP_AUTH. Adapted from Stage 2.0's IAM patch erpnext1-smtp-implicit-tls-r2 to main's env-passed SMTP_PASS. test_email_account.py covers implicit TLS, STARTTLS, plain, both auth cases, convergence of an account left on STARTTLS, and the commit; against main's script 5 of its 7 tests fail (negative control). The new test is the mirrored unit test of email_account.py, so its nocheck: mirrored-unit-test exemption goes; _fake_frappe gains is_new, db_insert and db_update. 🎯 Fix: 90 % 💥 Break: 4 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 86 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../files/python/apply/email_account.py | 10 +- .../tasks/addons/email_account.yml | 5 +- .../files/apply/_fake_frappe.py | 12 +++ .../files/apply/test_email_account.py | 94 +++++++++++++++++++ 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 tests/unit/python/roles/web-app-erpnext/files/apply/test_email_account.py diff --git a/roles/web-app-erpnext/files/python/apply/email_account.py b/roles/web-app-erpnext/files/python/apply/email_account.py index f97769cb2d..846e62ee30 100644 --- a/roles/web-app-erpnext/files/python/apply/email_account.py +++ b/roles/web-app-erpnext/files/python/apply/email_account.py @@ -1,5 +1,3 @@ -# nocheck: mirrored-unit-test - imports frappe at module level and runs inside `bench -# execute`; the framework is not installable outside the ERPNext image import os import frappe @@ -9,6 +7,9 @@ MAIL_FROM_NAME = os.environ["MAIL_FROM_NAME"] MAIL_FROM_ADDRESS = os.environ["MAIL_FROM_ADDRESS"] SMTP_HOST = os.environ["SMTP_HOST"] SMTP_PORT = int(os.environ["SMTP_PORT"]) +SMTP_TLS = os.environ["SMTP_TLS"] == "true" +SMTP_START_TLS = os.environ["SMTP_START_TLS"] == "true" +SMTP_AUTH = os.environ["SMTP_AUTH"] == "true" SMTP_USER = os.environ["SMTP_USER"] SMTP_PASS = os.environ["SMTP_PASS"] @@ -27,7 +28,8 @@ def upsert_outbound_account(): ea.enable_incoming = 0 ea.smtp_server = SMTP_HOST ea.smtp_port = SMTP_PORT - ea.use_tls = 1 + ea.use_ssl_for_outgoing = int(SMTP_TLS and not SMTP_START_TLS) + ea.use_tls = int(SMTP_TLS and SMTP_START_TLS) ea.login_id_is_different = 1 ea.login_id = SMTP_USER ea.password = SMTP_PASS @@ -35,7 +37,7 @@ def upsert_outbound_account(): ea.flags.ignore_permissions = True ea.flags.ignore_validate = True ea.flags.no_check_in_db = True - ea.no_smtp_authentication = 0 + ea.no_smtp_authentication = int(not SMTP_AUTH) ea.flags.ignore_links = True ea.flags.ignore_mandatory = True try: diff --git a/roles/web-app-erpnext/tasks/addons/email_account.yml b/roles/web-app-erpnext/tasks/addons/email_account.yml index 5b7b64db86..91eb8cc1fe 100644 --- a/roles/web-app-erpnext/tasks/addons/email_account.yml +++ b/roles/web-app-erpnext/tasks/addons/email_account.yml @@ -5,7 +5,7 @@ cmd: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node container exec -i -e SITE_NAME -e MAIL_FROM_NAME -e MAIL_FROM_ADDRESS - -e SMTP_HOST -e SMTP_PORT -e SMTP_USER -e SMTP_PASS + -e SMTP_HOST -e SMTP_PORT -e SMTP_TLS -e SMTP_START_TLS -e SMTP_AUTH -e SMTP_USER -e SMTP_PASS {{ ERPNEXT_BACKEND_LOCAL_CID | quote }} {{ ERPNEXT_BENCH_PYTHON }} stdin: "{{ lookup('ansible.builtin.file', role_path ~ '/files/python/apply/email_account.py') }}" @@ -16,6 +16,9 @@ MAIL_FROM_ADDRESS: "{{ ERPNEXT_MAIL.username | default('') }}" SMTP_HOST: "{{ ERPNEXT_MAIL.host | default('') }}" SMTP_PORT: "{{ ERPNEXT_MAIL.port | default(587) }}" + SMTP_TLS: "{{ ERPNEXT_MAIL.tls | bool | string | lower }}" + SMTP_START_TLS: "{{ ERPNEXT_MAIL.start_tls | bool | string | lower }}" + SMTP_AUTH: "{{ ERPNEXT_MAIL.auth | bool | string | lower }}" SMTP_USER: "{{ ERPNEXT_MAIL.username | default('') }}" SMTP_PASS: "{{ ERPNEXT_MAIL.password | default('') }}" when: ERPNEXT_MAIL.host is defined and (ERPNEXT_MAIL.host | length > 0) diff --git a/tests/unit/python/roles/web-app-erpnext/files/apply/_fake_frappe.py b/tests/unit/python/roles/web-app-erpnext/files/apply/_fake_frappe.py index e2f2b6bbde..5837207a3f 100644 --- a/tests/unit/python/roles/web-app-erpnext/files/apply/_fake_frappe.py +++ b/tests/unit/python/roles/web-app-erpnext/files/apply/_fake_frappe.py @@ -24,6 +24,7 @@ CHILD_TABLES = {"Fiscal Year": ("companies",), "User": ("roles",)} NAME_FIELDS = { "Company": "company_name", "Customer Group": "customer_group_name", + "Email Account": "email_account_name", "Fiscal Year": "year", "Item Group": "item_group_name", "Price List": "price_list_name", @@ -101,6 +102,17 @@ class FakeDoc: self._values["name"] = self._frappe.insert(self.doctype, self._values) return self + def is_new(self): + return not self._values.get("name") + + def db_insert(self): + return self.insert() + + def db_update(self): + self._frappe.records[self.doctype][self._values["name"]] = copy.deepcopy( + self._values + ) + def save(self, ignore_permissions=False): if self._single: self._frappe.singles[self.doctype] = copy.deepcopy(self._values) diff --git a/tests/unit/python/roles/web-app-erpnext/files/apply/test_email_account.py b/tests/unit/python/roles/web-app-erpnext/files/apply/test_email_account.py new file mode 100644 index 0000000000..ce1c1b8a11 --- /dev/null +++ b/tests/unit/python/roles/web-app-erpnext/files/apply/test_email_account.py @@ -0,0 +1,94 @@ +from __future__ import annotations + +import unittest + +from . import PROJECT_ROOT +from ._fake_frappe import FakeFrappe, run_script + +SCRIPT = PROJECT_ROOT / "roles/web-app-erpnext/files/python/apply/email_account.py" +ACCOUNT = "Email Account" +NAME = "ERPNext Outbound" + + +def _env(*, port, tls, start_tls, auth): + return { + "SITE_NAME": "next.erp.infinito.example", + "MAIL_FROM_NAME": "Infinito ERPNext", + "MAIL_FROM_ADDRESS": "no-reply@infinito.example", + "SMTP_HOST": "mail.infinito.example", + "SMTP_PORT": str(port), + "SMTP_TLS": str(tls).lower(), + "SMTP_START_TLS": str(start_tls).lower(), + "SMTP_AUTH": str(auth).lower(), + "SMTP_USER": "no-reply@infinito.example", + "SMTP_PASS": "submission-token", + } + + +class TestEmailAccount(unittest.TestCase): + def setUp(self) -> None: + self.frappe = FakeFrappe() + + def _account(self, **transport): + run_script(SCRIPT, self.frappe, _env(**transport)) + return self.frappe.records[ACCOUNT][NAME] + + def _run(self, **transport): + account = self._account(**transport) + return ( + account.get("smtp_port"), + account.get("use_ssl_for_outgoing"), + account.get("use_tls"), + ) + + def test_an_implicit_tls_relay_opens_the_session_inside_tls(self) -> None: + self.assertEqual( + (465, 1, 0), self._run(port=465, tls=True, start_tls=False, auth=True) + ) + + def test_a_starttls_relay_upgrades_a_plain_session(self) -> None: + self.assertEqual( + (587, 0, 1), self._run(port=587, tls=True, start_tls=True, auth=True) + ) + + def test_a_relay_without_tls_speaks_plain_smtp(self) -> None: + self.assertEqual( + (25, 0, 0), self._run(port=25, tls=False, start_tls=False, auth=False) + ) + + def test_a_relay_that_takes_no_login_is_sent_to_without_smtp_auth(self) -> None: + account = self._account(port=25, tls=False, start_tls=False, auth=False) + + self.assertEqual(1, account.get("no_smtp_authentication")) + + def test_a_relay_that_takes_a_login_is_sent_to_with_smtp_auth(self) -> None: + account = self._account(port=465, tls=True, start_tls=False, auth=True) + + self.assertEqual(0, account.get("no_smtp_authentication")) + + def test_an_account_left_on_starttls_converges_to_the_relay_transport( + self, + ) -> None: + self.frappe.seed( + ACCOUNT, + NAME, + email_account_name=NAME, + smtp_port=465, + use_ssl_for_outgoing=0, + use_tls=1, + ) + + transport = self._run(port=465, tls=True, start_tls=False, auth=True) + + self.assertEqual((465, 1, 0), transport) + self.assertEqual([NAME], list(self.frappe.records[ACCOUNT])) + + def test_the_account_is_committed_and_the_site_closed(self) -> None: + self._run(port=465, tls=True, start_tls=False, auth=True) + + self.assertTrue(self.frappe.db.committed) + self.assertEqual(("destroy",), self.frappe.calls[-1]) + + +if __name__ == "__main__": + unittest.main()