mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
fix(utils): resolve_term keeps the requested clearnet domain instead of an onion-swapped primary
roles/sys-ctl-hlth-webserver and roles/sys-ctl-hlth-csp both derive
their probe protocol from lookup('tls', DOMAIN_PRIMARY, 'protocols.web')
- a single, global flag applied to every domain they check. Under Tor,
svc-prx-openresty's own domain (DOMAIN_PRIMARY) gets swapped for its
onion sibling (exclusive: true, the provider default), so
lookup('tls', 'infinito.test') falls through resolve_term's app-primary
fallback and resolves against the onion address instead - flipping the
protocol to http for every domain check in the run.
That's correct for every currently-deployed app, since every other
Tor-enabled role is onion-exclusive - but web-app-wazuh is the first
role to set exclusive: false, keeping a real clearnet domain alongside
its onion one. Under Tor, wazuh.infinito.test still gets probed over
plain http (correct for onion, wrong for it), and nginx's normal
301 HTTP->HTTPS redirect isn't in the health check's accepted status
list, failing the whole service - and separately, the CSP crawler
silently reads its http/ directory instead of https/, never actually
crawling Wazuh's clearnet vhost at all.
Fixes resolve_term to keep the originally-requested clearnet domain
when the owning app's primary has been swapped to onion, rather than
following that fallback - mirroring align_domain_to_consumer's existing
pattern for the same situation. Fixes both callers with one change;
script.py needs no change, since it already sends onion domains over
http correctly.
Root cause confirmed via a real repro: lookup('tls', 'infinito.test')
returns protocols.web=http under Tor before this fix. Not yet
confirmed: whether the dual-stack HTTPS vhost actually answers with an
accepted status code once probed correctly - that requires a live Tor
CI run.
This touches resolve_term, used by every lookup('tls', <domain>) call
platform-wide - a wider-reaching shared-code change than the earlier
sys-front-tls fix. Flagging to Kevin as its own review item.
This commit is contained in:
2 files changed
+40
No files matched your search
@@ -133,6 +133,38 @@ class TestTlsCommon(unittest.TestCase):
|
||||
"x", domains=self.domains, forced_mode="invalid", err_prefix="t"
|
||||
)
|
||||
|
||||
def test_resolve_term_clearnet_domain_swapped_to_onion_keeps_clearnet(self):
|
||||
domains = {"svc-prx-openresty": ["abc.onion"]}
|
||||
applications = {
|
||||
"svc-prx-openresty": {"domains": {"canonical": ["infinito.test"]}}
|
||||
}
|
||||
app_id, primary = resolve_term(
|
||||
"infinito.test",
|
||||
domains=domains,
|
||||
applications=applications,
|
||||
forced_mode="auto",
|
||||
err_prefix="t",
|
||||
)
|
||||
self.assertEqual(app_id, "svc-prx-openresty")
|
||||
self.assertEqual(primary, "infinito.test")
|
||||
self.assertTrue(resolve_enabled({}, True, primary_domain=primary))
|
||||
|
||||
def test_resolve_term_alias_without_onion_swap_keeps_canonical(self):
|
||||
domains = {"web-app-x": ["x.example"]}
|
||||
applications = {
|
||||
"web-app-x": {
|
||||
"domains": {"canonical": ["x.example"], "aliases": ["old.example"]}
|
||||
}
|
||||
}
|
||||
_, primary = resolve_term(
|
||||
"old.example",
|
||||
domains=domains,
|
||||
applications=applications,
|
||||
forced_mode="auto",
|
||||
err_prefix="t",
|
||||
)
|
||||
self.assertEqual(primary, "x.example")
|
||||
|
||||
def test_resolve_enabled_and_mode(self):
|
||||
app = {}
|
||||
self.assertTrue(resolve_enabled(app, True))
|
||||
|
||||
Reference in new issue
Block a user