codeql
codeql copied to clipboard
Having predicate call external tool?
trafficstars
Is there a way, directly or indirectly, to have a CodeQL query use an external tool?
predicate isCurrentYear(string year) {
year = cmd("date +%Y")
}
There is no direct way. However, you can
- define an
externalpredicate, - run the command before running the query
- save the command output in a CSV file
- pass the flag
--external=<pred>=<file.csv>when running the query
$ codeql database run-queries --help
...
--external=<pred>=<file.csv>
A CSV file that contains rows for external predicate <pred>. Multiple --external options can be supplied.
Hi @Manouchehri,
I'm closing this issue because it seems @aibaars provided you with next steps to import data into a query at runtime.
An alternative to external predicates are data extensions.
If you have further questions, feel free to re-open this issue.