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

codeql query chromium didn't work... #13552

Open
18Fl opened this issue Jun 24, 2023 · 7 comments
Open

codeql query chromium didn't work... #13552

18Fl opened this issue Jun 24, 2023 · 7 comments
Labels
question Further information is requested

Comments

@18Fl
Copy link

18Fl commented Jun 24, 2023

Introduction

Hey, I have download codeql version 2.13.4

PS D:\luck\src> codeql --version
CodeQL command-line toolchain release 2.13.4.
Copyright (C) 2019-2023 GitHub, Inc.
Unpacked in: C:\Users\18f\Desktop\18_floor\misc_fun\codeql\codeql-win64\codeql
   Analysis results depend critically on separately distributed query and
   extractor modules. To list modules that are visible to the toolchain,
   use 'codeql resolve qlpacks' and 'codeql resolve languages'.

and try to work it with chromium. but seems it dosen't wrok...

My OS is windows 10. and I change chromium src one file content.

gfx::Vector2dF CssPixelsToVector2dF(double x, double y, float scale_factor) { //  [+] create this for codeql
  return gfx::Vector2dF(x * scale_factor, y * scale_factor);
}

bool StringToGestureSourceType(Maybe<std::string> in,
                               content::mojom::GestureSourceType& out) {
   [...]
}

I add a command in this file, so it should recompile this. with this log , it could confirm I build the database successful.

PS D:\luck\src> codeql database create D:\code_db\hunting  --overwrite --language=cpp --command='autoninja -C out\hope chrome'
Initializing database at D:\code_db\hunting.
Running build command: [autoninja, -C, out\hope, chrome]
[2023-06-24 23:00:02] [build-stdout] "C:\Users\18f\Desktop\18_floor\source_code\build_chromium_tools\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\python3.exe" C:\Users\18f\Desktop\18_floor\source_code\build_chromium_tools\depot_tools\ninja.py -C out\hope chrome -j 22
[2023-06-24 23:00:38] [build-stdout] ninja: Entering directory `out\hope'
[2023-06-24 23:00:38] [build-stdout] [1/7] CXX obj/content/browser/browser/input_handler.obj
[2023-06-24 23:00:38] [build-stdout] [2/7] STAMP obj/content/browser/browser.stamp
[2023-06-24 23:00:38] [build-stdout] [3/7] LINK(DLL) chrome.dll chrome.dll.lib chrome.dll.pdb
[2023-06-24 23:00:38] [build-stdout] [4/7] LINK initialexe/chrome.exe initialexe/chrome.exe.pdb
[2023-06-24 23:00:38] [build-stdout] [5/7] ACTION //chrome:reorder_imports(//build/toolchain/win:win_clang_x64)
[2023-06-24 23:00:38] [build-stdout] [6/7] STAMP obj/chrome/reorder_imports.stamp
[2023-06-24 23:00:38] [build-stdout] [7/7] STAMP obj/chrome/chrome.stamp
Finalizing database at D:\code_db\hunting.
Successfully created database at D:\code_db\hunting.

and then I write a query file:

import cpp

from Function risk_func
where risk_func.getQualifiedName().matches("%StringToGestureSourceType%")
//where risk_func.getAFile().getBaseName().matches("%input%")  //  [+] ensure the file
select risk_func, "query function"

And it returns no result...
image
And If I just want to query all function it still failed, like this:

import cpp

from Function risk_func
//where risk_func.getQualifiedName().matches("%StringToGestureSourceType%")
//where risk_func.getAFile().getBaseName().matches("%input%")  //  [+] ensure the file
select risk_func, "query function"

To see what happened , I unzip the src.zip file in the database, and I did found the function:

image

I attach the database, could u give me anytips which part I am wrong. thank u so much!

hunting.zip

@18Fl 18Fl added the question Further information is requested label Jun 24, 2023
@18Fl
Copy link
Author

18Fl commented Jun 24, 2023

@Jackenmen @aibaars any tips, thanks. :(

@jketema
Copy link
Contributor

jketema commented Jun 24, 2023

Hi. Thanks for your question. Am I correct that the changes you make were to a file called input_handler.cc?

@18Fl
Copy link
Author

18Fl commented Jun 25, 2023

Hi. Thanks for your question. Am I correct that the changes you make were to a file called input_handler.cc

Yeah.

@jketema
Copy link
Contributor

jketema commented Jun 25, 2023

The contents of the modified file actually didn't end up in the database due to the problem also reported here: #13489 (comment). I'll try to have a closer look at this.

@18Fl
Copy link
Author

18Fl commented Jun 25, 2023

The contents of the modified file actually didn't end up in the database due to the problem also reported here: #13489 (comment). I'll try to have a closer look at this.

I found this bug occurs in windows, but don't exist in wsl ubuntu... But when I use wsl ubuntu to create database, I meet another problem. LOL :( .... #7582

@jketema
Copy link
Contributor

jketema commented Jun 25, 2023

#7582

That particular issue was fixed. So, you're probably running into a similar but different problem. Could you open an issue for that too, and provide the logs. Thanks.

@18Fl
Copy link
Author

18Fl commented Jun 25, 2023

#7582

That particular issue was fixed. So, you're probably running into a similar but different problem. Could you open an issue for that too, and provide the logs. Thanks.

Yeah, I will

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