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

Failed to run query: The query depends on an extensional predicate selectedSourceColumn which has not been defined. #18227

Open
Wowhere opened this issue Dec 5, 2024 · 3 comments
Labels
question Further information is requested

Comments

@Wowhere
Copy link

Wowhere commented Dec 5, 2024

I`am trying to print CFG for my source code by running command:
codeql database analyze testdb C:\sast\codeql-main\csharp\ql\lib\printCfg.ql --format=dot --output=result1.dot

and I`am receiving error

"Failed to run query: The query depends on an extensional predicate selectedSourceColumn which has not been defined."

As i read in the docs, selectedSourceColumn is a predicate which can be used only in IDE (VS Code) but i cant find how to specify file with source code in VS Code (CodeQL plugin GUI doesnt have button like 'select one file for query' or kinda that).

My questions:

  1. How to launch printCfg.ql in IDE (VS Code)?
  2. Is it possible to change printCfg.ql query (i think about redefining selectedSourceColumn ) to lauch in CLI against source code?
@Wowhere Wowhere added the question Further information is requested label Dec 5, 2024
@hvitved
Copy link
Contributor

hvitved commented Dec 6, 2024

Hi

  • How to launch printCfg.ql in IDE (VS Code)?

I think you may have to opt into Canary Mode in order for this to work. This is done by adding

"codeQL.canary": true,

to your VS Code settings.json file. After that, you should be able to run CodeQL: View CFG on source files inside the loaded DB (just like you can already now run CodeQL: View AST).

  • Is it possible to change printCfg.ql query (i think about redefining selectedSourceColumn ) to lauch in CLI against source code?

Yes, as you suggest, you can simply redefine the predicates selectedSourceFile, selectedSourceLine, and selectedSourceColumn in order to restrict it to the methods that you want to print CFG for.

@Wowhere
Copy link
Author

Wowhere commented Dec 6, 2024

  1. I added "codeQL.canary": true to settings.json file in <project_folder>.vscode\settings.json but i dont see "View CFG" button in CodeQL Extension

image

  1. I cant figure out how to redefine selectedSourceFile and other predicates, i cant find any examples of redefining in GitHub.

@hvitved
Copy link
Contributor

hvitved commented Dec 9, 2024

  1. i dont see "View CFG" button in CodeQL Extension

Sorry, I wasn't clear: There is no button, so you need to run the command manually using CMD+SHIFT+P (on Mac), and you need to have a source file from the DB open (just like you need in order to be able to click the View AST button).

2. I cant figure out how to redefine selectedSourceFile and other predicates, i cant find any examples of redefining in GitHub.

What I meant was that you need to edit the query file yourself.

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

2 participants