From f7ad2ff0fa7d0bc544959f927fa207aad6dbc9b9 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 2 Sep 2026 12:12:07 +0200 Subject: [PATCH] fix(flowise): read a refused registration as the deny list working The deploy points a throwaway registry entry at loopback and at the metadata address and fails unless Flowise refuses to reach it, because HTTP_SECURITY_CHECK=false replaces the built-in deny list rather than merging into it, and a typo there would disable every protection while the registry kept working. The check assumed the entry always registers and that only authorize can refuse. Flowise consults the list at registration too, so the create came back 400 {"statusCode":400,"success":false, "message":"Server URL is not allowed by policy"} and the probe reported its own strongest proof as a failure, taking the deploy with it after forty minutes. Accept that answer, and only that answer: a 400 naming the policy is the list refusing the address. Every other non-2xx still aborts, and a list that is not live still returns the entry, so the authorize call below remains the judge of that case. The check cannot pass on a dead deny list. Co-Authored-By: Claude Opus 5 (1M context) --- .../files/python/reconcile/mcp_servers.py | 2 ++ .../files/reconcile/test_mcp_servers.py | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/roles/web-app-flowise/files/python/reconcile/mcp_servers.py b/roles/web-app-flowise/files/python/reconcile/mcp_servers.py index e7c921e3e2..ec2197e928 100644 --- a/roles/web-app-flowise/files/python/reconcile/mcp_servers.py +++ b/roles/web-app-flowise/files/python/reconcile/mcp_servers.py @@ -367,6 +367,8 @@ def assert_denied(url): "workspaceId": WORKSPACE, } status, body = call(REGISTRY, method="POST", payload=probe) + if status == 400 and "not allowed by policy" in str(body): + return if status not in (200, 201): sys.exit(f"FAILED creating the deny-list probe: {status} {body}") diff --git a/tests/unit/python/roles/web-app-flowise/files/reconcile/test_mcp_servers.py b/tests/unit/python/roles/web-app-flowise/files/reconcile/test_mcp_servers.py index fdc65b3eaa..35e1bd78dd 100644 --- a/tests/unit/python/roles/web-app-flowise/files/reconcile/test_mcp_servers.py +++ b/tests/unit/python/roles/web-app-flowise/files/reconcile/test_mcp_servers.py @@ -65,8 +65,12 @@ class FakeApi: flows=(), prediction=None, permissive=False, + refuse_on_create=False, + create_error=None, ): self.permissive = permissive + self.refuse_on_create = refuse_on_create + self.create_error = create_error self.entries = [dict(entry) for entry in entries] if duplicate and self.entries: self.entries.append(dict(self.entries[0], id="dup")) @@ -107,6 +111,14 @@ class FakeApi: if path == "/api/v1/custom-mcp-servers" and method == "GET": return 200, [dict(entry) for entry in self.entries] if path == "/api/v1/custom-mcp-servers" and method == "POST": + url = str(payload.get("serverUrl") or "") + if self.create_error and any(bad in url for bad in DENIED): + return self.create_error + if self.refuse_on_create and any(bad in url for bad in DENIED): + return ( + 400, + '{"statusCode":400,"message":"Server URL is not allowed by policy"}', + ) created = dict(payload, id=f"id-{payload['name']}") self.entries.append(created) if payload["name"] != PROBE_NAME: @@ -351,6 +363,20 @@ class TestReconcileMcpServers(unittest.TestCase): ) self.assertNotIn(f"id-{PROBE_NAME}", api.authorized) + def test_a_registry_that_refuses_the_denied_url_is_a_pass(self) -> None: + module = load_script([SUPPORTED_SERVER]) + api = FakeApi(refuse_on_create=True) + with patch.object(module, "call", api): + module.main() + self.assertNotIn(f"id-{PROBE_NAME}", api.authorized) + + def test_a_create_that_fails_for_another_reason_still_fails(self) -> None: + module = load_script([SUPPORTED_SERVER]) + api = FakeApi(create_error=(500, "upstream exploded")) + with patch.object(module, "call", api), self.assertRaises(SystemExit) as exit_: + module.main() + self.assertIn("deny-list probe", str(exit_.exception)) + def test_a_flowise_that_reaches_loopback_fails_the_deploy(self) -> None: module = load_script([SUPPORTED_SERVER]) api = FakeApi(permissive=True)