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

Improvement/cldsrv 428 put apis implicit deny #5450

Conversation

benzekrimaha
Copy link
Contributor

@benzekrimaha benzekrimaha commented Nov 21, 2023

PR opened after closing : #5325

Bucket policies are not correctly interpreted, this is part of the following epic to fix that: scality/Arsenal#2181

This PR is aiming to update put apis since object and bucket authorisations are made at API level and need to support implicit denies, ticket linked to this issue here : https://scality.atlassian.net/browse/CLDSRV-428

PRs providing implicit Deny logic to CS for processing in this PR
scality/Arsenal#2181
https://github.com/scality/Vault/pull/2135
#5322
#5420
#5432

Green CI for tests against zenko on 8.7 branch here : https://github.com/scality/Zenko/actions/runs/6956317229/job/18929846711
https://github.com/scality/Zenko/actions/runs/6967777856
https://github.com/scality/Zenko/actions/runs/6967837993/job/18962214972

I'll be bumping a new CLDSRV once the reviews done as these are changes that will be tested against Integration

(cherry picked from commit 8878814)
(cherry picked from commit 4b3983f)
(cherry picked from commit 62e15fa)
@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Hello benzekrimaha,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Incorrect fix version

The Fix Version/s in issue CLDSRV-428 contains:

  • 7.10.34

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 7.10.34

  • 7.70.31

  • 8.6.13

  • 8.7.32

  • 8.8.6

Please check the Fix Version/s of CLDSRV-428, or the target
branch of this pull request.

@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-428-put-apis-implicitDeny branch from 9df29db to c55e153 Compare November 21, 2023 11:04
@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

@benzekrimaha
Copy link
Contributor Author

/create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny with contents from improvement/CLDSRV-428-put-apis-implicitDeny
and development/7.70.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/7.70
 $ git merge origin/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny with contents from w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny
and development/8.6.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/8.6
 $ git merge origin/w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny with contents from w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny
and development/8.7.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/8.7
 $ git merge origin/w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/7.4

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_integration_branches

(cherry picked from commit 402078a)
(cherry picked from commit fd691c6)
(cherry picked from commit 78ec4b8)
@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-428-put-apis-implicitDeny branch from af38aae to e590b47 Compare November 21, 2023 14:56
@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

History mismatch

Merge commit #c55e153902f161d09b545e8717c26b4a5de6bad0 on the integration branch
w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny is merging a branch which is neither the current
branch improvement/CLDSRV-428-put-apis-implicitDeny nor the development branch
development/7.70.

