Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin): upgrade to latest version of Sentry and uWSGI #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions sentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ static int sentry_dsn_parse(struct sentry_config *sc) {

// find colon
char *colon = memchr(auth, ':', auth_len);
if (!colon) goto error;

sc->key = uwsgi_concat2n(auth, colon-auth, "", 0);
sc->secret = uwsgi_concat2n(colon+1, at-(colon+1), "", 0);
if (colon) {
sc->key = uwsgi_concat2n(auth, colon-auth, "", 0);
sc->secret = uwsgi_concat2n(colon+1, at-(colon+1), "", 0);
} else {
sc->key = uwsgi_concat2n(auth, at-auth, "", 0);
}

if (sc->debug) {
uwsgi_log("[sentry] parsed url: %s\n", sc->url);
Expand Down Expand Up @@ -315,12 +317,16 @@ static void sentry_request(struct sentry_config *sc, char *msg, size_t len) {

// we need a uwsgi buffer to build the X-Sentry-Auth header
ub_auth = uwsgi_buffer_new(uwsgi.page_size);
if (uwsgi_buffer_append(ub_auth, "X-Sentry-Auth: Sentry sentry_version=5, sentry_timestamp=", 57)) goto end;;
if (uwsgi_buffer_append(ub_auth, "X-Sentry-Auth: Sentry sentry_version=7, sentry_timestamp=", 57)) goto end;;
if (uwsgi_buffer_num64(ub_auth, now)) goto end;
if (uwsgi_buffer_append(ub_auth, ", sentry_key=", 13)) goto end;
if (uwsgi_buffer_append(ub_auth, sc->key, strlen(sc->key))) goto end;
if (uwsgi_buffer_append(ub_auth, ", sentry_client=uwsgi-sentry, sentry_secret=", 44)) goto end;
if (uwsgi_buffer_append(ub_auth, sc->secret, strlen(sc->secret))) goto end;
if (uwsgi_buffer_append(ub_auth, ", sentry_client=uwsgi-sentry", 28)) goto end;
if (sc->secret) {
if (uwsgi_buffer_append(ub_auth, ", sentry_secret=", 16)) goto end;
if (uwsgi_buffer_append(ub_auth, sc->secret, strlen(sc->secret))) goto end;
}

// null ending
if (uwsgi_buffer_append(ub_auth, "\0", 1)) goto end;

Expand Down Expand Up @@ -351,10 +357,9 @@ static void sentry_request(struct sentry_config *sc, char *msg, size_t len) {
uwsgi_uuid(uuid);
if (uwsgi_buffer_append(ub_body, "{\"event_id\":\"", 13)) goto end;
if (uwsgi_buffer_append(ub_body, uuid, 8)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+9, 4)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+14, 4)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+19, 4)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+24, 12)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+9, 8)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+18, 8)) goto end;
if (uwsgi_buffer_append(ub_body, uuid+27, 8)) goto end;
if (uwsgi_buffer_append(ub_body, "\"", 1)) goto end;

if (sc->level) {
Expand Down