Skip to content

Commit 16b9abe

Browse files
authored
Merge pull request #2220 from github/koesie10/update-unique-command-use-typed-commands
Add support for typed commands to CodeQL query
2 parents 7837f30 + f57bfb6 commit 16b9abe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/codeql/queries/unique-command-use.ql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@
7272

7373
override string getCommandName() { result = this.getArgument(0).(StringLiteral).getValue() }
7474
}
75+
76+
/**
77+
* A usage of a command from the typescript code, by calling `CommandManager.execute`.
78+
*/
79+
class CommandUsageCommandManagerMethodCallExpr extends CommandUsage, MethodCallExpr {
80+
CommandUsageCommandManagerMethodCallExpr() {
81+
this.getCalleeName() = "execute" and
82+
this.getReceiver().getType().unfold().(TypeReference).getTypeName().getName() = "CommandManager" and
83+
this.getArgument(0).(StringLiteral).getValue().matches("%codeQL%") and
84+
not this.getFile().getRelativePath().matches("extensions/ql-vscode/test/%")
85+
}
86+
87+
override string getCommandName() { result = this.getArgument(0).(StringLiteral).getValue() }
88+
}
7589

7690
/**
7791
* A usage of a command from any menu that isn't the command palette.

0 commit comments

Comments
 (0)