Extend logi to support additional logging libraries#42
Merged
Conversation
logi to support additional logging libraries
There was a problem hiding this comment.
Pull Request Overview
This PR extends the logi analyzer to detect log injection in additional Go logging libraries and adds tests for each new sink.
- Added support for
glog,go-hclog,logrus, andzapsinks ininjection.go - Updated import detection to recursively walk dependency graph
- Added test cases under
testdatafor each new logging library
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| log/injection/injection.go | Added new sinks for multiple logging libraries and recursive import check |
| log/injection/injection_test.go | Added TestH, TestI, TestJ, TestK, and TestL to cover new libraries |
| log/injection/testdata/src/h/main.go … /l/main.go | Test fixtures for glog, zap, logrus, and hclog usage |
| README.md | Updated logi description to list the newly supported packages |
Comments suppressed due to low confidence (2)
log/injection/injection.go:215
- [nitpick] The error message is generic; consider including the specific sink or field name to give more context, e.g.,
potential log injection in %s.
pass.Reportf(result.SinkValue.Pos(), "potential log injection")
log/injection/injection_test.go:39
- You’ve registered sinks for method-based loggers like (*logrus.Logger).Info and (*zap.SugaredLogger).Info but haven’t added tests for those method receivers. Consider adding table-driven tests to cover those cases.
func TestH(t *testing.T) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request extends the functionality of the
logianalyzer to detect potential log injection vulnerabilities across several popular logging libraries. It introduces support forgithub.com/golang/glog,github.com/hashicorp/go-hclog,github.com/sirupsen/logrus, andgo.uber.org/zap. Additionally, it improves the analysis logic and adds comprehensive test cases for the new logging libraries.https://chatgpt.com/codex/tasks/task_e_686bdcbf3d10833184af56bd6a0f8798