Merge pull request #3478 from github/robertbrignull/token-query
Simplify query now we've deleted withInheritedProgress
This commit is contained in:
28
.github/codeql/queries/ProgressBar.qll
vendored
28
.github/codeql/queries/ProgressBar.qll
vendored
@@ -1,36 +1,16 @@
|
|||||||
import javascript
|
import javascript
|
||||||
|
|
||||||
abstract class ProgressBar extends CallExpr {
|
class WithProgressCall extends CallExpr {
|
||||||
ProgressBar() { any() }
|
WithProgressCall() { this.getCalleeName() = "withProgress" }
|
||||||
|
|
||||||
abstract Function getCallback();
|
|
||||||
|
|
||||||
abstract ObjectExpr getOptions();
|
|
||||||
|
|
||||||
predicate usesToken() { exists(this.getTokenParameter()) }
|
predicate usesToken() { exists(this.getTokenParameter()) }
|
||||||
|
|
||||||
Parameter getTokenParameter() { result = this.getCallback().getParameter(1) }
|
Parameter getTokenParameter() { result = this.getArgument(0).(Function).getParameter(1) }
|
||||||
|
|
||||||
Property getCancellableProperty() { result = this.getOptions().getPropertyByName("cancellable") }
|
Property getCancellableProperty() { result = this.getArgument(1).(ObjectExpr).getPropertyByName("cancellable") }
|
||||||
|
|
||||||
predicate isCancellable() {
|
predicate isCancellable() {
|
||||||
this.getCancellableProperty().getInit().(BooleanLiteral).getBoolValue() =
|
this.getCancellableProperty().getInit().(BooleanLiteral).getBoolValue() =
|
||||||
true
|
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) }
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
import javascript
|
import javascript
|
||||||
import ProgressBar
|
import ProgressBar
|
||||||
|
|
||||||
from ProgressBar t
|
from WithProgressCall t
|
||||||
where not t.isCancellable() and t.usesToken()
|
where not t.isCancellable() and t.usesToken()
|
||||||
select t,
|
select t,
|
||||||
"The $@ should not be used when the progress bar is not cancellable. Either stop using the $@ or mark the progress bar as cancellable.",
|
"The $@ should not be used when the progress bar is not cancellable. Either stop using the $@ or mark the progress bar as cancellable.",
|
||||||
|
|||||||
2
.github/codeql/queries/token-not-used.ql
vendored
2
.github/codeql/queries/token-not-used.ql
vendored
@@ -13,6 +13,6 @@
|
|||||||
import javascript
|
import javascript
|
||||||
import ProgressBar
|
import ProgressBar
|
||||||
|
|
||||||
from ProgressBar t
|
from WithProgressCall t
|
||||||
where t.isCancellable() and not t.usesToken()
|
where t.isCancellable() and not t.usesToken()
|
||||||
select t, "This progress bar is $@ but the token is not used. Either use the token or mark the progress bar as not cancellable.", t.getCancellableProperty(), "cancellable"
|
select t, "This progress bar is $@ but the token is not used. Either use the token or mark the progress bar as not cancellable.", t.getCancellableProperty(), "cancellable"
|
||||||
|
|||||||
Reference in New Issue
Block a user