Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 4 additions & 24 deletions .github/codeql/queries/ProgressBar.qll
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
import javascript

abstract class ProgressBar extends CallExpr {
ProgressBar() { any() }

abstract Function getCallback();

abstract ObjectExpr getOptions();
class WithProgressCall extends CallExpr {
WithProgressCall() { this.getCalleeName() = "withProgress" }

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() {
this.getCancellableProperty().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) }
}
2 changes: 1 addition & 1 deletion .github/codeql/queries/progress-not-cancellable.ql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import javascript
import ProgressBar

from ProgressBar t
from WithProgressCall t
where not t.isCancellable() and t.usesToken()
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.",
Expand Down
2 changes: 1 addition & 1 deletion .github/codeql/queries/token-not-used.ql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
import javascript
import ProgressBar

from ProgressBar t
from WithProgressCall t
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"