-
Notifications
You must be signed in to change notification settings - Fork 254
adding header handling in routeVeam + unit tests #6022
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,117 @@ describe('RouteVeeam: checkBucketAndKey', () => { | |
| assert.strictEqual(routeVeeam.checkBucketAndKey(...test), undefined); | ||
| }); | ||
| }); | ||
|
|
||
| it('should allow SigV4 presigned GET query parameters in mixed case', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { | ||
| 'X-Amz-Algorithm': 'AWS4-HMAC-SHA256', | ||
| 'X-Amz-Credential': 'cred', | ||
| 'X-Amz-Date': '20240101T000000Z', | ||
| 'X-Amz-Expires': '900', | ||
| 'X-Amz-SignedHeaders': 'host', | ||
| 'X-Amz-Signature': 'signature', | ||
| 'X-Amz-Security-Token': 'token', | ||
| }, | ||
| 'GET', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err, undefined); | ||
| }); | ||
|
|
||
| it('should allow SigV4-style query parameters on non-GET when they are presigned', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { | ||
| 'x-amz-algorithm': 'AWS4-HMAC-SHA256', | ||
| 'x-amz-credential': 'cred', | ||
| 'x-amz-date': '20240101T000000Z', | ||
| 'x-amz-expires': '900', | ||
| 'x-amz-signedheaders': 'host', | ||
| 'x-amz-signature': 'signature', | ||
| }, | ||
| 'DELETE', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err, undefined); | ||
| }); | ||
|
|
||
| it('should reject unexpected query parameters even when presigned GET keys are present', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { | ||
| 'X-Amz-Credential': 'a', | ||
| extra: 'not-allowed', | ||
| }, | ||
| 'GET', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err.is.InvalidRequest, true); | ||
| }); | ||
|
|
||
| it('should allow AWS SDK x-id=PutObject query on PUT for system.xml', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { 'x-id': 'PutObject' }, | ||
| 'PUT', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err, undefined); | ||
| }); | ||
|
|
||
| it('should allow AWS SDK auxiliary x-amz-sdk-* query params on PUT for system.xml', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could add a test with a wrong param x-iamwrong ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're already testing a wrong value here => 51810dd#diff-7d9febf34141ec8f0c48580a4e9e899f15f34227d9ecc39fcda6c5392e87f581R108, isn't it over testing to add other headers as we already know that we reject them directly ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at all the branches in the code, more tests are needed : e.g. having "presigned" headers, on GET or otherwise, different case for headers, ... |
||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { | ||
| 'x-id': 'PutObject', | ||
| 'x-amz-sdk-request': 'attempt=1', | ||
| 'x-amz-sdk-invocation-id': 'abc-123', | ||
| 'x-amz-user-agent': 'aws-sdk-js-v3', | ||
| }, | ||
| 'PUT', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err, undefined); | ||
| }); | ||
|
|
||
| it('should reject mismatched x-id value on PUT for system.xml', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { 'x-id': 'GetObject' }, | ||
| 'PUT', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err.is.InvalidRequest, true); | ||
| }); | ||
|
|
||
| it('should reject mismatched x-id value on GET for system.xml', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { 'x-id': 'PutObject' }, | ||
| 'GET', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err.is.InvalidRequest, true); | ||
| }); | ||
|
|
||
| it('should accept x-id with different casing when value matches action', () => { | ||
| const err = routeVeeam.checkBucketAndKey( | ||
| 'test', | ||
| '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml', | ||
| { 'X-Id': 'GetObject' }, | ||
| 'GET', | ||
| log, | ||
| ); | ||
| assert.strictEqual(err, undefined); | ||
| }); | ||
| }); | ||
|
|
||
| describe('RouteVeeam: checkBucketAndKey', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the reason for the build failure? Is there a new release of pykmip?
should the fix not include specifying the version of pykmip that we checkout, so we avoid unexpected behavior changes (or incompatibility when it requires a newer version of python...) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build was failing in the python3 setup.py install step when building pykmip from the GitHub repo on python:3.10-alpine (the setup.py invocation was exiting with status 1). There isn’t a new PyPI release of pykmip; we’re building from the GitHub repo because the latest fixes we need are only there (the last tagged release is still 0.10.0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we need a specific SHA1, we can (and should!) specify it anyway; and add a comment explaining why we don't use the release / ...