codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Use Cli to analyze database but get no result

Open icy17 opened this issue 2 years ago • 6 comments

Hi, I write a ql like:

/**
 * @name test_compile
 * @description test if target is compiled
 * @kind problem
 * @severity error
 * @id cpp/test-compile
 * @tags security
 */

import cpp
from FunctionCall fc
where 
fc.getTarget().hasName("av_dict_set") 
select  fc, fc.getLocation().toString()

I am sure there are some function calls, but the result is none. And I found this situation maybe related with the sourceLocationPrefix ? I compile this software in one machine, and query this database in the other machine. And I found that in analyse log: [2023-01-12 21:13:24] [SPAMMY] database interpret-results> Skipping location 'file:///root/output/ffmpeg/HandBrake/libhb/decavcodec.c:1819:13:1819:23' since it is outside the source archive.

But I change sourceLocationPrefix to the source code dir, and the log is the same. I can't get the right result in my output file. What can I do to solve this problem?

icy17 avatar Jan 12 '23 13:01 icy17

Hi @icy17

Thanks for your question.

I compile this software in one machine, and query this database in the other machine.

This shouldn't be a problem, and is something we do routinely. May I ask what exactly copied from one machine to another (I'm interested in the directory contents)?

jketema avatar Jan 12 '23 22:01 jketema

@jketema Thank you for your reply! I copy the database dir: image And the codeql-database.yml is:

---
sourceLocationPrefix: "/root/output/ffmpeg/HandBrake/build"
baselineLinesOfCode: 2227454
unicodeNewlines: false
columnKind: "utf8"
primaryLanguage: "cpp"
creationMetadata:
  cliVersion: "2.11.1"
  creationTime: "2023-01-12T08:34:17.682938669Z"

I run a query, and I found that: [SPAMMY] database interpret-results> Skipping location 'file:///root/output/ffmpeg/HandBrake/libhb/decavcodec.c:1819:13:1819:23' since it is outside the source archive. And I unzip the src.zip to get the source code, then I change the codeql-database.yml to:

sourceLocationPrefix: "/home/jhliu/database/ffmpeg/HandBrake-82905bb/root/output/ffmpeg/HandBrake/build/"
baselineLinesOfCode: 2227454
unicodeNewlines: false
columnKind: "utf8"
primaryLanguage: "cpp"
creationMetadata:
  cliVersion: "2.11.1"
  creationTime: "2023-01-12T08:34:17.682938669Z"

but when I run the query again, I got the same result....:

I don't know why. I have changed the sourceLocationPrefix, why the log writes:'file:///root/output/ffmpeg/HandBrake/libhb/decavcodec.c? Did I do something wrong?

icy17 avatar Jan 13 '23 02:01 icy17

Thanks. All the files I expect there seem to be there. What are the file permissions on the src.zip file?

jketema avatar Jan 13 '23 07:01 jketema

It's -rw-rw-r-- And I found that other database compiled in the same machine with the HandBrake can show the results in the output file without changing the .yml file. I'm confused.....maybe I should re-compile it ?

icy17 avatar Jan 13 '23 07:01 icy17

And I found that other database compiled in the same machine with the HandBrake can show the results in the output file without changing the .yml file.

This is what I would expect. How does this build differ from the other one?

I'm confused.....maybe I should re-compile it ?

That shouldn't help, but you can give it a try.

jketema avatar Jan 13 '23 07:01 jketema

Did you manage to resolve this @icy17 ?

v-p-b avatar Nov 14 '25 14:11 v-p-b