From 86b43a46a417eaf92a6d9a54990c1cb08d6f9527 Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Wed, 26 Oct 2022 16:23:17 -0700 Subject: [PATCH 1/3] Added CodeQL security scan --- .github/actions/codeql/security-pack.yml | 19 ++++++++ .github/actions/spelling/expect.txt | 1 + .github/workflows/codeql-security-scan.yml | 50 ++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .github/actions/codeql/security-pack.yml create mode 100644 .github/workflows/codeql-security-scan.yml diff --git a/.github/actions/codeql/security-pack.yml b/.github/actions/codeql/security-pack.yml new file mode 100644 index 0000000000..1c9e6d08f4 --- /dev/null +++ b/.github/actions/codeql/security-pack.yml @@ -0,0 +1,19 @@ +name: "CodeQL security and quality" + +queries: + - uses: security-and-quality + +query-filters: + - include: + id: cpp/incorrect-not-operator-usage + - include: + tags contain: correctness + - include: + tags contain: reliability + +paths-ignore: + - docs/ + - cmake/docs/ + - cmake/test/ + - Autocoders/Python/src/fprime_ac/utils/DiffAndRename.py + - Autocoders/Python/src/fprime_ac/utils/pyparsing.py diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 8df0f29c10..c25e3927b9 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -206,6 +206,7 @@ cntx cobj CODEFILE codegen +codeql colno COLORSTYLE colorwheel diff --git a/.github/workflows/codeql-security-scan.yml b/.github/workflows/codeql-security-scan.yml new file mode 100644 index 0000000000..4959df42f1 --- /dev/null +++ b/.github/workflows/codeql-security-scan.yml @@ -0,0 +1,50 @@ +# Semantic code analysis with CodeQL +# see https://github.com/github/codeql-action + +name: "CodeQL Security Scan" + +on: + push: + branches: [ "master", "develop" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master", "develop" ] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'python' ] + + 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 }} + config-file: ./.github/actions/codeql/security-pack.yml + + - if: ${{ matrix.language == 'cpp' }} + 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 + with: + category: "/language:${{matrix.language}}" From e6adb4937fe90b1bd3e58cfd1d07cda33b493368 Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Wed, 26 Oct 2022 17:04:55 -0700 Subject: [PATCH 2/3] typo fix --- .github/workflows/codeql-security-scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-security-scan.yml b/.github/workflows/codeql-security-scan.yml index 4959df42f1..41509f86ae 100644 --- a/.github/workflows/codeql-security-scan.yml +++ b/.github/workflows/codeql-security-scan.yml @@ -5,10 +5,10 @@ name: "CodeQL Security Scan" on: push: - branches: [ "master", "develop" ] + branches: [ master, devel ] pull_request: # The branches below must be a subset of the branches above - branches: [ "master", "develop" ] + branches: [ master, devel ] jobs: analyze: From 3feac2bcf6da10f70bc051c35a6ea980f366d63a Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Thu, 27 Oct 2022 12:56:48 -0700 Subject: [PATCH 3/3] Fix codeql error alert --- Autocoders/Python/src/fprime_ac/generators/formatters.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Autocoders/Python/src/fprime_ac/generators/formatters.py b/Autocoders/Python/src/fprime_ac/generators/formatters.py index 80418ec56f..3aea505404 100644 --- a/Autocoders/Python/src/fprime_ac/generators/formatters.py +++ b/Autocoders/Python/src/fprime_ac/generators/formatters.py @@ -1318,10 +1318,7 @@ def subThreadModuleFirstCap(self, mod_id): and no '_' in string form. """ mod_id_list = mod_id.strip("_").split("_") - if len(mod_id_list) == 1: - mod_id_cap = mod_id[0].upper() + mod_id[1:] - elif len(mod_id_list) == 2: - mod_id_cap = [x[0].upper() + x[1:] for x in mod_id_list] + mod_id_cap = [x[0].upper() + x[1:] for x in mod_id_list] # size of mod_id list error in subThreadDir method. mod_id_cap_str = "".join(mod_id_cap) return mod_id_cap_str