GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Python: promote log injection by yoff · Pull Request #7735 · github/codeql Conversation
|
| | | ||
| this = Logger::instance().getMember(method).getACall() | ||
| or | ||
| this = API::moduleImport("logging").getMember(method).getACall() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't agree about this removal. I see that API::moduleImport("logging") is now modeled as a LoggerInstance... but that is not true, these are helper methods defined on the module leve.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is there value in modelling instances specifically? Or could we just rename instance to something like loggingMethodProvider?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Reverted to previous modelling approach as discussed offline.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| class ReplaceLineBreaksSanitizer extends Sanitizer, DataFlow::CallCfgNode { | ||
| ReplaceLineBreaksSanitizer() { | ||
| this.getFunction().(DataFlow::AttrRead).getAttributeName() = "replace" and | ||
| this.getArg(0).asExpr().(StrConst).getText() in ["\r\n", "\n"] | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This sanitizer check seems a bit weak. What if it only did text.replace("\r\n", "\n")? I guess it's not trivial to write a sanitizer that knows we've eliminated both, so maybe this is ok? (what are your thoughts on this)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have had the same concerns from the beginning.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to have a small comment in the code to explain this dilemma, and explain why the solution implemented was deemed ok.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| module Logger { | ||
| /** | ||
| * An instance of `logging.Logger`. Extend this class to model new instances. | ||
| * Most major frameworks will provide a logger instance as a class attribute. | ||
| */ | ||
| abstract class LoggerInstance extends API::Node { | ||
| override string toString() { result = "logger" } | ||
| } | ||
|
|
||
| /** Gets a reference to the `logging.Logger` class or any subclass. */ | ||
| API::Node subclassRef() { | ||
| result = API::moduleImport("logging").getMember("Logger").getASubclass*() | ||
| } | ||
|
|
||
| /** Gets a reference to an instance of `logging.Logger` or any subclass. */ | ||
| API::Node instance() { | ||
| result instanceof LoggerInstance | ||
| or | ||
| result = subclassRef().getReturn() | ||
| or | ||
| result = API::moduleImport("logging") | ||
| or | ||
| result = API::moduleImport("logging").getMember("root") | ||
| or | ||
| result = API::moduleImport("logging").getMember("getLogger").getReturn() | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see that I created this non-standard setup with just using API::Node, but now that we're exposing it more publicly, we need to rewrite this to use the standard library modeling setup with InstanceSource and type-tracking (which has a snippet, so it's quite easy).
Looking over the code again, I don't quite know why I did this in the first place. LoggerLogCall can easily be written with the standard approach together with DataFlow::MethodCallNode 🤷
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Surely it is nicer, if we can get away with using an API:Node?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Moved to standard setup as discussed offline.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I did not even consider that we would have such options, I just checked that it looked reasonable :-) Thanks for the heads-up! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
Given both the original FP score and our concerns regarding sanitizers, `@precision medium`, which is aligned with other languages, feels appropriate.
(combining the Java version and the JS version)
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nice updates so far 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Two minor things, then we should be good to go 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| class ReplaceLineBreaksSanitizer extends Sanitizer, DataFlow::CallCfgNode { | ||
| ReplaceLineBreaksSanitizer() { | ||
| this.getFunction().(DataFlow::AttrRead).getAttributeName() = "replace" and | ||
| this.getArg(0).asExpr().(StrConst).getText() in ["\r\n", "\n"] | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to have a small comment in the code to explain this dilemma, and explain why the solution implemented was deemed ok.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
I actually got a bit annoyed with the explanation. Do let me know if we can live with postponing this, or if I should attempt a rewrite in this PR.. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to have a small comment in the code to explain this dilemma, and explain why the solution implemented was deemed ok.
I actually got a bit annoyed with the explanation. Do let me know if we can live with postponing this, or if I should attempt a rewrite in this PR..
Thanks for writing this 👍 I think it's very nice that the next person thinking about this code can just read the comment explaining we thought about this 👍 I have a small suggestion for writing it, but otherwise LGTM 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…omizations.qll Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
…omizations.qll Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
Trailing whitespace is a bit too easy with the ```suggestions through the UI :|
|
Thanks for the auto format fix :-) (it confused me for a bit that I could not get it to change the file locally 😁) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Python 3 Language tests failed seems to have been flaky, so I've rerun them. 🤞 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Tests are all good, Actually, we should do a performance test for this 😳 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Performance does looks fine, so in it goes 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.