mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-11 22:53:04 +00:00
fix: use module-level BLOCKED_HOSTNAMES set and add metadata.internal
This commit is contained in:
parent
131e195324
commit
f2fc02b636
1 changed files with 2 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ export function getCloneDir(repoName: string): string {
|
|||
|
||||
// Cloud metadata hostnames that must never be reachable via user-supplied URLs
|
||||
const BLOCKED_HOSTNAMES = new Set([
|
||||
'localhost',
|
||||
'metadata.google.internal',
|
||||
'metadata.azure.com',
|
||||
'metadata.internal',
|
||||
|
|
@ -50,8 +51,7 @@ export function validateGitUrl(url: string): void {
|
|||
const host = parsed.hostname.toLowerCase();
|
||||
|
||||
// Block known dangerous hostnames (cloud metadata services)
|
||||
const blockedHostnames = ['localhost', 'metadata.google.internal', 'metadata.azure.com'];
|
||||
if (blockedHostnames.includes(host)) {
|
||||
if (BLOCKED_HOSTNAMES.has(host)) {
|
||||
throw new Error('Cloning from private/internal addresses is not allowed');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue