Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission check for 'Not strict check' is wrong AFAIK #11280

Open
2 tasks done
sunnysideup opened this issue Jun 17, 2024 · 5 comments
Open
2 tasks done

Permission check for 'Not strict check' is wrong AFAIK #11280

sunnysideup opened this issue Jun 17, 2024 · 5 comments

Comments

@sunnysideup
Copy link
Contributor

Module version(s) affected

5.x-dev

Description

Have a look here:

image

https://github.com/silverstripe/silverstripe-framework/blob/5/src/Security/Permission.php#L152-L153

And compare to:
image
https://github.com/silverstripe/silverstripe-framework/blob/5/src/Security/Permission.php#L259-L275

What I am seeing is that the comment is right, but the code is wrong. It should return TRUE if the permission code is not found at all.

How to reproduce

I am just reading the code here. It says "returns TRUE", but the actual return statement is FALSE

Possible Solution

Since this has never been picked up, I would recommend removing the strict at all.

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@michalkleiner michalkleiner changed the title SECURITY: Permission Check for not Strict is wrong AFAIK Permission check for 'Not strict check' is wrong AFAIK Jun 17, 2024
@michalkleiner
Copy link
Contributor

It's definitely the safer way how it currently is though I agree the code may not match the comment/the intended use.

@GuySartorelli
Copy link
Member

Please avoid using images when referencing code - just the link to the code is sufficient, or use codeblocks if you really want to include the code in the issue itself.

@GuySartorelli
Copy link
Member

GuySartorelli commented Jun 18, 2024

Looks like in this commit (back in the SilverStripe 2 days) a refactor accidentally missed out the true from the return statement, and then later in this commit (very early Silverstripe 4) another refactor added false which probably seemed like the correct value to return without checking the PHPDoc.

Given it's been wrong since Silverstripe 2 I'm inclined to agree that the strict check should just be removed. It can be removed in 5.x without any BC changes since it ultimately returns false either way once you get to that part of the code. The parameter itself should be deprecated, to be removed in 6.

@sunnysideup
Copy link
Contributor Author

will you make the changes?

@GuySartorelli
Copy link
Member

GuySartorelli commented Jun 19, 2024

There are over 2000 issues across the supported modules, and three total people on the CMS Squad. I can't commit to saying I or anyone on the CMS Squad will make changes for any given issue unless it has a high or critical impact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants