Skip to content

Conversation

@matysek
Copy link
Contributor

@matysek matysek commented Aug 26, 2025

Description

LCORE-595: Fix bandit GH actions - use GH actions from PyQCA

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Chores
    • Upgraded the security scanning workflow to the latest Bandit action for improved reliability.
    • Adjusted permissions to enable reporting security findings to GitHub’s Security tab.
    • Updated configuration to scan the intended source targets.
    • Enforced non-zero exit on security findings to prevent merging insecure changes.
    • Aligns CI setup with GitHub Actions best practices for clearer, more actionable security feedback.
    • No user-facing functionality changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Updated the Bandit GitHub Actions workflow: switched to PyCQA/bandit-action@v1, changed input from path to targets, removed exit_zero, and added permissions for security-events: write and actions: read.

Changes

Cohort / File(s) Summary
CI workflow — Bandit
./.github/workflows/bandit.yaml
Switched action mdegis/bandit-action@v1.0 → PyCQA/bandit-action@v1; changed input key path → targets ("src"); removed exit_zero: true; added permissions: security-events: write, actions: read.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant GH as GitHub Actions
  participant Job as bandit job
  participant Act as PyCQA/bandit-action@v1
  participant Sec as GitHub Security (SARIF)

  Dev->>GH: Push/PR triggers workflow
  GH->>Job: Start bandit job (with permissions)
  Job->>Act: Run Bandit on targets="src"
  Act->>Act: Scan code and produce report
  Act-->>Sec: Upload SARIF (security-events: write)
  Sec-->>Dev: Results visible in Security tab

  note over Job,Act: exit_zero removed → non-zero exit on findings
  note over Job: permissions added: actions: read, security-events: write
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled the YAML with whiskered delight,
Swapped in PyCQA—so clean, so right.
Set targets to "src", let findings ring true,
No exit_zero—we’ll face what we chew.
With security writes, I hop to the page,
A carrot for CI, and a safer stage. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/workflows/bandit.yaml (4)

12-12: Nit: actions: read is only needed for private repos.

If this repository is public, you can drop actions: read to minimize token scope; keep it if the repo is private.

Rationale and examples are in the official docs and general GitHub Actions least-privilege guidance. (github.com, wellarchitected.github.com)


16-16: Pin the action to a stable release (or commit SHA) for supply-chain safety.

Tag @v1 can drift. Prefer pinning to the latest stable release (e.g., @v1.0.1 as of Aug 1, 2025) or a full commit SHA.

Apply this minimal change:

-      - uses: PyCQA/bandit-action@v1
+      - uses: PyCQA/bandit-action@v1.0.1

Release reference: v1.0.1 noted in the repo’s Releases. (github.com)


18-18: targets input name is correct; verify the path and consider scanning the repo root.

  • targets is the right input for PyCQA/bandit-action. ✔
  • Ensure the src directory exists in this repository; Bandit will error if the path is missing.
  • If code is spread across multiple dirs (e.g., also under tests or scripts), consider scanning the repo root (".") or listing multiple targets.

Two alternative tweaks:

Option A (scan whole repo):

-          targets: "src"
+          targets: "."

Option B (scan multiple top-level dirs):

-          targets: "src"
+          targets: "src tests"

Official inputs reference for targets. (github.com, bandit.readthedocs.io)


18-18: Plan for failing builds now that exit_zero is gone.

Dropping an “exit zero” behavior is good to enforce fixes, but it will fail builds if legacy Bandit findings exist. Consider one of:

  • Set thresholds to reduce noise while still failing on meaningful issues: severity: medium, confidence: medium.
  • Introduce a Bandit baseline (commit current findings), then fail only on regressions.

Here are minimal, optional inputs you can add under the same with: block:

           targets: "src"
+          severity: "medium"
+          confidence: "medium"
+# If needed:
+#         baseline: ".bandit-baseline.json"

Inputs are supported by the official action. (github.com, bandit.readthedocs.io)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 969904b and c5e90d2.

📒 Files selected for processing (1)
  • .github/workflows/bandit.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests
🔇 Additional comments (3)
.github/workflows/bandit.yaml (3)

11-11: Good: enabling SARIF upload with security-events: write.

This permission is required for code scanning alerts to be uploaded. Matches the official Bandit action guidance.

See: PyCQA/bandit-action README and Bandit docs. (github.com, bandit.readthedocs.io)


16-16: Switch to the official PyCQA/bandit-action looks right.

Using PyCQA/bandit-action@v1 aligns with upstream recommendations.

Reference: official README/Marketplace. (github.com)


15-19: Sanity check: no explicit checkout step.

The official example doesn’t show actions/checkout, suggesting the action handles source retrieval internally. If you observe empty scans or unexpected “no files” behavior in CI, add an explicit checkout step before running Bandit.

If needed, insert before the Bandit step:

     steps:
+      - uses: actions/checkout@v4
       - uses: PyCQA/bandit-action@v1
         with:
           targets: "src"

Official example (no checkout) and common practice references. (github.com)

@eranco74
Copy link
Contributor

/lgtm

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM

@tisnik tisnik merged commit 6192b8c into lightspeed-core:main Aug 26, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants