Skip to content

Commit 2887364

Browse files
ajfabbripan3793
andauthored
HADOOP-19858: ci: Add CodeQL scanning for github actions (#8428)
* ci: Add github-generated CodeQL security scan action * ci: modify generated codeql.yml, only scan actions for now * ci: add path filter for GH actions scan * ci: remove some comments we don't need, add main link * Apply suggestions from pan3793 code review Co-authored-by: Cheng Pan <pan3793@gmail.com> --------- Co-authored-by: Cheng Pan <pan3793@gmail.com>
1 parent b143491 commit 2887364

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copyright 2026 The Apache Software Foundation
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
# This was adapted from the GitHub-generated template.
20+
# See https://docs.github.com/en/code-security/how-tos/find-and-fix-code-vulnerabilities/configure-code-scanning/configuring-default-setup-for-code-scanning
21+
22+
name: "CodeQL Advanced"
23+
24+
on:
25+
push:
26+
branches: [ "trunk", "branch-*" ]
27+
pull_request:
28+
branches: [ "trunk", "branch-*" ]
29+
paths:
30+
- '.github/**'
31+
schedule:
32+
- cron: '22 4 * * 4'
33+
34+
jobs:
35+
analyze:
36+
name: Analyze (${{ matrix.language }})
37+
# Runner size impacts CodeQL analysis time. See:
38+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
39+
runs-on: ubuntu-24.04
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+
strategy:
48+
fail-fast: false
49+
matrix:
50+
include:
51+
# Initially only enabling scans for github actions
52+
- language: actions
53+
build-mode: none
54+
# We should consider enabling these in the future:
55+
# - language: c-cpp
56+
# build-mode: autobuild
57+
# - language: java-kotlin
58+
# build-mode: none # This mode only analyzes Java. Set to 'autobuild' or 'manual' to include Kotlin.
59+
# - language: javascript-typescript
60+
# build-mode: none
61+
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v6
65+
66+
# Add any setup steps before running the `github/codeql-action/init` action.
67+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
68+
# or others). This is typically only required for manual builds.
69+
# - name: Setup runtime (example)
70+
# uses: actions/setup-example@v1
71+
72+
# Initializes the CodeQL tools for scanning.
73+
- name: Initialize CodeQL
74+
uses: github/codeql-action/init@v4
75+
with:
76+
languages: ${{ matrix.language }}
77+
build-mode: ${{ matrix.build-mode }}
78+
# Query details can be added here or in a config file.
79+
# For more details on CodeQL's query packs, see:
80+
# 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
81+
# queries: security-extended,security-and-quality
82+
83+
# If the analyze step fails for one of the languages you are analyzing with
84+
# "We were unable to automatically build your code", modify the matrix above
85+
# to set the build mode to "manual" for that language. Then modify this step
86+
# to build your code.
87+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
88+
- name: Run manual build steps
89+
if: matrix.build-mode == 'manual'
90+
shell: bash
91+
run: |
92+
echo 'If you are using a "manual" build mode for one or more of the' \
93+
'languages you are analyzing, replace this with the commands to build' \
94+
'your code, for example:'
95+
echo ' make bootstrap'
96+
echo ' make release'
97+
exit 1
98+
99+
- name: Perform CodeQL Analysis
100+
uses: github/codeql-action/analyze@v4
101+
with:
102+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)