Skip to content

fix: backport HSTS configuration and route coverage to 2.x - #142

Merged
stevehu merged 2 commits into
2.xfrom
fix/hsts-2.x
Oct 28, 2026
Merged

stevehu merged 2 commits into
2.xfrom
fix/hsts-2.x

Conversation

@stevehu

@stevehu stevehu commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Backport the merged master fix from #141 to 2.x for Checkmarx A02 (favicon HSTS).

Put header first in the packaged default/admin chains and seven direct-response routes. Add the same opt-in dedicated HTTPS ingress overlay with a late root-prefix response rule, so backend headers cannot override HSTS/no-store/nosniff or retain X-Powered-By. No full chains are copied into the overlay.

The overlay disables plaintext HTTP, including normal sidecar egress on localhost:9080. Do not apply it to a co-located sidecar needing that port; use a separate ingress instance or trusted TLS edge. Defaults retain HTTP and do not enable HSTS. No includeSubDomains/preload is added.

The production values and overlay match master. Tests use the 2.x SnakeYAML API instead of master's YAML utility. Validation: mvn -q clean test — 31 tests, 0 failures, 0 errors, 9 existing skips. Five regression tests cover the real handler/configuration pipeline, direct/admin routes, favicon bytes, conflicting backend headers on 200/302/404/500 responses, and default plaintext proxy access. git diff --check passes.

Public deployment verification and partner rescan remain required for closure.

@stevehu

stevehu commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Review of the 2.x backport (d2b988f). No blocking issues. I read the diff and ran SpecificationHstsConfigurationTest on this head: 5 tests, 0 failures, 0 errors. I did not run the full suite or the remote builds.

Production config matches master: header is first in the default and admin chains, direct routes include it explicitly, and the overlay uses the root header.pathPrefixHeader response rule. Tests use the 2.x YAML API.

Minor items:

  1. Ready file race: the test polls Files.exists(ready) and then reads it, but the fixture writes it non-atomically with Files.writeString. An empty read would fail with NumberFormatException and make the test flaky. Write to a temp file and move it into place.
  2. Listener order: the fixture takes the HTTP port from getListenerInfo().get(1), assuming HTTPS is listed first. Look the ports up by protocol instead.
  3. Overlay footgun: server.enableHttp: false is carried over from master. It is documented as dedicated-ingress only, but remains a footgun if merged into a co-located sidecar.
  4. Test drift: this test has an extra default-profile /adm/logger Cache-Control assertion that the master test lacks. Consider porting it to master.
  5. Pom resources: the testResources block copies the production values.yml into the test classpath under hsts-input. It is namespaced, so it is harmless today.

@stevehu

stevehu commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up review of 6834aa2. I read the diff and re-ran SpecificationHstsConfigurationTest on this head: 5 tests, 0 failures, 0 errors. I did not run the full suite or the remote checks.

Fixed

  • Ready-file race: the fixture now writes ready.pending and publishes it with ATOMIC_MOVE.
  • Listener order: port(server, tls) selects the listener by its SSL context and throws if it is missing.

No change needed

Skipped (accepted)

  • The enableHttp: false overlay stays documented as dedicated-ingress only.
  • The namespaced testResources copy stays, as intended.

@stevehu
stevehu merged commit f683a2f into 2.x Oct 28, 2026
1 check passed
@stevehu
stevehu deleted the fix/hsts-2.x branch October 28, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant