Skip to content

Conversation

@ggppdk
Copy link
Contributor

@ggppdk ggppdk commented Aug 8, 2016

Pull Request for Issue #11463 and #11510

Summary of Changes

Fixed edit check in backend not allowing edit via edit.own after soft deny
Same code used for frontend

Testing Instructions

(check is the same for frontend / backend)

at backend articles manager,
at frontend views that show the edit button

make sure that people that should be allowed to edit can do and others can not

@ggppdk ggppdk changed the title Fix edit check in backend not allowing edit via edit.own after soft deny Fix edit check in backend articles manager, always denying edit after soft deny Aug 8, 2016
@infograf768
Copy link
Member

I have tested this item ✅ successfully on

Looks like working here.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@alikon
Copy link
Contributor

alikon commented Aug 8, 2016

i have experienced this issue on GsoC 2016 Multilingual project.

test conditions

  • Create a user "test" added to "Administrator" group
  • Go to com_content Options, Permissions tab and disable "Edit" for "Administrator" group
    permission
  • Create a new content item with the "test" user

before patch
You can't edit your own.

Apply patch
you can edit your own items.

p.s
tested on backend only

@joomla-cms-bot joomla-cms-bot changed the title Fix edit check in backend articles manager, always denying edit after soft deny Regression: Fix edit check in backend articles manager, always denying edit after soft deny Aug 8, 2016
@jeckodevelopment
Copy link
Member

I have tested this item ✅ successfully on


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@ggeorgg
Copy link

ggeorgg commented Aug 8, 2016

I have tested this item ✅ successfully on
Thanks a lot!

@zero-24
Copy link
Contributor

zero-24 commented Aug 8, 2016

RTC. Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 8, 2016
@matrix630307
Copy link

I have tested this item successfully. Thank's.

$user = JFactory::getUser();

// For new record (id:0) return component permission
// Zero record (id:0) return component permission, e.g. show edit btn
Copy link
Contributor

Choose a reason for hiding this comment

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

That makes less sense than it did before. Now I domt have a clue what it means

Copy link
Contributor Author

@ggppdk ggppdk Aug 9, 2016

Choose a reason for hiding this comment

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

It was like this before,

why any code is calling allowEdit() on zero id ?
only purpose would be to get component edit

for me it is meaningless, and from what i see in the code ,
we can probably return false and break nothing,

I have checked this,

  • there is no code in Joomla that uses allowEdit() to decide creating new records, or to get component permissions (by passing zero record id)

so we can change it to false !

(maybe some 3rd party extends the class though and use it to get component edit, but i think it is very unlikely)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, with like this before

  • i mean current "frontend" controller
  • and backend controller in J3.6.0

@zero-24
Copy link
Contributor

zero-24 commented Aug 10, 2016

Put off RTC so we get a retest after the last changes Thanks.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 10, 2016
@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

yes i made 1 more change (besides comments),

  • always return false if article id is 0

I searched through all calls of the method, i did not find any usage that will need to return component permissions, in such a case,

so better return false (aka deny), in case someone in the future writes code to misuse this

@mbabker
Copy link
Contributor

mbabker commented Aug 10, 2016

Except this is wrong. You've introduced a hard deny rule instead of continued use of the ACL system in this scenario. So there needs to be a pretty freakin' strong validation against this change because right now that screams massive B/C break to me.


// If we get a deny at the component level, we cannot override here.
if (!parent::allowEdit($data, $key))
// Zero record (id:0) return false, if caller wants component permissions just get them directly
Copy link
Contributor

Choose a reason for hiding this comment

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

So a method that is supposed to check the ACL now has a hardcoded deny rule in place when it should be using the ACL system? Am I the only one who sees an issue with this?

@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

Can you find a place that is needed today ?
And something that gets broken ?

example

    protected function allowSave($data, $key = 'id')
    {
        $recordId = isset($data[$key]) ? $data[$key] : '0';

        if ($recordId)
        {
            return $this->allowEdit($data, $key);
        }
        else
        {
            return $this->allowAdd($data);
        }
    }

so calling allowEdit() on zero record id as an indirect way to get return parent controler permissions ?
which return the component permission,

is weird usage

i will revert, i made this change worrying of someone misusing it in the future
it creates no problems

@mbabker
Copy link
Contributor

mbabker commented Aug 10, 2016

I don't have a place off hand that will break with that hardcoded change but the point of it is that something that should be reading the ACL system should be doing that, not introducing an arbitrary rule based on some condition and not even implement it consistently.

@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

I restored the code it is same as before, when all testing was done

but that deny would break nothing anyway, because it is not used anywhere

anyway this is PR makes the allowEdit how it should have been in the first place

@mbabker
Copy link
Contributor

mbabker commented Aug 10, 2016

