Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply @yoff's suggestion
  • Loading branch information
haby0 committed Sep 22, 2021
commit 6c07a3e260724df620467f3e05045fab56e9441b
16 changes: 8 additions & 8 deletions python/ql/src/experimental/semmle/python/frameworks/Log.qll
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ private module log {

override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result = this.getArg(0)
result in [this.getArg(_), this.getArgByName(_) ] // this includes the arg named "msg"
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result = this.getArg(1)
result in [this.getArg(any(int i | i > 0)), this.getArgByName(any(string s | s != "level"))]
}
Comment on lines +38 to +44
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result = this.getArg(0)
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result = this.getArg(1)
}
override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result in [this.getArg(_), this.getArgByName(_) ] // this includes the arg named "msg"
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result in [this.getArg(any(int i | i > 0)), this.getArgByName(any(string s | s != "level")]
}

I think my previous comment was a bit unclear, it should be something like the above.

If you have a signature like

warning(msg, *args, **kwargs)

you can call it with

warning("msg", "arg1", "arg2", kwarg1="kwarg1", kwargs="kwarg2")

and all of these arguments seem to end up in the log.

}

Expand All @@ -61,10 +61,10 @@ private module log {

override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result = this.getArg(0)
result in [this.getArg(_), this.getArgByName(_) ] // this includes the arg named "msg"
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result = this.getArg(1)
result in [this.getArg(any(int i | i > 0)), this.getArgByName(any(string s | s != "level"))]
}
}

Expand All @@ -84,10 +84,10 @@ private module log {

override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result = this.getArg(0)
result in [this.getArg(_), this.getArgByName(_) ] // this includes the arg named "msg"
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result = this.getArg(1)
result in [this.getArg(any(int i | i > 0)), this.getArgByName(any(string s | s != "level"))]
}
}

Expand All @@ -109,10 +109,10 @@ private module log {

override DataFlow::Node getAnInput() {
this.getFunction().(DataFlow::AttrRead).getAttributeName() != "log" and
result = this.getArg(0)
result in [this.getArg(_), this.getArgByName(_) ] // this includes the arg named "msg"
or
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "log" and
result = this.getArg(1)
result in [this.getArg(any(int i | i > 0)), this.getArgByName(any(string s | s != "level"))]
}
}
}