Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ pub const SentryClient = struct {
.items = buf[0..],
};

std.debug.print("Sending envelope", .{});
_ = try self.transport.send(envelope);

return prepared_event.event_id.value;
Expand Down
12 changes: 12 additions & 0 deletions src/transport.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ pub const HttpTransport = struct {
}

pub fn send(self: *HttpTransport, envelope: SentryEnvelope) !TransportResult {
std.debug.print("sending envelope", .{});
const payload = try self.envelopeToPayload(envelope);
defer self.allocator.free(payload);

// Check if DSN is configured
const dsn = self.options.dsn orelse {
return TransportResult{ .response_code = 0 };
};
std.debug.print("dsn: {any}", .{dsn});

// Construct the Sentry envelope endpoint URL
const netloc = dsn.getNetloc(self.allocator) catch {
return TransportResult{ .response_code = 0 };
};
defer self.allocator.free(netloc);
std.debug.print("netloc: {s}", .{netloc});

const endpoint_url = std.fmt.allocPrint(self.allocator, "{s}://{s}/api/{s}/envelope/", .{
dsn.scheme,
Expand All @@ -63,11 +66,13 @@ pub const HttpTransport = struct {
return TransportResult{ .response_code = 0 };
};
defer self.allocator.free(endpoint_url);
std.debug.print("endpoint_url: {s}", .{endpoint_url});

// Parse the URL and make the HTTP request
const uri = std.Uri.parse(endpoint_url) catch {
return TransportResult{ .response_code = 0 };
};
std.debug.print("uri: {any}", .{uri});

// Construct the auth header
const auth_header = std.fmt.allocPrint(self.allocator, "Sentry sentry_version=7,sentry_key={s},sentry_client=sentry-zig/0.1.0", .{
Expand All @@ -76,19 +81,23 @@ pub const HttpTransport = struct {
return TransportResult{ .response_code = 0 };
};
defer self.allocator.free(auth_header);
std.debug.print("auth_header: {s}", .{auth_header});

// Create Content-Length header value
const content_length = std.fmt.allocPrint(self.allocator, "{d}", .{payload.len}) catch {
return TransportResult{ .response_code = 0 };
};
defer self.allocator.free(content_length);
std.debug.print("content_length: {s}", .{content_length});

const headers = [_]std.http.Header{
.{ .name = "Content-Type", .value = "application/x-sentry-envelope" },
.{ .name = "Content-Length", .value = content_length },
.{ .name = "X-Sentry-Auth", .value = auth_header },
};

std.debug.print("headers: {any}", .{headers});

var response_body = std.ArrayList(u8).init(self.allocator);
defer response_body.deinit();

Expand Down Expand Up @@ -135,9 +144,12 @@ pub const HttpTransport = struct {
var list = std.ArrayList(u8).init(self.allocator);
errdefer list.deinit();

std.debug.print("stringifying event", .{});

try std.json.stringify(event, .{}, list.writer());

const data = try list.toOwnedSlice();
std.debug.print("Creating envelope item", .{});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Unconditional Debug Statements Leak Sensitive Information

A few unconditional std.debug.print statements were added that bypass the existing conditional std.log.debug system. These appear to be temporary debugging code and will produce unwanted output in production. Some also expose sensitive DSN details and authentication headers.

Additional Locations (1)

Fix in Cursor Fix in Web

return SentryEnvelopeItem{
.header = .{
.type = .event,
Expand Down
Loading