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

Fixed query with hidden search fields. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Daniel-KM
Copy link

Hi,

When a search field is removed from the advanced form, the search can always be done via direct manipulation of the url. This patch forbids it.

Sincerely,

Daniel Berthereau
Infodoc & Knowledge management

*/
public function hookItemsBrowseSql($args)
{
if ($this->_overrideFilter() || !isset($this->_settings['search']) || empty($this->_settings['search'])) {
Copy link
Owner

Choose a reason for hiding this comment

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

The !isset() on this line is redundant, it should be entirely covered by the empty().

Copy link
Author

Choose a reason for hiding this comment

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

Ok.

@zerocrates
Copy link
Owner

Have you thought about removing the offending advanced "rows" using the browse params filter instead? So the search would, instead of returning zero results, just act like those fields weren't part of the search, and you wouldn't have to touch the SQL.

At any rate, I'll have to think about this one. It may need to be toggleable by some specific setting, because I think it's reasonable to merely hide from the search, rather than totally remove the ability. For example, you could want to remove elements from the search form seen by users but still want something like SearchByMetadata to keep working (which makes direct "search" browse links that use the advanced search).

@Daniel-KM
Copy link
Author

Hi,

For this patch, my priority was a security one, but yours is an interface one. I don't want that a user can search an internal field or can guess what it is inside with multiple queries via the direct manipulation of the url. So in that case, a forbidden field should return an empty result. But it's ok if each field may be enable or not.

For the choice between the hook and the filter, I think it was simpler to use the last used, specially because the method should filter not only advanced params, but the main simple "Search for words" field too.

Sincerely,

Daniel Berthereau
Infodoc & Knowledge management

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.

2 participants