add CodeQL, Trivy and Clippy checks - #48
Conversation
7bd06e1 to
81b1e14
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Trivy failures do not gate deployment, and CodeQL does not analyze Rust.
Pull request overview
Adds CodeQL, Trivy, and Clippy checks to the CI workflow.
Changes:
- Runs Clippy with warnings denied.
- Adds C++ CodeQL analysis.
- Adds Trivy filesystem security scanning.
File summaries
| File | Summary |
|---|---|
.github/workflows/basic.yml |
Integrates the new checks; Trivy does not gate documentation deployment, and CodeQL omits Rust analysis. |
Review details
Suppressed comments (2)
.github/workflows/basic.yml:136
- A failed Trivy scan does not currently block documentation deployment:
deploy-documentationstill depends only onbuild-and-test, so a finding causes this job to fail while the main-branch deployment can proceed. Addtrivyto the deployment dependencies (or otherwise gate the deployment) so the newexit-code: 1check protects the published artifact.
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.deploy_documentation == 'true')
.github/workflows/basic.yml:64
languages: cppleaves the Rust workspace completely outside this CodeQL check, even though the repository is primarily Rust and the pinned CodeQL action supports Rust analysis. As a result, vulnerabilities in the public Rust API and bindings are not reported; includerustas an analyzed language (or add a separate Rust matrix job).
languages: cpp
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4101444 to
497dfd3
Compare
| /// # Safety | ||
| /// | ||
| /// `ptr` must come from `Arc::into_raw` and represent a strong reference owned by this callback. |
There was a problem hiding this comment.
This wording removes the information that the reference count needs to be incremented by the caller. This makes the whole comment pointless.
| NdRange::new([1024], [16]), | ||
| &kernel, | ||
| (f16::from_f32(3.14), &mut device_array), | ||
| (f16::from_f32(std::f32::consts::PI), &mut device_array), |
There was a problem hiding this comment.
f16 provides a PI constant.
https://docs.rs/half/latest/half/struct.f16.html#associatedconstant.PI
| impl Default for Queue { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
We deemed this to be dangerous w.r.t. performance since it hides the device the Queue is being assigned to.
There was a problem hiding this comment.
ok will remove this
| impl Default for SharedWaker { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This code will never be used.
There was a problem hiding this comment.
this is a fix for warning
warning: you should consider adding a `Default` implementation for `SharedWaker`
--> sycl/sycl-rs-sys/src/types-sys.rs:19:5
|
19 | / pub fn new() -> Self {
20 | | Self {
21 | | waker: AtomicWaker::new(),
22 | | done: AtomicBool::new(false),
23 | | }
24 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#new_without_default
= note: `#[warn(clippy::new_without_default)]` on by default
help: try adding this
|
18 + impl Default for SharedWaker {
19 + fn default() -> Self {
20 + Self::new()
21 + }
22 + }
|
| // SPDX-License-Identifier: MIT OR Apache-2.0 | ||
| // | ||
|
|
||
| #[allow(clippy::missing_safety_doc)] |
There was a problem hiding this comment.
Is this issue the reason behind that attribute? If yes - it should be documented with a comment.
|
|
||
| use crate::types::SharedWaker; | ||
|
|
||
| #[allow(clippy::missing_safety_doc)] |
There was a problem hiding this comment.
Is this issue the reason behind that attribute? If yes - it should be documented with a comment.
There was a problem hiding this comment.
this a fix for
warning: unsafe function's docs are missing a `# Safety` section
--> sycl/sycl-rs-sys/src/event-sys.rs:13:1
|
13 | #[cxx::bridge(namespace = "sycl_shims::event")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#missing_safety_doc
There was a problem hiding this comment.
These warnings are incorrectly emitted due to the linked issue. This allow attribute is a workaround.
497dfd3 to
2a24938
Compare
| ]; | ||
|
|
||
| cxx_build::bridges(&rust_sources) | ||
| cxx_build::bridges(rust_sources) |
There was a problem hiding this comment.
fixes:
warning: the borrowed expression implements the required traits
warning: the borrowed expression implements the required traits
|
|
||
| // Set the callback on first Future poll (Futures can't be active until polled) | ||
| if *this.set_callback == false { | ||
| if !*this.set_callback { |
There was a problem hiding this comment.
fixes:
warning: equality checks against false can be replaced by a negation
--> sycl/sycl-rs/src/event.rs:63:12
|
63 | if *this.set_callback == false {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!*this.set_callback`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#bool_comparison
= note: `#[warn(clippy::bool_comparison)]` on by default
| /// Submits a barrier to the queue. | ||
| pub fn barrier(&mut self) -> Result<Event> { | ||
| self.barrier_with_deps(&[]).map(Into::into) | ||
| self.barrier_with_deps(&[]) |
There was a problem hiding this comment.
fixes:
warning: useless conversion to the same type: `event::Event`
--> sycl/sycl-rs/src/queue.rs:131:36
|
131 | self.barrier_with_deps(&[]).map(Into::into)
| ____________________________________-^^^^^^^^^^^^^^^
132 | | }
| |____- help: consider removing
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#useless_conversion
= note: `#[warn(clippy::useless_conversion)]` on by default
| pub(crate) unsafe fn new(allocator: A, len: usize) -> Self { | ||
| let layout = Layout::array::<T>(len).unwrap(); | ||
| let ptr = match allocator.allocate(layout.clone()) { | ||
| let ptr = match allocator.allocate(layout) { |
There was a problem hiding this comment.
fixes:
warning: using `clone` on type `Layout` which implements the `Copy` trait
--> sycl/sycl-rs/src/usmbox.rs:54:44
|
54 | let ptr = match allocator.allocate(layout.clone()) {
| ^^^^^^^^^^^^^^ help: try removing the `clone` call: `layout`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#clone_on_copy
= note: `#[warn(clippy::clone_on_copy)]` on by default
warning: `sycl-rs` (lib test) generated 18 warnings (13 duplicates) (run `cargo clippy --fix --lib -p sycl-rs --tests` to apply 1 suggestion)
warning: `sycl-rs` (lib) generated 18 warnings (5 duplicates) (run `cargo clippy --fix --lib -p sycl-rs` to apply 2 suggestions)
| ]; | ||
|
|
||
| cxx_build::bridges(&rust_sources) | ||
| cxx_build::bridges(rust_sources) |
There was a problem hiding this comment.
fixes:
warning: the borrowed expression implements the required traits
e77035a to
07802e0
Compare
| NdRange::new([1024], [16]), | ||
| &kernel, | ||
| (f16::from_f32(3.14), &mut device_array), | ||
| (std::f16::consts::PI, &mut device_array), |
There was a problem hiding this comment.
This project uses half::f16 because std::f16 hasn't been stabilized yet - it's only available on nightly toolchains.
Removing the std:: prefix will fix this.
213215c to
c8c2203
Compare
997decf to
840c048
Compare
add CodeQL, Trivy and Clippy checks