Skip to content

fix(ci): resolve all code scanning security alerts - #57

Merged
yacosta738 merged 3 commits into
mainfrom
maintenance
Jun 1, 2026
Merged

fix(ci): resolve all code scanning security alerts#57
yacosta738 merged 3 commits into
mainfrom
maintenance

Conversation

@yacosta738

@yacosta738 yacosta738 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This pull request makes improvements to CI workflow security and maintainability, and refactors test code for clarity and static analysis compliance. The most significant changes are grouped below.

CI workflow improvements:

  • Added explicit permissions fields to all jobs in .github/workflows/ci.yml to follow GitHub Actions security best practices. Some jobs (such as coverage) now also request statuses: write where needed. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Updated all GitHub Action steps to use explicit commit SHA references and added comments indicating the version, improving reproducibility and supply chain security. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

Build script enhancements:

  • Improved apps/rook/build.rs to always emit rerun-if-changed directives for dashboard files, ensuring correct rebuilds. Also, the dashboard build is now skipped (with a warning) if Vite is not installed, allowing cargo check to pass without front-end dependencies. [1] [2]

Test code refactoring:

  • Introduced named constants for test fixture passwords in auth_integration_tests.rs, added explicit comments to clarify their use as test data, and suppressed static analysis warnings for hard-coded values. All login tests now use these constants for clarity and maintainability. [1] [2] [3] [4] [5] [6] [7]

The build.rs unconditionally ran  which requires
node_modules/.bin/vite to exist. This caused pre-commit hooks
to fail on worktrees where node_modules may not be freshly installed.

Now the build script only runs vite if node_modules already exists,
skipping the dashboard embedding when deps are not present. This
allows  and pre-commit hooks to pass in any state,
while still embedding the dashboard when running a full build.
- Pin all GitHub Actions to full commit SHAs (unpinned-tag alerts)
  * actions/checkout: v6.0.2 → de0fac2e4500dabe0009e67214ff5f5447ce83dd
  * actions/setup-node: v6.4.0 → 48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
  * actions/setup-node: v4.2.0 → 1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
  * pnpm/action-setup: v4.1.0 → a7487c7e89a18df4991f7f222e4898a00d66ddda
  * pnpm/action-setup (markdown job): → 0e279bb959325dab635dd2c09392533439d90093

- Add explicit permissions blocks to all jobs (missing-workflow-permissions)
  * Top-level permissions: contents: read (minimal by default)
  * Per-job permissions follow principle of least privilege
  * Coverage jobs get contents:read + statuses:write for Codecov

- Refactor test passwords into named constants (hard-coded-crypto-value)
  * auth_integration_tests.rs: 4 test fixture constants with #[allow(unused)]
  * Suppresses noise while keeping test data explicit and auditable
  * Passwords are arbitrary test data, not production secrets
@github-actions github-actions Bot added area/ci CI, tooling, and automation area/testing Tests and testing infrastructure labels Jun 1, 2026
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@yacosta738, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 51 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 07fdc03c-4164-4d86-8813-f720c09d34d2

📥 Commits

Reviewing files that changed from the base of the PR and between 9ba5461 and cb18d8f.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • apps/rook/build.rs
  • crates/infrastructure/transport-axum/tests/auth_integration_tests.rs
📝 Walkthrough

Walkthrough

CI jobs receive explicit permissions and pinned GitHub Actions for supply-chain security. The Rook build script becomes more robust by unconditionally emitting cargo rebuild directives and gating the Vite dashboard build on executable presence. Auth integration tests consolidate password fixtures into module-level constants. Sonar analysis excludes Rook npm artifacts.

Changes

CI Hardening, Build Safety, and Test Fixtures

