Actions for running CodeQL analysis
Перейти к файлу
Sentinel Reviewer 44d2b1f741 Update Dependabot config file 2022-12-02 09:48:46 -06:00
.github Update Dependabot config file 2022-12-02 09:48:46 -06:00
.vscode Add a tasks.json 2021-05-13 16:40:19 +00:00
analyze Add `expect-error` input to force PR check green on expected failure (#1177) 2022-08-16 16:27:14 -07:00
autobuild autobuild: add working-directory input 2022-04-08 13:37:42 -07:00
init Update changelog and input descriptions 2022-09-07 14:38:58 -07:00
lib Surface fatal CLI errors in `interpret-results` and `run-queries` (#1407) 2022-12-02 14:05:21 +01:00
node_modules Update checked-in dependencies 2022-12-01 13:51:17 +00:00
pr-checks Test Linux against Swift 5.7 2022-11-23 21:21:50 +00:00
python-setup python-setup: Remove outdated comment 2022-11-29 13:24:10 +01:00
queries Remove unguarded Actions library query 2022-08-24 11:50:07 +01:00
src Surface fatal CLI errors in `interpret-results` and `run-queries` (#1407) 2022-12-02 14:05:21 +01:00
tests Support Kotlin for public beta (#1370) 2022-11-17 18:38:48 +00:00
upload-sarif Re-enable waiting for processing by default, using the new API semantics. 2022-03-30 12:24:59 +01:00
.editorconfig Add a `.editorconfig` with our chosen formatting options. 2020-06-23 14:38:30 +01:00
.eslintignore Delete the runner 2022-11-14 16:23:14 +00:00
.eslintrc.json Upgrade Ava to v4 2022-02-01 18:56:42 +00:00
.gitattributes Refactor PR checks 2021-09-08 13:59:52 +01:00
.gitignore Delete the runner 2022-11-14 16:23:14 +00:00
.npmrc Add config file to support npm v8 and v9 simultaneously 2022-11-14 22:15:08 +00:00
CHANGELOG.md Update changelog and version after v2.1.35 2022-12-01 13:04:46 +00:00
CODEOWNERS Update CODEOWNERS 2022-04-12 16:34:35 +02:00
CODE_OF_CONDUCT.md Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
CONTRIBUTING.md Delete the runner 2022-11-14 16:23:14 +00:00
LICENSE Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
README.md Add Ruby to README 2022-11-16 18:31:04 +00:00
package-lock.json Update changelog and version after v2.1.35 2022-12-01 13:04:46 +00:00
package.json Update changelog and version after v2.1.35 2022-12-01 13:04:46 +00:00
tsconfig.json Store the default CodeQL bundle version in a JSON file. 2020-08-10 13:41:45 +01:00

README.md

CodeQL Action

This action runs GitHub's industry-leading semantic code analysis engine, CodeQL, against a repository's source code to find security vulnerabilities. It then automatically uploads the results to GitHub so they can be displayed in the repository's security tab. CodeQL runs an extensible set of queries, which have been developed by the community and the GitHub Security Lab to find common vulnerabilities in your code.

For a list of recent changes, see the CodeQL Action's changelog.

License

This project is released under the MIT License.

The underlying CodeQL CLI, used in this action, is licensed under the GitHub CodeQL Terms and Conditions. As such, this action may be used on open source projects hosted on GitHub, and on private repositories that are owned by an organisation with GitHub Advanced Security enabled.

Usage

This is a short walkthrough, but for more information read configuring code scanning.

To get code scanning results from CodeQL analysis on your repo you can use the following workflow as a template:


name: "Code Scanning - Action"

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  schedule:
    #        ┌───────────── minute (0 - 59)
    #        │  ┌───────────── hour (0 - 23)
    #        │  │ ┌───────────── day of the month (1 - 31)
    #        │  │ │ ┌───────────── month (1 - 12 or JAN-DEC)
    #        │  │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
    #        │  │ │ │ │
    #        │  │ │ │ │
    #        │  │ │ │ │
    #        *  * * * *
    - cron: '30 1 * * 0'

jobs:
  CodeQL-Build:
    # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
    runs-on: ubuntu-latest

    permissions:
      # required for all workflows
      security-events: write

      # only required for workflows in private repositories
      actions: read
      contents: read

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      # Initializes the CodeQL tools for scanning.
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v2
        # Override language selection by uncommenting this and choosing your languages
        # with:
        #   languages: go, javascript, csharp, python, cpp, java, ruby

      # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
      # If this step fails, then you should remove it and run the build manually (see below).
      - name: Autobuild
        uses: github/codeql-action/autobuild@v2

      #  Command-line programs to run using the OS shell.
      # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

      # ✏️ If the Autobuild fails above, remove it and uncomment the following
      #    three lines and modify them (or add more) to build your code if your
      #    project uses a compiled language

      #- run: |
      #     make bootstrap
      #     make release

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v2

If you prefer to integrate this within an existing CI workflow, it should end up looking something like this:

- name: Initialize CodeQL
  uses: github/codeql-action/init@v2
  with:
    languages: go, javascript

# Here is where you build your code
- run: |
    make bootstrap
    make release    

- name: Perform CodeQL Analysis
  uses: github/codeql-action/analyze@v2

Configuration file

Use the config-file parameter of the init action to enable the configuration file. The value of config-file is the path to the configuration file you want to use. This example loads the configuration file ./.github/codeql/codeql-config.yml.

- uses: github/codeql-action/init@v2
  with:
    config-file: ./.github/codeql/codeql-config.yml

The configuration file can be located in a different repository. This is useful if you want to share the same configuration across multiple repositories. If the configuration file is in a private repository you can also specify an external-repository-token option. This should be a personal access token that has read access to any repositories containing referenced config files and queries.

- uses: github/codeql-action/init@v2
  with:
    config-file: owner/repo/codeql-config.yml@branch
    external-repository-token: ${{ secrets.EXTERNAL_REPOSITORY_TOKEN }}

For information on how to write a configuration file, see "Using a custom configuration file."

If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the queries property of the init action:

- uses: github/codeql-action/init@v2
  with:
    queries: <local-or-remote-query>,<another-query>

By default, this will override any queries specified in a config file. If you wish to use both sets of queries, prefix the list of queries in the workflow with +:

- uses: github/codeql-action/init@v2
  with:
    queries: +<local-or-remote-query>,<another-query>

Troubleshooting

Read about troubleshooting code scanning.