Convert to an abstract class
This commit is contained in:
32
.github/codeql/queries/ProgressBar.qll
vendored
Normal file
32
.github/codeql/queries/ProgressBar.qll
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import javascript
|
||||
|
||||
abstract class ProgressBar extends CallExpr {
|
||||
ProgressBar() { any() }
|
||||
|
||||
abstract Function getCallback();
|
||||
|
||||
abstract ObjectExpr getOptions();
|
||||
|
||||
predicate usesToken() { this.getCallback().getNumParameter() >= 2 }
|
||||
|
||||
predicate isCancellable() {
|
||||
this.getOptions().getPropertyByName("cancellable").getInit().(BooleanLiteral).getBoolValue() =
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
class WithProgressCall extends ProgressBar {
|
||||
WithProgressCall() { this.getCalleeName() = "withProgress" }
|
||||
|
||||
override Function getCallback() { result = this.getArgument(0) }
|
||||
|
||||
override ObjectExpr getOptions() { result = this.getArgument(1) }
|
||||
}
|
||||
|
||||
class WithInheritedProgressCall extends ProgressBar {
|
||||
WithInheritedProgressCall() { this.getCalleeName() = "withInheritedProgress" }
|
||||
|
||||
override Function getCallback() { result = this.getArgument(1) }
|
||||
|
||||
override ObjectExpr getOptions() { result = this.getArgument(2) }
|
||||
}
|
||||
28
.github/codeql/queries/token-not-used.ql
vendored
28
.github/codeql/queries/token-not-used.ql
vendored
@@ -10,32 +10,8 @@
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import ProgressBar
|
||||
|
||||
class NewTokenSource extends CallExpr {
|
||||
NewTokenSource() {
|
||||
this.getCalleeName() = "withProgress" or this.getCalleeName() = "withInheritedProgress"
|
||||
}
|
||||
|
||||
Function getCallback() {
|
||||
this.getCalleeName() = "withProgress" and result = this.getArgument(0)
|
||||
or
|
||||
this.getCalleeName() = "withInheritedProgress" and result = this.getArgument(1)
|
||||
}
|
||||
|
||||
ObjectExpr getOptions() {
|
||||
this.getCalleeName() = "withProgress" and result = this.getArgument(1)
|
||||
or
|
||||
this.getCalleeName() = "withInheritedProgress" and result = this.getArgument(2)
|
||||
}
|
||||
|
||||
predicate usesToken() { this.getCallback().getNumParameter() >= 2 }
|
||||
|
||||
predicate isCancellable() {
|
||||
this.getOptions().getPropertyByName("cancellable").getInit().(BooleanLiteral).getBoolValue() =
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
from NewTokenSource t
|
||||
from ProgressBar t
|
||||
where t.isCancellable() and not t.usesToken()
|
||||
select t, "This progress bar is cancelable but the token is not used"
|
||||
|
||||
Reference in New Issue
Block a user