Skip to content

Commit

Permalink
Hash pin github workflows
Browse files Browse the repository at this point in the history
Description

A Static Application Security Testing (SAST) is a static analysis tool that can prevent known classes of bugs from being inadvertently introduced in the codebase.

This PR config the CodeQL, a GitHub-owned SAST tool, to scan the project periodically for bugs.

PiperOrigin-RevId: 585972795
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Nov 28, 2023
1 parent 150b724 commit 6ef32c2
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '29 13 * * 5'

permissions: {}

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'c-cpp', 'csharp', 'java-kotlin', 'python', 'ruby' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 1
submodules: 'recursive'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
languages: ${{ matrix.language }}

- name: Custom build protoc (C++) and build java
if: matrix.language == 'java-kotlin'
run: |
echo "Installing bazel"
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt-get update
sudo apt-get install bazel
echo "Building protoc"
bazel build :protoc :protobuf
mv bazel-bin/protoc protoc
echo "Building Java"
cd java
mvn clean package -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip=true -Dlicense.skip=true -Drat.skip=true -Dspotless.check.skip=true
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
- name: Autobuild
if: matrix.language == 'c-cpp' ||
matrix.language == 'csharp' ||
matrix.language == 'python' ||
matrix.language == 'ruby'
uses: github/codeql-action/autobuild@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
category: "/language:${{matrix.language}}"

0 comments on commit 6ef32c2

Please sign in to comment.