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 secret removal which was also removing carriage returns and not supporting multiple URLs in single string #942

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

benoit74
Copy link
Collaborator

@benoit74 benoit74 commented Mar 12, 2024

Rationale

Fix #924 (and enabler for #936)

Changes

The logic to remove S3 secrets was not taking into account the fact that some dictionary keys (e.g. logs) might contain long strings with many S3 secrets to remove. It was also considering that the string is a URL, hence removing all carriage returns.

Logic has been fixed to take all this into account and properly continue to remove secrets.

Test cases have been supplemented with new test cases and assertion logic has be supplemented with a check of the whole response.

Password in network location is removed as well.

Secret replacement is now "--------" instead of "********" so that it is not replaced by url encoding / is part of the allowed chars in a URL/URI.

@benoit74 benoit74 self-assigned this Mar 12, 2024
@benoit74 benoit74 force-pushed the fix_secret_removal branch from 2b75298 to 8382219 Compare March 12, 2024 10:07
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.84%. Comparing base (05fb9cd) to head (6effbe8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #942      +/-   ##
==========================================
+ Coverage   87.82%   87.84%   +0.01%     
==========================================
  Files          93       93              
  Lines        5299     5307       +8     
==========================================
+ Hits         4654     4662       +8     
  Misses        645      645              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benoit74 benoit74 marked this pull request as ready for review March 12, 2024 10:12
@benoit74 benoit74 requested a review from rgaudin March 12, 2024 10:12
dispatcher/backend/src/routes/utils.py Outdated Show resolved Hide resolved
dispatcher/backend/src/routes/utils.py Outdated Show resolved Hide resolved
dispatcher/backend/src/routes/utils.py Show resolved Hide resolved
@benoit74 benoit74 force-pushed the fix_secret_removal branch from 94c2ebe to 76d0296 Compare March 12, 2024 12:48
- redact password which might be present in URL netloc
- rename the function to remove_url_secrets since it does not remove
  only S3 secret
- handle properly the reconstruction of URL query
- prefer urlsplit and urlunsplit - instead of urlparse - since this is
  the future / we do not need to separate parameters from parts
@benoit74 benoit74 force-pushed the fix_secret_removal branch from 76d0296 to 6effbe8 Compare March 12, 2024 12:49
@benoit74
Copy link
Collaborator Author

  • Change secret replacement so that it is not re-processed by urlencode in query parameters
    • Use -------- instead of ********
  • Enhance URL secrets removal
    • redact password which might be present in URL netlo
    • rename the function to remove_url_secrets since it does not remove only S3 secret
    • handle properly the reconstruction of URL query
    • prefer urlsplit and urlunsplit - instead of urlparse - since this is the future / we do not need to separate parameters from parts

@benoit74 benoit74 requested a review from rgaudin March 12, 2024 12:51
@benoit74 benoit74 merged commit 7c68b32 into main Mar 12, 2024
7 checks passed
@benoit74 benoit74 deleted the fix_secret_removal branch March 12, 2024 13:15
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.

Missing carriage returns in log output
2 participants