Skip to content

Implement API key masking in logs and error messages#54

Merged
RonaldRonnie merged 3 commits intomainfrom
issue/46-api-key-masking
Jan 2, 2026
Merged

Implement API key masking in logs and error messages#54
RonaldRonnie merged 3 commits intomainfrom
issue/46-api-key-masking

Conversation

@RonaldRonnie
Copy link
Collaborator

  • Created credential masking utility (app/utils/credential_masking.py)

    • mask_credential(): Masks individual credentials (shows last 4 chars)
    • mask_string(): Masks credentials in text strings
    • mask_dict(): Masks credentials in dictionaries
    • safe_log_message(): Creates safe log messages
    • mask_exception_message(): Masks exception messages
  • Fixed all logging statements to mask credentials:

    • app/utils/config.py: Fixed error logging
    • app/models/llm_provider.py: Fixed all error logging
    • app/models/unified_qa.py: Fixed all error logging
    • app/models/gemini_qa.py: Fixed all error logging
    • app/services/data_retrieval.py: Fixed 12 error logging instances
    • app/api/routers/system.py: Fixed 10 error logging instances
    • app/api/routers/bugsigdb_analysis.py: Fixed error logging
    • app/api/routers/bugsigdb_analysis_v2.py: Fixed 5 error logging instances
    • app/api/routers/study_analysis.py: Fixed error logging
    • app/api/utils/api_utils.py: Fixed error logging
    • app/api/app.py: Fixed global exception handler
  • Fixed error messages to not expose credentials

  • Added comprehensive test suite (tests/test_credential_masking.py)

  • Security audit completed for all critical files

Fixes #46"

- Remove excessive bold formatting and structured sections
- Simplify language to be more conversational
- Remove 'Answer:' and 'Pros:' patterns
- Make it sound more like developer-written documentation
- Remove 'Questions Addressed' section
- Simplify testing checklist format
- Created pyproject.toml with build system configuration and project metadata
- Migrated all metadata from setup.py to pyproject.toml
- Updated Dockerfile to install package from pyproject.toml during build
- Updated documentation (README.md, QUICKSTART.md, DEPLOYMENT_REQUIREMENTS.md)
- Maintained backward compatibility with setup.py

Fixes #45
- Created credential masking utility (app/utils/credential_masking.py)
  - mask_credential(): Masks individual credentials (shows last 4 chars)
  - mask_string(): Masks credentials in text strings
  - mask_dict(): Masks credentials in dictionaries
  - safe_log_message(): Creates safe log messages
  - mask_exception_message(): Masks exception messages

- Fixed all logging statements to mask credentials:
  - app/utils/config.py: Fixed error logging
  - app/models/llm_provider.py: Fixed all error logging
  - app/models/unified_qa.py: Fixed all error logging
  - app/models/gemini_qa.py: Fixed all error logging
  - app/services/data_retrieval.py: Fixed 12 error logging instances
  - app/api/routers/system.py: Fixed 10 error logging instances
  - app/api/routers/bugsigdb_analysis.py: Fixed error logging
  - app/api/routers/bugsigdb_analysis_v2.py: Fixed 5 error logging instances
  - app/api/routers/study_analysis.py: Fixed error logging
  - app/api/utils/api_utils.py: Fixed error logging
  - app/api/app.py: Fixed global exception handler

- Fixed error messages to not expose credentials
- Added comprehensive test suite (tests/test_credential_masking.py)
- Security audit completed for all critical files

Fixes #46
@RonaldRonnie RonaldRonnie self-assigned this Dec 31, 2025
@RonaldRonnie RonaldRonnie merged commit bf54263 into main Jan 2, 2026
2 checks passed
@RonaldRonnie RonaldRonnie deleted the issue/46-api-key-masking branch January 2, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement API key masking in logs and error messages

1 participant