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. 5: Clear-text logging of sensitive information #153

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/5

To fix the problem, we should avoid logging sensitive information directly. Instead, we can log a generic error message without including the secret_name or the detailed error message e. This ensures that sensitive information is not exposed in the logs.

  • Replace the logging statements on lines 83 and 87 to avoid including secret_name and e.
  • Use a generic error message that does not reveal 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 removing specific details from 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 could potentially expose secret names or detailed error information with generic error messages.

Sequence diagram for error handling in get_secret function

sequenceDiagram
    participant User
    participant System
    participant AWS

    User->>System: Request secret
    System->>AWS: Retrieve secret
    AWS-->>System: Secret or error
    alt Secret retrieved
        System-->>User: Return secret
    else Error occurred
        System->>System: Log "Failed retrieving of secret. An error occurred."
        System-->>User: Return default
    end

    alt No credentials
        System->>System: Log "No credentials error occurred while retrieving secret."
        System-->>User: Return default
    end
Loading

File-Level Changes

Change Details Files
Replaced specific error logging with generic messages to avoid exposing sensitive information
  • Modified error logging for RetrieveSecretException to use a generic message
  • Updated error logging for NoCredentialsError to use a generic message
  • Removed references to secret_name and detailed error messages from log statements
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..49c7ae3. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython❌ Failure
❗ 1 occurence introduced
View 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