diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..a400c2c --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,74 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '23 5 * * 4' + workflow_dispatch: + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + mode: [ 'pico', 'local' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # 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@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + - run: | + echo "Run, Build Application using script" + ./workflows/autobuild.sh ${{ matrix.mode }} + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..864abb4 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,35 @@ +name: "Nightly deploy" + +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +jobs: + nightly: + name: Deploy nightly + strategy: + fail-fast: false + matrix: + refs: [main] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ matrix.refs }} + submodules: 'recursive' + - name : Build + env: + PICO_SDK_PATH: ../pico-sdk + run: | + ./workflows/autobuild.sh pico + ./build_pico_fido.sh + ./workflows/autobuild.sh esp32 + - name: Update nightly release + uses: pyTooling/Actions/releaser@main + with: + tag: nightly-${{ matrix.refs }} + rm: true + token: ${{ secrets.GITHUB_TOKEN }} + files: release/*.* diff --git a/build_pico_fido2.sh b/build_pico_fido2.sh new file mode 100755 index 0000000..2c380be --- /dev/null +++ b/build_pico_fido2.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +VERSION_MAJOR="6" +VERSION_MINOR="6" +NO_EDDSA=0 +SUFFIX="${VERSION_MAJOR}.${VERSION_MINOR}" +#if ! [[ -z "${GITHUB_SHA}" ]]; then +# SUFFIX="${SUFFIX}.${GITHUB_SHA}" +#fi + +mkdir -p build_release +mkdir -p release +rm -rf -- release/* +cd build_release + +PICO_SDK_PATH="${PICO_SDK_PATH:-../../pico-sdk}" +board_dir=${PICO_SDK_PATH}/src/boards/include/boards + +for board in "$board_dir"/* +do + board_name="$(basename -- "$board" .h)" + rm -rf -- ./* + PICO_SDK_PATH="${PICO_SDK_PATH}" cmake .. -DPICO_BOARD=$board_name -DSECURE_BOOT_PKEY=../../ec_private_key.pem -DENABLE_EDDSA=1 + make -j`nproc` + mv pico_fido2.uf2 ../release/pico_fido2_$board_name-$SUFFIX.uf2 +done diff --git a/workflows/autobuild.sh b/workflows/autobuild.sh new file mode 100755 index 0000000..3daee2e --- /dev/null +++ b/workflows/autobuild.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +git submodule update --init --recursive +sudo apt update + +if [[ $1 == "pico" ]]; then +sudo apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib +git clone https://github.com/raspberrypi/pico-sdk +cd pico-sdk +git checkout tags/2.1.1 +git submodule update --init +cd .. +git clone https://github.com/raspberrypi/picotool +cd picotool +git submodule update --init +mkdir build +cd build +cmake -DPICO_SDK_PATH=../../pico-sdk .. +make -j`nproc` +sudo make install +cd ../.. +mkdir build_pico +cd build_pico +cmake -DPICO_SDK_PATH=../pico-sdk .. +make +cd .. +elif [[ $1 == "esp32" ]]; then +sudo apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 +git clone --recursive https://github.com/espressif/esp-idf.git +cd esp-idf +./install.sh esp32s3 +. ./export.sh +cd .. +idf.py set-target esp32s3 +idf.py all +mkdir -p release +cd build +esptool.py --chip ESP32-S3 merge_bin -o ../release/pico_fido_esp32-s3.bin @flash_args +cd .. +cd esp-idf +./install.sh esp32s2 +. ./export.sh +cd .. +idf.py set-target esp32s2 +idf.py all +mkdir -p release +cd build +esptool.py --chip ESP32-S2 merge_bin -o ../release/pico_fido_esp32-s2.bin @flash_args +cd .. +else +mkdir build +cd build +cmake -DENABLE_EMULATION=1 .. +make +fi