* Update beta-codeql-runner.md * Rename beta-codeql-runner.md to deprecation-codeql-runner.md * update reusable name * Update about-codeql-code-scanning-in-your-ci-system.md * Update running-codeql-code-scanning-in-a-container.md * Update uploading-a-sarif-file-to-github.md * Update sarif-support-for-code-scanning.md * Update running-codeql-runner-in-your-ci-system.md * Update configuring-codeql-cli-in-your-ci-system.md * Update configuring-codeql-runner-in-your-ci-system.md * Update running-codeql-runner-in-your-ci-system.md * Update content/github/finding-security-vulnerabilities-and-errors-in-your-code/using-codeql-code-scanning-with-your-existing-ci-system/troubleshooting-codeql-code-scanning-in-your-ci-system.md * Update configuring-codeql-cli-in-your-ci-system.md * Apply suggestions from code review Co-authored-by: Steve Guntrip <12534592+stevecat@users.noreply.github.com> * update codeql runner reusable * add new article about runner to cli migration * fix typo in new article title * Update deprecation-codeql-runner.md * Update deprecation-codeql-runner.md * Apply suggestions from code review * fix failing test * fix failing test * Update versioning to fix failing test * add `codeql-cli-binaries` to allow list Co-authored-by: James Fletcher <42464962+jf205@users.noreply.github.com> Co-authored-by: Felicity Chapman <felicitymay@github.com> Co-authored-by: Steve Guntrip <12534592+stevecat@users.noreply.github.com> Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com>
93 lines
5.4 KiB
Markdown
93 lines
5.4 KiB
Markdown
---
|
|
title: Running CodeQL code scanning in a container
|
|
shortTitle: '{% data variables.product.prodname_code_scanning_capc %} in a container'
|
|
intro: 'You can run {% data variables.product.prodname_code_scanning %} in a container by ensuring that all processes run in the same container.'
|
|
product: '{% data reusables.gated-features.code-scanning %}'
|
|
redirect_from:
|
|
- /github/finding-security-vulnerabilities-and-errors-in-your-code/running-codeql-code-scanning-in-a-container
|
|
- /code-security/secure-coding/running-codeql-code-scanning-in-a-container
|
|
- /code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/running-codeql-code-scanning-in-a-container
|
|
versions:
|
|
fpt: '*'
|
|
ghes: '>=3.0'
|
|
ghae: '*'
|
|
type: how_to
|
|
topics:
|
|
- Advanced Security
|
|
- Code scanning
|
|
- CodeQL
|
|
- Actions
|
|
- Repositories
|
|
- Containers
|
|
- Java
|
|
---
|
|
<!--For this article in earlier GHES versions, see /content/github/finding-security-vulnerabilities-and-errors-in-your-code-->
|
|
|
|
{% data reusables.code-scanning.beta %}
|
|
{% data reusables.code-scanning.deprecation-codeql-runner %}
|
|
|
|
## About {% data variables.product.prodname_code_scanning %} with a containerized build
|
|
|
|
If you're setting up {% data variables.product.prodname_code_scanning %} for a compiled language, and you're building the code in a containerized environment, the analysis may fail with the error message "No source code was seen during the build." This indicates that {% data variables.product.prodname_codeql %} was unable to monitor your code as it was compiled.
|
|
|
|
{% ifversion fpt or ghes > 3.0 or ghae-next %}
|
|
You must run {% data variables.product.prodname_codeql %} inside the container in which you build your code. This applies whether you are using the {% data variables.product.prodname_codeql_cli %}, the {% data variables.product.prodname_codeql_runner %}, or {% data variables.product.prodname_actions %}. For the {% data variables.product.prodname_codeql_cli %} or the {% data variables.product.prodname_codeql_runner %}, see "[Installing {% data variables.product.prodname_codeql_cli %} in your CI system](/code-security/secure-coding/using-codeql-code-scanning-with-your-existing-ci-system/installing-codeql-cli-in-your-ci-system)" or "[Running {% data variables.product.prodname_codeql_runner %} in your CI system](/code-security/secure-coding/running-codeql-runner-in-your-ci-system)" for more information. If you're using {% data variables.product.prodname_actions %}, configure your workflow to run all the actions in the same container. For more information, see "[Example workflow](#example-workflow)."
|
|
{% else %}
|
|
You must run {% data variables.product.prodname_codeql %} inside the container in which you build your code. This applies whether you are using the {% data variables.product.prodname_codeql_runner %} or {% data variables.product.prodname_actions %}. For the {% data variables.product.prodname_codeql_runner %}, see "[Running {% data variables.product.prodname_codeql_runner %} in your CI system](/code-security/secure-coding/running-codeql-runner-in-your-ci-system)" for more information. If you're using {% data variables.product.prodname_actions %}, configure your workflow to run all the actions in the same container. For more information, see "[Example workflow](#example-workflow)."
|
|
{% endif %}
|
|
|
|
## Dependencies
|
|
|
|
You may have difficulty running {% data variables.product.prodname_code_scanning %} if the container you're using is missing certain dependencies (for example, Git must be installed and added to the PATH variable). If you encounter dependency issues, review the list of software typically included on {% data variables.product.prodname_dotcom %}'s virtual environments. For more information, see the version-specific `readme` files in these locations:
|
|
|
|
* Linux: https://github.com/actions/virtual-environments/tree/main/images/linux
|
|
* macOS: https://github.com/actions/virtual-environments/tree/main/images/macos
|
|
* Windows: https://github.com/actions/virtual-environments/tree/main/images/win
|
|
|
|
## Example workflow
|
|
|
|
This sample workflow uses {% data variables.product.prodname_actions %} to run {% data variables.product.prodname_codeql %} analysis in a containerized environment. The value of `container.image` identifies the container to use. In this example the image is named `codeql-container`, with a tag of `f0f91db`. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer)."
|
|
|
|
``` yaml
|
|
name: "{% data variables.product.prodname_codeql %}"
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: '15 5 * * 3'
|
|
|
|
jobs:
|
|
analyze:
|
|
name: Analyze
|
|
runs-on: ubuntu-latest{% ifversion fpt or ghes > 3.1 or ghae-next %}
|
|
permissions:
|
|
security-events: write
|
|
actions: read{% endif %}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
language: [java]
|
|
|
|
# Specify the container in which actions will run
|
|
container:
|
|
image: codeql-container:f0f91db
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
- name: Initialize {% data variables.product.prodname_codeql %}
|
|
uses: github/codeql-action/init@v1
|
|
with:
|
|
languages: {% raw %}${{ matrix.language }}{% endraw %}
|
|
- name: Build
|
|
run: |
|
|
./configure
|
|
make
|
|
- name: Perform {% data variables.product.prodname_codeql %} Analysis
|
|
uses: github/codeql-action/analyze@v1
|
|
```
|