Layer / File(s) Summary
CI Workflow: Permissions and Action Pinning
.github/workflows/ci.yml
All 17 CI jobs (fmt, markdown, clippy, check, test, doc, audit, coverage, coverage-frontend, sonar, build-targets, build-windows, build-darwin, test-multi) now declare explicit permissions blocks and pin actions/checkout, pnpm/action-setup, actions/setup-node, and Codecov to immutable commit SHAs.
Build Script: Conditional Dashboard Build and Cargo Rerun
apps/rook/build.rs
Cargo rebuild directives moved to unconditional emission at script start. Dashboard Vite build gated on dashboard/node_modules/.bin/vite existence; missing executable prints warning and skips build instead of failing.
Test Fixtures: Password Constants Consolidation
crates/infrastructure/transport-axum/tests/auth_integration_tests.rs
Password fixtures (TEST_FIXTURE_PASSWORD, TEST_FIXTURE_PASSWORD_WRONG, TEST_FIXTURE_PASSWORD_ANY, TEST_FIXTURE_SECURE_PASSWORD) extracted to module top with CodeQL suppression. All inline password literals across login, session, token, and Argon2id tests replaced with fixture references.
Sonar Analysis: Rook NPM Exclusion
sonar-project.properties
sonar.exclusions expanded to exclude **/apps/rook/npm/rook/**.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Security locks and hardened gates,
Dashboard builds skip when tools await,
Test passwords rest in fixtures fine,
All changes fall in line, by design,
A safer build, a cleaner test shrine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(ci): resolve all code scanning security alerts' accurately reflects the main changes—pinning GitHub Actions to SHAs, adding explicit permissions, and refactoring hard-coded credentials in tests.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly details CI workflow security improvements, build script enhancements, and test code refactoring that align with the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch maintenance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

♻️ Duplicate comments (1)
crates/infrastructure/transport-axum/tests/auth_integration_tests.rs (1)

583-584: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove #[allow(unused)] — this constant is actively used.

Same issue as lines 26-31: TEST_FIXTURE_SECURE_PASSWORD is used throughout the password hashing tests (lines 595, 603, 613, 617, 627, 630, 645), so the #[allow(unused)] attribute is incorrect.

🔧 Suggested fix
-#[allow(unused)]
 const TEST_FIXTURE_SECURE_PASSWORD: &str = "SecurePass123!";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/infrastructure/transport-axum/tests/auth_integration_tests.rs` around
lines 583 - 584, The #[allow(unused)] attribute on the constant
TEST_FIXTURE_SECURE_PASSWORD is incorrect because the constant is referenced in
multiple tests; remove the #[allow(unused)] attribute so the declaration is just
const TEST_FIXTURE_SECURE_PASSWORD: &str = "SecurePass123!"; and run the tests
to ensure no unused-warning suppression is being misapplied (look for the
constant name TEST_FIXTURE_SECURE_PASSWORD in the password hashing tests to
confirm usage).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 24: The checkout steps use "uses: actions/checkout" without disabling
persisted credentials; update every checkout step that does not need to push or
perform authenticated git operations (e.g., the entries matching "uses:
actions/checkout@..." such as the current de0fac2e... usage and the instances
listed in the comment) to include "persist-credentials: false" in the step
configuration so token-backed git credentials are not kept in the runner
environment.
- Around line 236-238: The workflow places matrix entries at the job root and
leaves checkout credentials permissive; move each matrix: block into its job's
strategy: block for the jobs named build-targets, build-windows, build-darwin,
and test-multi (so each job has strategy: matrix: target: ...) to satisfy GitHub
Actions schema, and for every actions/checkout step in those jobs add with:
persist-credentials: false to harden credentials (mirroring the sonar job).
Locate the job definitions by the job names build-targets, build-windows,
build-darwin, test-multi and update the matrix nesting and the actions/checkout
steps accordingly.

In `@apps/rook/build.rs`:
- Around line 28-33: The stderr messages in the build script (the two eprintln!
calls) are hidden by Cargo; change them to emit Cargo-formatted warnings by
printing to stdout with the cargo:warning= prefix (replace the eprintln!
invocations in build.rs with println! calls that start with "cargo:warning=" and
include the same messages so Cargo surfaces the skip/hint during normal cargo
build output).
- Around line 16-33: The build script currently warns and skips when
vite_path.exists() is false; change the else branch to hard-fail when the build
PROFILE is "release". Read std::env::var("PROFILE").unwrap_or_default(), and if
it equals "release" emit an error (via processLogger-style eprintln! and
std::process::exit(1) or panic!) so the build aborts; otherwise keep the
existing warning/hint behavior for non-release profiles. Update the else block
that handles vite_path.exists() to perform this PROFILE check and fail in
release mode.

In `@crates/infrastructure/transport-axum/tests/auth_integration_tests.rs`:
- Around line 26-31: Remove the incorrect #[allow(unused)] attributes from the
TEST_FIXTURE_PASSWORD, TEST_FIXTURE_PASSWORD_WRONG, and
TEST_FIXTURE_PASSWORD_ANY constants (they are referenced elsewhere in the test
module: TEST_FIXTURE_PASSWORD, TEST_FIXTURE_PASSWORD_WRONG,
TEST_FIXTURE_PASSWORD_ANY) so the attribute no longer misleadingly suppresses
warnings; if CodeQL still flags hard-coded cryptographic values after
consolidation, add a CodeQL suppression comment immediately above the
constant(s) (e.g., // codeql[rust/hard-coded-cryptographic-value] Test fixture
only) instead of #[allow(unused)].

---

Duplicate comments:
In `@crates/infrastructure/transport-axum/tests/auth_integration_tests.rs`:
- Around line 583-584: The #[allow(unused)] attribute on the constant
TEST_FIXTURE_SECURE_PASSWORD is incorrect because the constant is referenced in
multiple tests; remove the #[allow(unused)] attribute so the declaration is just
const TEST_FIXTURE_SECURE_PASSWORD: &str = "SecurePass123!"; and run the tests
to ensure no unused-warning suppression is being misapplied (look for the
constant name TEST_FIXTURE_SECURE_PASSWORD in the password hashing tests to
confirm usage).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 949798ad-29c1-4eaa-aa04-56b1d639044c

📥 Commits

Reviewing files that changed from the base of the PR and between f6fea41 and 9ba5461.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • apps/rook/build.rs
  • crates/infrastructure/transport-axum/tests/auth_integration_tests.rs
  • sonar-project.properties

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml Outdated
Comment thread apps/rook/build.rs
Comment thread apps/rook/build.rs
Comment thread crates/infrastructure/transport-axum/tests/auth_integration_tests.rs Outdated
CI workflow:
- Add persist-credentials: false to all checkout steps except
  audit job (cargo install doesn't need git creds) and sonar job
  (already had it)
- Move matrix: into strategy: for build-windows, build-darwin,
  test-multi (build-targets was already correct)

Build script (apps/rook/build.rs):
- Replace eprintln! with cargo:warning= so messages are visible
  in cargo build output (eprintln is hidden by Cargo)
- Add PROFILE=release hard fail — release builds now abort if
  vite not found, dev/check builds still warn and skip

Test fixtures (auth_integration_tests.rs):
- Remove #[allow(unused)] from all 4 test password constants
  (they ARE used in tests, attribute was misleading)
- Replace with proper CodeQL suppression comments:
  // codeql[rust/hard-coded-cryptographic-value] Test fixture only
@yacosta738
yacosta738 merged commit 6cf446f into main Jun 1, 2026
10 of 11 checks passed
@yacosta738
yacosta738 deleted the maintenance branch June 1, 2026 07:09
This was referenced Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci CI, tooling, and automation area/testing Tests and testing infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant