cerbos icon indicating copy to clipboard operation
cerbos copied to clipboard

Detect missing lenient scopes configuration

Open alexolivier opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Feature description

When compiling policies, if there is a nested scope but the lenient scopes flag isn't set in the server config or the test suite show a message to the user suggesting this is why things are working as expected

What would the ideal solution look like to you?

No response

Anything else?

No response

alexolivier avatar Oct 01 '24 08:10 alexolivier

Hello @alexolivier :)

Hello please include a check to see if the "lenient scopes" flag is absent when using nested scopes during policy compilation. Show the user a clear warning message if the flag is not set and advise them to enable it in the server configuration or test suite. This will guarantee correct handling of nested scopes in policies and avoid confusion.

naaa760 avatar Oct 01 '24 08:10 naaa760

I don't understand this one. As it says in the docs

This setting only affects how Cerbos treats missing leaf scopes when searching for policies.

How could we know at compile time if the user is going to query at run time for a leaf scope that doesn't exist?

The only thing we can check at compile time is if there are any broken scope chains. We already do that (and it's independent of whether lenient scopes are enabled).

haines avatar Oct 01 '24 11:10 haines

Agreed for compile time - where this got run into is specifically around tests which don't have the flag enabled. We have the fixtures and so know the scopes.

alexolivier avatar Oct 01 '24 12:10 alexolivier

Ok, that makes more sense. So maybe we can do something like "If a test fails, but would've passed had lenientScopeSearch been enabled, include a warning in the results"?

haines avatar Oct 01 '24 12:10 haines

Maybe something even simpler. "Your policies contain scopes and the test suite is running with leninetScopesSearch ENABLED/DISABLED"

alexolivier avatar Oct 01 '24 14:10 alexolivier

I would be reluctant to print a message if everything is fine, except maybe in verbose mode.

haines avatar Oct 01 '24 15:10 haines