fix: leak of keys on logs during exception#2100
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai check the risk of merging this PR will it effect any functionality? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr view 2100 --repo langflow-ai/openrag --json title,body,files,additions,deletions,changedFiles
echo "-----DIFF-----"
gh pr diff 2100 --repo langflow-ai/openragLength of output: 9614 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "structlog" -g "*.txt" -g "*.toml" -g "*.lock" -g "*.cfg" | head -50
echo "---"
fd -e py logging_config.py
echo "---"
cat src/utils/logging_config.py | sed -n '1,60p'
echo "---rest---"
sed -n '120,180p' src/utils/logging_config.pyLength of output: 574 🏁 Script executed: #!/bin/bash
set +e
rg -n "structlog" pyproject.toml requirements*.txt 2>/dev/null
echo "---files---"
fd -e py -a logging_config.py
echo "---content---"
sed -n '1,200p' src/utils/logging_config.py
echo "---pyproject---"
find . -maxdepth 2 -iname "pyproject.toml" -exec cat {} \;Length of output: 12921
Breakdown of the 5 changed files:
Why this is safe:
Only trade-off to be aware of: if any log dashboards (ELK/Datadog/Splunk) or alerting rules specifically parse Net: merging should not affect any existing functionality other than removing local-variable data from exception tracebacks in production JSON logs, which is the intended fix. (๑˃̵ᴗ˂̵)و |
|
@coderabbitai any change sin production env required ? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr diff 2100 --repo langflow-ai/openrag -- src/utils/logging_config.pyLength of output: 448 🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr diff 2100 --repo langflow-ai/openrag | sed -n '/logging_config.py/,/diff --git/p'Length of output: 3647
The only thing to be aware of operationally (not a required change, just informational): once deployed, production JSON exception logs will no longer include the |
mpawlow
left a comment
There was a problem hiding this comment.
Code Review 1
- ✅ Approved / LGTM 🚀
c0a8435
into
release-saas-ga-0.6.2
This pull request strengthens the application's protection against leaking sensitive information (such as API keys and JWTs) into logs. It does so by improving documentation, updating logging configuration to avoid serializing local variables in exception tracebacks, and adding unit tests to ensure secrets are never exposed in production logs.
Logging and Security Improvements:
src/agent.py,src/services/chat_service.py, andsrc/utils/langflow_headers.pyto warn developers never to log or pass header dictionaries (which may contain secrets) to loggers, and to use sanitization if logging is required. [1] [2] [3] [4] [5]Logging Configuration Changes:
configure_logginginsrc/utils/logging_config.pyto ensure production JSON logs do not serialize exception-frame locals, which could leak secrets. Now usesExceptionRendererwithshow_locals=Falsefor structured tracebacks.Testing and Validation:
tests/unit/utils/test_logging_config.pyto verify that JSON exception logs do not leak local variables (such as API keys) and still include necessary frame information for debugging.