I agree it shouldn't be getting used, but in the off case someone's code is screwed up somewhere it should still respect the ACL system or throw an Exception because at that point it's dealing with an invalid record anyway.

@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

The code is correct to be there
i am not saying something different

but after 1 or 2 years someone may write code to misuse it

  • that was my only reason for making that change

@mbabker
Copy link
Contributor

mbabker commented Aug 10, 2016

It needs to be a separate proposal if you're going to push for it. We all have a very bad habit of throwing unrelated items into pull requests because we're already making a change or want to enforce some arbitrary standard. That crap needs to stop.

@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

It needs to be a separate proposal if you're going to push for it. We all have a very bad habit of throwing unrelated items into pull requests because we're already making a change or want to enforce some arbitrary standard. That crap needs to stop.

yes correct, it is unrelated to this PR, but you know how it is with finding people to test PRs etc

@mbabker
Copy link
Contributor

mbabker commented Aug 10, 2016

Oh I know, I know. I've got cache PRs stalled out because someone asked for an arbitrary extra change, one of which actually adds support for a PHP 5.3 feature to our callback system.

@infograf768
Copy link
Member

where do we stand here?

@ggppdk
Copy link
Contributor Author

ggppdk commented Aug 10, 2016

Hello

please click on each of the commit made August 10,
https://github.com/joomla/joomla-cms/pull/11511/commits

5 commits

  • 1 commit changes comments
  • 2 next commits changed in the 2 controllers (frontend / backend identical), for the case of record ID zero
        if (!$recordId)
        {
-           return parent::allowEdit($data, $key);
+           return false;
        }

this should be still be RTC

  • 2 more commits changed it back to be the same as when all tests where made
        if (!$recordId)
        {
-           return false;
+           return parent::allowEdit($data, $key);
        }

@zero-24
Copy link
Contributor

zero-24 commented Aug 10, 2016

Back to RTC. Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 10, 2016
@Sieger66
Copy link
Contributor

I have tested this item ✅ successfully on 84d0dad


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11511.

@rdeutz rdeutz added this to the Joomla 3.6.3 milestone Aug 14, 2016
@rdeutz rdeutz merged commit cb4ffa5 into joomla:staging Aug 14, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 14, 2016
izharaazmi added a commit to izharaazmi/joomla-cms that referenced this pull request Aug 15, 2016
* re-arrayhelper-min: (2467 commits)
  Minimize JArrayHelper methods `toInteger`, `pivot`, `arrayUnique` by using Joomla\Utilities\ArrayHelper internally. Leaving (reverting from joomla#7782) other four methods as is for b/c reasons as mentioned in joomla#8455.
  remove platform include (joomla#11615)
  [GitHub Templates] Make headings bigger (joomla#11607)
  [com_contact] Make ACL core.edit.own work (PR for 11466) (joomla#11503)
  Small review on docs & code structure in JModelLegacy library classes (joomla#11057)
  Obviously, this should be an array. (joomla#11610)
  Don't manually import JPlatform anymore (joomla#10841)
  Parse preprocess rules from component routers (joomla#8986)
  Add the correct exception after 11593 merge (was waiting for that merrge) (joomla#11606)
  Add missing clean line after joomla#9277 (joomla#11605)
  Deprecate the _PROFILER global var (joomla#10845)
  Spelling errors (joomla#11604)
  Moved travis javascript bash file to build/travis like joomla#11600 (joomla#11603)
  Regression: Fix edit check in backend articles manager, always denying edit after soft deny (joomla#11511)
  [com_plugins] User not allowed to core.manage? Use 403 php custom exception (instead of a 404 JError) (joomla#11593)
  [com_newsfeeds] Make ACL core.edit.own work (PR for 11466) (joomla#11502)
  $result-variable-undefined-given-default-value (joomla#9277)
  com_banners use exceptions. and not allowed is a 403 (joomla#11418)
  Frontend & plugins using the autoloader (joomla#10882)
  New version of PR 6788 (JText::_() Optimizations) (joomla#11235)
  ...
ggppdk added a commit to ggppdk/joomla-cms that referenced this pull request Aug 19, 2016
…g edit after soft deny (joomla#11511)

* Fix allow after soft deny in backend

* Improve edit check in frontend similar to backend

* Better comments for the code

* Force better usage of allowEdit

* Force better usage of allowEdit

* Restore behaviour on zero record id to return component edit permissions

* Restore behaviour on zero record id to return component edit permissions
roland-d pushed a commit to roland-d/joomla-cms that referenced this pull request Sep 11, 2016
…g edit after soft deny (joomla#11511)

* Fix allow after soft deny in backend

* Improve edit check in frontend similar to backend

* Better comments for the code

* Force better usage of allowEdit

* Force better usage of allowEdit

* Restore behaviour on zero record id to return component edit permissions

* Restore behaviour on zero record id to return component edit permissions
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.