Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having predicate call external tool? #17265

Open
Manouchehri opened this issue Aug 20, 2024 · 1 comment
Open

Having predicate call external tool? #17265

Manouchehri opened this issue Aug 20, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Manouchehri
Copy link

Is there a way, directly or indirectly, to have a CodeQL query use an external tool?

predicate isCurrentYear(string year) {
  year = cmd("date +%Y")
}
@Manouchehri Manouchehri added the question Further information is requested label Aug 20, 2024
@aibaars
Copy link
Contributor

aibaars commented Aug 21, 2024

There is no direct way. However, you can

  • define an external predicate,
  • 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.

@rvermeulen rvermeulen added awaiting-response The CodeQL team is awaiting further input or clarification from the original reporter of this issue. and removed awaiting-response The CodeQL team is awaiting further input or clarification from the original reporter of this issue. labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants