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

Cluster permissions evaluation logic will now include index_template type action #1885

Merged
merged 2 commits into from
Jun 15, 2022

Conversation

DarshitChanpura
Copy link
Member

@DarshitChanpura DarshitChanpura commented Jun 13, 2022

Description

Title

  • Category : Bug Fix

Issues Resolved

Testing

A test is written to evaluate this

Check List

  • New functionality includes testing
    - [ ] New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@DarshitChanpura DarshitChanpura requested a review from a team June 13, 2022 19:59
@DarshitChanpura DarshitChanpura force-pushed the cluster-perm-check branch 3 times, most recently from e5c6b46 to eb73447 Compare June 13, 2022 20:11
@DarshitChanpura
Copy link
Member Author

@opensearch-project/security Seems like the test failures are related to audit-log changes. Need some help fixing this.

cliu123
cliu123 previously approved these changes Jun 14, 2022
@cliu123
Copy link
Member

cliu123 commented Jun 14, 2022

@DarshitChanpura CI failed. Would you please take a look?

@DarshitChanpura
Copy link
Member Author

@DarshitChanpura CI failed. Would you please take a look?

It failed due to errors unrelated to the changes in this PR, example look here. Have we seen this error before?

} else {
} else if (request instanceof PutComponentTemplateAction.Request) {
// do nothing
}else {

Choose a reason for hiding this comment

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

nitpick: space before else (do we have a linting rule for this?)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@davidlago
Copy link

Could you please add a description to either this PR or the associated issue explaining what the implications of index_template not being initially included? i.e., what is the behavior change after fixing this issue?

@DarshitChanpura
Copy link
Member Author

DarshitChanpura commented Jun 14, 2022

Could you please add a description to either this PR or the associated issue explaining what the implications of index_template not being initially included? i.e., what is the behavior change after fixing this issue?

done... description added to the referenced issue

@DarshitChanpura DarshitChanpura force-pushed the cluster-perm-check branch 2 times, most recently from 6d92a32 to cbc53e5 Compare June 14, 2022 17:56
@codecov-commenter
Copy link

Codecov Report

Merging #1885 (260f7bb) into main (001d73f) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@            Coverage Diff            @@
##               main    #1885   +/-   ##
=========================================
  Coverage     61.01%   61.02%           
  Complexity     3232     3232           
=========================================
  Files           256      256           
  Lines         18085    18087    +2     
  Branches       3222     3224    +2     
=========================================
+ Hits          11034    11037    +3     
+ Misses         5469     5466    -3     
- Partials       1582     1584    +2     
Impacted Files Coverage Δ
...earch/security/resolver/IndexResolverReplacer.java 65.34% <0.00%> (-0.19%) ⬇️
...earch/security/privileges/PrivilegesEvaluator.java 72.02% <100.00%> (+0.09%) ⬆️
...security/auditlog/sink/ExternalOpenSearchSink.java 59.25% <0.00%> (-2.47%) ⬇️
...nsearch/security/dlic/rest/api/AuditApiAction.java 68.08% <0.00%> (+4.25%) ⬆️
...ecurity/configuration/StaticResourceException.java 25.00% <0.00%> (+25.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 001d73f...260f7bb. Read the comment docs.

cliu123
cliu123 previously approved these changes Jun 14, 2022
final String pathEntry = jsonPathScanner.next();
String pathEntry = jsonPathScanner.next();
// if pathEntry is an array lookup
boolean isArrayLookup = pathEntry.contains("[");
Copy link
Member

Choose a reason for hiding this comment

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

Much cleaner to use a regex, here is an example https://ideone.com/wEcFot

'test[12]'	 Name was: test,	 index position: 12
'result[2]'	 Name was: result,	 index position: 2
'res[2da]'	 No Match
'[a2da]'	 No Match
'sitename'	 No Match

If you have a match, immediately assign currentNode = currentNode.get(arrayEntryIdx); and then call continue to go back to the top of the loop

Copy link
Member Author

Choose a reason for hiding this comment

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

good find.. this is much better.. Slight change, I can't immediately continue once I find the match, as I first have to check whether the current node on the requested path is an array and then try to get the request index.

…mission and fixes existing broken tests

Signed-off-by: Darshit Chanpura <[email protected]>
@peternied peternied merged commit e40d935 into opensearch-project:main Jun 15, 2022
@peternied
Copy link
Member

Great work @DarshitChanpura

rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 2, 2022
…endistro-1.11

Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 2, 2022
…endistro-1.10

Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 2, 2022
…endistro-1.2

Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 2, 2022
…endistro-1.2

Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 2, 2022
…endistro-1.11

Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
peternied pushed a commit that referenced this pull request Aug 8, 2022
peternied pushed a commit that referenced this pull request Aug 8, 2022
peternied pushed a commit that referenced this pull request Aug 8, 2022
Signed-off-by: Rutuja Surve <[email protected]>
(cherry picked from commit 702c81a)
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 9, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
… to opendistro-1.11 (opensearch-project#1986)"

This reverts commit ec80578.

Signed-off-by: Rutuja Surve <[email protected]>
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
… to opendistro-1.11 (opensearch-project#1986)"

This reverts commit ec80578.

Signed-off-by: Rutuja Surve <[email protected]>
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
rutuja-amazon added a commit to rutuja-amazon/security that referenced this pull request Aug 10, 2022
stephen-crawford pushed a commit to stephen-crawford/security that referenced this pull request Nov 10, 2022
…` type action (opensearch-project#1885)

* Updates the cluster permission check function to include index_template permission type

Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Stephen Crawford <[email protected]>
wuychn pushed a commit to ochprince/security that referenced this pull request Mar 16, 2023
…` type action (opensearch-project#1885)

* Updates the cluster permission check function to include index_template permission type

Signed-off-by: Darshit Chanpura <[email protected]>
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.

[BUG] index_template action type is not part of cluster-permissions check even though template is.
5 participants