-
Notifications
You must be signed in to change notification settings - Fork 1
Improve CI gates: drift checks, coverage, CodeQL, PR analysis #6
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: master
Are you sure you want to change the base?
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,13 @@ | ||
| name: "CodeQL config" | ||
|
|
||
| query-filters: | ||
| - exclude: | ||
| problem.severity: | ||
| - warning | ||
| - recommendation | ||
| - exclude: | ||
| id: go/log-injection | ||
|
|
||
| paths-ignore: | ||
| - '**/*_test.go' | ||
| - '**/*.test.*' | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||||||
| name: "CodeQL" | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| push: | ||||||||||||||
| branches: [master, 'release-*'] | ||||||||||||||
| pull_request: | ||||||||||||||
| branches: [master, 'release-*'] | ||||||||||||||
| schedule: | ||||||||||||||
| - cron: '30 4 * * 0' | ||||||||||||||
|
|
||||||||||||||
| permissions: | ||||||||||||||
| contents: read | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| analyze: | ||||||||||||||
| permissions: | ||||||||||||||
| security-events: write | ||||||||||||||
| name: Analyze | ||||||||||||||
|
Comment on lines
+16
to
+18
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. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '== .github/workflows/codeql-analysis.yml (outline) ==\n'
ast-grep outline .github/workflows/codeql-analysis.yml --view expanded || true
printf '\n== .github/workflows/codeql-analysis.yml (numbered, first 240 lines) ==\n'
cat -n .github/workflows/codeql-analysis.yml | sed -n '1,240p'
printf '\n== Search for permissions blocks in workflow files ==\n'
rg -n --glob '.github/workflows/*.yml' --glob '.github/workflows/*.yaml' 'permissions:|contents: read|security-events: write|actions/checkout|github/codeql-action' .github/workflowsRepository: mattermost/mattermost-plugin-docs Length of output: 3583 🌐 Web query:
💡 Result: In GitHub Actions, when you define the permissions key at the job level, it completely overrides any permissions defined at the workflow level [1][2]. The permissions do not merge; the job-level configuration becomes the definitive set of permissions for that specific job [2]. When you explicitly use the permissions key—at either the workflow or job level—any permissions that you do not specify are automatically set to none (no access), with the sole exception of the metadata scope, which always retains read access [1][3][4]. For the actions/checkout action, the recommended configuration to ensure it can successfully check out your repository is to explicitly grant read access to the contents scope [5][6][7]: permissions: contents: read If you have a workflow-level permissions block but need to override it for a specific job while maintaining the actions/checkout functionality, you must include contents: read in that job's permissions block, as it will otherwise be reset to none [1][2]. Citations:
Add 🤖 Prompt for AI Agents |
||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
|
|
||||||||||||||
| strategy: | ||||||||||||||
| fail-fast: false | ||||||||||||||
| matrix: | ||||||||||||||
| language: ['go', 'javascript'] | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| - name: Checkout repository | ||||||||||||||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||||||
|
Comment on lines
+27
to
+28
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 Disable checkout credential persistence.
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.26.1)[warning] 27-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||
|
|
||||||||||||||
| - name: Initialize CodeQL | ||||||||||||||
| uses: github/codeql-action/init@v3.28.9 | ||||||||||||||
| with: | ||||||||||||||
| languages: ${{ matrix.language }} | ||||||||||||||
| debug: false | ||||||||||||||
| config-file: ./.github/codeql/codeql-config.yml | ||||||||||||||
|
|
||||||||||||||
| - name: Autobuild | ||||||||||||||
| uses: github/codeql-action/autobuild@v3.28.9 | ||||||||||||||
|
|
||||||||||||||
| - name: Perform CodeQL Analysis | ||||||||||||||
| uses: github/codeql-action/analyze@v3.28.9 | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: PR Test Analysis Override | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| concurrency: | ||
| group: test-analyzer-${{ github.event.issue.number }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| override: | ||
| permissions: | ||
| statuses: write | ||
| pull-requests: read | ||
| contents: read | ||
| issues: write | ||
| if: >- | ||
| github.repository == 'mattermost/mattermost-plugin-docs' && | ||
| github.event.issue.pull_request && | ||
| startsWith(github.event.comment.body, '/test-analysis-override') && | ||
| contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) | ||
| uses: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis-override.yml@main | ||
| with: | ||
| pr_number: ${{ github.event.issue.number }} | ||
| target_repo: mattermost/mattermost-plugin-docs | ||
| comment_body: ${{ github.event.comment.body }} | ||
| comment_id: ${{ github.event.comment.id }} | ||
| sender: ${{ github.event.comment.user.login }} | ||
| secrets: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| WEBHOOK_URL: ${{ secrets.WEBHOOK_URL_TEST_PR_ANALYSIS_HUB }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: PR Test Analysis | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: | ||
| - master | ||
| - 'release-*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: 'PR number to analyze' | ||
| required: true | ||
| type: number | ||
| claude_model: | ||
| description: 'Claude model to use (default: claude-sonnet-4-6)' | ||
| required: false | ||
| type: string | ||
|
|
||
| concurrency: | ||
| group: test-analyzer-${{ github.event.pull_request.number || inputs.pr_number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| analyze: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| statuses: write | ||
| id-token: write | ||
| # pull_request: skip drafts and forks (drafts are not ready for analysis; | ||
| # fork runs do not receive this repo's Actions secrets). | ||
| # workflow_dispatch: always allowed — runs in this repo with secrets, so you can pass a fork PR number manually. | ||
| if: >- | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event.pull_request.draft == false && | ||
| github.event.pull_request.head.repo.full_name == 'mattermost/mattermost-plugin-docs') | ||
| uses: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis.yml@main | ||
|
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
for f in .github/workflows/pr-test-analysis.yml .github/workflows/codeql-analysis.yml .github/workflows/pr-test-analysis-override.yml; do
echo "===== $f ====="
nl -ba "$f" | sed -n '1,120p'
echo
doneRepository: mattermost/mattermost-plugin-docs Length of output: 262 🏁 Script executed: #!/bin/bash
set -euo pipefail
for f in .github/workflows/pr-test-analysis.yml .github/workflows/codeql-analysis.yml .github/workflows/pr-test-analysis-override.yml; do
echo "===== $f ====="
sed -n '1,140p' "$f"
echo
doneRepository: mattermost/mattermost-plugin-docs Length of output: 3976 Pin reusable workflows and CodeQL actions to commit SHAs. These references still use mutable tags/branches while running with repository permissions and secrets:
📍 Affects 3 files
🤖 Prompt for AI Agents |
||
| with: | ||
| pr_number: ${{ github.event.pull_request.number || inputs.pr_number }} | ||
| target_repo: mattermost/mattermost-plugin-docs | ||
| claude_model: ${{ inputs.claude_model || vars.CLAUDE_MODEL || 'claude-sonnet-4-6' }} | ||
| secrets: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| WEBHOOK_URL: ${{ secrets.WEBHOOK_URL_TEST_PR_ANALYSIS_HUB }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: mattermost/mattermost-plugin-docs
Length of output: 2623
🏁 Script executed:
Repository: mattermost/mattermost-plugin-docs
Length of output: 13249
Remove the global
go/log-injectionexclusion in.github/codeql/codeql-config.yml:3-9. This disables CodeQL’s log-injection check across every Go file in the repo; keep it only with a documented repository-wide false-positive review, otherwise scope it to the specific finding.🤖 Prompt for AI Agents