Actions for running CodeQL analysis
Перейти к файлу
Robert 9da537eb33
Merge pull request #93 from github/codeql_mock
Introduce wrapper around codeql
2020-07-06 10:38:41 +01:00
.github Remove test builds section of PR template 2020-07-02 13:37:46 +01:00
.vscode Configure VSCode to ignore transpiled JavaScript 2020-06-17 14:57:29 +01:00
analyze introduce inputs.threads flag to analyze action 2020-06-22 13:27:03 +02:00
autobuild Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
init Update codeql bundle 2020-06-30 11:39:56 +01:00
lib Make parameter names more descriptive 2020-07-02 14:45:14 +01:00
node_modules Add .DS_Store files from node module 2020-06-29 09:18:18 +01:00
queries Make use of getContainer 2020-05-04 15:16:23 +01:00
src Make parameter names more descriptive 2020-07-02 14:45:14 +01:00
tests/multi-language-repo Fix gemfile 2020-05-08 17:03:40 +02:00
upload-sarif Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
.editorconfig Add a `.editorconfig` with our chosen formatting options. 2020-06-23 14:38:30 +01:00
.gitattributes Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
CODE_OF_CONDUCT.md Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
CONTRIBUTING.md Add details of who will merge (CONTRIBUTING.md) 2020-07-02 13:35:29 +01:00
LICENSE Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
README.md Remove `strategy: fail-fast` 2020-06-29 08:49:16 +01:00
package-lock.json Add sinon package for mocking 2020-06-24 14:34:08 +01:00
package.json Update node modules 2020-06-26 16:27:11 +01:00
tsconfig.json enable source maps 2020-05-14 11:07:58 +01:00
tslint.json Update TSLint configuration to detect bad indentation. 2020-06-23 14:44:36 +01:00

README.md

CodeQL Action

This action runs GitHub's industry-leading static 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.

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:
  pull_request:
  schedule:
    - cron: '0 0 * * 0'

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

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          # Must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head of the pull request.
          # Only include this option if you are running this workflow on pull requests.
          fetch-depth: 2

      # If this run was triggered by a pull request event then checkout
      # the head of the pull request instead of the merge commit.
      # Only include this step if you are running this workflow on pull requests.
      - run: git checkout HEAD^2
        if: ${{ github.event_name == 'pull_request' }}

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

      # Autobuild attempts to build any compiled languages (C/C++, C#, 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@v1

      #  Command-line programs to run using the OS shell.
      # 📚 https://git.io/JvXDl

      # ✏️ 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@v1

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@v1
  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@v1

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@v1
  with:
    config-file: ./.github/codeql/codeql-config.yml

The configuration file must be located within the local repository. For information on how to write a configuration file, see "Using a custom configuration."

Troubleshooting

Read about troubleshooting code scanning.