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

depends on 'codeql-python@*', but pack 'codeql-python' was not found #13364

Open
lilocruz opened this issue Jun 3, 2023 · 5 comments
Open

depends on 'codeql-python@*', but pack 'codeql-python' was not found #13364

lilocruz opened this issue Jun 3, 2023 · 5 comments
Labels
question Further information is requested

Comments

@lilocruz
Copy link

lilocruz commented Jun 3, 2023

Package was not found in the pack download cache

@lilocruz lilocruz added the question Further information is requested label Jun 3, 2023
@hmakholm
Copy link
Contributor

hmakholm commented Jun 6, 2023

Can you explain what you're doing to get this error message? Which command are you running? If you've written a qlpack.yml file yourself, what does it contain?

@lilocruz
Copy link
Author

lilocruz commented Jun 6, 2023

qlpack.yaml content:

name: python-qlpack
version: 0.9.2
libraryPathDependencies:
  - codeql-python

@lilocruz
Copy link
Author

lilocruz commented Jun 6, 2023

I was just trying to start using CodeQL, so i setup an example for a python codebase so i can get a glance of it. Here's the codql code im using:

import python

from python import FunctionCall, Str

where
  exists(FunctionCall call |
    call.getFunction().hasQualifiedName("exec") and
    call.getArgument(0) instanceof Str
  )
select call

@hmakholm
Copy link
Contributor

hmakholm commented Jun 9, 2023

That sounds like you either haven't downloaded the CodeQL library code you depend on (from https://github.com/github/codeql) or haven's put it in a place where the codeql binary can find it. There are several ways to do that:

  1. Put the github/codeql checkout as a sibling directory to the one you've unpacked the CodeQL CLI in.
  2. If you're using the CodeQL CLI, point it to your github/codeql checkout with the --search-path or --additional-packs options.
  3. Let both your query source and github/codeql be subdirectories of a directory containing a workspace definition file
  4. If you're using the Visual Studio Code extension, clone https://github.com/github/vscode-codeql-starter which pulls in the library as a Git submodule.

After the you get the library found, you'll find that there is some trouble with your query source:

from python import FunctionCall, Str

This is bad syntax and not needed. The initial import python in itself makes all the names of the Python analysis library available at the top level.

select call

won't work because select is outside the scope of exists(FunctionCall call | ...). This is what the from keyword is actually for; you're supposed to write

from FunctionCall call
where <condition here>
select call

However, as far as I can see the Python QL library doesn't actually define classes named FunctionCall or Str, so there'll be more problems there. You probably want the Call and StrConst classes instead. (You may have seen FunctionCall in example queries for, say, Java, but the names and structure of the language model differs according to which language you're analysing).

For some working examples of Python queries, see e.g. https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-python/ and the QL library reference at https://codeql.github.com/codeql-standard-libraries/python/index.html

@18Fl
Copy link

18Fl commented Aug 15, 2023

That sounds like you either haven't downloaded the CodeQL library code you depend on (from https://github.com/github/codeql) or haven's put it in a place where the codeql binary can find it. There are several ways to do that:

  1. Put the github/codeql checkout as a sibling directory to the one you've unpacked the CodeQL CLI in.
  2. If you're using the CodeQL CLI, point it to your github/codeql checkout with the --search-path or --additional-packs options.
  3. Let both your query source and github/codeql be subdirectories of a directory containing a workspace definition file
  4. If you're using the Visual Studio Code extension, clone https://github.com/github/vscode-codeql-starter which pulls in the library as a Git submodule.

After the you get the library found, you'll find that there is some trouble with your query source:

from python import FunctionCall, Str

This is bad syntax and not needed. The initial import python in itself makes all the names of the Python analysis library available at the top level.

select call

won't work because select is outside the scope of exists(FunctionCall call | ...). This is what the from keyword is actually for; you're supposed to write

from FunctionCall call
where <condition here>
select call

However, as far as I can see the Python QL library doesn't actually define classes named FunctionCall or Str, so there'll be more problems there. You probably want the Call and StrConst classes instead. (You may have seen FunctionCall in example queries for, say, Java, but the names and structure of the language model differs according to which language you're analysing).

For some working examples of Python queries, see e.g. https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-python/ and the QL library reference at https://codeql.github.com/codeql-standard-libraries/python/index.html

Hey, I meet same question now. And I more like use the fourth way: Use vscode-plugin.

I write a query which will work well when I use vscode-codeql-starter. But it run too slow because the database is so large. So I decide run this query in command(powshell), instead of vscode-codeql-starter. Because I could use the "--threads" optioins. Seems If I set it to 0, all core will be used. So I guess it will make my query run faster. And I failed.

So, Is there a way could make me still use Vscode-codeql-starter, and I still could set the "--threads" options in vscode?

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