-
Notifications
You must be signed in to change notification settings - Fork 74
Add codeql workflow #1685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add codeql workflow #1685
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||||||||
| # | ||||||||||||||
| # Copyright (c) 2019-2026 Red Hat, Inc. | ||||||||||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||
| # you may not use this file except in compliance with the License. | ||||||||||||||
| # You may obtain a copy of the License at | ||||||||||||||
| # | ||||||||||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||
| # | ||||||||||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||||||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||
| # See the License for the specific language governing permissions and | ||||||||||||||
| # limitations under the License. | ||||||||||||||
| # | ||||||||||||||
|
|
||||||||||||||
| name: DevWorkspace Operator CodeQL scan | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| push: | ||||||||||||||
| branches: [ main ] | ||||||||||||||
| pull_request: | ||||||||||||||
| branches: [ main ] | ||||||||||||||
| schedule: | ||||||||||||||
| - cron: '15 7 * * 1' | ||||||||||||||
|
|
||||||||||||||
| permissions: | ||||||||||||||
| contents: read | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| analyze: | ||||||||||||||
| name: Analyze (${{ matrix.language }}) | ||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
| permissions: | ||||||||||||||
| security-events: write | ||||||||||||||
| packages: read | ||||||||||||||
|
Comment on lines
+26
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the CodeQL job’s repository read permissions. The job-level Proposed fix permissions:
+ actions: read
+ contents: read
security-events: write
packages: read🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| strategy: | ||||||||||||||
| fail-fast: false | ||||||||||||||
| matrix: | ||||||||||||||
| include: | ||||||||||||||
| - language: go | ||||||||||||||
| build-mode: manual | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| - name: Checkout repository | ||||||||||||||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | ||||||||||||||
|
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== workflow excerpt =="
if [ -f .github/workflows/codeql.yml ]; then
nl -ba .github/workflows/codeql.yml | sed -n '1,140p'
else
echo "missing .github/workflows/codeql.yml"
fi
echo
echo "== all actions/checkout inputs (if any) =="
rg -n "uses:\s*actions/checkout@|persist-credentials|make\s+|github_token|GITHUB_TOKEN" .github/workflows/codeql.yml .github/workflows 2>/dev/null || true
echo
echo "== deterministic default check from available README text in repo =="
rg -n "persist-credentials|persist credentials|defaults:" README.md **/README.md 2>/dev/null || trueRepository: devfile/devworkspace-operator Length of output: 230 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== workflow excerpt =="
if [ -f .github/workflows/codeql.yml ]; then
awk '{printf "%6d %s\n", NR, $0}' .github/workflows/codeql.yml | sed -n '1,140p'
else
echo "missing .github/workflows/codeql.yml"
fi
echo
echo "== actions/checkout and credential-related references =="
grep -RInE "actions/checkout@|persist-credentials|make[[:space:]]+|github_token|GITHUB_TOKEN|permissions:" .github/workflows/codeql.yml .github/workflows 2>/dev/null || true
echo
echo "== workflow files matching codeql =="
find .github/workflows -maxdepth 1 -type f | sort | xargs grep -l "codeql\|actions/checkout" 2>/dev/null || true
echo
echo "== lockfiles mentioning actions checkout =="
for f in action.lock actions.lock actionlint.yml .github/actionlint.yaml; do
[ -f "$f" ] && { echo "--- $f"; grep -n "actions/checkout" "$f" || true; }
doneRepository: devfile/devworkspace-operator Length of output: 6115 🌐 Web query:
💡 Result: In Citations:
🌐 Web query:
💡 Result: The persist-credentials input for the actions/checkout GitHub Action controls whether the repository's authentication token (typically GITHUB_TOKEN) is configured in the local Git configuration [1][2]. Key details regarding this setting include: Default Behavior: The default value for persist-credentials is true [1][2]. When enabled, the action configures the Git environment to allow subsequent steps in the same job to execute authenticated Git commands (such as git fetch, git pull, or git push) automatically [1][2]. Security Context: - Risk: When set to true (the default), any step within the same job can potentially access the persisted token [3]. This has historically been a concern for security-sensitive workflows, as it can allow unauthorized access if a job is compromised [4][3]. - Mitigation: To enhance security, users are recommended to set persist-credentials to false if the workflow does not require authenticated Git commands in subsequent steps [3][1]. - Recent Improvements: As of version v6 of actions/checkout, credential storage has been improved by moving the persisted credentials to a separate file under $RUNNER_TEMP rather than directly in the repository's.git/config [2][5]. This change was intended to mitigate risks associated with direct exposure of the token in the Git configuration [6][5]. Despite community discussions and pull requests proposing to change the default value to false to improve security posture, the default has remained true in the official actions/checkout action as of July 2026 [7][4]. Users concerned about security are advised to explicitly configure persist-credentials: false in their workflow YAML files when the functionality is not explicitly required [3][1]. Citations:
Disable checkout credential persistence.
Proposed fix uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
+ with:
+ persist-credentials: false📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.28.0)[warning] 44-45: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI AgentsSources: MCP tools, Linters/SAST tools |
||||||||||||||
|
|
||||||||||||||
| - name: Set up Go 1.x | ||||||||||||||
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 | ||||||||||||||
| with: | ||||||||||||||
| go-version-file: go.mod | ||||||||||||||
|
|
||||||||||||||
| - name: Initialize CodeQL | ||||||||||||||
| uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 | ||||||||||||||
| with: | ||||||||||||||
| languages: ${{ matrix.language }} | ||||||||||||||
| build-mode: ${{ matrix.build-mode }} | ||||||||||||||
|
|
||||||||||||||
| - name: Run manual build steps | ||||||||||||||
| if: matrix.build-mode == 'manual' | ||||||||||||||
| shell: bash | ||||||||||||||
| run: | | ||||||||||||||
| make manager | ||||||||||||||
| make compile-devworkspace-controller | ||||||||||||||
| make compile-webhook-server | ||||||||||||||
| - | ||||||||||||||
| name: Perform CodeQL Analysis | ||||||||||||||
| uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 | ||||||||||||||
| with: | ||||||||||||||
| category: "/language:${{matrix.language}}" | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.