Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const SNYK_DEFAULT_API_VERSION = "2024-04-22"
const SNYK_DEFAULT_IN_MEMORY_THRESHOLD_MB = 512 * 1024 * 1024
const SNYK_DOCS_URL = "https://docs.snyk.io"
const SNYK_DOCS_ERROR_CATALOG_PATH = "/scan-with-snyk/error-catalog"
const SNYK_DEFAULT_ALLOWED_HOST_REGEXP = `^(https?://)?api(\.(.+))?\.(snyk|snykgov)\.io$`
const SNYK_DEFAULT_ALLOWED_HOST_REGEXP = `^(https?:\/\/)?api(\.([a-z0-9._-]+))?\.(snyk|snykgov)\.io$`
Copy link
Copy Markdown
Contributor

@bastiandoetsch bastiandoetsch Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would prevent snyk to use private cloud unicode URLs.

It would be better to update IsValidHost with url.Parse to extract the actual host. The function could be moved to its own package to prevent possible import cycles.

7 changes: 7 additions & 0 deletions pkg/auth/authHost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ func Test_isValidAuthHost(t *testing.T) {
{"api.snyk.io", true},
{"api.snykgov.io", true},
{"api.pre-release.snykgov.io", true},
{"api.a.b.c.snyk.io", true},
{"snyk.io", false},
{"api.example.com", false},
{"api.snyk.evil.com", false},
{"evilsnykgov.io", false},
{"api.example.snyk.io.evil.com", false},
{"api.snyk.io.attacker.com", false},
{"api.snyk.io/haha", false},
{"api.attacker.io/haha.snyk.io", false},
{"token@api.snyk.io", false},
{"api.something api.snyk.io", false},
}

for _, tc := range testCases {
Expand Down