Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_x86_64
build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_aarch64

common --extra_toolchains=@gcc_toolchain//:host_gcc_12


# Clippy linting (enabled by default)
build --aspects=@score_rust_policies//clippy:linters.bzl%clippy_strict
build --output_groups=+rules_lint_human
build:lint --@aspect_rules_lint//lint:fail_on_violation=true

29 changes: 29 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
name: Bazel Clippy

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
merge_group:
types: [checks_requested]

jobs:
bazel-clippy:
uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@main
with:
bazel-targets: "//src/..."
bazel-config: "lint"
Comment on lines +26 to +29

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: {}

Copilot Autofix

AI 13 days ago

To fix the problem, the workflow must declare an explicit permissions block, either at the workflow root (recommended here) or on the bazel-clippy job. Since this workflow only triggers static analysis through a reusable workflow and does not appear to need any write operations, we can set the GITHUB_TOKEN to read-only for repository contents. A minimal safe baseline is permissions: contents: read, which aligns with GitHub’s recommended least-privilege configuration for read-only workflows.

The best fix without changing functionality is to add a top-level permissions block right after the on: section (or directly after name:), applying to all jobs that do not override it. This will limit GITHUB_TOKEN to read-only on repository contents while still allowing the reusable workflow to run its analysis. No additional imports or methods are needed; only the YAML in .github/workflows/clippy.yml is changed.

Concretely: in .github/workflows/clippy.yml, insert a new top-level block:

permissions:
  contents: read

between the on: section (lines 15–22) and the jobs: section (line 24). This is sufficient to address the CodeQL finding.

Suggested changeset 1
.github/workflows/clippy.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/clippy.yml b/.github/workflows/clippy.yml
--- a/.github/workflows/clippy.yml
+++ b/.github/workflows/clippy.yml
@@ -21,6 +21,9 @@
   merge_group:
     types: [checks_requested]
 
+permissions:
+  contents: read
+
 jobs:
   bazel-clippy:
     uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@main
EOF
@@ -21,6 +21,9 @@
merge_group:
types: [checks_requested]

permissions:
contents: read

jobs:
bazel-clippy:
uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@main
Copilot is powered by AI and may make mistakes. Always verify output.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
profile: minimal
toolchain: 1.87.0
override: true
components: rustfmt, clippy
components: rustfmt

- name: check code format (rustfmt)
uses: actions-rs/cargo@v1
Expand All @@ -63,9 +63,3 @@ jobs:
with:
command: xtask
args: check_lic

- name: check clippy errors
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features tracing --all-targets --workspace -- -D warnings
5 changes: 4 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ module(
bazel_dep(name = "rules_python", version = "1.4.1")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_rust", version = "0.61.0")

bazel_dep(name = "score_rust_policies", version = "0.0.4", dev_dependency = True)

bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
bazel_dep(name = "aspect_rules_lint", version = "2.0.0")
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
bazel_dep(name = "platforms", version = "1.0.0")

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ Build all targets:
bazel build //...
```

## Clippy

- Clippy runs by default via `.bazelrc` when building Rust targets (rules_lint aspect).
- Use `bazel build //src/...` (or any Rust target pattern) while developing.
- Use `bazel build --config=lint //src/...` to enable lint config, including `--@aspect_rules_lint//lint:fail_on_violation=true`.
- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`.

## Build for QNX8

### Preparations
Expand Down
Loading