Skip to content

Commit

Permalink
Static Analysis for JPL Coding Guidelines (#1742)
Browse files Browse the repository at this point in the history
* Added JPL Coding Standard workflow

* Trigger queries

* Clean up config file

* Fix devel branch name
  • Loading branch information
thomas-bc authored Oct 28, 2022
1 parent cdc452b commit dec2630
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/actions/codeql/jpl-standard-pack-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "CodeQL JPL Coding Standard - Errors and Warnings"

disable-default-queries: true

packs:
# Source of the query pack is https://github.com/github/codeql/tree/main/cpp/ql/src/JPL_C
- codeql/cpp-queries:JPL_C

query-filters:
- exclude:
problem.severity:
- recommendation
20 changes: 20 additions & 0 deletions .github/actions/codeql/jpl-standard-pack-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "CodeQL JPL Coding Standard - Recommendations 1 of 2"

disable-default-queries: true

packs:
# Source of the query pack is https://github.com/github/codeql/tree/main/cpp/ql/src/JPL_C
- codeql/cpp-queries:JPL_C

query-filters:
- exclude:
problem.severity:
- error
- warning
# We are excluding the following query because it overflows the limit of
# 5000 results that the SARIF upload can handle
# This sole query is ran in jpl-standard-pack-3.yml
# https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github#uploading-a-code-scanning-analysis-with-github-actions
- exclude:
id:
- cpp/jpl-c/basic-int-types
13 changes: 13 additions & 0 deletions .github/actions/codeql/jpl-standard-pack-3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "CodeQL JPL Coding Standard - Recommendations 2 of 2"

disable-default-queries: true

packs:
# Source of the query pack is https://github.com/github/codeql/tree/main/cpp/ql/src/JPL_C
- codeql/cpp-queries:JPL_C

query-filters:
# This will ONLY include the following query
- include:
id:
- cpp/jpl-c/basic-int-types
50 changes: 50 additions & 0 deletions .github/workflows/codeql-jpl-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Semantic code analysis with CodeQL
# see https://github.com/github/codeql-action

name: "JPL Coding Standard Scan"

on:
push:
branches: [ master, devel ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, devel ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
config-file: ['jpl-standard-pack-1.yml', 'jpl-standard-pack-2.yml', 'jpl-standard-pack-3.yml']

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# Run jobs in parallel for each config-file
config-file: ./.github/actions/codeql/${{ matrix.config-file }}

- name: Build
run: |
python3 -m venv ./fprime-venv
. ./fprime-venv/bin/activate
pip install -U setuptools setuptools_scm wheel pip
pip install -r ./requirements.txt
fprime-util generate
fprime-util build --all
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

0 comments on commit dec2630

Please sign in to comment.