Skip to content

Commit f182cc9

Browse files
committed
fix: security issue
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 31d69f0 commit f182cc9

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

services/apps/packages_worker/src/maven/scripts/fetchMavenMaintainers.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ function sleep(ms: number): Promise<void> {
7979
return new Promise((r) => setTimeout(r, ms))
8080
}
8181

82-
async function safeGet<T>(client: AxiosInstance, url: string): Promise<T | null> {
82+
async function safeGet<T>(
83+
client: AxiosInstance,
84+
url: string,
85+
params?: Record<string, string>,
86+
): Promise<T | null> {
8387
try {
84-
const res = await client.get<T>(url)
88+
const res = await client.get<T>(url, { params })
8589
return res.data
8690
} catch (err) {
8791
if (axios.isAxiosError(err)) {
@@ -92,9 +96,9 @@ async function safeGet<T>(client: AxiosInstance, url: string): Promise<T | null>
9296
const wait = reset ? Math.max(0, Number(reset) * 1000 - Date.now()) + 1000 : 60_000
9397
console.warn(` Rate limited — waiting ${Math.round(wait / 1000)}s`)
9498
await sleep(wait)
95-
return safeGet<T>(client, url)
99+
return safeGet<T>(client, url, params)
96100
}
97-
console.warn(` HTTP ${status} for ${url.replace(/([?&]api_key=)[^&]+/, '$1[redacted]')}`)
101+
console.warn(` HTTP ${status} for ${url}`)
98102
}
99103
return null
100104
}
@@ -198,7 +202,8 @@ async function getLibIoRepoUrl(groupId: string, artifactId: string): Promise<str
198202
if (!LIBRARIES_IO_KEY) return null
199203
const data = await safeGet<LibIoPackage>(
200204
libIo,
201-
`/maven/${encodeURIComponent(`${groupId}:${artifactId}`)}?api_key=${LIBRARIES_IO_KEY}`,
205+
`/maven/${encodeURIComponent(`${groupId}:${artifactId}`)}`,
206+
{ api_key: LIBRARIES_IO_KEY },
202207
)
203208
return data?.repository_url ?? null
204209
}

0 commit comments

Comments
 (0)