Skip to content
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

Fix code scanning alert no. 6: Clear-text logging of sensitive information #151

Draft
wants to merge 1 commit into
base: old/develop
Choose a base branch
from

Conversation

gitworkflows
Copy link
Contributor

@gitworkflows gitworkflows commented Oct 23, 2024

Fixes https://github.com/khulnasoft/ThreatMatrix/security/code-scanning/6

To fix the problem, we should avoid logging sensitive information directly. Instead, we can log a generic error message that does not include the secret_name. This way, we maintain the functionality of logging errors without exposing sensitive data.

  • Replace the logging statements that include secret_name with more generic messages.
  • Ensure that the new log messages still provide enough context to understand that an error occurred without revealing sensitive information.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Summary by Sourcery

Bug Fixes:

  • Prevent clear-text logging of sensitive information by replacing specific secret names in log messages with generic error messages.

…ation

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: gitworkflows <[email protected]>
Copy link

sourcery-ai bot commented Oct 23, 2024

Reviewer's Guide by Sourcery

This pull request addresses a code scanning alert by modifying the error logging in the get_secret function to prevent clear-text logging of sensitive information. The changes focus on replacing specific error messages that include the secret_name with more generic error messages that maintain context without exposing sensitive data.

Sequence diagram for error logging in get_secret function

sequenceDiagram
    participant User
    participant get_secret
    participant aws_get_secret
    participant logging

    User->>get_secret: Call get_secret(secret_name)
    get_secret->>aws_get_secret: Retrieve secret
    aws_get_secret-->>get_secret: Return secret or throw RetrieveSecretException
    alt RetrieveSecretException
        get_secret->>logging: Log "Failed retrieving secret. Error: {e}."
    end
    aws_get_secret-->>get_secret: Return secret or throw NoCredentialsError
    alt NoCredentialsError
        get_secret->>logging: Log "Error: {e}. Failed to retrieve secret."
    end
Loading

File-Level Changes

Change Details Files
Modify error logging to remove sensitive information
  • Replace specific error message including secret_name with a generic message for RetrieveSecretException
  • Update error message for NoCredentialsError to remove reference to specific secret
  • Maintain error context while removing sensitive data from logs
threat_matrix/secrets.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

deepsource-io bot commented Oct 23, 2024

Here's the code health analysis summary for commits 2d9ca9e..de8dc41. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@gitworkflows gitworkflows changed the base branch from master to develop October 23, 2024 00:53
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.

1 participant