mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
count both named and positional arguments in the WithArity filter
This commit is contained in:
@@ -349,8 +349,8 @@ module API {
|
||||
result.getAnImmediateUse() = this
|
||||
}
|
||||
|
||||
/** Gets the number of arguments of this call. */
|
||||
int getNumArgument() { result = count(this.getArg(_)) }
|
||||
/** Gets the number of arguments of this call. Both positional and named arguments are counted. */
|
||||
int getNumArgument() { result = count([this.getArg(_), this.getArgByName(_)]) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,8 @@ isSink
|
||||
| test.py:85:8:85:53 | ControlFlowNode for Attribute() | test-sink |
|
||||
| test.py:86:8:86:60 | ControlFlowNode for Attribute() | test-sink |
|
||||
| test.py:87:8:87:67 | ControlFlowNode for Attribute() | test-sink |
|
||||
| test.py:89:21:89:23 | ControlFlowNode for one | test-source |
|
||||
| test.py:90:25:90:27 | ControlFlowNode for one | test-source |
|
||||
isSource
|
||||
| test.py:3:5:3:15 | ControlFlowNode for getSource() | test-source |
|
||||
| test.py:9:8:9:14 | ControlFlowNode for alias() | test-source |
|
||||
|
||||
@@ -84,4 +84,9 @@ mySink(Steps.preserveArgZeroAndTwo("foo", "bar", getSource())) # FLOW
|
||||
|
||||
mySink(Steps.preserveAllButFirstArgument(getSource())) # NO FLOW
|
||||
mySink(Steps.preserveAllButFirstArgument("foo", getSource())) # FLOW
|
||||
mySink(Steps.preserveAllButFirstArgument("foo", "bar", getSource())) # FLOW
|
||||
mySink(Steps.preserveAllButFirstArgument("foo", "bar", getSource())) # FLOW
|
||||
|
||||
CallFilter.arityOne(one) # match
|
||||
CallFilter.arityOne(one=one) # match
|
||||
CallFilter.arityOne(one, two=two) # NO match
|
||||
CallFilter.arityOne(one=one, two=two) # NO match
|
||||
|
||||
@@ -41,7 +41,7 @@ class Sinks extends ModelInput::SinkModelCsv {
|
||||
"testlib;;Member[Args].Member[lastarg].Argument[N-1];test-source", //
|
||||
"testlib;;Member[Args].Member[nonFist].Argument[1..];test-source", //
|
||||
// callsite filter.
|
||||
"testlib;;Member[CallFilter].Member[arityOne].WithArity[1].Argument[0..];test-source", //
|
||||
"testlib;;Member[CallFilter].Member[arityOne].WithArity[1].Argument[any];test-source", //
|
||||
"testlib;;Member[CallFilter].Member[twoOrMore].WithArity[2..].Argument[0..];test-source", //
|
||||
// testing non-positional arguments
|
||||
"testlib;;Member[ArgPos].Member[selfThing].Argument[self];test-source", //
|
||||
|
||||
Reference in New Issue
Block a user