- Notifications
You must be signed in to change notification settings - Fork1.8k
Treat zap custom encoders as sanitizers for log-injection checks#20912
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Treat zap custom encoders as sanitizers for log-injection checks#20912
Conversation
d9379df to360014fCompareowen-mc commentedNov 25, 2025
This PR doesn't make much sense. I don't think the tests would pass. There is already a query called |
danielriddell21 commentedNov 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi@owen-mc thanks for looking. I am pretty new to codeql. So I will try and move all the stuff into the correct place when its ready. Am I okay to tag you when It is ready for a review? |
0aea3eb to997d300Comparedanielriddell21 commentedNov 25, 2025
My aim is to allow using a zap encoder with a sanitise within as a valid way to suppress a CWE 117 |
owen-mc commentedNov 25, 2025
Things are in the right place now, but the tests still don't make any sense. May I ask, are you using an LLM coding assistant? Yes, please tag me when you have got the tests passing locally on your machine, or you are stuck and need help with the CodeQL. |
| privatepredicateisSafeZapEncoder(Typet){ | ||
| exists(TypezapEncoder| | ||
| // Matches go.uber.org/zap/zapcore.JSONEncoder | ||
| zapEncoder.hasQualifiedName("go.uber.org/zap/zapcore","JSONEncoder")and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This type doesn't exist, at least according tohttps://pkg.go.dev/go.uber.org/zap/zapcore.
Uh oh!
There was an error while loading.Please reload this page.
Summary
Add an experimental CodeQL helper and query to treat custom zap encoders (types implementing go.uber.org/zap/zapcore.Encoder) as sanitizers for the purposes of log-injection detection. This reduces false positives where applications use a custom encoder to escape or sanitize log field values.
Notes for reviewers
Risks