Skip to content

fix(permissions): add a check for empty glob paths#5415

Merged
victorvhs017 merged 3 commits intomainfrom
fix/check-emprty-secretpath-for-service-token
Feb 10, 2026
Merged

fix(permissions): add a check for empty glob paths#5415
victorvhs017 merged 3 commits intomainfrom
fix/check-emprty-secretpath-for-service-token

Conversation

@victorvhs017
Copy link
Contributor

@victorvhs017 victorvhs017 commented Feb 10, 2026

Context

If the service token has an empty path, it would cause an error in the glob processor.

  • Added a check in the CASL index to prevent empty glob paths from being processed.
  • Added a simple validation to prevent empty secretPaths in the UI

Screenshots

image

Steps to verify the change

Create a Service Token with an empty Secrets Path and try to call the secrets endpoints with that token.

  • You'll have to update the path in the db because we are blocking this in the UI now
  • If you have an empty path, it will return nothing "{"secrets":[],"imports":[]}%"
  • If you have a non-empty path, it will do the query

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Read the contributing guide

Updated the project-permission service to consolidate permission conditions into a single object, improving readability and maintainability. Additionally, added a check in the CASL index to prevent empty glob paths from being processed.
@maidul98
Copy link
Collaborator

maidul98 commented Feb 10, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

Greptile Overview

Greptile Summary

This PR prevents empty glob patterns from being evaluated in CASL’s $glob matcher, and adds UI validation to block creating service token scopes with an empty secretPath.

The backend change lives in the CASL condition interpreter used for permission rule evaluation, while the frontend change updates the service token creation modal’s zod schema and small layout tweaks for the scopes form.

Confidence Score: 4/5

  • Mostly safe to merge once the frontend scope default is fixed
  • Backend change is narrowly-scoped and reduces error risk in glob evaluation. Main concern is the frontend now appends an invalid empty secretPath, which can regress the service token creation flow/UX and cause failed submissions.
  • frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx

Important Files Changed

Filename Overview
backend/src/lib/casl/index.ts Adds a guard to treat empty $glob patterns as non-matching before calling picomatch.
frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx Adds zod min(1) validation for secretPath and tweaks layout; introduces a default empty secretPath when adding new scope, which will always fail validation.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Added validation to ensure the secret path is not empty in the AddServiceTokenModal. Adjusted layout styles for better alignment of token scopes in the form, improving user experience.
@victorvhs017
Copy link
Contributor Author

@greptileai re-review and update the summary

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

Additional Comments (1)

frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx
New scope starts invalid

The new zod constraint (secretPath.min(1)) makes an empty string invalid, but the “Add Scope” button appends secretPath: "" (AddServiceTokenModal.tsx:210-214). This means every newly-added scope will immediately fail validation until the user types something, which is a regression in UX and can block submit if the user forgets to fill it. Appending the same default used elsewhere (e.g. "/") avoids creating an invalid form state by default.

Updated the AddServiceTokenModal to set a default secret path of "/" instead of an empty string. Additionally, modified the CASL index to trim whitespace from permission glob paths, preventing empty values from being processed.
@victorvhs017 victorvhs017 merged commit e916454 into main Feb 10, 2026
11 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