github / codeql

CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security

Home Page:https://codeql.github.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Referenced pack 'codeql-cpp' not found.

qky7 opened this issue · comments

commented

Description of the issue

Hello.I am a student and just come across this codeql recently. So I'm not very familiar with this codeql.I create a database and when I try to analyze the project, I get this error:

Commadn line: ../codeql/codeql database analyze /home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql_db ../data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql --quiet --format=csv --output=/home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql.csv --additional-packs=/home/test01/.codeql/packages/codeql/

ERROR: Referenced pack 'codeql-cpp' not found. (/home/test01/sven-master/data_eval/trained/cwe-125/0-c/qlpack.yml:1,1-1)
A fatal error occurred: Could not resolve library path for /home/test01/sven-master/data_eval/trained/cwe-125/0-c

Could you please give me some guidance on my specific error.I would very appreciate your help and your time to reply me.

Hi @qky7 👋

Thanks for checking out CodeQL! Based on the information you have shared, it looks like you have your own query and query pack. Have you run codeql pack install in the directory with the .qlpack file?

You may find the documentation at https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/creating-and-working-with-codeql-packs helpful as well.

commented

Hi @qky7 👋

Thanks for checking out CodeQL! Based on the information you have shared, it looks like you have your own query and query pack. Have you run codeql pack install in the directory with the .qlpack file?

You may find the documentation at https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/creating-and-working-with-codeql-packs helpful as well.

Thanks for your reply!I have run codeql pack install int the directory with the .qlpack file.But Errors are still reported.I'm a little worry and puzzle.Codeql is actually a new tool for me and maybe I had made some deviations in understanding.Could you please tell me what else can I do.Thank you very much. Here is the Directory content after the command codeql pack install is executed。
image

Does the codeql database analyze command work fine if you omit the --additional-packs=/home/test01/.codeql/packages/codeql/ part?

commented

Does the codeql database analyze command work fine if you omit the --additional-packs=/home/test01/.codeql/packages/codeql/ part?

Thanks for your advice and help!I try it without --additional-packs=/home/test01/.codeql/packages/codeql/.But Errors are still reported.I truly appreciate your help. I may need some luck and practice to overcome this issue.

What are the errors you are getting now? The same ones as before? What if you omit the ../data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql part as well?

commented

What are the errors you are getting now? The same ones as before? What if you omit the ../data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql part as well?

I'm very appreciate your help and you are truly a kind person.I try again the command without the ./data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql. But it report th error:A fatal error occurred: Query pack codeql/cpp-queries cannot be found. Check the spelling of the pack.Here is the all detail below:

~/sven-master/scripts$ ../codeql/codeql database analyze /home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql_db --quiet --format=csv --output=/home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql.csv --additional-packs=/home/test01/.codeql/packages/codeql/
A fatal error occurred: Query pack codeql/cpp-queries cannot be found. Check the spelling of the pack.

commented

When I was looking for a workaround online, someone mentioned that codeql-CPp was used by the old codeql, and the new codeql doesn't seem to use CodeqL-CPp anymore. I don't know if that's true

Sorry, I think there was a misunderstanding. I wanted you to omit both --additional-packs=/home/test01/.codeql/packages/codeql/ and ../data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql. In other words, just:

~/sven-master/scripts$ ../codeql/codeql database analyze /home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql_db --format=csv --output=/home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql.csv 

This was just to verify that the command succeeds on your machine without any custom queries.

You are correct, however, that codeql-cpp is the old name of codeql/cpp-all. So in your custom .qlpack you should use codeql/cpp-all instead of codeql-cpp

commented

Sorry, I think there was a misunderstanding. I wanted you to omit both --additional-packs=/home/test01/.codeql/packages/codeql/ and ../data_eval/trained/cwe-125/0-c/cwe_125_my-1.ql. In other words, just:

~/sven-master/scripts$ ../codeql/codeql database analyze /home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql_db --format=csv --output=/home/test01/sven-master/experiments/sec_eval/sec-eval-350m-lm/trained/cwe-125/0-c/orig_codeql.csv 

This was just to verify that the command succeeds on your machine without any custom queries.

You are correct, however, that codeql-cpp is the old name of codeql/cpp-all. So in your custom .qlpack you should use codeql/cpp-all instead of codeql-cpp

Thanks for your advice and help these days.I have found my error cause.I found I didn't git clone the right codeql cil.After I download the codeql I forgot to run these below commands:

git clone --depth=1 --branch codeql-cli-2.11.1 https://github.com/github/codeql.git codeql/codeql-repo
codeql/codeql pack download codeql-cpp@0.7.1 codeql-python@0.6.2 codeql/ssa@0.0.16 codeql/tutorial@0.0.9 codeql/regex@0.0.12 codeql/util@0.0.9

I think above commands may be important for codeql running. Luckily I solve my problems. And last I truely appreciate your help, mbg.I wish you all the best in the rest of your life. Thank you so much.