Skip to content

nginx/csp/frontend: ensure POSTs to Sentry are not blocked - #2066

Merged
alxndrsn merged 49 commits into
getodk:nextfrom
alxndrsn:sentry-frontend-csp
Jul 30, 2026
Merged

nginx/csp/frontend: ensure POSTs to Sentry are not blocked#2066
alxndrsn merged 49 commits into
getodk:nextfrom
alxndrsn:sentry-frontend-csp

Conversation

@alxndrsn

@alxndrsn alxndrsn commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Closes #2056

What has been done to verify that this works as intended?

  • new tests
  • had a good think about it

Why is this the best possible solution? Were any other approaches considered?

Could make the CSP more lax (e.g. the whole of sentry.org). This would be a smaller header, but would allow unexpected things from those domains.

How does this change impact users? Describe intentional behavior changes from code updates. What are the regression risks?

No effect expected.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Comment thread .github/workflows/main.yml
Comment thread .github/workflows/main.yml
Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml
Comment thread test/nginx/mock-sentry/index.js Outdated
Comment thread test/nginx/src/mocha/nginx.spec.js
Comment thread test/nginx/src/playwright/csp.spec.js Outdated
Comment thread files/nginx/setup-odk.sh Outdated
@alxndrsn alxndrsn changed the title nginx/csp: ensure POSTs to central-backend and Sentry are not blocked nginx/csp: ensure POSTs to Sentry are not blocked Jul 30, 2026
@alxndrsn alxndrsn changed the title nginx/csp: ensure POSTs to Sentry are not blocked nginx/csp/frontend: ensure POSTs to Sentry are not blocked Jul 30, 2026

@matthew-white matthew-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't take a close look at everything in test/, but I saw that there were some good new tests. The changes to files/ make sense to me. 👍 I can take a closer look at test/ later, but I don't feel like that needs to block merge. I think this PR can be merged at any point for inclusion in the upcoming patch release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making a note that I didn't review this file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes needed for this PR out of curiosity?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • generating SSL certs is very slow
  • the existing nginx-ssl-selfsign is explicitly testing the generation of SSL certs
  • the new tests start new containers repeatedly, but existence of SSL certs is only incidental to those tests

So either the tests can be really slow, or use pre-generated certs.

Comment thread files/nginx/setup-odk.sh Outdated
> /etc/nginx/conf.d/redirector.conf

CERT_DOMAIN=$( [ "$SSL_TYPE" = "customssl" ] && echo "local" || echo "$DOMAIN") \
SENTRY_DSN_FRONTEND_ROOT="$(awk 'sub(/:\/\/[a-z0-9]*@/, "://") && sub(/\/[0-9]*$/, "")' <<<"$SENTRY_DSN_FRONTEND")" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alxndrsn what about DSN with a trailing slash? that could easily bite back the system admin

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Please suggest a new test case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an admin accidentally includes a trailing slash in SENTRY_DSN_FRONTEND, for example: https://.....ingest.sentry.io/1234567/

@alxndrsn alxndrsn Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yes I can see that surprising an admin. But I don't think it's a valid DSN per https://docs.sentry.io/concepts/key-terms/dsn-explainer/#the-parts-of-the-data-source-name-dsn, so I'd rather just treat it as invalid.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful somewhere to validate the supplied DSN, and warn if it looks invalid?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK! If that's already not working in Sentry, agree to a reject and treat it as invalid

@alxndrsn
alxndrsn merged commit 8cc32f7 into getodk:next Jul 30, 2026
7 checks passed
@alxndrsn
alxndrsn deleted the sentry-frontend-csp branch July 30, 2026 07:19
@matthew-white matthew-white linked an issue Jul 30, 2026 that may be closed by this pull request
3 tasks
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.

[central-frontend] CSP blocking sentry reports

3 participants