-
Notifications
You must be signed in to change notification settings - Fork 135
Support non-standard compilation processes #12
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
Comments
To process C++ code, we indeed need to know how to compile it. The easiest way of setting that up is One possible approach is to leverage |
Maybe it would be good to have a way of determining what is needed for CodeQL to work properly, and then each build system could figure out how to export that data somehow. That way, having extractors for different build systems depends on the community. |
Using bear + #9 would be a decent solution in my opinion. =) |
I would expect CodeQL's built-in support to be able to handle any situation where |
Has CodeQL been tested to work with bazel by disabling the distributed aspect, or is this hypothetical? What changes were made to bazel to accomplish this?
|
For Bazel, one approach that we have used successfully is the following. It can be passed as the build command to
More involved integration into Bazel's dependency graph is possible but not likely for the majority of use cases. Please try this and let us know if it helps. |
The above approach did not work for me. I've also tried many combinations with |
@haxmeadroom could you share more about the project you're building (link if it's open source) and the build commands you're using with and without Bazel? |
I discovered CodeQL this weekend (while digging around in GitHub repo settings looking for other things). I enabled it to see what would happen, but beyond that I have put essentially zero extra time into reconfiguring my build or trying to get CodeQL to work better on my repo. Relevant to this bug/enhancement ticket:
My build also uses a submodule pointing to a different project that uses CMake, and when my build first compiles that project (which is a dependency of my app), then those files built with CMake do appear to get scanned. I know this because there are 3 warnings from the submodule codebase. I'm actually quite pleased to see the scan including the submodule code. (After all, any vulnerabilities in the submodule will become "my" vulns after I link to that library.) Now I just need the scan to include my code, too! Sometime (on the weekends, for my weekend-only side project), I am willing to tweak my build script to help the scanning work. QUESTION:
There must be a list (?), so I don't need to keep injecting bad code into files to see if a warning appears. Here is the PR where I investigated that my own code does not trigger CodeQL warnings: pestophagous/heory#46 I injected the same "Multiplication result converted to larger type" issue into my code to match the issue that I saw trigger a warning in the submodule. But the scan result says "No new or fixed alerts". |
@pestophagous you can see a brief summary of the lines of code seen by CodeQL within your Actions logs here: https://github.com/pestophagous/heory/runs/2765497253?check_suite_focus=true#step:5:257 ( We're in the process of rolling out some new features that give you additional diagnostic information about the codebase that was analysed, such as the number of files (or the list of files when running with higher verbosity). Will report back when you can try those out. |
@adityasharad This is all I see when I follow the link to the "brief summary" that you mention:
That provides a "no" answer to "can I see a list of all the cc/cpp files?" Right? I'm not mad if the answer is "no". I just want to clearly understand if it is yes or no to make sure I didn't misunderstand or follow an incorrect link. It's great to hear you are working on additional features! I look forward to it. I contributed to this ticket only in the spirit of "giving back" and providing more real-life test cases for the team. I'm not complaining! (How could I, this is all provided free of cost to me!) Thanks for your reply and interest. |
@pestophagous , I created issue #13 to track what you are asking for. There's a query that will give you the list of files that are in the database. |
I have seen that there's a new "Indirect Tracing Mode" for building CodeQL databases. Is this the recommended way to build databases for other build environments (for example, GOMA or RBE)? Would it be possible to just have something that parses compile_commands.json and emmits the env variables that are needed for codeql cli ? |
Ah, my bad, the Indirect Build Tracing still tries to figure out what the extractors are. But it seems like it should detect gomacc, right? |
👋 For
|
Hi @adityasharad ! I thought codeqlcli only needed to lookup the compiler invocations of the commands. My understanding is that when compiling with goma, you just use AIUI, RBE (Remote Build Execution) uses a similar thing, but uses a different prefix (no gomacc). So I am wondering what would we need to get those as recognized by the codeql cli extractors. |
Another option for bazel with strict action_env is to add following to bazelrc
and then use update: above works for java 11 code under bazel 4, java 17 with bazel 5 but not for java 11 with bazel 5 |
Is anyone aware of a method like @dmivankov's java approach that would suffice for bazel+cpp? I have a |
@j2kun could you first try adapting the Bazel example at https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#specifying-build-commands (scroll down from that link and look for "Project built using Bazel"). That approach has worked well for us in many scenarios internally and externally; if it doesn't work for your use case please file a separate issue with the details for us. Thanks! |
I created a separate issue for bazel builds here github/codeql#19447 I don't think the solutions discussed here work for our cases |
In a recent talk with @adityasharad , he mentioned that CodeQL would try to understand when a compiler is being invoked. Some projects use goma to speed up the build process, reusing previously built artifacts.
CodeQL seems to ignore all the artifacts that are obtained via goma.
The text was updated successfully, but these errors were encountered: