SG-44103 Mask secrets in git descriptors URLs - #1131
SG-44103 Mask secrets in git descriptors URLs#1131carlos-villavicencio-adsk wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (63.38%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1131 +/- ##
==========================================
- Coverage 80.09% 80.08% -0.02%
==========================================
Files 203 203
Lines 19537 19596 +59
==========================================
+ Hits 15649 15694 +45
- Misses 3888 3902 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| elif isinstance(cmd, str): | ||
| # For string commands, we need to be more careful | ||
| # Split on spaces but preserve quoted strings | ||
| import shlex |
There was a problem hiding this comment.
Why not importing this at the top of the file?
| return subprocess_check_output(*args, **kwargs) | ||
|
|
||
|
|
||
| def _sanitize_url(url): |
There was a problem hiding this comment.
Can you add Python typing info for all new methods, please?
| if isinstance(exc, SubprocessCalledProcessError): | ||
| sanitized_cmd = _sanitize_command(exc.cmd) | ||
| # Create a new exception with the sanitized command | ||
| new_exc = SubprocessCalledProcessError( | ||
| exc.returncode, sanitized_cmd, output=exc.output | ||
| ) | ||
| # Preserve the original traceback | ||
| return new_exc | ||
| return exc |
There was a problem hiding this comment.
Fail first?
| if isinstance(exc, SubprocessCalledProcessError): | |
| sanitized_cmd = _sanitize_command(exc.cmd) | |
| # Create a new exception with the sanitized command | |
| new_exc = SubprocessCalledProcessError( | |
| exc.returncode, sanitized_cmd, output=exc.output | |
| ) | |
| # Preserve the original traceback | |
| return new_exc | |
| return exc | |
| if isinstance(exc, SubprocessCalledProcessError): | |
| return exc | |
| sanitized_cmd = _sanitize_command(exc.cmd) | |
| # Create a new exception with the sanitized command | |
| new_exc = SubprocessCalledProcessError( | |
| exc.returncode, sanitized_cmd, output=exc.output | |
| ) | |
| # Preserve the original traceback | |
| return new_exc |
| ) | ||
| except Exception as e: | ||
| # Sanitize any credentials that might be in the exception or path | ||
| from ...util.process import SubprocessCalledProcessError |
There was a problem hiding this comment.
Why importing here and not top of the file?
This pull request introduces significant improvements to the handling of sensitive information in Git-related descriptors by ensuring that credentials (such as usernames, passwords, or tokens) are sanitized from logs, error messages, and string representations. The changes add utility functions for sanitizing URLs and exceptions, and update several methods and exception handlers to use these utilities, thereby reducing the risk of leaking secrets in logs or error outputs.
These changes collectively improve the security and robustness of the codebase by systematically preventing accidental exposure of sensitive credentials in logs and error messages.