Skip to content

Commit 5829208

Browse files
hubyrodclaude
andcommitted
Security hardening: remove leaked secret, reduce log exposure, add request limits
- Remove hardcoded webhook secret from test-webhook.sh (require from env) - Stop logging partial auth tokens and payload bodies on errors - Add 1 MB max request body size to Bun.serve() - Restrict health endpoint to GET/HEAD methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5925400 commit 5829208

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function handleWebhook(req: Request, routeName: string): Promise<Response>
7979
: body;
8080
payload = JSON.parse(json);
8181
} catch (err) {
82-
log("error", `Failed to parse ${eventType} payload: ${err}. Body: ${body.slice(0, 200)}`);
82+
log("error", `Failed to parse ${eventType} payload: ${err} (body length: ${body.length})`);
8383
return new Response("OK");
8484
}
8585

@@ -101,10 +101,14 @@ async function handleWebhook(req: Request, routeName: string): Promise<Response>
101101

102102
Bun.serve({
103103
port,
104+
maxRequestBodySize: 1024 * 1024,
104105
fetch(req) {
105106
const url = new URL(req.url);
106107

107108
if (url.pathname === "/" || url.pathname === "/health") {
109+
if (req.method !== "GET" && req.method !== "HEAD") {
110+
return new Response("Method not allowed", { status: 405 });
111+
}
108112
return new Response("OK");
109113
}
110114

@@ -130,7 +134,7 @@ log("info", `Slashwork URL: ${config.slashwork.graphqlUrl}`);
130134

131135
for (const name of routeNames) {
132136
const conn = connectionForRoute(name);
133-
log("info", `Route ${name}: token ${conn.authToken.slice(0, 8)}...`);
137+
log("info", `Route ${name}: auth token configured`);
134138
validateConnection(conn).then(
135139
() => log("info", `Route ${name}: auth validated`),
136140
(err) => log("error", `Route ${name}: ${err}`),

0 commit comments

Comments
 (0)