From 54d207b2eebc952a75b3fbd05074386916ae5568 Mon Sep 17 00:00:00 2001 From: sljory <107942063+sljory@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:11:22 +0000 Subject: [PATCH] [Complete] Code Scanning - Configuration files --- .github/workflows/codeql-scheduled.yml | 79 ++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/codeql-scheduled.yml diff --git a/.github/workflows/codeql-scheduled.yml b/.github/workflows/codeql-scheduled.yml new file mode 100644 index 0000000..ef0918d --- /dev/null +++ b/.github/workflows/codeql-scheduled.yml @@ -0,0 +1,79 @@ +name: "CodeQL - Complete analysis" + +on: + schedule: + - cron: '44 23 13 * *' # Run CodeQL scan on a day of every month at 11:44 PM UTC + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + timeout-minutes: 30 # Set timeout to 30 minutes; Change if your project takes longer to scan + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'ruby' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # This step will try to find a Dockerfile in the repository and extract the Ruby version from it. + # If you don't use Docker, you can remove this step and add the Ruby version directly to the + # ruby-version parameter in the `ruby/setup-ruby` step below. + - if: matrix.language == 'ruby' + name: Find Ruby version in Dockerfile + id: find-ruby-version-in-dockerfile + run: | + ruby_version=$(find . -name Dockerfile -exec sed -En 's/^FROM ruby:([0-9.]+)(.*)/\1/p' {} \;) + if [ -z "$ruby_version" ]; then + echo "No Dockerfile found, using default Ruby version" + ruby_version="2.7" + else + echo "Found Dockerfile, using Ruby version $ruby_version" + fi + echo USE_RUBY_VERSION=$ruby_version >> $GITHUB_OUTPUT + + - if: matrix.language == 'ruby' + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ steps.find-ruby-version-in-dockerfile.outputs.USE_RUBY_VERSION }} # The version of Ruby to use + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + #env: + # BUNDLE_GEMFILE: ./path/to/Gemfile # Change this to the path to your Gemfile if not in root + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # queries: security-extended,security-and-quality + # debug: true # Only use this for debugging. It will increase the runtime of the action and take up storage. + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - if: matrix.language == 'cpp' || matrix.language == 'csharp' || matrix.language == 'go' || matrix.language == 'java' + 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" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" \ No newline at end of file