Skip to content

Commit ddfd61b

Browse files
authored
Update CodeQL workflow to limit permissions (decke#177)
1 parent b6cbf2f commit ddfd61b

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
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+
#
112
name: "CodeQL"
213

314
on:
415
push:
5-
branches: [master]
616
pull_request:
717
# The branches below must be a subset of the branches above
818
branches: [master]
919
schedule:
1020
- cron: '0 15 * * 5'
1121

12-
permissions:
13-
contents: read
14-
1522
jobs:
1623
analyze:
17-
permissions:
18-
actions: read # for github/codeql-action/init to get workflow details
19-
contents: read # for actions/checkout to fetch code
20-
security-events: write # for github/codeql-action/autobuild to send a status report
2124
name: Analyze
2225
runs-on: ubuntu-latest
26+
permissions:
27+
actions: read
28+
contents: read
29+
security-events: write
2330

2431
strategy:
2532
fail-fast: false
2633
matrix:
27-
# Override automatic language detection by changing the below list
28-
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
29-
language: ['go']
30-
# Learn more...
31-
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
34+
language: [ 'go' ]
3235

3336
steps:
3437
- name: Harden Runner
@@ -38,23 +41,14 @@ jobs:
3841

3942
- name: Checkout repository
4043
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41-
with:
42-
# We must fetch at least the immediate parents so that if this is
43-
# a pull request then we can checkout the head.
44-
fetch-depth: 2
45-
46-
# If this run was triggered by a pull request event, then checkout
47-
# the head of the pull request instead of the merge commit.
48-
- run: git checkout HEAD^2
49-
if: ${{ github.event_name == 'pull_request' }}
5044

5145
# Initializes the CodeQL tools for scanning.
5246
- name: Initialize CodeQL
5347
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
5448
with:
5549
languages: ${{ matrix.language }}
5650
# If you wish to specify custom queries, you can do so here or in a config file.
57-
# By default, queries listed here will override any specified in a config file.
51+
# By default, queries listed here will override any specified in a config file.
5852
# Prefix the list here with "+" to use these queries and those in the config file.
5953
# queries: ./path/to/local/query, your-org/your-repo/queries@main
6054

0 commit comments

Comments
 (0)