|
|
|
@ -63,7 +63,6 @@ You can create {% data variables.product.prodname_codeql %} debugging artifacts
|
|
|
|
|
|
|
|
|
|
You need to ensure that you select **Enable debug logging** . This option enables runner diagnostic logging and step debug logging for the run. You'll then be able to download `debug-artifacts` to investigate further. You do not need to modify the workflow file when creating {% data variables.product.prodname_codeql %} debugging artifacts by re-running jobs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
{% ifversion fpt or ghec or ghes > 3.3 or ghae > 3.3 %}
|
|
|
|
@ -87,7 +86,7 @@ If an automatic build of code for a compiled language within your project fails,
|
|
|
|
|
|
|
|
|
|
- Remove the `autobuild` step from your {% data variables.product.prodname_code_scanning %} workflow and add specific build steps. For information about editing the workflow, see "[Configuring {% data variables.product.prodname_code_scanning %}](/code-security/secure-coding/configuring-code-scanning#editing-a-code-scanning-workflow)." For more information about replacing the `autobuild` step, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
|
|
|
|
|
|
- If your workflow doesn't explicitly specify the languages to analyze, {% data variables.product.prodname_codeql %} implicitly detects the supported languages in your code base. In this configuration, out of the compiled languages C/C++, C#, and Java, {% data variables.product.prodname_codeql %} only analyzes the language with the most source files. Edit the workflow and add a matrix specifying the languages you want to analyze. The default CodeQL analysis workflow uses such a matrix.
|
|
|
|
|
- If your workflow doesn't explicitly specify the languages to analyze, {% data variables.product.prodname_codeql %} implicitly detects the supported languages in your code base. In this configuration, out of the compiled languages C/C++, C#,{% ifversion codeql-go-autobuild %} Go,{% endif %} and Java, {% data variables.product.prodname_codeql %} only analyzes the language with the most source files. Edit the workflow and add a matrix specifying the languages you want to analyze. The default CodeQL analysis workflow uses such a matrix.
|
|
|
|
|
|
|
|
|
|
The following extracts from a workflow show how you can use a matrix within the job strategy to specify languages, and then reference each language within the "Initialize {% data variables.product.prodname_codeql %}" step:
|
|
|
|
|
|
|
|
|
@ -131,14 +130,15 @@ If your workflow fails with an error `No source code was seen during the build`
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
For more information, see the workflow extract in "[Automatic build for a compiled language fails](#automatic-build-for-a-compiled-language-fails)" above.
|
|
|
|
|
1. Your {% data variables.product.prodname_code_scanning %} workflow is analyzing a compiled language (C, C++, C#, or Java), but the code was not compiled. By default, the {% data variables.product.prodname_codeql %} analysis workflow contains an `autobuild` step, however, this step represents a best effort process, and may not succeed in building your code, depending on your specific build environment. Compilation may also fail if you have removed the `autobuild` step and did not include build steps manually. For more information about specifying build steps, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
|
1. Your workflow is analyzing a compiled language (C, C++, C#, or Java), but portions of your build are cached to improve performance (most likely to occur with build systems like Gradle or Bazel). Since {% data variables.product.prodname_codeql %} observes the activity of the compiler to understand the data flows in a repository, {% data variables.product.prodname_codeql %} requires a complete build to take place in order to perform analysis.
|
|
|
|
|
1. Your workflow is analyzing a compiled language (C, C++, C#, or Java), but compilation does not occur between the `init` and `analyze` steps in the workflow. {% data variables.product.prodname_codeql %} requires that your build happens in between these two steps in order to observe the activity of the compiler and perform analysis.
|
|
|
|
|
1. Your compiled code (in C, C++, C#, or Java) was compiled successfully, but {% data variables.product.prodname_codeql %} was unable to detect the compiler invocations. The most common causes are:
|
|
|
|
|
|
|
|
|
|
* Running your build process in a separate container to {% data variables.product.prodname_codeql %}. For more information, see "[Running CodeQL code scanning in a container](/code-security/secure-coding/running-codeql-code-scanning-in-a-container)."
|
|
|
|
|
* Building using a distributed build system external to GitHub Actions, using a daemon process.
|
|
|
|
|
* {% data variables.product.prodname_codeql %} isn't aware of the specific compiler you are using.
|
|
|
|
|
1. Your {% data variables.product.prodname_code_scanning %} workflow is analyzing a compiled language (C, C++, C#,{% ifversion codeql-go-autobuild %} Go,{% endif %} or Java), but the code was not compiled. By default, the {% data variables.product.prodname_codeql %} analysis workflow contains an `autobuild` step, however, this step represents a best effort process, and may not succeed in building your code, depending on your specific build environment. Compilation may also fail if you have removed the `autobuild` step and did not include build steps manually. For more information about specifying build steps, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
|
1. Your workflow is analyzing a compiled language (C, C++, C#,{% ifversion codeql-go-autobuild %} Go,{% endif %} or Java), but portions of your build are cached to improve performance (most likely to occur with build systems like Gradle or Bazel). Since {% data variables.product.prodname_codeql %} observes the activity of the compiler to understand the data flows in a repository, {% data variables.product.prodname_codeql %} requires a complete build to take place in order to perform analysis.
|
|
|
|
|
1. Your workflow is analyzing a compiled language (C, C++, C#,{% ifversion codeql-go-autobuild %} Go,{% endif %} or Java), but compilation does not occur between the `init` and `analyze` steps in the workflow. {% data variables.product.prodname_codeql %} requires that your build happens in between these two steps in order to observe the activity of the compiler and perform analysis.
|
|
|
|
|
1. Your compiled code (in C, C++, C#,{% ifversion codeql-go-autobuild %} Go,{% endif %} or Java) was compiled successfully, but {% data variables.product.prodname_codeql %} was unable to detect the compiler invocations. The most common causes are:
|
|
|
|
|
|
|
|
|
|
- Running your build process in a separate container to {% data variables.product.prodname_codeql %}. For more information, see "[Running CodeQL code scanning in a container](/code-security/secure-coding/running-codeql-code-scanning-in-a-container)."
|
|
|
|
|
- Building using a distributed build system external to GitHub Actions, using a daemon process.
|
|
|
|
|
- {% data variables.product.prodname_codeql %} isn't aware of the specific compiler you are using.
|
|
|
|
|
|
|
|
|
|
For .NET Framework projects, and for C# projects using either `dotnet build` or `msbuild`, you should specify `/p:UseSharedCompilation=false` in your workflow's `run` step, when you build your code.
|
|
|
|
|
|
|
|
|
@ -154,6 +154,7 @@ If your workflow fails with an error `No source code was seen during the build`
|
|
|
|
|
For more information about specifying build steps, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
|
|
|
|
|
|
{% ifversion fpt or ghes > 3.1 or ghae or ghec %}
|
|
|
|
|
|
|
|
|
|
## Lines of code scanned are lower than expected
|
|
|
|
|
|
|
|
|
|
For compiled languages like C/C++, C#, Go, and Java, {% data variables.product.prodname_codeql %} only scans files that are built during the analysis. Therefore the number of lines of code scanned will be lower than expected if some of the source code isn't compiled correctly. This can happen for several reasons:
|
|
|
|
@ -169,6 +170,7 @@ Replace the `autobuild` step with the same build commands you would use in produ
|
|
|
|
|
For more information, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
|
|
|
|
|
|
### Inspect the copy of the source files in the {% data variables.product.prodname_codeql %} database
|
|
|
|
|
|
|
|
|
|
You may be able to understand why some source files haven't been analyzed by inspecting the copy of the source code included with the {% data variables.product.prodname_codeql %} database. To obtain the database from your Actions workflow, modify the `init` step of your {% data variables.product.prodname_codeql %} workflow file and set `debug: true`.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
@ -194,6 +196,7 @@ The extraction diagnostics information gives an indication of overall database h
|
|
|
|
|
However, if you see extractor errors in the overwhelming majority of files that were compiled during database creation, you should look into the errors in more detail to try to understand why some source files weren't extracted properly.
|
|
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
|
|
|
|
|
|
## Portions of my repository were not analyzed using `autobuild`
|
|
|
|
|
|
|
|
|
|
The {% data variables.product.prodname_codeql %} `autobuild` feature uses heuristics to build the code in a repository, however, sometimes this approach results in incomplete analysis of a repository. For example, when multiple `build.sh` commands exist in a single repository, the analysis may not complete since the `autobuild` step will only execute one of the commands. The solution is to replace the `autobuild` step with build steps which build all of the source code which you wish to analyze. For more information, see "[Configuring the {% data variables.product.prodname_codeql %} workflow for compiled languages](/code-security/secure-coding/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)."
|
|
|
|
@ -237,6 +240,7 @@ You may be running extra queries or query suites in addition to the default quer
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
{% ifversion fpt or ghec %}
|
|
|
|
|
|
|
|
|
|
## Results differ between analysis platforms
|
|
|
|
|
|
|
|
|
|
If you are analyzing code written in Python, you may see different results depending on whether you run the {% data variables.product.prodname_codeql_workflow %} on Linux, macOS, or Windows.
|
|
|
|
@ -256,11 +260,13 @@ On very large projects, {% data variables.product.prodname_codeql %} may run out
|
|
|
|
|
{% else %}If you encounter this issue, try increasing the memory on the runner.{% endif %}
|
|
|
|
|
|
|
|
|
|
{% ifversion fpt or ghec %}
|
|
|
|
|
|
|
|
|
|
## Error: 403 "Resource not accessible by integration" when using {% data variables.product.prodname_dependabot %}
|
|
|
|
|
|
|
|
|
|
{% data variables.product.prodname_dependabot %} is considered untrusted when it triggers a workflow run, and the workflow will run with read-only scopes. Uploading {% data variables.product.prodname_code_scanning %} results for a branch usually requires the `security_events: write` scope. However, {% data variables.product.prodname_code_scanning %} always allows the uploading of results when the `pull_request` event triggers the action run. This is why, for {% data variables.product.prodname_dependabot %} branches, we recommend you use the `pull_request` event instead of the `push` event.
|
|
|
|
|
|
|
|
|
|
A simple approach is to run on pushes to the default branch and any other important long-running branches, as well as pull requests opened against this set of branches:
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
@ -270,7 +276,9 @@ on:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
An alternative approach is to run on all pushes except for {% data variables.product.prodname_dependabot %} branches:
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
@ -282,6 +290,7 @@ on:
|
|
|
|
|
### Analysis still failing on the default branch
|
|
|
|
|
|
|
|
|
|
If the {% data variables.product.prodname_codeql_workflow %} still fails on a commit made on the default branch, you need to check:
|
|
|
|
|
|
|
|
|
|
- whether {% data variables.product.prodname_dependabot %} authored the commit
|
|
|
|
|
- whether the pull request that includes the commit has been merged using `@dependabot squash and merge`
|
|
|
|
|
|
|
|
|
|