Problem/Motivation
cron_example module doesn't demonstrate basic security best practices on its routes.
We need to change that.
In the routes.yml file, it currently says:
requirements:
_access: 'TRUE'
This allows anyone with access to the site to see the page, which opens up other possible security concerns.
Proposed resolution
- Change the routes.yml file to say something like this:
requirements: _permission: 'access content' - Update the tool menu test to reflect that this route is not visible to anonymous users, and *is* visible once a user with 'access content' permissions has been logged in.
- Amend any tests which use these routes to log in a user who can access them.
Comments
Comment #2
sumthief commentedComment #3
mile23Comment #4
mile23Comment #7
sumthief commentedNeed manually review.
Comment #9
sumthief commentedUpdate tests in patch #2.
Comment #10
marvil07 commentedHow was the 2nd and 3rd hunk related t the issue here? (i.e. use minimal profile and give admin permission to the test user)
Comment #11
sumthief commentedThanks for your response. The test failed cause it can't find 'Run cron now' button: because it'll shown only for user with 'administer site configuration' permission. So including profile is one of ways to provide this permission for user creating process. But it's incorrect. So there is new patch.
Comment #12
sumthief commentedComment #16
sumthief commentedUpdate patch.
Comment #17
sumthief commentedComment #18
andrew.mikhailov commentedHello!
Grigory's patch correct but not quite, you need to define user's permissions in setUp method.
Please check interdiff and apply this patch from Grigory.
Thank you.
Best regards.
Comment #20
andrew.mikhailov commentedSorry, old my problem)
I've created patch via phpStorm)
I removed unnecessary module 'system' from test)
Best regards.
Comment #22
andrew.mikhailov commentedSeems it was wrong...
One more time, don't forget apply this patch from Grigoriy.
Best regards.
Comment #24
mile23We don't need system, but we do need node since it provides 'access content.'
Fixed on commit.
Thanks!
Comment #25
sumthief commented@Mile23, why we don't need 'system'? It provides permision 'administer site configuration'.
According to patch from #20: It has no 'system' in module list, but tests failed because there are no button 'Run cron now'. I think it caused by missing permission (in form builder there is the condition that checks the permission and doesn't create form element if user has no permission). But patch from #22 (or 18) absolutely identical to patch from #20 excluding existing 'system' in module list. And patches from #22 and #18 passed tests succesfully. So I think we should include system in module list.
Comment #26
mile23The patch in #20 says
...which should be '_permission'.
The 'administer site configuration' permission doesn't come from the system module.