Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Rust CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Check formatting
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test

- name: Build
run: cargo build --release
Comment on lines +14 to +36

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

In general, this issue is fixed by explicitly declaring a minimal permissions block for the workflow or each job, instead of relying on repository or organization defaults. For a CI workflow that only checks, tests, and builds code, contents: read is sufficient and recommended.

For this specific workflow, we can add a root-level permissions block so it applies to all jobs (there is only one job, build). We do not need any write permissions because the workflow performs only local cargo commands and uses actions/checkout@v4, which works with contents: read. The least intrusive fix is to insert:

permissions:
  contents: read

between the on: trigger block and the env: block (after line 7 and before line 9). No additional methods, imports, or dependencies are required; this is purely a YAML configuration change within .github/workflows/rust-ci.yml.

Suggested changeset 1
.github/workflows/rust-ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml
--- a/.github/workflows/rust-ci.yml
+++ b/.github/workflows/rust-ci.yml
@@ -6,6 +6,9 @@
   pull_request:
     branches: [ main ]
 
+permissions:
+  contents: read
+
 env:
   CARGO_TERM_COLOR: always
 
EOF
@@ -6,6 +6,9 @@
pull_request:
branches: [ main ]

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

Copilot is powered by AI and may make mistakes. Always verify output.
Loading