Skip to content

Commit b9f377d

Browse files
Potential fix for code scanning alert no. 3: Server-side request forgery
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent bd135ea commit b9f377d

File tree

1 file changed

+8
-7
lines changed
  • catalog-analytics/app/api/github/ci-status

1 file changed

+8
-7
lines changed

catalog-analytics/app/api/github/ci-status/route.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,25 @@ export async function POST(request: Request) {
4848
}, {} as Record<string, CIStatus>);
4949

5050
return NextResponse.json(statusMap);
51+
}
52+
53+
// Fetch CI status for all repos in parallel
54+
const statusPromises = repositories.map(async (repo_id) => {
5155
// Validate repo_id before using it in an outbound request
52-
if (typeof repo_id !== 'string' || !isValidRepoId(repo_id)) {
56+
const repoIdStr = String(repo_id).trim();
57+
if (!isValidRepoId(repoIdStr)) {
5358
return {
54-
repo_id: String(repo_id),
59+
repo_id: repoIdStr,
5560
state: 'unknown' as const,
5661
total_checks: 0,
5762
updated_at: new Date().toISOString(),
5863
details: 'Invalid repository identifier',
5964
};
6065
}
6166

62-
}
63-
64-
// Fetch CI status for all repos in parallel
65-
const statusPromises = repositories.map(async (repo_id) => {
6667
try {
6768
const response = await fetch(
68-
`https://api.github.com/repos/${repo_id.trim()}/commits/main/status`,
69+
`https://api.github.com/repos/${repoIdStr}/commits/main/status`,
6970
{
7071
headers: {
7172
'Authorization': `Bearer ${token}`,

0 commit comments

Comments
 (0)