diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml new file mode 100644 index 0000000..d0aa629 --- /dev/null +++ b/.github/workflows/codeql-build.yml @@ -0,0 +1,55 @@ +name: "CodeQL Analysis" + +on: + push: + branches: + - main + pull_request: + +env: + SIMULATION: native + ENABLE_UNIT_TESTS: true + OMIT_DEPRECATED: true + BUILDTYPE: release + +jobs: + + CodeQL-Build: + runs-on: ubuntu-18.04 + timeout-minutes: 15 + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout bundle + uses: actions/checkout@v2 + with: + repository: nasa/cFS + submodules: true + + - name: Checkout submodule + uses: actions/checkout@v2 + with: + path: tools/tblCRCTool + + - name: Check versions + run: git submodule + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: c + queries: +security-extended, security-and-quality + + # Setup the build system + - name: Set up for build + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + make prep + + # Build the code + - name: Build + run: make tools/tblCRCTool/ + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml new file mode 100644 index 0000000..0a998ec --- /dev/null +++ b/.github/workflows/format-check.yml @@ -0,0 +1,53 @@ +name: Format Check + +# Run on main push and pull requests +on: + push: + branches: + - main + pull_request: + +jobs: + + static-analysis: + name: Run format check + runs-on: ubuntu-18.04 + timeout-minutes: 15 + + steps: + + - name: Install format checker + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' + sudo apt-get update && sudo apt-get install clang-format-10 + + - name: Checkout bundle + uses: actions/checkout@v2 + with: + repository: nasa/cFS + + - name: Checkout + uses: actions/checkout@v2 + with: + path: repo + + - name: Generate format differences + run: | + cd repo + find . -name "*.[ch]" -exec clang-format-10 -i -style=file {} + + git diff > $GITHUB_WORKSPACE/style_differences.txt + + - name: Archive Static Analysis Artifacts + uses: actions/upload-artifact@v2 + with: + name: style_differences + path: style_differences.txt + + - name: Error on differences + run: | + if [[ -s style_differences.txt ]]; + then + cat style_differences.txt + exit -1 + fi diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..de318d5 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,40 @@ +name: Static Analysis + +# Run on main push and pull requests +on: + push: + branches: + - main + pull_request: + +jobs: + + static-analysis: + name: Run cppcheck + runs-on: ubuntu-18.04 + timeout-minutes: 15 + + steps: + + - name: Install cppcheck + run: sudo apt-get install cppcheck -y + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run general cppcheck + run: cppcheck --force --inline-suppr --quiet . 2> cppcheck_err.txt + + - name: Archive Static Analysis Artifacts + uses: actions/upload-artifact@v2 + with: + name: cppcheck-err + path: ./cppcheck_err.txt + + - name: Check for errors + run: | + if [[ -s cppcheck_err.txt ]]; + then + cat cppcheck_err.txt + exit -1 + fi diff --git a/README.md b/README.md index 22bc0ff..e3883ec 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +![Static Analysis](https://github.com/nasa/tblCRCTool/workflows/Static%20Analysis/badge.svg) +![Format Check](https://github.com/nasa/tblCRCTool/workflows/Format%20Check/badge.svg) + # Core Flight System : Framework : Tool : Table CRC Generator This repository contains NASA's Table CRC Generator Tool (tblCRCTool), which is a framework component of the Core Flight System. @@ -6,6 +9,13 @@ This lab application is a ground utility to generate binary table CRCs for cFS. ## Version Notes +### Development Build: 1.2.0-rc1+dev19 + +- Changes CLI "help" option to use two dashes: `--help` +- Adds static analysis and format check to continuous integration workflow. Adds workflow status badges to ReadMe. +- Adds CodeQL Analysis to continuous integration workflow. +- See + ### Development Build: 1.2.0-rc1+dev12 - Documentation: Add `Security.md` with instructions on reporting vulnerabilities diff --git a/cfe_ts_crc.c b/cfe_ts_crc.c index 20a2a0d..0eba5d4 100644 --- a/cfe_ts_crc.c +++ b/cfe_ts_crc.c @@ -98,7 +98,6 @@ uint32 CalculateCRC(void *DataPtr, uint32 DataLength, uint32 InputCRC) } return (Crc); - } int main(int argc, char **argv) @@ -112,7 +111,7 @@ int main(int argc, char **argv) char buffer[100]; /* check for valid input */ - if ((argc != 2) || (strncmp(argv[1], "-help", 100) == 0)) + if ((argc != 2) || (strncmp(argv[1], "--help", 100) == 0)) { printf("%s\n", CFE_TS_CRC_VERSION_STRING); printf("\nUsage: cfe_ts_crc [filename]\n"); diff --git a/cfe_ts_crc_version.h b/cfe_ts_crc_version.h index 0da92f5..0895201 100644 --- a/cfe_ts_crc_version.h +++ b/cfe_ts_crc_version.h @@ -31,7 +31,7 @@ /* * Development Build Macro Definitions */ -#define CFE_TS_CRC_BUILD_NUMBER 12 /*!< @brief Number of commits since baseline */ +#define CFE_TS_CRC_BUILD_NUMBER 19 /*!< @brief Number of commits since baseline */ #define CFE_TS_CRC_BUILD_BASELINE \ "v1.2.0+dev" /*!< @brief Development Build: git tag that is the base for the current */ @@ -40,9 +40,11 @@ */ #define CFE_TS_CRC_MAJOR_VERSION 1 /*!< @brief ONLY APPLY for OFFICIAL releases. Major version number. */ #define CFE_TS_CRC_MINOR_VERSION 1 /*!< @brief ONLY APPLY for OFFICIAL releases. Minor version number. */ -#define CFE_TS_CRC_REVISION 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. A value of "99" indicates an unreleased development version. */ +#define CFE_TS_CRC_REVISION \ + 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. A value of "99" indicates an unreleased \ + development version. */ -#define CFE_TS_CRC_MISSION_REV 0 /*!< @brief ONLY USED by MISSION Implementations. Mission revision */ +#define CFE_TS_CRC_MISSION_REV 0 /*!< @brief ONLY USED by MISSION Implementations. Mission revision */ /* * Tools to construct version string @@ -61,10 +63,10 @@ * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest * official version. @n See @ref cfsversions for format differences between development and release versions. */ -#define CFE_TS_CRC_VERSION_STRING \ - " cFE TS CRC calculator (tblCRCtool) \n" \ - " DEVELOPMENT BUILD \n" \ - " " CFE_TS_CRC_VERSION " \n" \ - " Last Offical Release: tblCRCtool v3.1.0" /* For full support please use official release version */ +#define CFE_TS_CRC_VERSION_STRING \ + " cFE TS CRC calculator (tblCRCtool) \n" \ + " DEVELOPMENT BUILD \n" \ + " " CFE_TS_CRC_VERSION " \n" \ + " Last Offical Release: tblCRCtool v3.1.0" /* For full support please use official release version */ #endif /* CFE_TS_CRC_VERSION_H */