🔒 fix: Replace hardcoded API key with environment variable - #1401
Open
poliakarmai wants to merge 1 commit into
Open
🔒 fix: Replace hardcoded API key with environment variable#1401poliakarmai wants to merge 1 commit into
poliakarmai wants to merge 1 commit into
Conversation
The invoice-generator.com API key was hardcoded in source code,
exposing it to anyone with repository access.
Fix: use os.getenv('INVOICE_GENERATOR_API_KEY') instead, following
the same pattern already used for GCP_API_KEY in translation.py.
Found by GSC (Git Security Checker)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Summary
Hardcoded
invoice-generator.comAPI key replaced withos.getenv("INVOICE_GENERATOR_API_KEY")— following the same pattern already used forGCP_API_KEYinapi/app/utils/translation.py.File:
api/app/invoice/generator.py:12Before:
After:
📚 Understanding This Vulnerability
What is it?
Hardcoded credentials (API keys, passwords, tokens) stored directly in source code — visible to anyone with repository access.
Why it matters
If the code leaks (GitHub, laptop, backup), an attacker gains access to all services using those credentials. Hardcoded secrets are one of the OWASP Top 10 (A07:2021 — Identification and Authentication Failures) and the #1 cause of cloud breaches according to multiple industry reports.
When it happens
config.py,settings.py, example code, test fixtures with real data.How to fix properly
os.getenv("KEY_NAME").envfile (gitignored) for local development🧠 Analogy
📖 Further Reading
🐛 Found by GSC — understand your code, don't just accept it.