newrelic / newrelic-python-agent

New Relic Python Agent
https://docs.newrelic.com/docs/agents/python-agent
Apache License 2.0
178 stars 102 forks source link

Obfuscate License Keys in Logs #1031

Closed TimPansino closed 10 months ago

TimPansino commented 10 months ago

Overview

Testing

github-actions[bot] commented 10 months ago

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Elapsed time
❌ PYTHON bandit 4 2 5.03s
✅ PYTHON black 4 1 0 1.47s
✅ PYTHON flake8 4 0 0.57s
✅ PYTHON isort 4 1 0 0.25s
❌ PYTHON pylint 4 15 4.6s

See detailed report in MegaLinter reports _Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff_

_MegaLinter is graciously provided by OX Security_

codecov-commenter commented 10 months ago

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (9990e71) 81.07% compared to head (72c00a0) 81.07%.

Files Patch % Lines
newrelic/common/encoding_utils.py 90.00% 4 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1031 +/- ## ========================================== - Coverage 81.07% 81.07% -0.01% ========================================== Files 190 190 Lines 19594 19607 +13 Branches 3419 3424 +5 ========================================== + Hits 15886 15896 +10 - Misses 2727 2728 +1 - Partials 981 983 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

TimPansino commented 10 months ago

Thank you for making this change! It looks like we might still be missing a couple places in the code. Primarily the other thing to look out for is if the license key is added as a api-key header. I've noted one in a comment but here's another:

  • newrelic/bootstrap/sitecustomize.py: 137
log_message("initialize_agent = %r", bool(license_key or config_file))
bool(license_key or config_file)

This is cast to a bool, it's not printing the license key out. It's just logging whether the agent will be initialized or not as True/False.