Skip to content

SO-5566 Version API search restrictions#1226

Open
AAAlinaaa wants to merge 10 commits into9.xfrom
issue/SO-5566-version-api-search-restrictions
Open

SO-5566 Version API search restrictions#1226
AAAlinaaa wants to merge 10 commits into9.xfrom
issue/SO-5566-version-api-search-restrictions

Conversation

@AAAlinaaa
Copy link
Contributor

No description provided.

@AAAlinaaa AAAlinaaa self-assigned this Oct 6, 2023
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Attention: Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.

Project coverage is 48.00%. Comparing base (e57082a) to head (0fdc6f4).
Report is 798 commits behind head on 9.x.

Files with missing lines Patch % Lines
...owl/core/request/version/VersionSearchRequest.java 76.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                9.x    #1226      +/-   ##
============================================
+ Coverage     47.96%   48.00%   +0.03%     
- Complexity    13831    13861      +30     
============================================
  Files          1942     1942              
  Lines         94946    94971      +25     
  Branches      10955    10961       +6     
============================================
+ Hits          45541    45588      +47     
+ Misses        46378    46353      -25     
- Partials       3027     3030       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Set<String> accessibleResources = authz.getAccessibleResources(context, context.service(User.class));

resourceIds.removeIf(resourceId -> !accessibleResources.contains(resourceId));
queryBuilder.filter(VersionDocument.Expressions.resourceIds(resourceIds));
Copy link
Member

Choose a reason for hiding this comment

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

If resourceIds becomes empty after authorization check, the search request can return quickly by throwing a NoResultException.

if (containsKey(OptionKey.RESOURCE)) {
Collection<String> resources = getCollection(OptionKey.RESOURCE, String.class);
Collection<String> resourceIds = resources.stream()
.map(resource -> resource.contains("/") ? new ResourceURI(resource).getResourceId() : resource)
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
.map(resource -> resource.contains("/") ? new ResourceURI(resource).getResourceId() : resource)
.map(resource -> resource.contains(Branch.SEPARATOR) ? new ResourceURI(resource).getResourceId() : resource)

.map(resource -> resource.contains("/") ? new ResourceURI(resource).getResourceId() : resource)
.toList();

if (user.isAdministrator()) {
Copy link
Member

Choose a reason for hiding this comment

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

Not just the administrator user can access all resources, any user with the browse:* permission can do that, please fix and create test cases for the various scenarios. Thanks!

return getResource().getResourceId();
}

@JsonIgnore
Copy link
Member

Choose a reason for hiding this comment

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

This is a valid API response property. Please remove this JsonIgnore annotation.

@AAAlinaaa AAAlinaaa force-pushed the issue/SO-5566-version-api-search-restrictions branch from 6bec14a to 0fdc6f4 Compare December 6, 2023 09:39
@cmark cmark added the on hold label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants