Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1025, Add Coding Standard Rules in CodeQL #1034

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/codeql/codeql-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "CodeQL Coding Standard Configuration File"

disable-default-queries: true

queries:
- name: JPL Rules
uses: ./codeql/cpp/ql/src/JPL_C
- name: MISRA Rule 9-5-1
uses: ./codeql/cpp/ql/src/jsf/4.20 Unions and Bit Fields/AV Rule 153.ql
- name: MISRA Rule 5-18-1
uses: ./codeql/cpp/ql/src/jsf/4.21 Operators/AV Rule 168.ql
- name: MISRA 6-2-2
uses: ./codeql/cpp/ql/src/jsf/4.25 Expressions/AV Rule 202.ql
- name: MISRA Rule 5-14-1
uses: ./codeql/cpp/ql/src/jsf/4.21 Operators/AV Rule 165.ql
- name: MISRA Rule 5-3-2
uses: ./codeql/cpp/ql/src/jsf/4.21 Operators/AV Rule 165.ql
- name: MISRA Rule 7-5-2
uses: ./codeql/cpp/ql/src/jsf/4.22 Pointers and References/AV Rule 173.ql

8 changes: 8 additions & 0 deletions .github/codeql/codeql-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "CodeQL Security Configuration File"

queries:
- name: Security and Quality
uses: security-and-quality
- name: Security Extended
uses: security-extended

61 changes: 59 additions & 2 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,65 @@ env:
BUILDTYPE: release

jobs:
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
check-for-duplicates:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'

CodeQL-Security-Build:
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS
submodules: true

- name: Checkout submodule
uses: actions/checkout@v2
with:
path: osal

- name: Check versions
run: git submodule

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: c
config-file: nasa/osal/.github/codeql/codeql-security.yml@main

- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep

- name: Build
run: make -j native/default_cpu1/osal/

- name: Run tests
run: (cd build/native/default_cpu1/osal && make test)

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

CodeQL-Build:
CodeQL-Coding-Standard-Build:
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
timeout-minutes: 15

Expand All @@ -35,7 +92,7 @@ jobs:
uses: github/codeql-action/init@v1
with:
languages: c
queries: +security-extended, security-and-quality
config-file: nasa/osal/.github/codeql/codeql-coding-standard.yml@main

- name: Set up for build
run: |
Expand Down