Skip to content

Commit e698028

Browse files
authored
Adding CodeQL Code Scanning Workflow (#71) (#73)
* Adding codeql code scanning to repo * Update .github/workflows/codeql.yml to use only ubuntu-latest for Go language build mode * chore: Update GOPATH on codeql.yml * Attempt to fix GOPATH * debug * debug * chore: Update GO111MODULE * chore: Update GOPATH and repo root path in codeql.yml * revert * adding more codeql queries
1 parent 3051598 commit e698028

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches:
17+
- master
18+
- feature/**
19+
pull_request:
20+
branches:
21+
- master
22+
- feature/**
23+
schedule:
24+
- cron: '0 9 * * *'
25+
26+
27+
jobs:
28+
analyze:
29+
name: Analyze (${{ matrix.language }})
30+
# Runner size impacts CodeQL analysis time. To learn more, please see:
31+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
32+
# - https://gh.io/supported-runners-and-hardware-resources
33+
# - https://gh.io/using-larger-runners (GitHub.com only)
34+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
35+
runs-on: ${{ matrix.os }}
36+
env:
37+
GOPATH: ${{ github.workspace }}/go
38+
39+
timeout-minutes: 360
40+
permissions:
41+
# required for all workflows
42+
security-events: write
43+
44+
# required to fetch internal or private CodeQL packs
45+
packages: read
46+
47+
# only required for workflows in private repositories
48+
actions: read
49+
contents: read
50+
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
include:
55+
- language: go
56+
build-mode: manual
57+
os : [ubuntu-latest]
58+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
59+
# Use `c-cpp` to analyze code written in C, C++ or both
60+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
61+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
62+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
63+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
64+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
65+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
66+
steps:
67+
- run : pwd
68+
- name: Setup Go
69+
uses: actions/setup-go@v5
70+
with:
71+
go-version: '1.22.2'
72+
73+
- name: Checkout repository
74+
uses: actions/checkout@v4
75+
76+
# Initializes the CodeQL tools for scanning.
77+
- name: Initialize CodeQL
78+
uses: github/codeql-action/init@v3
79+
with:
80+
languages: ${{ matrix.language }}
81+
build-mode: ${{ matrix.build-mode }}
82+
# If you wish to specify custom queries, you can do so here or in a config file.
83+
# By default, queries listed here will override any specified in a config file.
84+
# Prefix the list here with "+" to use these queries and those in the config file.
85+
86+
# For more 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
87+
queries: security-extended,security-and-quality
88+
89+
# If the analyze step fails for one of the languages you are analyzing with
90+
# "We were unable to automatically build your code", modify the matrix above
91+
# to set the build mode to "manual" for that language. Then modify this step
92+
# to build your code.
93+
# ℹ️ Command-line programs to run using the OS shell.
94+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
95+
- if: matrix.build-mode == 'manual'
96+
run: |
97+
go env
98+
make binary
99+
100+
- name: Perform CodeQL Analysis
101+
uses: github/codeql-action/analyze@v3
102+
with:
103+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)