diff --git a/.github/codeql/queries/ProgressBar.qll b/.github/codeql/queries/ProgressBar.qll index d9e0d04c0..289140f6f 100644 --- a/.github/codeql/queries/ProgressBar.qll +++ b/.github/codeql/queries/ProgressBar.qll @@ -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) } -} diff --git a/.github/codeql/queries/progress-not-cancellable.ql b/.github/codeql/queries/progress-not-cancellable.ql index 2cb1abd4c..3ed2a2a1d 100644 --- a/.github/codeql/queries/progress-not-cancellable.ql +++ b/.github/codeql/queries/progress-not-cancellable.ql @@ -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.", diff --git a/.github/codeql/queries/token-not-used.ql b/.github/codeql/queries/token-not-used.ql index 66d153bec..947138f00 100644 --- a/.github/codeql/queries/token-not-used.ql +++ b/.github/codeql/queries/token-not-used.ql @@ -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"