:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(proxy): enforce minimum tls version for managed proxies (#88736)
Reece Jones2f3d9e34ef01
diff --git a/posthog/temporal/proxy_service/cloudflare.py b/posthog/temporal/proxy_service/cloudflare.pyindex b9ae26a1507d..d724038a56dc 100644--- a/posthog/temporal/proxy_service/cloudflare.py+++ b/posthog/temporal/proxy_service/cloudflare.py@@ -17,6 +17,7 @@ from django.conf import settingsimport requestsCLOUDFLARE_API_BASE = "https://api.cloudflare.com/client/v4"+CLOUDFLARE_MIN_TLS_VERSION = "1.2"# Must stay under the tightest calling activity's 10s start_to_close, or Temporal kills the# activity before the request times out and a slow Cloudflare looks like an opaque timeout.@@ -254,6 +255,9 @@ def create_custom_hostname(domain: str) -> CustomHostname:"ssl": {"method": "http","type": "dv",+ "settings": {+ "min_tls_version": CLOUDFLARE_MIN_TLS_VERSION,+ },},}diff --git a/posthog/temporal/proxy_service/test/test_cloudflare.py b/posthog/temporal/proxy_service/test/test_cloudflare.pyindex d657ab9ebe3e..d438b24c8835 100644--- a/posthog/temporal/proxy_service/test/test_cloudflare.py+++ b/posthog/temporal/proxy_service/test/test_cloudflare.py@@ -1,4 +1,6 @@-from django.test import SimpleTestCase, TestCase+from unittest.mock import Mock, patch++from django.test import SimpleTestCase, TestCase, override_settingsfrom parameterized import parameterized@@ -7,6 +9,7 @@ from posthog.temporal.proxy_service.cloudflare import (CustomHostnameSSLStatus,CustomHostnameStatus,_parse_hostname,+ create_custom_hostname,parse_cloudflare_error_code,)@@ -114,6 +117,31 @@ class TestParseHostnameStatuses(SimpleTestCase):self.assertNotEqual(info.status, CustomHostnameStatus.ACTIVE)+class TestCreateCustomHostname(SimpleTestCase):+ @override_settings(CLOUDFLARE_API_TOKEN="token", CLOUDFLARE_ZONE_ID="zone")+ @patch("posthog.temporal.proxy_service.cloudflare.requests.post")+ def test_sets_minimum_tls_version(self, post):+ response = Mock()+ response.json.return_value = {"success": True, "result": _hostname_payload()}+ post.return_value = response++ create_custom_hostname("p.example.com")++ post.assert_called_once_with(+ "https://api.cloudflare.com/client/v4/zones/zone/custom_hostnames",+ headers={"Authorization": "Bearer token", "Content-Type": "application/json"},+ json={+ "hostname": "p.example.com",+ "ssl": {+ "method": "http",+ "type": "dv",+ "settings": {"min_tls_version": "1.2"},+ },+ },+ timeout=8.0,+ )++class TestParseCloudflareErrorCode(SimpleTestCase):@parameterized.expand([