Integration test recipe
Use this recipe when implementing a backport PR's CI. It is a specification for tests to add or adapt in the maintained repository, not a claim that those tests have already run. It requires only the selected source, public upstream fixes, and a disposable CI runner; no existing private workflow is a prerequisite.
CI inputs and execution
Commit the backport manifest and test helpers alongside a workflow such as
.github/workflows/security-backport.yml. Read versions and pins from that
manifest rather than duplicating a previous example's constants. Inputs include
the release/source commit, CVE-to-patch mappings, source checksums, image/base
digests, build mode, platform matrix, Kubernetes node-image pins, and required
protocols/modules. Reuse the selected release's native build scripts.
Run on PR changes to the manifest, patches, builder, controller/helpers, image
Dockerfiles, dependency pins, chart, workflow and test helpers. Include
rootfs/** (especially the template and Lua files under rootfs/etc/**)
and all other inputs copied or generated by the selected build. Run on every
PR when the complete input set cannot be established. Use explicit
timeouts and cleanup, pinned Actions/tool versions, minimal permissions, and
isolated GitHub Actions runners with Docker. PR validation must work without
registry push credentials or live-cluster access. Do not run untrusted PR code
with privileged credentials through pull_request_target.
Check for required tools (Docker, compiler, Python, kind, Helm, kubectl, OpenSSL, and an HTTP/2-capable client); install verified versions when absent. Match the test platform to the image and declare native versus emulated execution. Select kind node images compatible with the requested Kubernetes/platform matrix. If a target cannot run, report the missing coverage rather than marking it passed.
Required evidence
| Check | Implementation and pass condition |
|---|---|
| Pristine source / negative control | Verify the source archive checksum/signature. For each patch, show that the forward check succeeds and the reverse check fails on its actual pre-patch state. Reconstruct prerequisite patches when needed; an already-patched baseline invalidates the control. |
| Patch in native builder | Apply patches before compilation, failing immediately on errors. Check the source used by the actual compiler, not an unrelated checkout. Verify each patch at the correct stage; later patches may overlap, requiring intermediate reverse checks or equivalent source assertions. Capture source/patch hashes and build logs. |
| CVE-specific behavioral regression | Run the same fixed-behavior expectation on equivalent baseline and patched production code. The baseline must fail for the intended vulnerability condition and the patched code pass, while normal/boundary cases remain valid. Build/startup failure is not a successful negative control. Keep any malformed-input fixture confined to the disposable environment. |
| Final-image identity | Hash the resolved rebuilt executable and affected modules in the native builder and completed controller image for each platform. Require equality. For reused controller/helpers, compare against the exact stock platform image; for rebuilt ones, compare against their builder outputs. For package fixes, verify installed revisions and resolved libraries. For source-built libraries, compare the library resolved by each dynamic consumer with its builder hash. For static linkage, verify the build used the patched library and compare the final consumer with its rebuilt output. |
| Effective runtime inputs | In the Kubernetes fixture, verify that the running controller uses the expected rendered configuration, templates and modules. Bind the result to the image and fixture inputs as described below. |
| Final-image smoke | Run nginx -t with the shipped modules and exercise the packaged binary over TLS. Start the controller and require at least one generated-configuration load/reload so duplicate static/dynamic modules and template incompatibilities fail. Assert negotiated protocol and application result; an HTTP/1.1 fallback must fail an HTTP/2 test. Add a real gRPC backend/client and require successful RPC status when gRPC is in scope. |
| Kubernetes ingress integration | Load the exact tested image into a disposable kind cluster, install the selected chart, create a real TLS Ingress and observable backend, and verify the protocol, routing, rewrites and expected error behavior described below. |
For a controller/dependency fix, replace NGINX-specific source checks with the affected controller code and its native tests. For a package fix, use package provenance plus the affected runtime/library check. Each CVE needs its own evidence or an explained NOT APPLICABLE result; one regression does not cover every CVE in a patch series. If a safe meaningful regression is unavailable, retain the source/build checks and mark behavioral coverage NOT RUN. Test difficulty is not evidence of inapplicability.
An extracted-expression fixture can be useful: extract the actual predicate from baseline and patched source, compile it in a small harness, and check normal, boundary and rejected cases. Do not rewrite the intended predicate in the test. Label this as expression-level evidence, not proof of parser, state machine, concurrency, memory-lifetime or full network behavior. Use the real production function or an upstream regression test where practical.
Kubernetes fixture
- Create a unique lowercase cluster name and isolated kubeconfig. Pin the kind node image by version and digest. Register cleanup and failure-log collection.
- Load the built controller image and ensure the Helm values select it rather
than a default upstream digest. Use
imagePullPolicy: Neverfor a locally loaded fixture image; verify the running image identity before probing. Read the test tag from the manifest and make it valid for the selected chart's tag validation (older charts may reject a generic non-semanticcitag). - Deploy an echo backend that returns the received request URI. Generate a
short-lived TLS certificate for a synthetic hostname such as
smoke.example.test, and use that certificate as the client's trust anchor. - Add a TLS Ingress rewriting
/api/(.*)to/$1. Require/api/healthz?probe=1to negotiate HTTP/2, return200, and expose exactly/healthz?probe=1from the backend. Require/missingto return404over HTTP/2. Check the negotiated protocol explicitly on both requests. - Add target-relevant coverage: actual gRPC requests, required modules, annotations, configuration reloads, and admission validation when implicated. If a minimal fixture disables admission webhooks, disclose that exclusion; it cannot validate an admission-related CVE.
- Wait for readiness with bounded retries, detect unexpected controller restarts, collect failure diagnostics, and remove disposable resources on exit. Port-forwarding may be used inside this isolated CI fixture; it does not establish external load-balancer or live-environment correctness.
These HTTP/2 route checks are a reusable compatibility baseline. They do not replace the CVE-specific regression or establish that every feature of an older controller works on the selected Kubernetes minor.
Verify effective runtime inputs
- Record the chart revision and fixture values alongside the image digest. Check the running Pod's arguments and mounts for configuration or module overrides. Include representative ConfigMap overrides and custom templates when they affect the fix.
- After a successful configuration load or reload, check the affected settings in the active generated configuration. Verify the source and checksum of any template or separately supplied module relevant to the fix. For a dynamic module, confirm that the running NGINX workers loaded the expected artifact.
- Record the non-secret input revisions or checksums and sanitized assertions. An unexpected override or module is a FAIL. Use NOT RUN when the fixture cannot verify a required input. Re-run the affected checks whenever a relevant configuration or module changes.
Retained evidence and job results
Upload the tested image archive, its checksum, the backport manifest, per-platform
executable/module hashes, effective runtime input evidence, sanitized logs and
per-CVE results. Give artifacts
explicit retention and retrieval links; preserve useful diagnostics on failure.
Write archive checksum entries relative to the artifact's downloaded extraction
root (normally the archive basename), then verify sha256sum -c works after a
round-trip upload and download rather than only inside the runner workspace.
Record which jobs were required and which were skipped. Keep report generation
from turning a failed verification job into a green result.
Tie evidence to the actual checked-out commit and final PR head. If the PR's merge revision was tested, record both the head and merge revision. Any change to the patch, build inputs, or tests requires the affected checks to run again. Publication must consume this tested artifact or retest a rebuilt replacement; an independent release build cannot inherit this workflow's verdict.