-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go: Adds sources and sinks to go/clear-text-logging
#15268
Go: Adds sources and sinks to go/clear-text-logging
#15268
Conversation
|
837a6bb
to
e587ca7
Compare
@@ -8,7 +8,7 @@ import go | |||
module Log { | |||
private class LogFunction extends Function { | |||
LogFunction() { | |||
exists(string fn | fn.matches(["Fatal%", "Panic%", "Print%"]) | | |||
exists(string fn | fn.matches(["Fatal%", "Panic%", "Print%", "Output"]) | |
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.
Note that, because of this line, any argument is considered a message component (and hence a sink to two queries), including calldepth int
.
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.
You're right. I had to follow a slightly more complicated approach and introduce a new class instead of modifying the existing one to take this into account. See cf94554.
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.
One downside of the way you've done it is that there are now lots more instances of the LogCall
class. An approach we've used elsewhere is to add a field containing the index of the first message component, and then getAMessageComponent
by getSyntacticArgument(i)
where i >=
this index. This code is a good example.
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.
Good point. What about now?
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.
Ideally you would update the tests to cover the new source, new sink and new barrier
e587ca7
to
cf94554
Compare
I added a bunch of missing tests, not only for my new sink. The new barrier is hard to test because it only affects sources, but the test expectations only care about sinks currently (although we lose a few edges in certain test cases, so that may count as a test?). Also, it felt slightly overkill to test all the possible variations of |
Barrier-in addition removes an overlapping path
co-authored-by: Owen Mansel-Chan <[email protected]>
cf94554
to
ea21829
Compare
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.
I was actually thinking you could put Output
as part of LogFunction
and have firstPrintedArg
be a field on that, with a getter I suppose, and use the getter in LogCall
. Then you don't need a new class just for Output
.
@@ -16,16 +16,32 @@ module Log { | |||
} | |||
} | |||
|
|||
private class LogOutput extends Method { | |||
LogOutput() { this.hasQualifiedName("log", "Logger", "Output") } |
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.
You should also model (and test) the top-level version.
ea21829
to
5e8c63c
Compare
It seemed weird to reference an Anyway, done in 5e8c63c. |
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.
Looks good. Thanks for improving the tests.
Handles
log.Output
as a logging sink, andsecretkey
(case insensitive) as a potentially sensitive variable name. It also adds a barrier-in for sources togo/clear-text-logging
, so that overlapping paths are removed.This adds coverage for CVE-2023-46742.