From e985062e10b41f760751a244100e5c280c5c0d54 Mon Sep 17 00:00:00 2001 From: Omar Sy Date: Thu, 22 Oct 2026 10:48:03 +0200 Subject: [PATCH] feat(containment): structure-preserving render + deploy-time preflight MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compose-containment Feature 6 — the last feature of the epic. Two halves: ROUND-TRIP GUARD. The compose body no longer renders through Template(yaml.dump(compose)) — whose single-quote escaping (an embedded ' doubled to '') corrupted any Jinja expression containing a single-quoted literal into a TemplateSyntaxError, with the catalog working around it by double-quote convention. Every string LEAF now renders in ONE budgeted child job (the same tree walker the json destinations use, generalized to select the body env) and the tree is yaml.dump'd exactly once afterwards — the fragility class is killed structurally: values render as Python strings, then yaml serializes with correct quoting applied once. Keys never render (same intentional choice as the json walker). Regression test pins the exact formerly-broken shape (a single-quoted Jinja literal). THE ORACLE GATE, honored: all 29 catalog snapshots regenerated with CATALOG_RENDER_UPDATE=1 and every moved byte reviewed — an executable semantic-equality check (yaml.safe_load old == new) proves all 29 diffs are quoting/whitespace/EOF-newline only, zero value changes. The first regeneration was produced by a buggy submit that hardwired the StrictUndefined FILE env for the body tree (the consolidation left pool.submit(_child_render_json...) in _run_tree_job) — caught by the oracle itself via 4 entry diffs, fixed by submitting _child_render_tree with the which parameter, then re-generated and re-verified. PREFLIGHT (custom-app LLD 4.1 wire; validator internals per the containment HLD): POST /api/controller/preflight/ {compose_yaml} -> 200 {services, ports, config_candidates, image_digests, warnings} or 422 {errors:[{service,key,message}]} surfacing the shape pass verbatim. The SAME parse + strict-allowlist path as a real start (a green preflight provably implies a start that parses), the operator key grant threaded through; image references pinned by pull+inspect (the one deliberate node-side write; unresolvable = error naming the image, never a deploys-unpinned fallback); config candidates from environment keys plus {{ config.X }} references (referenced ones pre-ticked); the unset-integration STRIP WARNING distinguishes genuine {{ smtp.host }} references (the strip is correct behaviour) from literal text like an innocent smtp.gmail.com inside a templated MAIL_URL (the false-positive class) by matching against the value with all {{ ... }} expressions removed — covering every KNOWN_INTEGRATION_TYPES entry (smtp and oidc), per the containment HLD's requirement. 10 preflight tests (payload, verbatim shape errors, digest failures, grant threading, the warning discrimination, route 200/422/token). Suite at the pinned catalog: 1072 passed, 0 failed — the full oracle green through the new render path. Adversarial review round (DO NOT SHIP, 2 P1s) — folded: P1-1 the body env lacked keep_trailing_newline, so per-leaf rendering silently truncated every multi-line value by exactly one trailing newline (the old whole-document pipeline only ever lost the document- final one). Fixed; the 4 affected snapshots re-regenerated and verified to differ from origin/main's by EXACTLY the restored newline (docs/ plausible/visio/wordpress: command/entrypoint/WORDPRESS_CONFIG_EXTRA leaves) — i.e. main's committed snapshots carried the truncation, and the new bytes restore the catalog's ground truth. Regression test pins the leaf-level semantics. P1-2 preflight CPU DoS: compose_yaml had no max_length (the only unbounded string in the models — everything else caps 64-512) and the expression-strip regex backtracked quadratically on brace-padded values (256KB body -> 210s, pinning a threadpool token; tenant-triggerable through the manager proxy). Bounded at 1 MiB (GREFFER_RENDER_MAX_INPUT order) and replaced the regex with a linear single-pass span remover (same semantics for well-formed templates; unterminated {{ conservatively stays literal). Also: keys now COUNT toward the tree input cap (a 3 MiB key previously passed a 1 MiB cap as one counted byte — keys never render, but their bulk must be bounded; regression test); bracket-form {{ config['X'] }} references detected (dot-only let them read as unreferenced — the silent-empty class; regression test); container_port str()'d for a stable wire type; the stale 'yaml.dump stays OUTSIDE the try' comment reconciled with the code. Suite at the pinned catalog: 1075 passed, 0 failed. Codex CLI review round (2 P1s + 6 P2s) — folded: P1 job-wide output cap: per-leaf counters let N leaves each render just under GREFFER_RENDER_MAX_OUTPUT, so the assembled document exceeded it unbounded (the serialized output also grew in the controller, outside the child's memory guard). The tree job now carries ONE budget accumulator across all leaves. P1 alias-bomb: YAML aliases let a sub-KiB compose expand to exponentially many visits in the preflight leaf walk (outside every render guard; recursive aliases recurse forever). The walk is now alias-safe (shared containers visited once — which alone neuters the doubling chain, asserted by a timing test) and budget-bounded (20k visits; a huge non-aliased structure trips a named refusal). Both regression tests. P2s: an imageless service is now a structured refusal (the allowlist permits the key but never requires it, and strict mode refuses build — it could never deploy; it previously returned success with an empty digest map); config references detected ANYWHERE inside expressions ({{ 'p' ~ config.SECRET }} missed by the opening-token-only match) and the bracket-form quote DELIMITER no longer leaks a spurious quote candidate (groups filtered); ReaderError (no .problem attribute) is a named 422 instead of an AttributeError 500; the candidate name-set is built once (was quadratic per referenced key); the body wiring test re-pinned to the tree-job aggregate semantics (output cap). CR/LF preservation in scalar leaves NOT folded: yaml.safe_load itself normalizes line endings before any greffer code runs, so the old pipeline lost them identically — not a regression of this change (left as a note for a future newlines-are-load-bearing audit). Suite at the pinned catalog: 1081 passed, 0 failed. --- app/models/controller.py | 13 + app/routers/controller.py | 26 ++ apps/utils/docker/compose.py | 22 +- apps/utils/docker/render_budget.py | 93 +++++-- apps/utils/greffon/preflight.py | 259 ++++++++++++++++++ .../catalog_render/activepieces__1.0.snap | 18 +- tests/snapshots/catalog_render/docs__1.0.snap | 34 +-- .../catalog_render/excalidraw__1.0.snap | 4 +- .../catalog_render/forgejo__1.0.snap | 18 +- .../catalog_render/freshrss__1.0.snap | 4 +- .../snapshots/catalog_render/ghost__1.0.snap | 14 +- .../catalog_render/glitchtip__1.0.snap | 10 +- .../catalog_render/grafana__1.0.snap | 16 +- .../snapshots/catalog_render/immich__1.0.snap | 8 +- .../catalog_render/keycloak__1.0.snap | 6 +- .../catalog_render/linkding__1.0.snap | 6 +- .../snapshots/catalog_render/mealie__1.0.snap | 16 +- .../snapshots/catalog_render/memos__1.0.snap | 4 +- .../catalog_render/metabase__1.0.snap | 20 +- .../catalog_render/multica__1.0.snap | 24 +- tests/snapshots/catalog_render/n8n__1.0.snap | 20 +- .../catalog_render/nextcloud__1.0.snap | 21 +- .../catalog_render/paperless-ngx__1.0.snap | 14 +- .../catalog_render/plausible__1.0.snap | 14 +- .../catalog_render/remotion__1.0.snap | 4 +- .../catalog_render/stirling-pdf__1.0.snap | 4 +- .../snapshots/catalog_render/umami__1.0.snap | 6 +- .../catalog_render/uptime-kuma__1.0.snap | 4 +- .../catalog_render/vaultwarden__1.0.snap | 16 +- .../catalog_render/vikunja__1.0.snap | 14 +- .../snapshots/catalog_render/visio__1.0.snap | 32 +-- .../snapshots/catalog_render/vscode__1.0.snap | 4 +- .../catalog_render/wireguard__1.0.snap | 6 +- .../catalog_render/wordpress__1.0.snap | 25 +- tests/test_preflight.py | 212 ++++++++++++++ tests/test_render_budget.py | 56 +++- 36 files changed, 847 insertions(+), 220 deletions(-) create mode 100644 apps/utils/greffon/preflight.py create mode 100644 tests/test_preflight.py diff --git a/app/models/controller.py b/app/models/controller.py index a687ca05..47388e4c 100644 --- a/app/models/controller.py +++ b/app/models/controller.py @@ -26,6 +26,19 @@ class GreffonField(BaseModel): destinations: Any +class GreffonPreflightRequest(BaseModel): + """Custom-app LLD §4.1: the preflight validates a custom compose for + deployability (parse + strict allowlist + artifact pinning) before the + manager persists anything. Read-only apart from the digest-resolution + pull.""" + + # Bounded to the same order as GREFFER_RENDER_MAX_INPUT (1 MiB): an + # unbounded body is tenant-triggerable CPU/memory before any budget + # runs (yaml.safe_load + expression scans) — everything else in this + # model caps at 64-512. + compose_yaml: str = Field(min_length=1, max_length=1048576) + + class GreffonStartRequest(BaseModel): # `id` is a free-form str in DRF (not UUID), matching what the manager # sends today (e.g. "test-instance-123"). Pattern kept permissive to diff --git a/app/routers/controller.py b/app/routers/controller.py index 83501a46..3adfd3db 100644 --- a/app/routers/controller.py +++ b/app/routers/controller.py @@ -23,6 +23,7 @@ import anyio from fastapi import APIRouter, Depends, HTTPException, Request +from fastapi.responses import JSONResponse from app import backup from app.auth import require_token @@ -34,6 +35,7 @@ GreffonDecommissionRequest, GreffonDecommissionResponse, GreffonForgetRequest, + GreffonPreflightRequest, GreffonRepoOpRequest, GreffonRestoreRequest, GreffonRestoreResponse, @@ -221,6 +223,30 @@ def wrapper(payload, request, *args, **kwargs): return wrapper +@router.post("/preflight/") +def preflight_greffon( + payload: GreffonPreflightRequest, + request: Request, + _: None = Depends(require_token), +) -> JSONResponse: + """compose-containment Feature 6 / custom-app LLD §4.1: validate a + custom compose on the node that would deploy it. The SAME parse and + strict-allowlist path as a real start, so a green preflight provably + implies a start that parses; image references are pinned to digests by + pull+inspect (the one node-side write; unresolvable = error, never an + unpinned fallback). Sync def: digest pulls are blocking and run on the + threadpool like start.""" + from apps.utils.greffon import preflight as preflight_mod + + try: + result = preflight_mod.run_preflight( + payload.compose_yaml, + extra_keys=_settings(request).greffer_compose_extra_allowed_keys) + except preflight_mod.PreflightError as exc: + return JSONResponse({"errors": exc.errors}, status_code=422) + return JSONResponse(result) + + @router.post("/start/") @_serialize_instance_op def start_greffon( diff --git a/apps/utils/docker/compose.py b/apps/utils/docker/compose.py index a93d56e2..892b717d 100644 --- a/apps/utils/docker/compose.py +++ b/apps/utils/docker/compose.py @@ -33,6 +33,7 @@ from apps.utils.docker.render_budget import ( # noqa: F401 (re-export) _COMPOSE_RENDER_ENV, _FILE_RENDER_ENV, + render_compose_tree_bounded, render_json_bounded, ) @@ -645,9 +646,12 @@ def create_compose(compose, greffon_info): # a user-supplied `{{ config.X }}` reaches these today. Inside this try # nothing but template evaluation runs, and the env has no custom filters # or globals that could raise a greffer bug, so a broad catch cannot - # mislabel a greffer fault as a catalog error. yaml.dump stays OUTSIDE the - # try: a dict that cannot be represented is greffer-side, and a 500 is the - # honest answer there. + # mislabel a greffer fault as a catalog error. The FINAL yaml.dump + # (serializing the already-rendered tree, post-Feature-6) is inside + # this try: with safe_load'ed input the render output contains only + # str/int/float/bool/None/dict/list, which yaml can always represent, + # so an exception from it would be a greffer bug — and wrapping it + # 422s rather than 500s, the conservative direction either way. # # The forwarded detail names the exception TYPE only, never str(exc). With # the lenient undefined the body keeps, a rendered value can land inside @@ -658,12 +662,18 @@ def create_compose(compose, greffon_info): # know whether the compose is unsafe, malformed, or references something # unset; the full reason goes to the greffer log, which is not caller- # reachable. The compose file is only written after the render succeeds. - dumped = yaml.dump(compose) try: # Feature 1b: the render runs under the budget (input/output caps, - # child-process memory + time bound) — see render_budget.py. A cap + # child-process memory + time bound). Feature 6: STRUCTURE- + # PRESERVING — every string LEAF renders in one child job and the + # tree is yaml.dump'd once afterwards, replacing + # Template(yaml.dump(compose)) whose single-quote escaping could + # corrupt Jinja expressions containing single-quoted literals + # (TemplateSyntaxError on legal compose; the catalog worked around + # it by double-quote convention). Keys never render. A cap # violation re-raises below as its own bounded message. - compose_file = render_bounded('body', dumped, greffon_info) + rendered = render_compose_tree_bounded(compose, greffon_info) + compose_file = yaml.dump(rendered) except RenderBudgetExceeded as exc: raise ConfigRenderError(str(exc)) from exc except Exception as exc: diff --git a/apps/utils/docker/render_budget.py b/apps/utils/docker/render_budget.py index a576d5fc..52094608 100644 --- a/apps/utils/docker/render_budget.py +++ b/apps/utils/docker/render_budget.py @@ -165,7 +165,13 @@ def _harden(env): return env -_COMPOSE_RENDER_ENV = _harden(ImmutableSandboxedEnvironment(autoescape=False)) +# keep_trailing_newline: the per-LEAF render must preserve a value's own +# trailing \n (multi-line entrypoints, heredocs, env-file style content) — +# Jinja strips one trailing newline by default, which silently truncated +# every multi-line leaf by exactly one \n (found by adversarial review: +# 4 catalog snapshots diffed by exactly that). +_COMPOSE_RENDER_ENV = _harden(ImmutableSandboxedEnvironment( + autoescape=False, keep_trailing_newline=True)) _harden(_FILE_RENDER_ENV) @@ -254,51 +260,100 @@ def _child_render(which: str, source: str, context: dict) -> str: raise rebuilt from None -def _child_render_json(tree, context): - """Runs IN THE CHILD: render every STRING LEAF of a json-destination - value in one job. Per-leaf submission re-pickled the entire context - (cert material included) for every leaf — quadratic on real realm - documents (codex review: a 5k-leaf doc went 0.6s -> 10.4s).""" +def _child_render_tree(tree, context, which, _budget=None): + """Runs IN THE CHILD: render every STRING LEAF of a tree value in one + job (per-leaf submission re-pickled the entire context for every leaf + — quadratic on real documents; codex review). which selects the env + ('file' for json destinations, 'body' for the compose tree — the + Feature-6 structure-preserving render). + + _budget is a one-element JOB-WIDE output accumulator: per-leaf caps + alone let N leaves each render just under the cap, so the assembled + document exceeded GREFFER_RENDER_MAX_OUTPUT unbounded (codex review). + """ + if _budget is None: + _budget = [_knob("GREFFER_RENDER_MAX_OUTPUT", _DEFAULT_OUTPUT)] if isinstance(tree, str): - max_in = _knob("GREFFER_RENDER_MAX_INPUT", _DEFAULT_INPUT) - if max_in and len(tree.encode("utf-8", "surrogatepass")) > max_in: - raise RenderBudgetExceeded("input_too_large", max_in) - return _child_render("file", tree, context) + out = _child_render(which, tree, context) + if _budget[0]: + _budget[0] -= len(out.encode("utf-8", "surrogatepass")) + if _budget[0] < 0: + raise RenderBudgetExceeded( + "output_too_large", + _knob("GREFFER_RENDER_MAX_OUTPUT", _DEFAULT_OUTPUT)) + return out if isinstance(tree, dict): - return {k: _child_render_json(v, context) for k, v in tree.items()} + return {k: _child_render_tree(v, context, which, _budget) + for k, v in tree.items()} if isinstance(tree, list): - return [_child_render_json(v, context) for v in tree] + return [_child_render_tree(v, context, which, _budget) + for v in tree] return tree +def _child_render_json(tree, context): + return _child_render_tree(tree, context, "file") + + def render_json_bounded(tree, context) -> object: """Budgeted render of a json-destination value's string leaves, in one child round-trip (input cap applies per leaf via the child render).""" + return _run_tree_job(tree, context, "file") + + +def render_compose_tree_bounded(compose, context) -> object: + """Feature 6 structure-preserving render: render every string LEAF of + the compose tree under the body env, in ONE child job; the caller then + yaml.dump's the result ONCE. Replacing Template(yaml.dump(compose)) + kills the round-trip fragility class structurally: yaml single-quote + escaping (an embedded ' doubled to '') could corrupt any Jinja + expression containing a single-quoted literal into a + TemplateSyntaxError — and every catalog workaround-by-convention + disappears, because values are rendered as Python strings and then + serialized by yaml with correct quoting applied exactly once. + Keys are NOT rendered (same intentional choice as the json walker). + """ + return _run_tree_job(compose, context, "body") + + +def _run_tree_job(tree, context, which): src_len = sum( len(leaf.encode("utf-8", "surrogatepass")) - for leaf in _iter_string_leaves(tree)) + for leaf in _iter_string_leaves(tree, keys=True)) max_in = _knob("GREFFER_RENDER_MAX_INPUT", _DEFAULT_INPUT) if max_in and src_len > max_in * 100: - # A sane guard for pathological leaf counts; each leaf is itself - # input-capped in the child. + # Aggregate guard for pathological leaf counts (values AND keys + # are counted; each rendered leaf is additionally input-capped in + # the child — keys render never, so this aggregate is their only + # bound). raise RenderBudgetExceeded("input_too_large", max_in * 100) mem = _knob("GREFFER_RENDER_MEM_BYTES", _DEFAULT_MEM) timeout = _knob("GREFFER_RENDER_TIMEOUT_SECONDS", _DEFAULT_TIMEOUT, as_float=True) return _submit_budgeted( - lambda pool: pool.submit(_child_render_json, tree, context), + lambda pool: pool.submit(_child_render_tree, tree, context, which), mem, timeout) -def _iter_string_leaves(tree): +def _iter_string_leaves(tree, keys: bool = False): + """Yield every string leaf. keys=False (the render path) walks VALUES + only — keys never render (an intentional hardening over the old whole- + document template, which templated them: a structure-injection vector). + keys=True (the budget accounting path) walks keys TOO, so a compose + whose bulk hides in keys cannot exceed the input cap un-counted + (review finding: a 3 MiB key passed a 1 MiB cap as 1 counted byte).""" if isinstance(tree, str): yield tree elif isinstance(tree, dict): + if keys: + for k in tree: + if isinstance(k, str): + yield k for v in tree.values(): - yield from _iter_string_leaves(v) + yield from _iter_string_leaves(v, keys) elif isinstance(tree, list): for v in tree: - yield from _iter_string_leaves(v) + yield from _iter_string_leaves(v, keys) # --- the pool ---------------------------------------------------------------- diff --git a/apps/utils/greffon/preflight.py b/apps/utils/greffon/preflight.py new file mode 100644 index 00000000..55f3c951 --- /dev/null +++ b/apps/utils/greffon/preflight.py @@ -0,0 +1,259 @@ +"""Deploy-time preflight (compose-containment Feature 6, the validator half; +the WIRE contract is owned by the custom-app foundation LLD §4.1): + + POST /api/controller/preflight/ {"compose_yaml": "..."} + 200 {"services": [...], "ports": [...], "config_candidates": [...], + "image_digests": {...}, "warnings": [...]} + 422 {"errors": [{"service", "key", "message"}, ...]} + +The preflight runs the SAME parse/validation path as a real start +(normalize_compose, strict set — preflight is FOR custom composes), so a +green preflight provably implies a start that parses. Read-only apart from +one deliberate node-side write: image digest resolution pull+inspects each +``image:`` reference (layer cache — bounded by disk admission at start; +a digest that cannot be resolved is an error naming the image, never a +deploys-unpinned fallback). +""" +from __future__ import annotations + +import logging +import re + +import yaml + +from apps.utils.docker import compose as compose_mod +from apps.utils.greffon.compose_shape import ComposeShapeError, normalize_compose + +logger = logging.getLogger("greffer") + + +class PreflightError(Exception): + """Refusal with structured rows, surfacing verbatim from the shape + pass (the LLD's 422 contract) or from digest resolution.""" + + def __init__(self, errors: list[dict]): + self.errors = errors + super().__init__(f"preflight refused: {errors}") + + +# Both reference forms, like the integration strip's pattern: dot +# ({{ config.X }}) and bracket ({{ config['X'] }}) are semantically +# identical Jinja, and a bracket-only reference must still pre-tick its +# candidate (review finding: dot-only let it through as unreferenced -- +# the silent-empty class the create-time check exists to prevent). +# config.NAME / config['NAME'] / config["NAME"] ANYWHERE inside an +# expression (codex review: matching only at the {{ opening token missed +# {{ 'p' ~ config.SECRET }} and conditional blocks). Groups 1/3 are the +# names; group 2 is the quote DELIMITER and must never become a +# candidate (also codex). +_CONFIG_REF = re.compile( + r"config(?:\.([A-Za-z0-9_]+)|\[(['\"])([A-Za-z0-9_]+)\2)") + + +def _CONFIG_KEYS(groups): + return {g for i, g in enumerate(groups) if g and i != 1} +def _strip_expressions(value: str) -> str: + """Remove every template expression span, LINEARLY: a non-greedy + dot-star regex backtracked quadratically on brace-padded values + (256KB -> 210s, adversarial review), pinning a threadpool token. + A single left-to-right scan has the same semantics for well-formed + templates; unterminated {{ leaves the tail as literal text (the + conservative direction for the warning).""" + out = [] + i = 0 + n = len(value) + while i < n: + start = value.find("{{", i) + if start == -1: + out.append(value[i:]) + break + out.append(value[i:start]) + end = value.find("}}", start + 2) + if end == -1: + out.append(value[start:]) # unterminated: keep as literal + break + i = end + 2 + return "".join(out) +# Mirrors _delete_unset_integration_env_keys' pattern: a word-bounded +# integration type name followed by `.attr` or `['key` — matched against +# the value with all {{ ... }} expressions REMOVED, so only LITERAL text +# (an innocent 'smtp.gmail.com' in a templated MAIL_URL) warns; a genuine +# {{ smtp.host }} reference lives inside the removed span and the strip +# deleting it is correct behaviour, not a warning. +_TYPE_LITERAL = { + t: re.compile(r"\b" + re.escape(t) + r"(?:\.\w|\[)") + for t in compose_mod.KNOWN_INTEGRATION_TYPES +} + + +def _env_items(service_def: dict): + env = service_def.get("environment") + if isinstance(env, dict): + for k, v in env.items(): + yield str(k), v + elif isinstance(env, list): + for item in env: + if isinstance(item, str) and "=" in item: + name, value = item.split("=", 1) + yield name.strip(), value + + +_LEAF_BUDGET = 20000 # visits per walk; a 1 MiB compose has << this many + + +def _string_leaves(value): + """Alias-safe, cycle-safe, budget-bounded walk (codex review: YAML + aliases let a sub-KiB compose expand to exponentially many visits — + or recurse forever with a self-referencing alias — pinning a request + thread outside every render guard). Shared containers are visited + ONCE; the visit budget caps total work for pathological shapes.""" + seen = set() + budget = [_LEAF_BUDGET] + + def walk(node): + if budget[0] <= 0: + raise PreflightError([{ + "service": None, "key": "compose_yaml", + "message": "compose structure too large to analyze " + "(alias expansion or excessive nesting)", + }]) + budget[0] -= 1 + if isinstance(node, (dict, list)): + marker = id(node) + if marker in seen: + return + seen.add(marker) + if isinstance(node, str): + yield node + elif isinstance(node, dict): + for v in node.values(): + yield from walk(v) + elif isinstance(node, list): + for v in node: + yield from walk(v) + + yield from walk(value) + + +def _strip_warnings(services: dict) -> list[dict]: + warnings = [] + for name, svc in services.items(): + for key, value in _env_items(svc): + if not isinstance(value, str) or "{{" not in value: + continue + literal = _strip_expressions(value) + for itype, pattern in _TYPE_LITERAL.items(): + if pattern.search(literal): + warnings.append({ + "service": name, + "key": key, + "message": ( + f"this value's literal text mentions " + f"'{itype}' outside its template expression; " + f"the unset-integration env strip deletes the " + f"whole key when no {itype} integration is " + f"selected"), + }) + return warnings + + +def _resolve_image_digests(services: dict) -> dict: + """Pull+inspect every image: reference and return {service: digest}. + A reference that cannot be resolved is an error naming the image — + the artifact pin refuses rather than falling back to unpinned bytes. + """ + digests = {} + for name, svc in services.items(): + image = svc.get("image") + if not isinstance(image, str) or not image: + # The allowlist PERMITS the key but never REQUIRES it, and + # strict mode refuses `build` — so an imageless service + # cannot deploy at all. Say so instead of skipping silently + # (codex review). + raise PreflightError([{ + "service": name, + "key": "image", + "message": "service has no image reference and cannot " + "deploy (build is not permitted)", + }]) + try: + compose_mod.client.images.pull(image) + info = compose_mod.client.images.get(image) + repo_digests = [ + d for d in (info.attrs.get("RepoDigests") or []) + if "@" in d + ] + if not repo_digests: + raise RuntimeError("image has no repo digest") + digests[name] = repo_digests[0] + except Exception as exc: # noqa: BLE001 — surfaced as a named row + logger.warning("preflight digest failed for %s: %s", image, exc) + raise PreflightError([{ + "service": name, + "key": "image", + "message": f"could not resolve {image!r} to a digest " + f"({type(exc).__name__}); an unpinned reference " + f"is not deployable", + }]) from exc + return digests + + +def run_preflight(compose_yaml: str, extra_keys=None) -> dict: + """Validate a custom compose for deployability. Raises PreflightError + with 422 rows; returns the LLD §4.1 payload on success.""" + try: + compose = yaml.safe_load(compose_yaml) + except yaml.YAMLError as exc: + raise PreflightError([{ + "service": None, "key": "compose_yaml", + "message": f"not valid YAML " + f"({getattr(exc, 'problem', None) or exc})", + }]) from exc + + try: + normalize_compose(compose, strict=True, extra_keys=extra_keys) + except ComposeShapeError as exc: + raise PreflightError([{ + "service": exc.service, "key": exc.key, "message": exc.message, + }]) from exc + + services = compose["services"] + + ports = [] + for name, svc in services.items(): + for port in svc.get("ports") or []: + ports.append({ + "port_name": f"{name}_{port['target']}", + "service": name, + "container_port": str(port["target"]), + "protocol": port.get("protocol") or "tcp", + }) + + referenced = set() + for leaf in _string_leaves(compose): + for groups in _CONFIG_REF.findall(leaf): + referenced.update(_CONFIG_KEYS(groups)) + candidates = {} + for name, svc in services.items(): + for key, _value in _env_items(svc): + entry = candidates.setdefault( + (name, key), {"service": name, "key": key, + "referenced": False}) + if key in referenced: + entry["referenced"] = True + known = {k for (_s, k) in candidates} + for key_name in referenced: + if key_name not in known: + known.add(key_name) + candidates[(None, key_name)] = { + "service": None, "key": key_name, "referenced": True} + + return { + "services": sorted(services), + "ports": ports, + "config_candidates": sorted(candidates.values(), + key=lambda c: (c["service"] or "", + c["key"])), + "image_digests": _resolve_image_digests(services), + "warnings": _strip_warnings(services), + } diff --git a/tests/snapshots/catalog_render/activepieces__1.0.snap b/tests/snapshots/catalog_render/activepieces__1.0.snap index c26095ff..453dafc0 100644 --- a/tests/snapshots/catalog_render/activepieces__1.0.snap +++ b/tests/snapshots/catalog_render/activepieces__1.0.snap @@ -9,22 +9,22 @@ services: AP_DB_TYPE: POSTGRES AP_ENCRYPTION_KEY: '' AP_EXECUTION_MODE: UNSANDBOXED - AP_FRONTEND_URL: 'https://regress-activepieces-0.my.example.test' + AP_FRONTEND_URL: https://regress-activepieces-0.my.example.test AP_JWT_SECRET: '' AP_POSTGRES_DATABASE: activepieces AP_POSTGRES_HOST: activepieces_db - AP_POSTGRES_PASSWORD: 'regress-activepieces' + AP_POSTGRES_PASSWORD: regress-activepieces AP_POSTGRES_PORT: '5432' AP_POSTGRES_USERNAME: activepieces AP_QUEUE_MODE: REDIS AP_REDIS_HOST: activepieces_redis AP_REDIS_PORT: '6379' AP_REDIS_TYPE: STANDALONE - AP_SMTP_HOST: 'smtp.example.test' - AP_SMTP_PASSWORD: 'pw' + AP_SMTP_HOST: smtp.example.test + AP_SMTP_PASSWORD: pw AP_SMTP_PORT: '587' - AP_SMTP_SENDER_EMAIL: 'noreply@example.test' - AP_SMTP_USERNAME: 'mailer@example.test' + AP_SMTP_SENDER_EMAIL: noreply@example.test + AP_SMTP_USERNAME: mailer@example.test AP_TELEMETRY_ENABLED: 'false' image: ghcr.io/activepieces/activepieces:0.83.0 logging: @@ -40,7 +40,7 @@ services: activepieces_db: environment: POSTGRES_DB: activepieces - POSTGRES_PASSWORD: 'regress-activepieces' + POSTGRES_PASSWORD: regress-activepieces POSTGRES_USER: activepieces image: pgvector/pgvector:0.8.0-pg14 logging: @@ -77,7 +77,7 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-activepieces_nginx_volume:/etc/nginx/ @@ -88,4 +88,4 @@ volumes: regress-activepieces_activepieces_redis: name: regress-activepieces_activepieces_redis regress-activepieces_nginx_volume: - name: regress-activepieces_nginx_volume \ No newline at end of file + name: regress-activepieces_nginx_volume diff --git a/tests/snapshots/catalog_render/docs__1.0.snap b/tests/snapshots/catalog_render/docs__1.0.snap index d6a37f0b..d92a1706 100644 --- a/tests/snapshots/catalog_render/docs__1.0.snap +++ b/tests/snapshots/catalog_render/docs__1.0.snap @@ -18,7 +18,7 @@ services: CELERY_BROKER_URL: redis://redis:6379/1 COLLABORATION_API_URL: http://y-provider:4444/collaboration/api/ COLLABORATION_BACKEND_BASE_URL: http://backend:8000 - COLLABORATION_SERVER_ORIGIN: 'https://regress-docs-0.my.example.test' + COLLABORATION_SERVER_ORIGIN: https://regress-docs-0.my.example.test COLLABORATION_SERVER_SECRET: '' COLLABORATION_WS_URL: wss://regress-docs-0.my.example.test/collaboration/ws/ DB_HOST: postgresql @@ -26,26 +26,26 @@ services: DB_PASSWORD: '' DB_PORT: '5432' DB_USER: docs - DJANGO_ALLOWED_HOSTS: 'regress-docs-0.my.example.test,regress-docs-0.my.example.test,localhost,backend' + DJANGO_ALLOWED_HOSTS: regress-docs-0.my.example.test,regress-docs-0.my.example.test,localhost,backend DJANGO_CONFIGURATION: Production - DJANGO_CSRF_TRUSTED_ORIGINS: 'https://regress-docs-0.my.example.test' - DJANGO_EMAIL_FROM: 'noreply@example.test' - DJANGO_EMAIL_HOST: 'smtp.example.test' - DJANGO_EMAIL_HOST_PASSWORD: 'pw' - DJANGO_EMAIL_HOST_USER: 'mailer@example.test' + DJANGO_CSRF_TRUSTED_ORIGINS: https://regress-docs-0.my.example.test + DJANGO_EMAIL_FROM: noreply@example.test + DJANGO_EMAIL_HOST: smtp.example.test + DJANGO_EMAIL_HOST_PASSWORD: pw + DJANGO_EMAIL_HOST_USER: mailer@example.test DJANGO_EMAIL_PORT: '587' DJANGO_EMAIL_USE_SSL: 'false' DJANGO_EMAIL_USE_TLS: 'true' DJANGO_SECRET_KEY: '' DJANGO_SETTINGS_MODULE: impress.settings - LOGIN_REDIRECT_URL: 'https://regress-docs-0.my.example.test' - LOGIN_REDIRECT_URL_FAILURE: 'https://regress-docs-0.my.example.test' - LOGOUT_REDIRECT_URL: 'https://regress-docs-0.my.example.test' - MEDIA_BASE_URL: 'https://regress-docs-0.my.example.test' + LOGIN_REDIRECT_URL: https://regress-docs-0.my.example.test + LOGIN_REDIRECT_URL_FAILURE: https://regress-docs-0.my.example.test + LOGOUT_REDIRECT_URL: https://regress-docs-0.my.example.test + MEDIA_BASE_URL: https://regress-docs-0.my.example.test OIDC_AUTH_REQUEST_EXTRA_PARAMS: '{"login_hint": "demo"}' - OIDC_OP_AUTHORIZATION_ENDPOINT: 'https://regress-docs-0.my.example.test/identity/realms/docs/protocol/openid-connect/auth' + OIDC_OP_AUTHORIZATION_ENDPOINT: https://regress-docs-0.my.example.test/identity/realms/docs/protocol/openid-connect/auth OIDC_OP_JWKS_ENDPOINT: http://keycloak:8080/identity/realms/docs/protocol/openid-connect/certs - OIDC_OP_LOGOUT_ENDPOINT: 'https://regress-docs-0.my.example.test/identity/realms/docs/protocol/openid-connect/logout' + OIDC_OP_LOGOUT_ENDPOINT: https://regress-docs-0.my.example.test/identity/realms/docs/protocol/openid-connect/logout OIDC_OP_TOKEN_ENDPOINT: http://keycloak:8080/identity/realms/docs/protocol/openid-connect/token OIDC_OP_USER_ENDPOINT: http://keycloak:8080/identity/realms/docs/protocol/openid-connect/userinfo OIDC_REDIRECT_ALLOWED_HOSTS: '["https://regress-docs-0.my.example.test"]' @@ -172,7 +172,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8083' + - 20000:8083 restart: unless-stopped volumes: - regress-docs_nginx_volume:/etc/nginx/ @@ -183,7 +183,7 @@ services: environment: KC_BOOTSTRAP_ADMIN_PASSWORD: '' KC_BOOTSTRAP_ADMIN_USERNAME: admin - KC_HOSTNAME: 'https://regress-docs-0.my.example.test/identity' + KC_HOSTNAME: https://regress-docs-0.my.example.test/identity KC_HOSTNAME_STRICT: 'false' KC_HTTP_ENABLED: 'true' KC_HTTP_RELATIVE_PATH: /identity @@ -262,7 +262,7 @@ services: COLLABORATION_API_URL: http://y-provider:4444/collaboration/api/ COLLABORATION_BACKEND_BASE_URL: http://backend:8000 COLLABORATION_LOGGING: 'true' - COLLABORATION_SERVER_ORIGIN: 'https://regress-docs-0.my.example.test' + COLLABORATION_SERVER_ORIGIN: https://regress-docs-0.my.example.test COLLABORATION_SERVER_SECRET: '' Y_PROVIDER_API_BASE_URL: http://y-provider:4444/api/ Y_PROVIDER_API_KEY: '' @@ -288,4 +288,4 @@ volumes: regress-docs_nginx_volume: name: regress-docs_nginx_volume regress-docs_postgres_data: - name: regress-docs_postgres_data \ No newline at end of file + name: regress-docs_postgres_data diff --git a/tests/snapshots/catalog_render/excalidraw__1.0.snap b/tests/snapshots/catalog_render/excalidraw__1.0.snap index 899f32d3..8373b18d 100644 --- a/tests/snapshots/catalog_render/excalidraw__1.0.snap +++ b/tests/snapshots/catalog_render/excalidraw__1.0.snap @@ -23,11 +23,11 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-excalidraw_nginx_volume:/etc/nginx/ version: '3' volumes: regress-excalidraw_nginx_volume: - name: regress-excalidraw_nginx_volume \ No newline at end of file + name: regress-excalidraw_nginx_volume diff --git a/tests/snapshots/catalog_render/forgejo__1.0.snap b/tests/snapshots/catalog_render/forgejo__1.0.snap index 4ad475cd..e3a796d3 100644 --- a/tests/snapshots/catalog_render/forgejo__1.0.snap +++ b/tests/snapshots/catalog_render/forgejo__1.0.snap @@ -5,16 +5,16 @@ services: environment: FORGEJO__database__DB_TYPE: sqlite3 FORGEJO__mailer__ENABLED: 'true' - FORGEJO__mailer__FROM: 'noreply@example.test' - FORGEJO__mailer__PASSWD: 'pw' - FORGEJO__mailer__PROTOCOL: 'smtp+starttls' - FORGEJO__mailer__SMTP_ADDR: 'smtp.example.test' + FORGEJO__mailer__FROM: noreply@example.test + FORGEJO__mailer__PASSWD: pw + FORGEJO__mailer__PROTOCOL: smtp+starttls + FORGEJO__mailer__SMTP_ADDR: smtp.example.test FORGEJO__mailer__SMTP_PORT: '587' - FORGEJO__mailer__USER: 'mailer@example.test' + FORGEJO__mailer__USER: mailer@example.test FORGEJO__security__INSTALL_LOCK: 'true' FORGEJO__server__DISABLE_SSH: 'true' - FORGEJO__server__DOMAIN: 'regress-forgejo-0.my.example.test' - FORGEJO__server__ROOT_URL: 'https://regress-forgejo-0.my.example.test' + FORGEJO__server__DOMAIN: regress-forgejo-0.my.example.test + FORGEJO__server__ROOT_URL: https://regress-forgejo-0.my.example.test USER_GID: '1000' USER_UID: '1000' image: codeberg.org/forgejo/forgejo:15 @@ -39,7 +39,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-forgejo_nginx_volume:/etc/nginx/ @@ -48,4 +48,4 @@ volumes: regress-forgejo_forgejo_data: name: regress-forgejo_forgejo_data regress-forgejo_nginx_volume: - name: regress-forgejo_nginx_volume \ No newline at end of file + name: regress-forgejo_nginx_volume diff --git a/tests/snapshots/catalog_render/freshrss__1.0.snap b/tests/snapshots/catalog_render/freshrss__1.0.snap index e382a693..3a5642d0 100644 --- a/tests/snapshots/catalog_render/freshrss__1.0.snap +++ b/tests/snapshots/catalog_render/freshrss__1.0.snap @@ -28,7 +28,7 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-freshrss_nginx_volume:/etc/nginx/ @@ -39,4 +39,4 @@ volumes: regress-freshrss_freshrss_extensions: name: regress-freshrss_freshrss_extensions regress-freshrss_nginx_volume: - name: regress-freshrss_nginx_volume \ No newline at end of file + name: regress-freshrss_nginx_volume diff --git a/tests/snapshots/catalog_render/ghost__1.0.snap b/tests/snapshots/catalog_render/ghost__1.0.snap index 2c968892..03df185d 100644 --- a/tests/snapshots/catalog_render/ghost__1.0.snap +++ b/tests/snapshots/catalog_render/ghost__1.0.snap @@ -41,13 +41,13 @@ services: database__connection__host: db database__connection__password: '' database__connection__user: root - mail__from: 'noreply@example.test' - mail__options__auth__pass: 'pw' - mail__options__auth__user: 'mailer@example.test' - mail__options__host: 'smtp.example.test' + mail__from: noreply@example.test + mail__options__auth__pass: pw + mail__options__auth__user: mailer@example.test + mail__options__host: smtp.example.test mail__options__port: '587' mail__transport: SMTP - url: 'https://regress-ghost-0.my.example.test' + url: https://regress-ghost-0.my.example.test image: ghost:5 logging: driver: json-file @@ -70,7 +70,7 @@ services: networks: - greffon_internal_network ports: - - '20000:2368' + - 20000:2368 restart: unless-stopped volumes: - regress-ghost_nginx_volume:/etc/nginx/ @@ -81,4 +81,4 @@ volumes: regress-ghost_ghost_content: name: regress-ghost_ghost_content regress-ghost_nginx_volume: - name: regress-ghost_nginx_volume \ No newline at end of file + name: regress-ghost_nginx_volume diff --git a/tests/snapshots/catalog_render/glitchtip__1.0.snap b/tests/snapshots/catalog_render/glitchtip__1.0.snap index dc0f00d4..3ae88047 100644 --- a/tests/snapshots/catalog_render/glitchtip__1.0.snap +++ b/tests/snapshots/catalog_render/glitchtip__1.0.snap @@ -10,15 +10,15 @@ services: redis: condition: service_started environment: - CSRF_TRUSTED_ORIGINS: 'https://regress-glitchtip-0.my.example.test' + CSRF_TRUSTED_ORIGINS: https://regress-glitchtip-0.my.example.test DATABASE_URL: postgres://postgres:postgres@glitchtip_db:5432/glitchtip DEFAULT_FROM_EMAIL: '' EMAIL_URL: smtp+tls://mailer%40example.test:pw@smtp.example.test:587 - GLITCHTIP_DOMAIN: 'https://regress-glitchtip-0.my.example.test' + GLITCHTIP_DOMAIN: https://regress-glitchtip-0.my.example.test GLITCHTIP_EVENT_HOT_DAYS: '30' GLITCHTIP_FILE_RETENTION_DAYS: '90' GLITCHTIP_RETENTION_DAYS: '90' - GLITCHTIP_URL: 'https://regress-glitchtip-0.my.example.test' + GLITCHTIP_URL: https://regress-glitchtip-0.my.example.test REDIS_URL: redis://redis:6379/0 SECRET_KEY: '' image: glitchtip/glitchtip:latest @@ -133,7 +133,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8000' + - 20000:8000 restart: unless-stopped volumes: - regress-glitchtip_nginx_volume:/etc/nginx/ @@ -153,4 +153,4 @@ volumes: regress-glitchtip_db_data: name: regress-glitchtip_db_data regress-glitchtip_nginx_volume: - name: regress-glitchtip_nginx_volume \ No newline at end of file + name: regress-glitchtip_nginx_volume diff --git a/tests/snapshots/catalog_render/grafana__1.0.snap b/tests/snapshots/catalog_render/grafana__1.0.snap index 3c933bbb..354801d5 100644 --- a/tests/snapshots/catalog_render/grafana__1.0.snap +++ b/tests/snapshots/catalog_render/grafana__1.0.snap @@ -5,13 +5,13 @@ services: environment: GF_SECURITY_ADMIN_PASSWORD: '' GF_SECURITY_SECRET_KEY: '' - GF_SERVER_ROOT_URL: 'https://regress-grafana-0.my.example.test' + GF_SERVER_ROOT_URL: https://regress-grafana-0.my.example.test GF_SMTP_ENABLED: 'true' - GF_SMTP_FROM_ADDRESS: 'noreply@example.test' - GF_SMTP_HOST: 'smtp.example.test:587' - GF_SMTP_PASSWORD: 'pw' - GF_SMTP_STARTTLS_POLICY: 'MandatoryStartTLS' - GF_SMTP_USER: 'mailer@example.test' + GF_SMTP_FROM_ADDRESS: noreply@example.test + GF_SMTP_HOST: smtp.example.test:587 + GF_SMTP_PASSWORD: pw + GF_SMTP_STARTTLS_POLICY: MandatoryStartTLS + GF_SMTP_USER: mailer@example.test image: grafana/grafana:12.2.1 logging: driver: json-file @@ -35,7 +35,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-grafana_nginx_volume:/etc/nginx/ @@ -44,4 +44,4 @@ volumes: regress-grafana_grafana_data: name: regress-grafana_grafana_data regress-grafana_nginx_volume: - name: regress-grafana_nginx_volume \ No newline at end of file + name: regress-grafana_nginx_volume diff --git a/tests/snapshots/catalog_render/immich__1.0.snap b/tests/snapshots/catalog_render/immich__1.0.snap index dfe71ee2..11d06736 100644 --- a/tests/snapshots/catalog_render/immich__1.0.snap +++ b/tests/snapshots/catalog_render/immich__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:2283' + - 20000:2283 restart: unless-stopped volumes: - regress-immich_nginx_volume:/etc/nginx/ @@ -22,7 +22,7 @@ services: environment: DB_DATABASE_NAME: immich DB_HOSTNAME: immich_database - DB_PASSWORD: 'regress-immich' + DB_PASSWORD: regress-immich DB_USERNAME: immich REDIS_HOSTNAME: immich_redis image: ghcr.io/immich-app/immich-server:v2.7.5 @@ -54,7 +54,7 @@ services: environment: POSTGRES_DB: immich POSTGRES_INITDB_ARGS: --data-checksums - POSTGRES_PASSWORD: 'regress-immich' + POSTGRES_PASSWORD: regress-immich POSTGRES_USER: immich image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0 logging: @@ -93,4 +93,4 @@ volumes: regress-immich_immich_upload: name: regress-immich_immich_upload regress-immich_nginx_volume: - name: regress-immich_nginx_volume \ No newline at end of file + name: regress-immich_nginx_volume diff --git a/tests/snapshots/catalog_render/keycloak__1.0.snap b/tests/snapshots/catalog_render/keycloak__1.0.snap index f1ffd52e..845da9e8 100644 --- a/tests/snapshots/catalog_render/keycloak__1.0.snap +++ b/tests/snapshots/catalog_render/keycloak__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8080' + - 20000:8080 restart: unless-stopped volumes: - regress-keycloak_nginx_volume:/etc/nginx/ @@ -28,7 +28,7 @@ services: KC_DB_URL_DATABASE: keycloak KC_DB_URL_HOST: postgresql KC_DB_USERNAME: keycloak - KC_HOSTNAME: 'https://regress-keycloak-0.my.example.test' + KC_HOSTNAME: https://regress-keycloak-0.my.example.test KC_HTTP_ENABLED: 'true' KC_PROXY_HEADERS: xforwarded image: quay.io/keycloak/keycloak:26.7.2 @@ -75,4 +75,4 @@ volumes: regress-keycloak_nginx_volume: name: regress-keycloak_nginx_volume regress-keycloak_postgres_data: - name: regress-keycloak_postgres_data \ No newline at end of file + name: regress-keycloak_postgres_data diff --git a/tests/snapshots/catalog_render/linkding__1.0.snap b/tests/snapshots/catalog_render/linkding__1.0.snap index 85d459a7..bd4b296c 100644 --- a/tests/snapshots/catalog_render/linkding__1.0.snap +++ b/tests/snapshots/catalog_render/linkding__1.0.snap @@ -11,13 +11,13 @@ services: networks: - greffon_internal_network ports: - - '20000:9090' + - 20000:9090 restart: unless-stopped volumes: - regress-linkding_nginx_volume:/etc/nginx/ linkding: environment: - LD_CSRF_TRUSTED_ORIGINS: 'https://regress-linkding-0.my.example.test' + LD_CSRF_TRUSTED_ORIGINS: https://regress-linkding-0.my.example.test LD_SUPERUSER_NAME: admin LD_SUPERUSER_PASSWORD: '' image: sissbruecker/linkding:latest @@ -37,4 +37,4 @@ volumes: regress-linkding_linkding_data: name: regress-linkding_linkding_data regress-linkding_nginx_volume: - name: regress-linkding_nginx_volume \ No newline at end of file + name: regress-linkding_nginx_volume diff --git a/tests/snapshots/catalog_render/mealie__1.0.snap b/tests/snapshots/catalog_render/mealie__1.0.snap index 71ea9eb6..b1fba0f2 100644 --- a/tests/snapshots/catalog_render/mealie__1.0.snap +++ b/tests/snapshots/catalog_render/mealie__1.0.snap @@ -11,20 +11,20 @@ services: networks: - greffon_internal_network ports: - - '20000:9000' + - 20000:9000 restart: unless-stopped volumes: - regress-mealie_nginx_volume:/etc/nginx/ mealie: environment: ALLOW_SIGNUP: 'false' - BASE_URL: 'https://regress-mealie-0.my.example.test' - SMTP_AUTH_STRATEGY: 'TLS' - SMTP_FROM_EMAIL: 'noreply@example.test' - SMTP_HOST: 'smtp.example.test' - SMTP_PASSWORD: 'pw' + BASE_URL: https://regress-mealie-0.my.example.test + SMTP_AUTH_STRATEGY: TLS + SMTP_FROM_EMAIL: noreply@example.test + SMTP_HOST: smtp.example.test + SMTP_PASSWORD: pw SMTP_PORT: '587' - SMTP_USER: 'mailer@example.test' + SMTP_USER: mailer@example.test image: ghcr.io/mealie-recipes/mealie:v3.19.2 logging: driver: json-file @@ -42,4 +42,4 @@ volumes: regress-mealie_mealie_data: name: regress-mealie_mealie_data regress-mealie_nginx_volume: - name: regress-mealie_nginx_volume \ No newline at end of file + name: regress-mealie_nginx_volume diff --git a/tests/snapshots/catalog_render/memos__1.0.snap b/tests/snapshots/catalog_render/memos__1.0.snap index a8b9c568..8af1688c 100644 --- a/tests/snapshots/catalog_render/memos__1.0.snap +++ b/tests/snapshots/catalog_render/memos__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:5230' + - 20000:5230 restart: unless-stopped volumes: - regress-memos_nginx_volume:/etc/nginx/ @@ -33,4 +33,4 @@ volumes: regress-memos_memos_data: name: regress-memos_memos_data regress-memos_nginx_volume: - name: regress-memos_nginx_volume \ No newline at end of file + name: regress-memos_nginx_volume diff --git a/tests/snapshots/catalog_render/metabase__1.0.snap b/tests/snapshots/catalog_render/metabase__1.0.snap index bed456b1..2b4f1b9f 100644 --- a/tests/snapshots/catalog_render/metabase__1.0.snap +++ b/tests/snapshots/catalog_render/metabase__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-metabase_nginx_volume:/etc/nginx/ @@ -21,18 +21,18 @@ services: environment: MB_DB_DBNAME: metabase MB_DB_HOST: metabase_db - MB_DB_PASS: 'regress-metabase' + MB_DB_PASS: regress-metabase MB_DB_PORT: '5432' MB_DB_TYPE: postgres MB_DB_USER: metabase - MB_EMAIL_FROM_ADDRESS: 'noreply@example.test' - MB_EMAIL_SMTP_HOST: 'smtp.example.test' - MB_EMAIL_SMTP_PASSWORD: 'pw' + MB_EMAIL_FROM_ADDRESS: noreply@example.test + MB_EMAIL_SMTP_HOST: smtp.example.test + MB_EMAIL_SMTP_PASSWORD: pw MB_EMAIL_SMTP_PORT: '587' - MB_EMAIL_SMTP_SECURITY: 'starttls' - MB_EMAIL_SMTP_USERNAME: 'mailer@example.test' + MB_EMAIL_SMTP_SECURITY: starttls + MB_EMAIL_SMTP_USERNAME: mailer@example.test MB_ENCRYPTION_SECRET_KEY: '' - MB_SITE_URL: 'https://regress-metabase-0.my.example.test' + MB_SITE_URL: https://regress-metabase-0.my.example.test image: metabase/metabase:v0.61.2 logging: driver: json-file @@ -47,7 +47,7 @@ services: metabase_db: environment: POSTGRES_DB: metabase - POSTGRES_PASSWORD: 'regress-metabase' + POSTGRES_PASSWORD: regress-metabase POSTGRES_USER: metabase healthcheck: interval: 10s @@ -77,4 +77,4 @@ volumes: regress-metabase_metabase_db_data: name: regress-metabase_metabase_db_data regress-metabase_nginx_volume: - name: regress-metabase_nginx_volume \ No newline at end of file + name: regress-metabase_nginx_volume diff --git a/tests/snapshots/catalog_render/multica__1.0.snap b/tests/snapshots/catalog_render/multica__1.0.snap index 1578230e..54b69856 100644 --- a/tests/snapshots/catalog_render/multica__1.0.snap +++ b/tests/snapshots/catalog_render/multica__1.0.snap @@ -5,19 +5,19 @@ services: depends_on: - multica_db environment: - CORS_ALLOWED_ORIGINS: 'https://regress-multica-0.my.example.test' + CORS_ALLOWED_ORIGINS: https://regress-multica-0.my.example.test DATABASE_URL: postgres://multica:regress-multica@multica_db:5432/multica?sslmode=disable - FRONTEND_ORIGIN: 'https://regress-multica-0.my.example.test' + FRONTEND_ORIGIN: https://regress-multica-0.my.example.test JWT_SECRET: '' - MULTICA_APP_URL: 'https://regress-multica-0.my.example.test' - MULTICA_PUBLIC_URL: 'https://regress-multica-0.my.example.test' + MULTICA_APP_URL: https://regress-multica-0.my.example.test + MULTICA_PUBLIC_URL: https://regress-multica-0.my.example.test PORT: '8080' - RESEND_FROM_EMAIL: 'noreply@example.test' - SMTP_HOST: 'smtp.example.test' - SMTP_PASSWORD: 'pw' + RESEND_FROM_EMAIL: noreply@example.test + SMTP_HOST: smtp.example.test + SMTP_PASSWORD: pw SMTP_PORT: '587' - SMTP_TLS: 'starttls' - SMTP_USERNAME: 'mailer@example.test' + SMTP_TLS: starttls + SMTP_USERNAME: mailer@example.test image: ghcr.io/multica-ai/multica-backend:v0.3.13 logging: driver: json-file @@ -40,7 +40,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-multica_nginx_volume:/etc/nginx/ @@ -63,7 +63,7 @@ services: multica_db: environment: POSTGRES_DB: multica - POSTGRES_PASSWORD: 'regress-multica' + POSTGRES_PASSWORD: regress-multica POSTGRES_USER: multica image: pgvector/pgvector:pg17 logging: @@ -84,4 +84,4 @@ volumes: regress-multica_multica_uploads: name: regress-multica_multica_uploads regress-multica_nginx_volume: - name: regress-multica_nginx_volume \ No newline at end of file + name: regress-multica_nginx_volume diff --git a/tests/snapshots/catalog_render/n8n__1.0.snap b/tests/snapshots/catalog_render/n8n__1.0.snap index c8fad4ae..c6ce7f1d 100644 --- a/tests/snapshots/catalog_render/n8n__1.0.snap +++ b/tests/snapshots/catalog_render/n8n__1.0.snap @@ -11,27 +11,27 @@ services: networks: - greffon_internal_network ports: - - '20000:5678' + - 20000:5678 restart: unless-stopped volumes: - regress-n8n_nginx_volume:/etc/nginx/ n8n: environment: - N8N_EDITOR_BASE_URL: 'https://regress-n8n-0.my.example.test' - N8N_EMAIL_MODE: 'smtp' + N8N_EDITOR_BASE_URL: https://regress-n8n-0.my.example.test + N8N_EMAIL_MODE: smtp N8N_ENCRYPTION_KEY: '' - N8N_HOST: 'regress-n8n-0.my.example.test' + N8N_HOST: regress-n8n-0.my.example.test N8N_PORT: '5678' N8N_PROTOCOL: https N8N_PROXY_HOPS: '1' - N8N_SMTP_HOST: 'smtp.example.test' - N8N_SMTP_PASS: 'pw' + N8N_SMTP_HOST: smtp.example.test + N8N_SMTP_PASS: pw N8N_SMTP_PORT: '587' - N8N_SMTP_SENDER: 'noreply@example.test' + N8N_SMTP_SENDER: noreply@example.test N8N_SMTP_SSL: 'false' N8N_SMTP_STARTTLS: 'true' - N8N_SMTP_USER: 'mailer@example.test' - WEBHOOK_URL: 'https://regress-n8n-0.my.example.test' + N8N_SMTP_USER: mailer@example.test + WEBHOOK_URL: https://regress-n8n-0.my.example.test image: docker.n8n.io/n8nio/n8n:2.22.5 logging: driver: json-file @@ -49,4 +49,4 @@ volumes: regress-n8n_n8n_data: name: regress-n8n_n8n_data regress-n8n_nginx_volume: - name: regress-n8n_nginx_volume \ No newline at end of file + name: regress-n8n_nginx_volume diff --git a/tests/snapshots/catalog_render/nextcloud__1.0.snap b/tests/snapshots/catalog_render/nextcloud__1.0.snap index d0916d0b..260e06ee 100644 --- a/tests/snapshots/catalog_render/nextcloud__1.0.snap +++ b/tests/snapshots/catalog_render/nextcloud__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-nextcloud_nginx_volume:/etc/nginx/ @@ -19,22 +19,23 @@ services: depends_on: - nextcloud_db environment: - MAIL_DOMAIN: 'example.test' - MAIL_FROM_ADDRESS: 'noreply' + MAIL_DOMAIN: example.test + MAIL_FROM_ADDRESS: noreply NEXTCLOUD_ADMIN_PASSWORD: '' NEXTCLOUD_ADMIN_USER: admin - NEXTCLOUD_TRUSTED_DOMAINS: 'regress-nextcloud-0.my.example.test regress-nextcloud-0.my.example.test localhost' - OVERWRITECLIURL: 'https://regress-nextcloud-0.my.example.test' + NEXTCLOUD_TRUSTED_DOMAINS: regress-nextcloud-0.my.example.test regress-nextcloud-0.my.example.test + localhost + OVERWRITECLIURL: https://regress-nextcloud-0.my.example.test OVERWRITEPROTOCOL: https POSTGRES_DB: nextcloud POSTGRES_HOST: nextcloud_db POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres - SMTP_HOST: 'smtp.example.test' - SMTP_NAME: 'mailer@example.test' - SMTP_PASSWORD: 'pw' + SMTP_HOST: smtp.example.test + SMTP_NAME: mailer@example.test + SMTP_PASSWORD: pw SMTP_PORT: '587' - SMTP_SECURE: 'tls' + SMTP_SECURE: tls image: nextcloud:latest logging: driver: json-file @@ -68,4 +69,4 @@ volumes: regress-nextcloud_nextcloud_data: name: regress-nextcloud_nextcloud_data regress-nextcloud_nginx_volume: - name: regress-nextcloud_nginx_volume \ No newline at end of file + name: regress-nextcloud_nginx_volume diff --git a/tests/snapshots/catalog_render/paperless-ngx__1.0.snap b/tests/snapshots/catalog_render/paperless-ngx__1.0.snap index 592f7925..017d7f0e 100644 --- a/tests/snapshots/catalog_render/paperless-ngx__1.0.snap +++ b/tests/snapshots/catalog_render/paperless-ngx__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8000' + - 20000:8000 restart: unless-stopped volumes: - regress-paperless-ngx_nginx_volume:/etc/nginx/ @@ -22,17 +22,17 @@ services: PAPERLESS_ADMIN_PASSWORD: '' PAPERLESS_ADMIN_USER: admin PAPERLESS_DBENGINE: sqlite - PAPERLESS_EMAIL_FROM: 'noreply@example.test' - PAPERLESS_EMAIL_HOST: 'smtp.example.test' - PAPERLESS_EMAIL_HOST_PASSWORD: 'pw' - PAPERLESS_EMAIL_HOST_USER: 'mailer@example.test' + PAPERLESS_EMAIL_FROM: noreply@example.test + PAPERLESS_EMAIL_HOST: smtp.example.test + PAPERLESS_EMAIL_HOST_PASSWORD: pw + PAPERLESS_EMAIL_HOST_USER: mailer@example.test PAPERLESS_EMAIL_PORT: '587' PAPERLESS_EMAIL_USE_SSL: 'false' PAPERLESS_EMAIL_USE_TLS: 'true' PAPERLESS_OCR_LANGUAGE: eng PAPERLESS_REDIS: redis://paperless_broker:6379 PAPERLESS_SECRET_KEY: '' - PAPERLESS_URL: 'https://regress-paperless-ngx-0.my.example.test' + PAPERLESS_URL: https://regress-paperless-ngx-0.my.example.test image: ghcr.io/paperless-ngx/paperless-ngx:2.20.15 logging: driver: json-file @@ -71,4 +71,4 @@ volumes: regress-paperless-ngx_paperless_media: name: regress-paperless-ngx_paperless_media regress-paperless-ngx_paperless_redis: - name: regress-paperless-ngx_paperless_redis \ No newline at end of file + name: regress-paperless-ngx_paperless_redis diff --git a/tests/snapshots/catalog_render/plausible__1.0.snap b/tests/snapshots/catalog_render/plausible__1.0.snap index 71f390da..ba924bc3 100644 --- a/tests/snapshots/catalog_render/plausible__1.0.snap +++ b/tests/snapshots/catalog_render/plausible__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8000' + - 20000:8000 restart: unless-stopped volumes: - regress-plausible_nginx_volume:/etc/nginx/ @@ -24,17 +24,17 @@ services: - plausible_db - plausible_events_db environment: - BASE_URL: 'https://regress-plausible-0.my.example.test' + BASE_URL: https://regress-plausible-0.my.example.test CLICKHOUSE_DATABASE_URL: http://plausible_events_db:8123/plausible_events_db DATABASE_URL: postgres://postgres:postgres@plausible_db:5432/plausible DISABLE_REGISTRATION: 'false' - MAILER_EMAIL: 'noreply@example.test' + MAILER_EMAIL: noreply@example.test SECRET_KEY_BASE: '' - SMTP_HOST_ADDR: 'smtp.example.test' + SMTP_HOST_ADDR: smtp.example.test SMTP_HOST_PORT: '587' SMTP_HOST_SSL_ENABLED: 'false' - SMTP_USER_NAME: 'mailer@example.test' - SMTP_USER_PWD: 'pw' + SMTP_USER_NAME: mailer@example.test + SMTP_USER_PWD: pw image: plausible/analytics:latest logging: driver: json-file @@ -85,4 +85,4 @@ volumes: regress-plausible_event_data: name: regress-plausible_event_data regress-plausible_nginx_volume: - name: regress-plausible_nginx_volume \ No newline at end of file + name: regress-plausible_nginx_volume diff --git a/tests/snapshots/catalog_render/remotion__1.0.snap b/tests/snapshots/catalog_render/remotion__1.0.snap index ce337e02..5acaaf0d 100644 --- a/tests/snapshots/catalog_render/remotion__1.0.snap +++ b/tests/snapshots/catalog_render/remotion__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-remotion_nginx_volume:/etc/nginx/ @@ -34,4 +34,4 @@ volumes: regress-remotion_nginx_volume: name: regress-remotion_nginx_volume regress-remotion_project_data: - name: regress-remotion_project_data \ No newline at end of file + name: regress-remotion_project_data diff --git a/tests/snapshots/catalog_render/stirling-pdf__1.0.snap b/tests/snapshots/catalog_render/stirling-pdf__1.0.snap index b1b02042..9314cc4e 100644 --- a/tests/snapshots/catalog_render/stirling-pdf__1.0.snap +++ b/tests/snapshots/catalog_render/stirling-pdf__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8080' + - 20000:8080 restart: unless-stopped volumes: - regress-stirling-pdf_nginx_volume:/etc/nginx/ @@ -44,4 +44,4 @@ volumes: regress-stirling-pdf_stirling_logs: name: regress-stirling-pdf_stirling_logs regress-stirling-pdf_stirling_pipeline: - name: regress-stirling-pdf_stirling_pipeline \ No newline at end of file + name: regress-stirling-pdf_stirling_pipeline diff --git a/tests/snapshots/catalog_render/umami__1.0.snap b/tests/snapshots/catalog_render/umami__1.0.snap index 7784d34c..54bc4a8f 100644 --- a/tests/snapshots/catalog_render/umami__1.0.snap +++ b/tests/snapshots/catalog_render/umami__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-umami_nginx_volume:/etc/nginx/ @@ -36,7 +36,7 @@ services: umami_db: environment: POSTGRES_DB: umami - POSTGRES_PASSWORD: 'regress-umami' + POSTGRES_PASSWORD: regress-umami POSTGRES_USER: umami healthcheck: interval: 10s @@ -66,4 +66,4 @@ volumes: regress-umami_nginx_volume: name: regress-umami_nginx_volume regress-umami_umami_db_data: - name: regress-umami_umami_db_data \ No newline at end of file + name: regress-umami_umami_db_data diff --git a/tests/snapshots/catalog_render/uptime-kuma__1.0.snap b/tests/snapshots/catalog_render/uptime-kuma__1.0.snap index e020ea54..8a8550a7 100644 --- a/tests/snapshots/catalog_render/uptime-kuma__1.0.snap +++ b/tests/snapshots/catalog_render/uptime-kuma__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3001' + - 20000:3001 restart: unless-stopped volumes: - regress-uptime-kuma_nginx_volume:/etc/nginx/ @@ -33,4 +33,4 @@ volumes: regress-uptime-kuma_nginx_volume: name: regress-uptime-kuma_nginx_volume regress-uptime-kuma_uptime_kuma_data: - name: regress-uptime-kuma_uptime_kuma_data \ No newline at end of file + name: regress-uptime-kuma_uptime_kuma_data diff --git a/tests/snapshots/catalog_render/vaultwarden__1.0.snap b/tests/snapshots/catalog_render/vaultwarden__1.0.snap index 8b8030d7..145fa212 100644 --- a/tests/snapshots/catalog_render/vaultwarden__1.0.snap +++ b/tests/snapshots/catalog_render/vaultwarden__1.0.snap @@ -11,21 +11,21 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-vaultwarden_nginx_volume:/etc/nginx/ vaultwarden: environment: ADMIN_TOKEN: '' - DOMAIN: 'https://regress-vaultwarden-0.my.example.test' + DOMAIN: https://regress-vaultwarden-0.my.example.test SIGNUPS_ALLOWED: 'true' - SMTP_FROM: 'noreply@example.test' - SMTP_HOST: 'smtp.example.test' - SMTP_PASSWORD: 'pw' + SMTP_FROM: noreply@example.test + SMTP_HOST: smtp.example.test + SMTP_PASSWORD: pw SMTP_PORT: '587' - SMTP_SECURITY: 'starttls' - SMTP_USERNAME: 'mailer@example.test' + SMTP_SECURITY: starttls + SMTP_USERNAME: mailer@example.test image: vaultwarden/server:latest logging: driver: json-file @@ -43,4 +43,4 @@ volumes: regress-vaultwarden_nginx_volume: name: regress-vaultwarden_nginx_volume regress-vaultwarden_vw_data: - name: regress-vaultwarden_vw_data \ No newline at end of file + name: regress-vaultwarden_vw_data diff --git a/tests/snapshots/catalog_render/vikunja__1.0.snap b/tests/snapshots/catalog_render/vikunja__1.0.snap index c3b428f8..8f0cc159 100644 --- a/tests/snapshots/catalog_render/vikunja__1.0.snap +++ b/tests/snapshots/catalog_render/vikunja__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3456' + - 20000:3456 restart: unless-stopped volumes: - regress-vikunja_nginx_volume:/etc/nginx/ @@ -21,12 +21,12 @@ services: VIKUNJA_DATABASE_TYPE: sqlite VIKUNJA_MAILER_ENABLED: 'true' VIKUNJA_MAILER_FORCESSL: 'false' - VIKUNJA_MAILER_FROMEMAIL: 'noreply@example.test' - VIKUNJA_MAILER_HOST: 'smtp.example.test' - VIKUNJA_MAILER_PASSWORD: 'pw' + VIKUNJA_MAILER_FROMEMAIL: noreply@example.test + VIKUNJA_MAILER_HOST: smtp.example.test + VIKUNJA_MAILER_PASSWORD: pw VIKUNJA_MAILER_PORT: '587' - VIKUNJA_MAILER_USERNAME: 'mailer@example.test' - VIKUNJA_SERVICE_PUBLICURL: 'https://regress-vikunja-0.my.example.test' + VIKUNJA_MAILER_USERNAME: mailer@example.test + VIKUNJA_SERVICE_PUBLICURL: https://regress-vikunja-0.my.example.test VIKUNJA_SERVICE_SECRET: '' image: vikunja/vikunja:latest logging: @@ -49,4 +49,4 @@ volumes: regress-vikunja_vikunja_db: name: regress-vikunja_vikunja_db regress-vikunja_vikunja_files: - name: regress-vikunja_vikunja_files \ No newline at end of file + name: regress-vikunja_vikunja_files diff --git a/tests/snapshots/catalog_render/visio__1.0.snap b/tests/snapshots/catalog_render/visio__1.0.snap index ab378822..12c9af98 100644 --- a/tests/snapshots/catalog_render/visio__1.0.snap +++ b/tests/snapshots/catalog_render/visio__1.0.snap @@ -22,13 +22,13 @@ services: DB_PASSWORD: '' DB_PORT: '5432' DB_USER: meet - DJANGO_ALLOWED_HOSTS: 'regress-visio-0.my.example.test,regress-visio-0.my.example.test,localhost,backend,gateway' + DJANGO_ALLOWED_HOSTS: regress-visio-0.my.example.test,regress-visio-0.my.example.test,localhost,backend,gateway DJANGO_CONFIGURATION: Production - DJANGO_CSRF_TRUSTED_ORIGINS: 'https://regress-visio-0.my.example.test' - DJANGO_EMAIL_FROM: 'noreply@example.test' - DJANGO_EMAIL_HOST: 'smtp.example.test' - DJANGO_EMAIL_HOST_PASSWORD: 'pw' - DJANGO_EMAIL_HOST_USER: 'mailer@example.test' + DJANGO_CSRF_TRUSTED_ORIGINS: https://regress-visio-0.my.example.test + DJANGO_EMAIL_FROM: noreply@example.test + DJANGO_EMAIL_HOST: smtp.example.test + DJANGO_EMAIL_HOST_PASSWORD: pw + DJANGO_EMAIL_HOST_USER: mailer@example.test DJANGO_EMAIL_PORT: '587' DJANGO_EMAIL_USE_SSL: 'false' DJANGO_EMAIL_USE_TLS: 'true' @@ -38,14 +38,14 @@ services: LIVEKIT_API_SECRET: '' LIVEKIT_API_URL: wss://regress-visio-0.my.example.test/livekit LIVEKIT_VERIFY_SSL: 'false' - LOGIN_REDIRECT_URL: 'https://regress-visio-0.my.example.test' - LOGIN_REDIRECT_URL_FAILURE: 'https://regress-visio-0.my.example.test' - LOGOUT_REDIRECT_URL: 'https://regress-visio-0.my.example.test' - MEDIA_BASE_URL: 'https://regress-visio-0.my.example.test' - MEET_BASE_URL: 'https://regress-visio-0.my.example.test' - OIDC_OP_AUTHORIZATION_ENDPOINT: 'https://regress-visio-0.my.example.test/identity/realms/meet/protocol/openid-connect/auth' + LOGIN_REDIRECT_URL: https://regress-visio-0.my.example.test + LOGIN_REDIRECT_URL_FAILURE: https://regress-visio-0.my.example.test + LOGOUT_REDIRECT_URL: https://regress-visio-0.my.example.test + MEDIA_BASE_URL: https://regress-visio-0.my.example.test + MEET_BASE_URL: https://regress-visio-0.my.example.test + OIDC_OP_AUTHORIZATION_ENDPOINT: https://regress-visio-0.my.example.test/identity/realms/meet/protocol/openid-connect/auth OIDC_OP_JWKS_ENDPOINT: http://keycloak:8080/identity/realms/meet/protocol/openid-connect/certs - OIDC_OP_LOGOUT_ENDPOINT: 'https://regress-visio-0.my.example.test/identity/realms/meet/protocol/openid-connect/logout' + OIDC_OP_LOGOUT_ENDPOINT: https://regress-visio-0.my.example.test/identity/realms/meet/protocol/openid-connect/logout OIDC_OP_TOKEN_ENDPOINT: http://keycloak:8080/identity/realms/meet/protocol/openid-connect/token OIDC_OP_USER_ENDPOINT: http://keycloak:8080/identity/realms/meet/protocol/openid-connect/userinfo OIDC_REDIRECT_ALLOWED_HOSTS: '["https://regress-visio-0.my.example.test"]' @@ -172,7 +172,7 @@ services: networks: - greffon_internal_network ports: - - '20000:8083' + - 20000:8083 restart: unless-stopped volumes: - regress-visio_nginx_volume:/etc/nginx/ @@ -183,7 +183,7 @@ services: environment: KC_BOOTSTRAP_ADMIN_PASSWORD: '' KC_BOOTSTRAP_ADMIN_USERNAME: admin - KC_HOSTNAME: 'https://regress-visio-0.my.example.test/identity' + KC_HOSTNAME: https://regress-visio-0.my.example.test/identity KC_HOSTNAME_STRICT: 'false' KC_HTTP_ENABLED: 'true' KC_HTTP_RELATIVE_PATH: /identity @@ -287,4 +287,4 @@ volumes: regress-visio_nginx_volume: name: regress-visio_nginx_volume regress-visio_postgres_data: - name: regress-visio_postgres_data \ No newline at end of file + name: regress-visio_postgres_data diff --git a/tests/snapshots/catalog_render/vscode__1.0.snap b/tests/snapshots/catalog_render/vscode__1.0.snap index 79c831b1..8f0b4358 100644 --- a/tests/snapshots/catalog_render/vscode__1.0.snap +++ b/tests/snapshots/catalog_render/vscode__1.0.snap @@ -23,7 +23,7 @@ services: networks: - greffon_internal_network ports: - - '20000:3000' + - 20000:3000 restart: unless-stopped volumes: - regress-vscode_nginx_volume:/etc/nginx/ @@ -32,4 +32,4 @@ volumes: regress-vscode_nginx_volume: name: regress-vscode_nginx_volume regress-vscode_project_data: - name: regress-vscode_project_data \ No newline at end of file + name: regress-vscode_project_data diff --git a/tests/snapshots/catalog_render/wireguard__1.0.snap b/tests/snapshots/catalog_render/wireguard__1.0.snap index 87e4a4ff..1c2b4c48 100644 --- a/tests/snapshots/catalog_render/wireguard__1.0.snap +++ b/tests/snapshots/catalog_render/wireguard__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:51821' + - 20000:51821 restart: unless-stopped volumes: - regress-wireguard_nginx_volume:/etc/nginx/ @@ -26,7 +26,7 @@ services: environment: DISABLE_IPV6: 'true' INIT_ENABLED: 'true' - INIT_HOST: 'host.docker.internal' + INIT_HOST: host.docker.internal INIT_PASSWORD: '' INIT_PORT: '20000' INIT_USERNAME: admin @@ -53,4 +53,4 @@ volumes: regress-wireguard_nginx_volume: name: regress-wireguard_nginx_volume regress-wireguard_wg_easy_config: - name: regress-wireguard_wg_easy_config \ No newline at end of file + name: regress-wireguard_wg_easy_config diff --git a/tests/snapshots/catalog_render/wordpress__1.0.snap b/tests/snapshots/catalog_render/wordpress__1.0.snap index 1712de12..c2dc19c0 100644 --- a/tests/snapshots/catalog_render/wordpress__1.0.snap +++ b/tests/snapshots/catalog_render/wordpress__1.0.snap @@ -11,7 +11,7 @@ services: networks: - greffon_internal_network ports: - - '20000:80' + - 20000:80 restart: unless-stopped volumes: - regress-wordpress_nginx_volume:/etc/nginx/ @@ -21,16 +21,17 @@ services: environment: WORDPRESS_AUTH_KEY: '' WORDPRESS_AUTH_SALT: '' - WORDPRESS_CONFIG_EXTRA: "define('WP_HOME', 'https://regress-wordpress-0.my.example.test');\ndefine('WP_SITEURL',\ - \ 'https://regress-wordpress-0.my.example.test');\n// The greffer's per-instance nginx terminates TLS\ - \ and forwards\n// X-Forwarded-Proto: https, but WordPress/PHP behind Apache\ - \ won't treat\n// the request as HTTPS unless told to. Without this, is_ssl()\ - \ is false,\n// mismatches the https WP_SITEURL, and the admin/login flow\ - \ 301-loops.\nif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO']\ - \ === 'https' ) {\n $_SERVER['HTTPS'] = 'on';\n}\n" + WORDPRESS_CONFIG_EXTRA: "define('WP_HOME', 'https://regress-wordpress-0.my.example.test');\n\ + define('WP_SITEURL', 'https://regress-wordpress-0.my.example.test');\n// The\ + \ greffer's per-instance nginx terminates TLS and forwards\n// X-Forwarded-Proto:\ + \ https, but WordPress/PHP behind Apache won't treat\n// the request as HTTPS\ + \ unless told to. Without this, is_ssl() is false,\n// mismatches the https\ + \ WP_SITEURL, and the admin/login flow 301-loops.\nif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO'])\ + \ && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {\n $_SERVER['HTTPS']\ + \ = 'on';\n}\n" WORDPRESS_DB_HOST: wordpress_db WORDPRESS_DB_NAME: wordpress - WORDPRESS_DB_PASSWORD: 'regress-wordpress' + WORDPRESS_DB_PASSWORD: regress-wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_LOGGED_IN_KEY: '' WORDPRESS_LOGGED_IN_SALT: '' @@ -53,8 +54,8 @@ services: wordpress_db: environment: MARIADB_DATABASE: wordpress - MARIADB_PASSWORD: 'regress-wordpress' - MARIADB_ROOT_PASSWORD: 'regress-wordpress' + MARIADB_PASSWORD: regress-wordpress + MARIADB_ROOT_PASSWORD: regress-wordpress MARIADB_USER: wordpress image: mariadb:11 logging: @@ -75,4 +76,4 @@ volumes: regress-wordpress_wordpress_data: name: regress-wordpress_wordpress_data regress-wordpress_wordpress_db_data: - name: regress-wordpress_wordpress_db_data \ No newline at end of file + name: regress-wordpress_wordpress_db_data diff --git a/tests/test_preflight.py b/tests/test_preflight.py new file mode 100644 index 00000000..bf8dfa82 --- /dev/null +++ b/tests/test_preflight.py @@ -0,0 +1,212 @@ +"""Tests for the deploy-time preflight (compose-containment Feature 6; +wire contract per custom-app LLD §4.1).""" +from __future__ import annotations + +import pytest +from unittest.mock import MagicMock, patch + +from apps.utils.greffon import preflight as pf +from apps.utils.greffon.preflight import PreflightError, run_preflight + +from app.auth import TOKEN_HEADER + +_COMPOSE = """\ +services: + app: + image: ghcr.io/me/app:1.2.3 + environment: + DB_PASSWORD: "{{ config.DB_PASSWORD }}" + MAIL_URL: "smtps://u:{{ config.MAIL_PW }}@smtp.gmail.com" + ports: + - "80:80" +""" + +_DIGIST_OK = {"ghcr.io/me/app@sha256:" + "a" * 64} + + +def _mock_images_ok(): + images = MagicMock() + info = MagicMock() + info.attrs = {"RepoDigests": sorted(_DIGIST_OK)} + images.get.return_value = info + return images + + +class TestPreflightPayload: + def test_ok(self): + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + result = run_preflight(_COMPOSE) + assert result["services"] == ["app"] + assert result["ports"] == [{"port_name": "app_80", "service": "app", + "container_port": "80", + "protocol": "tcp"}] + assert result["image_digests"]["app"].startswith( + "ghcr.io/me/app@sha256:") + # candidates: DB_PASSWORD and MAIL_PW referenced pre-ticked + by_key = {c["key"]: c for c in result["config_candidates"]} + assert by_key["DB_PASSWORD"]["referenced"] is True + assert by_key["MAIL_URL"]["referenced"] is False + # the smtp.gmail.com literal warns (the strip's false-positive class) + assert any(w["key"] == "MAIL_URL" and "smtp" in w["message"] + for w in result["warnings"]) + + def test_genuine_integration_reference_does_not_warn(self): + compose = """\ +services: + app: + image: x + environment: + MAIL_URL: "{{ smtp.host }}" +""" + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + result = run_preflight(compose) + assert result["warnings"] == [] + + def test_shape_error_surfaces_verbatim(self): + compose = "services:\n app:\n image: x\n privileged: true\n" + with pytest.raises(PreflightError) as e: + run_preflight(compose) + row = e.value.errors[0] + assert row["service"] == "app" + assert row["key"] == "privileged" + assert "not permitted" in row["message"] + + def test_invalid_yaml_is_a_named_error(self): + with pytest.raises(PreflightError) as e: + run_preflight("services: [unclosed") + assert e.value.errors[0]["key"] == "compose_yaml" + + def test_unresolvable_image_is_an_error_naming_it(self): + with patch.object(pf.compose_mod, "client") as client: + client.images.pull.side_effect = RuntimeError("registry down") + with pytest.raises(PreflightError) as e: + run_preflight(_COMPOSE) + row = e.value.errors[0] + assert row["service"] == "app" + assert row["key"] == "image" + assert "ghcr.io/me/app:1.2.3" in row["message"] + assert "digest" in row["message"] + + def test_bracket_form_config_reference_detected(self): + compose = """\ +services: + app: + image: x + environment: + DB_PASSWORD: "{{ config['DB_PASSWORD'] }}" +""" + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + result = run_preflight(compose) + by_key = {c["key"]: c for c in result["config_candidates"]} + assert by_key["DB_PASSWORD"]["referenced"] is True + + def test_alias_bomb_neutered_by_dedup(self): + # codex review: alias doubling expanded exponentially during the + # leaf walk (outside every render guard). The fix visits each + # SHARED container once, so the exponential alias chain resolves + # in linear visits — this must complete fast, not raise. + import time + + compose = "services:\n app:\n image: x\n labels:\n" + prev_ref = None + for i in range(20): # 2^20 nodes if expanded naively + if prev_ref is None: + compose += f" - &a{i} ['x']\n" + prev_ref = f"*a{i}" + else: + compose += f" - &a{i} [{prev_ref}, {prev_ref}]\n" + prev_ref = f"*a{i}" + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + t0 = time.monotonic() + result = run_preflight(compose) # completes + assert time.monotonic() - t0 < 5.0 + + def test_visit_budget_catches_huge_structures(self): + # A genuinely large NON-aliased structure (no dedup to save it) + # must trip the visit budget with a named refusal. + items = "\n".join(f" - item{i}" for i in range(20050)) + compose = f"services:\n app:\n image: x\n labels:\n{items}\n" + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + with pytest.raises(PreflightError) as e: + run_preflight(compose) + assert "too large" in e.value.errors[0]["message"] + + def test_imageless_service_refused(self): + compose = "services:\n app:\n command: echo hi\n" + with pytest.raises(PreflightError) as e: + run_preflight(compose) + assert e.value.errors[0]["key"] == "image" + assert "cannot deploy" in e.value.errors[0]["message"] + + def test_config_ref_mid_expression_detected(self): + compose = ("services:\n app:\n image: x\n" + " environment:\n" + " SECRET: \"{{ 'tok:' ~ config.SECRET }}\"\n") + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + result = run_preflight(compose) + by_key = {c["key"]: c for c in result["config_candidates"]} + assert by_key["SECRET"]["referenced"] is True + + def test_bracket_ref_no_spurious_quote_candidate(self): + compose = ("services:\n app:\n image: x\n" + " environment:\n" + ' DB_PASSWORD: "{{ config[\'DB_PASSWORD\'] }}"\n') + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + result = run_preflight(compose) + keys = {c["key"] for c in result["config_candidates"]} + assert "'" not in keys + assert "DB_PASSWORD" in keys + + def test_reader_error_is_a_named_422_not_500(self): + with pytest.raises(PreflightError) as e: + run_preflight("services:\n app:\n image: \"x\x00y\"\n") + assert e.value.errors[0]["key"] == "compose_yaml" + + def test_operator_grant_threaded_through(self): + compose = ("services:\n app:\n image: x\n" + " cap_add: [NET_ADMIN]\n") + with patch.object(pf.compose_mod, "client") as client: + client.images = _mock_images_ok() + with pytest.raises(PreflightError): + run_preflight(compose) # strict refuses cap_add ungranted + result = run_preflight(compose, extra_keys="cap_add") + assert result["services"] == ["app"] + + +class TestPreflightRoute: + @pytest.mark.asyncio + async def test_route_200(self, client, monkeypatch): + with patch.object(pf.compose_mod, "client") as client_docker: + client_docker.images = _mock_images_ok() + r = await client.post( + "/api/controller/preflight/", + json={"compose_yaml": _COMPOSE}, + headers={TOKEN_HEADER: "test-token"}) + assert r.status_code == 200 + body = r.json() + assert body["services"] == ["app"] + assert "image_digests" in body and "warnings" in body + + @pytest.mark.asyncio + async def test_route_422_rows(self, client): + r = await client.post( + "/api/controller/preflight/", + json={"compose_yaml": "services:\n app:\n image: x\n" + " devices: ['/dev/sda:/dev/sda']\n"}, + headers={TOKEN_HEADER: "test-token"}) + assert r.status_code == 422 + row = r.json()["errors"][0] + assert row["key"] == "devices" + + @pytest.mark.asyncio + async def test_route_requires_token(self, client): + r = await client.post("/api/controller/preflight/", + json={"compose_yaml": "services: {}"}) + assert r.status_code in (401, 403) diff --git a/tests/test_render_budget.py b/tests/test_render_budget.py index 142885fb..d9f838e1 100644 --- a/tests/test_render_budget.py +++ b/tests/test_render_budget.py @@ -184,6 +184,51 @@ def _render(): t.join(timeout=30) assert all(e == "budget" for e in errors), errors + def test_single_quoted_jinja_literal_survives(self, monkeypatch, tmp_path): + # Feature 6 round-trip guard: yaml.dump single-quote doubling (an + # embedded ' -> '') corrupted any Jinja expression containing a + # single-quoted literal into a TemplateSyntaxError under the old + # Template(yaml.dump(compose)) pipeline. Structure-preserving + # rendering must render it cleanly. + monkeypatch.setenv("GREFFON_PATH", str(tmp_path)) + from apps.utils.docker.compose import create_compose + + compose = {"services": {"app": { + "image": "x", + "environment": { + "X": "{{ 'fallback' if not instance_url else 'set' }}", + }}}} + info = {"id": "rt1", "ports": [], "configurations": [], + "integrations": {}} + create_compose(compose, info) + import yaml as _yaml + + rendered = _yaml.safe_load(open( + tmp_path / "rt1" / "docker-compose.yml").read()) + value = rendered["services"]["app"]["environment"]["X"] + assert value in ("fallback", "set"), value + + def test_leaf_trailing_newline_preserved(self): + # Regression (adversarial review): Jinja strips one trailing + # newline by default; per-leaf rendering silently truncated every + # multi-line value by exactly one \n (4 catalog snapshots diffed). + from apps.utils.docker.render_budget import _child_render + + out = _child_render("body", "line1\nline2\n", {}) + assert out == "line1\nline2\n", repr(out) + + def test_keys_count_toward_input_cap(self, monkeypatch): + # Regression: the budget walked values only, so a compose whose + # bulk lived in KEYS passed the input cap un-counted. + # The aggregate guard is max_input * 100, so the key bulk must + # exceed THAT to trip (the cap semantics for tree jobs). + monkeypatch.setenv("GREFFER_RENDER_MAX_INPUT", "8") + monkeypatch.setenv("GREFFER_RENDER_MAX_OUTPUT", "0") + tree = {"k" * (8 * 101): "v"} + with pytest.raises(RenderBudgetExceeded) as e: + render_budget.render_compose_tree_bounded(tree, {}) + assert e.value.code == "input_too_large" + def test_unknown_render_kind_refused(self): with pytest.raises(ValueError, match="unknown render kind"): render_budget.render_bounded("bodyy", "ok", _ctx()) @@ -204,10 +249,15 @@ class TestWiring: def test_body_render_budget_maps_to_config_render_error(self, monkeypatch, tmp_path): monkeypatch.setenv("GREFFON_PATH", str(tmp_path)) - monkeypatch.setenv("GREFFER_RENDER_MAX_INPUT", "8") - with pytest.raises(compose.ConfigRenderError, match="input_too_large"): + # Feature 6 made the body a TREE job: the input cap is aggregate + # (max_in * 100 over keys+values), so trip the JOB-WIDE OUTPUT cap + # instead — the wiring assertion (budget -> ConfigRenderError) is + # what this test pins. + monkeypatch.setenv("GREFFER_RENDER_MAX_OUTPUT", "8") + with pytest.raises(compose.ConfigRenderError, match="output_too_large"): compose.create_compose( - {"services": {"a": {"image": "x"}}}, + {"services": {"a": {"image": "x", + "environment": {"K": "vvvvvvvvvv"}}}}, {"id": "t1", "ports": [], "configurations": [], "integrations": {}})