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

BUG Don't auto grant session access when resampling images #477

Merged
merged 1 commit into from Feb 17, 2022

Conversation

maxime-rainville
Copy link
Contributor

We considered treating this as a security issue but decided that the amount of sensitive information in an image does not warrant it.

In some context, the CMS will grant your session permission to view a file irrespective of if you have access to view it. The specific thing we are trying to address here is being able to view a restricted image if it's added to a campaign.

Previous places where we addressed this included an option to allow automatic session grant via a config. I don't think we need to do this anymore since tho AssetStore now automatically grant you access to view files.

Copy link
Contributor Author

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

Note tht you can still an entry for the image in campaign admin, but you won't be able to see the actual thumbnail.

image

@maxime-rainville
Copy link
Contributor Author

Not 100% sure if this is worth covering with Unit test ... I can add some if we think it is.

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Unit tests are probably worth it to ensure someone doesn't revert this in the future in order to fix something else

@maxime-rainville maxime-rainville self-assigned this Feb 9, 2022
@maxime-rainville
Copy link
Contributor Author

Just added some unit test ... I also specifically tested that they would have failed with the old logic

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Looks good, some trivial changes to make to failed test messaging and whitespace changes

tests/php/ImageTest.php Outdated Show resolved Hide resolved
tests/php/ImageTest.php Outdated Show resolved Hide resolved
tests/php/ImageTest.php Outdated Show resolved Hide resolved
$assetStore = Injector::inst()->get(AssetStore::class);
$this->assertFalse(
$assetStore->isGranted('folder/a870de278b/test-image-high-quality__Resampled.jpg'),
'Current user is not automatically granted access to resampled image'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'Current user is not automatically granted access to resampled image'
'Logged out user was granted access to draft resampled image'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about this?

Suggested change
'Current user is not automatically granted access to resampled image'
'Current user should not automatically be granted access to resampled image'

$assetStore = Injector::inst()->get(AssetStore::class);
$this->assertFalse(
$assetStore->isGranted($fileUrl),
'Current user is not automatically granted access'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'Current user is not automatically granted access'
'Logged out user was granted access to draft resampled image'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer assertion message to describe what is being asserted, rather than what has failed.

But I can see the message here could be confusing if you think Current user is not automatically granted access describes what has failed.

What about this instead?

Suggested change
'Current user is not automatically granted access'
'Current user should not automatically be granted access to view thumbnail'

@emteknetnz
Copy link
Member

Merge on green

@emteknetnz
Copy link
Member

@maxime-rainville
Copy link
Contributor Author

Just fixed the linting issue.

@emteknetnz emteknetnz merged commit c22473b into silverstripe:1 Feb 17, 2022
@emteknetnz emteknetnz deleted the pulls/1/no-auto-grant branch February 17, 2022 04:11
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.

None yet

2 participants