It is likely due to a rebase of the branch improvement/CLDSRV-428-put-apis-implicitDeny and the
merge is not possible until all related w/* branches are deleted or updated.

Please use the reset command to have me reinitialize these branches.

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

/reset

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Reset complete

I have successfully deleted this pull request's integration branches.

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny with contents from improvement/CLDSRV-428-put-apis-implicitDeny
and development/7.70.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/7.70
 $ git merge origin/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny with contents from w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny
and development/8.6.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/8.6
 $ git merge origin/w/7.70/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Conflict

A conflict has been raised during the creation of
integration branch w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny with contents from w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny
and development/8.7.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny origin/development/8.7
 $ git merge origin/w/8.6/improvement/CLDSRV-428-put-apis-implicitDeny
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.7/improvement/CLDSRV-428-put-apis-implicitDeny

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

ping

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/7.4

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 21, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_integration_branches

@benzekrimaha
Copy link
Contributor Author

@bert-e create_pull_requests

@benzekrimaha benzekrimaha marked this pull request as ready for review November 22, 2023 13:10
@bert-e
Copy link
Contributor

bert-e commented Nov 22, 2023

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/7.4

Follow integration pull requests if you would like to be notified of
build statuses by email.

The following options are set: create_pull_requests, create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 22, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_pull_requests, create_integration_branches

Copy link

@KazToozs KazToozs left a comment

Choose a reason for hiding this comment

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

With context that the 7.70 apis are being added seperately, looks good to me

Copy link
Contributor

@anurag4DSB anurag4DSB left a comment

Choose a reason for hiding this comment

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

It is complicated to review the PR due to the linter changes.
Would you be able to help point out in the tests which tests actually have logic changes and need review?

Other than that some over all logic looks good.

Lastly, the commit messages need to be self explanatory and it should be a commit story. Here we have a large commit cherry-picked and then a "fixups" commit. Once this is merged, looking back in the commit history it will be extremely difficult to debug.

If we are making 1 to 2 big commit, I would recommend removing all linter changes and only have logical changes or having a commit story with short logical commits.

if (!Array.isArray(requestType)) {
requestType = [requestType];
}
async.waterfall([
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, we should add a return here to make sure event loop execution as per our need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lib/api/bucketPutObjectLock.js Show resolved Hide resolved
}
return null;
}


/** metadataValidateBucketAndObj - retrieve bucket and object md from metadata
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: JS doc needs an update as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -249,6 +243,9 @@ function objectPutCopyPart(authInfo, request, sourceBucket,
splitter,
next,
) {
const originalIdentityAuthzResults = request.actionImplicitDenies;
// eslint-disable-next-line no-param-reassign
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we disabling this linter rule eslint-disable-next-line no-param-reassign?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the asynchronous nature of the operations and the manipulation of shared objects (like request), there's a risk of race conditions. Care should be taken to ensure that the shared state is managed safely.

Copy link
Contributor

Choose a reason for hiding this comment

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

same for other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The request object is unique per API call so there's no risk of race conditions accessing it so I think that we can still delete on the request object.

},
(retentionInfo, next) => standardMetadataValidateBucketAndObj(metadataValParams, request.actionImplicitDenies,
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why did we change the sequence here?
Do we know why it was the other way around before?

@@ -3,20 +3,17 @@ const async = require('async');
const crypto = require('crypto');
const { parseString } = require('xml2js');
const AWS = require('aws-sdk');
const { metadata } = require('arsenal').storage.metadata.inMemory.metadata;
Copy link
Contributor

Choose a reason for hiding this comment

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

adding comment here as well for shorthand
but might be at other places.

@bert-e
Copy link
Contributor

bert-e commented Nov 23, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following reviewers are expecting changes from the author, or must review again:

The following options are set: create_pull_requests, create_integration_branches

@anurag4DSB
Copy link
Contributor

Adding integration PR reveiw here:
https://github.com/scality/cloudserver/pull/5451/commits the 4th commit message should prefixed with a ticket number "fix lint"
If this linter is required by the CI then its okay to add.

I haven't reviewed other integration branches, as I am uncertain which merge commit has extra changes with all the linter changes. Removing the linters will help with that, or I need your help in pointing out which merge commits have more logic changes. I am thinking of changes which might have taken place during conflicts (if any)

tests/unit/api/objectPutTagging.js Show resolved Hide resolved
tests/unit/api/objectPutTagging.js Show resolved Hide resolved
lib/api/objectPutACL.js Show resolved Hide resolved
@@ -58,7 +58,7 @@ function objectPut(authInfo, request, streamingV4Params, log, callback) {
}
const invalidSSEError = errors.InvalidArgument.customizeDescription(
'The encryption method specified is not supported');
const requestType = 'objectPut';
const requestType = request.apiMethods || 'objectPut';
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency between the request property name and the defaults, we might want to set all defaults as arrays, even if we recreate one if needed later

Copy link
Contributor Author

@benzekrimaha benzekrimaha Nov 24, 2023

Choose a reason for hiding this comment

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

in the standardMetadataValidateBucketAndObj function the requestType is set to an array if it's not the case , so the outcome will be the same

Comment on lines +208 to +209
// eslint-disable-next-line no-param-reassign
delete request.actionImplicitDenies;
Copy link
Contributor

@williamlardier williamlardier Nov 23, 2023

Choose a reason for hiding this comment

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

I have done it in the PoC but I'm not sure it's safe enough; if we make additional APIs with HTTP calls based on the current request object in any API, we might run into problems because of the new properties we've added for convenience.
Another approach I had in mind was to create a new parameter (or extend the authResult of the 'AuthInfo' class) for all APIs to transmit the authz results in a safe way, to avoid this kind of code. If not possible, we should at least store the field names in a globally-defined constant and use an helper to cleanup the request everytime we need to. And document it

Copy link
Contributor Author

@benzekrimaha benzekrimaha Nov 27, 2023

Choose a reason for hiding this comment

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

As the request object is unique per api call this delete will not be impacting other API calls , how will the additional properties impact new API calls ?
For the change in authInfo this will alter all the changes that have already been made and merged for this epic.
Cc : @anurag4DSB

lib/metadata/metadataUtils.js Show resolved Hide resolved
tests/multipleBackend/objectPutCopyPart.js Show resolved Hide resolved
@benzekrimaha
Copy link
Contributor Author

Closing this PR , a new one is opened here : #5456

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.

5 participants