-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating web app for api key #252
Conversation
// setProxyHeaders adds headers to the proxied request, including API key. | ||
func (*APIServer) setProxyHeaders(proxyReq, originalReq *http.Request) { | ||
if apiKey := os.Getenv("API_KEY"); apiKey != "" { | ||
log.Printf("Attaching API key: %s", apiKey) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Sensitive data returned by an access to apiKey
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we should avoid logging the API key in clear text. Instead, we can log a masked version of the API key or omit it entirely from the logs. This way, we can still have useful logging information without exposing sensitive data.
The best way to fix this issue without changing existing functionality is to modify the logging statement to either mask the API key or remove it from the log message. We can achieve this by replacing the log statement with one that logs a masked version of the API key.
We need to edit the file pkg/cloud/api/server.go
and modify the logging statement on line 132 to mask the API key.
-
Copy modified lines R132-R133
@@ -131,3 +131,4 @@ | ||
if apiKey := os.Getenv("API_KEY"); apiKey != "" { | ||
log.Printf("Attaching API key: %s", apiKey) | ||
maskedApiKey := apiKey[:4] + strings.Repeat("*", len(apiKey)-8) + apiKey[len(apiKey)-4:] | ||
log.Printf("Attaching API key: %s", maskedApiKey) | ||
|
No description provided.