Skip to content

Commit fe7dd9e

Browse files
authored
Enable code scanning alerts (#38817)
* [wip] try codesql * Update codeql.yml to remove all other branches but master * Update codeql.yml
1 parent 8e8327d commit fe7dd9e

1 file changed

Lines changed: 118 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Enables code scanning alerts in repo.
17+
18+
name: "CodeQL Advanced"
19+
20+
on:
21+
push:
22+
branches: [ "master" ]
23+
pull_request:
24+
branches: [ "master" ]
25+
workflow_dispatch:
26+
schedule:
27+
- cron: '25 10 * * 6'
28+
29+
jobs:
30+
analyze:
31+
name: Analyze (${{ matrix.language }})
32+
# Runner size impacts CodeQL analysis time. To learn more, please see:
33+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
34+
# - https://gh.io/supported-runners-and-hardware-resources
35+
# - https://gh.io/using-larger-runners (GitHub.com only)
36+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
37+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
38+
permissions:
39+
# required for all workflows
40+
security-events: write
41+
42+
# required to fetch internal or private CodeQL packs
43+
packages: read
44+
45+
# only required for workflows in private repositories
46+
actions: read
47+
contents: read
48+
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
include:
53+
- language: actions
54+
build-mode: none
55+
# - language: c-cpp
56+
# build-mode: autobuild
57+
- language: go
58+
build-mode: autobuild
59+
- language: java-kotlin
60+
build-mode: autobuild
61+
- language: javascript-typescript
62+
build-mode: none
63+
- language: python
64+
build-mode: none
65+
- language: rust
66+
build-mode: none
67+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
68+
# Use `c-cpp` to analyze code written in C, C++ or both
69+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
70+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
71+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
72+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
73+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
74+
# 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
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
79+
# Add any setup steps before running the `github/codeql-action/init` action.
80+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
81+
# or others). This is typically only required for manual builds.
82+
# - name: Setup runtime (example)
83+
# uses: actions/setup-example@v1
84+
85+
# Initializes the CodeQL tools for scanning.
86+
- name: Initialize CodeQL
87+
uses: github/codeql-action/init@v4
88+
with:
89+
languages: ${{ matrix.language }}
90+
build-mode: ${{ matrix.build-mode }}
91+
# If you wish to specify custom queries, you can do so here or in a config file.
92+
# By default, queries listed here will override any specified in a config file.
93+
# Prefix the list here with "+" to use these queries and those in the config file.
94+
95+
# 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
96+
# queries: security-extended,security-and-quality
97+
98+
# If the analyze step fails for one of the languages you are analyzing with
99+
# "We were unable to automatically build your code", modify the matrix above
100+
# to set the build mode to "manual" for that language. Then modify this step
101+
# to build your code.
102+
# ℹ️ Command-line programs to run using the OS shell.
103+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
104+
- name: Run manual build steps
105+
if: matrix.build-mode == 'manual'
106+
shell: bash
107+
run: |
108+
echo 'If you are using a "manual" build mode for one or more of the' \
109+
'languages you are analyzing, replace this with the commands to build' \
110+
'your code, for example:'
111+
echo ' make bootstrap'
112+
echo ' make release'
113+
exit 1
114+
115+
- name: Perform CodeQL Analysis
116+
uses: github/codeql-action/analyze@v4
117+
with:
118+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)