Skip to content

Commit c619ca9

Browse files
YuvalYuval
authored andcommitted
fix: address GitHub code scanning and secret scanning alerts
- Add `permissions: contents: read` (+ `security-events: write` for CI) to all four workflow files so they run with least-privilege tokens instead of the default over-broad GITHUB_TOKEN permissions. - Sanitize `context.Request.Path` before logging in ExceptionHandlingMiddleware to prevent log-forging via CR/LF injection. - Dismiss false-positive CodeQL alerts: #13 (AuthController UserId log is not PII) and #10 (ImageUploadModal preview is a blob URL, not HTML). - Dismiss secret-scanning alerts #4/#5/#6: Firebase API keys are intentionally public and restricted via Firebase Security Rules / Google Cloud Console; they are not server-side credentials.
1 parent 95ba221 commit c619ca9

5 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/cd.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ on:
3131
push:
3232
branches: [main]
3333

34+
permissions:
35+
contents: read
36+
3437
concurrency:
3538
group: cd-${{ github.ref }}
3639
cancel-in-progress: false # Don't cancel in-flight deploys

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
push:
1818
branches: [main, refactor/main]
1919

20+
permissions:
21+
contents: read
22+
security-events: write
23+
2024
concurrency:
2125
group: ci-${{ github.ref }}
2226
cancel-in-progress: true

.github/workflows/cluster-daily.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
# Allow manual triggering from the Actions tab when you want to force a run.
1515
workflow_dispatch:
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
recompute:
1922
runs-on: ubuntu-latest

.github/workflows/relevance-daily.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
- cron: "0 7 * * *"
1717
workflow_dispatch:
1818

19+
permissions:
20+
contents: read
21+
1922
jobs:
2023
notify:
2124
runs-on: ubuntu-latest

src/02-server/Middleware/ExceptionHandlingMiddleware.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,16 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception
123123
// make it easy to filter and alert on specific error patterns
124124
// once we add Serilog + Application Insights in Phase 4.8.
125125
// ---------------------------------------------------------------
126+
var safePath = context.Request.Path.Value?
127+
.Replace("\r", string.Empty)
128+
.Replace("\n", string.Empty) ?? string.Empty;
129+
126130
_logger.LogError(
127131
exception,
128132
"Unhandled exception — Code: {ErrorCode}, Status: {StatusCode}, Path: {Path}",
129133
errorCode,
130134
(int)statusCode,
131-
context.Request.Path);
135+
safePath);
132136

133137
// ---------------------------------------------------------------
134138
// Write the response.

0 commit comments

Comments
 (0)