Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update csp and action (#21020)
ecmadao58985cba00bc
diff --git a/.github/workflows/build-push-cloud-image.yml b/.github/workflows/build-push-cloud-image.ymlindex 28ad84a0cc..6952709bbf 100644--- a/.github/workflows/build-push-cloud-image.yml+++ b/.github/workflows/build-push-cloud-image.yml@@ -53,11 +53,18 @@ jobs:uses: docker/setup-buildx-action@v4- name: Write frontend release env+ env:+ BB_POSTHOG_KEY: ${{ vars.BB_POSTHOG_KEY }}+ BB_POSTHOG_HOST: ${{ vars.BB_POSTHOG_HOST }}+ BB_POSTHOG_RECORDING_SAMPLE_RATE: ${{ vars.BB_POSTHOG_RECORDING_SAMPLE_RATE || '1' }}run: |+ if [ -z "${BB_POSTHOG_KEY}" ] || [ -z "${BB_POSTHOG_HOST}" ]; then+ echo "BB_POSTHOG_KEY or BB_POSTHOG_HOST is not configured. Frontend analytics will be disabled." >&2+ fi{- echo "BB_POSTHOG_KEY=${{ secrets.BB_POSTHOG_KEY }}"- echo "BB_POSTHOG_HOST=${{ vars.BB_POSTHOG_HOST }}"- echo "BB_POSTHOG_RECORDING_SAMPLE_RATE=${{ vars.BB_POSTHOG_RECORDING_SAMPLE_RATE || '1' }}"+ echo "BB_POSTHOG_KEY=${BB_POSTHOG_KEY}"+ echo "BB_POSTHOG_HOST=${BB_POSTHOG_HOST}"+ echo "BB_POSTHOG_RECORDING_SAMPLE_RATE=${BB_POSTHOG_RECORDING_SAMPLE_RATE}"} > frontend/.env.release- name: Build and push Docker imagediff --git a/backend/server/echo_routes.go b/backend/server/echo_routes.goindex 8ad1e6bbf3..bcaa0ef98b 100644--- a/backend/server/echo_routes.go+++ b/backend/server/echo_routes.go@@ -161,7 +161,7 @@ func securityHeadersMiddleware(saas bool) echo.MiddlewareFunc {if saas {scriptSrc += " https://www.googletagmanager.com"imgSrc += " https://*.google-analytics.com https://*.googletagmanager.com"- connectSrc += " https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com"+ connectSrc += " https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://*.i.posthog.com"}csp := "default-src 'self'; " +scriptSrc + "; " +diff --git a/backend/server/echo_routes_test.go b/backend/server/echo_routes_test.goindex 8ba433270e..88107c45dd 100644--- a/backend/server/echo_routes_test.go+++ b/backend/server/echo_routes_test.go@@ -60,6 +60,13 @@ func TestSecurityHeadersMiddleware_GA4Sources(t *testing.T) {}}+func TestSecurityHeadersMiddleware_SaaSAllowsPostHogIngestionHosts(t *testing.T) {+ csp := testSecurityHeadersCSP(t, true)+ if !strings.Contains(csp, "https://*.i.posthog.com") {+ t.Errorf("Content-Security-Policy = %q, want to contain PostHog ingestion hosts", csp)+ }+}+func testSecurityHeadersCSP(t *testing.T, saas bool) string {t.Helper()diff --git a/frontend/src/app/analytics/RouteBehaviorRecorder.test.tsx b/frontend/src/app/analytics/RouteBehaviorRecorder.test.tsxindex 20d33a7f88..f334ac2d91 100644--- a/frontend/src/app/analytics/RouteBehaviorRecorder.test.tsx+++ b/frontend/src/app/analytics/RouteBehaviorRecorder.test.tsx@@ -237,4 +237,44 @@ describe("RouteBehaviorRecorder", () => {},});});++ test("keeps the current page session when only route query changes", async () => {+ await act(async () => {+ root.render(<RouteBehaviorRecorder />);+ });++ mocks.route.fullPath =+ "/projects/customer-a/[email protected]&filter=prod";++ await act(async () => {+ root.render(<RouteBehaviorRecorder />);+ });++ expect(mocks.analytics.captureMetric).not.toHaveBeenCalled();+ });++ test("emits a page session metric when route path changes", async () => {+ vi.useFakeTimers();+ vi.setSystemTime(1_000);++ await act(async () => {+ root.render(<RouteBehaviorRecorder />);+ });++ vi.setSystemTime(6_000);+ mocks.route.fullPath = "/projects/customer-b/databases";++ await act(async () => {+ root.render(<RouteBehaviorRecorder />);+ });++ expect(mocks.analytics.captureMetric).toHaveBeenCalledWith({+ event: "page session",+ properties: expect.objectContaining({+ route_id: "workspace.project.database",+ duration_ms: 5000,+ visible_duration_ms: 5000,+ }),+ });+ });});diff --git a/frontend/src/app/analytics/RouteBehaviorRecorder.tsx b/frontend/src/app/analytics/RouteBehaviorRecorder.tsxindex ebf6779e9f..88742c6ac9 100644--- a/frontend/src/app/analytics/RouteBehaviorRecorder.tsx+++ b/frontend/src/app/analytics/RouteBehaviorRecorder.tsx@@ -44,6 +44,7 @@ function EnabledRouteBehaviorRecorder() {const currentUserName = useAppStore((state) => state.currentUserName);const workspaceName = useAppStore((state) => state.workspaceResourceName());const pageSessionRef = useRef<ActivePageSession | undefined>(undefined);+ const routePath = route.fullPath.split(/[?#]/, 1)[0];const config = useMemo(() =>@@ -112,7 +113,7 @@ function EnabledRouteBehaviorRecorder() {visibleDurationMs: 0,}: undefined;- }, [config, route.name, route.fullPath]);+ }, [config, route.name, routePath]);useEffect(() => {const handleVisibilityChange = () => {