mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Don't allow getParameter(-1) for BoundMethodValue
As per discussion in the PR
This commit is contained in:
@@ -438,10 +438,18 @@ class BoundMethodObjectInternal extends CallableObjectInternal, TBoundMethod {
|
||||
PointsTo::pointsTo(result.getFunction(), ctx, this, _)
|
||||
}
|
||||
|
||||
override NameNode getParameter(int n) { result = this.getFunction().getParameter(n + 1) }
|
||||
/** Gets the parameter node that will be used for `self`. */
|
||||
NameNode getSelfParameter() { result = this.getFunction().getParameter(0) }
|
||||
|
||||
override NameNode getParameter(int n) {
|
||||
result = this.getFunction().getParameter(n + 1) and
|
||||
// don't return the parameter for `self` at `n = -1`
|
||||
n >= 0
|
||||
}
|
||||
|
||||
override NameNode getParameterByName(string name) {
|
||||
result = this.getFunction().getParameterByName(name)
|
||||
result = this.getFunction().getParameterByName(name) and
|
||||
not result = this.getSelfParameter()
|
||||
}
|
||||
|
||||
override predicate neverReturns() { this.getFunction().neverReturns() }
|
||||
|
||||
@@ -454,6 +454,9 @@ class BoundMethodValue extends CallableValue {
|
||||
* The value for `o` in `o.func`.
|
||||
*/
|
||||
Value getSelf() { result = this.(BoundMethodObjectInternal).getSelf() }
|
||||
|
||||
/** Gets the parameter node that will be used for `self`. */
|
||||
NameNode getSelfParameter() { result = this.(BoundMethodObjectInternal).getSelfParameter() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
| Function f | 1 | ControlFlowNode for arg1 |
|
||||
| Function f | 2 | ControlFlowNode for arg2 |
|
||||
| Method(Function C.n, C()) | 0 | ControlFlowNode for arg1 |
|
||||
| Method(Function C.n, C()) | -1 | ControlFlowNode for self |
|
||||
| Method(Function C.n, class C) | 0 | ControlFlowNode for arg1 |
|
||||
| Method(Function C.n, class C) | -1 | ControlFlowNode for self |
|
||||
| Method(Function f, C()) | 0 | ControlFlowNode for arg1 |
|
||||
| Method(Function f, C()) | 1 | ControlFlowNode for arg2 |
|
||||
| Method(Function f, C()) | -1 | ControlFlowNode for arg0 |
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
| Function f | arg1 | ControlFlowNode for arg1 |
|
||||
| Function f | arg2 | ControlFlowNode for arg2 |
|
||||
| Method(Function C.n, C()) | arg1 | ControlFlowNode for arg1 |
|
||||
| Method(Function C.n, C()) | self | ControlFlowNode for self |
|
||||
| Method(Function C.n, class C) | arg1 | ControlFlowNode for arg1 |
|
||||
| Method(Function C.n, class C) | self | ControlFlowNode for self |
|
||||
| Method(Function f, C()) | arg0 | ControlFlowNode for arg0 |
|
||||
| Method(Function f, C()) | arg1 | ControlFlowNode for arg1 |
|
||||
| Method(Function f, C()) | arg2 | ControlFlowNode for arg2 |
|
||||
|
||||
Reference in New Issue
Block a user