-
Notifications
You must be signed in to change notification settings - Fork 894
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
[workspace]feat: Add ACL auditor #8557
[workspace]feat: Add ACL auditor #8557
Conversation
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8557 +/- ##
==========================================
+ Coverage 60.93% 60.96% +0.03%
==========================================
Files 3769 3780 +11
Lines 89506 89973 +467
Branches 14012 14099 +87
==========================================
+ Hits 54539 54853 +314
- Misses 31557 31676 +119
- Partials 3410 3444 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: SuZhou-Joe <[email protected]>
@@ -66,6 +71,8 @@ export class SavedObjectsPermissionControl { | |||
savedObjectsToGet.length > 0 | |||
? (await this.getScopedClient?.(request)?.bulkGet(savedObjectsToGet))?.saved_objects || [] | |||
: []; | |||
// System request, -1 * savedObjectsToGet.length for compensation. | |||
ACLAuditor?.increment(ACLAuditorStateKey.DATABASE_OPERATION, -1 * savedObjectsToGet.length); |
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.
How about add a decrement method?
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.
I would like to keep the interface simple, increment with a negative value can give the same functionality here actually.
src/plugins/workspace/server/saved_objects/repository_wrapper.ts
Outdated
Show resolved
Hide resolved
@@ -485,10 +519,14 @@ export class WorkspaceSavedObjectsClientWrapper { | |||
false | |||
)) | |||
) { | |||
ACLAuditor?.increment(ACLAuditorStateKey.VALIDATE_FAILURE, 1); |
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.
Since we will throw error if not permitted, the sum of VALIDATE_FAILURE
+ VALIDATE_SUCCESS
will always less than DATABASE_OPERATION
? For example, we have 10 objects and increment 10 data source operation. We don't have permission to the last saved objects. We will only increment 1 VALIDATE_FAILURE
and throw error if not permitted. Other permitted saved objects won't be recorded.
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.
Actually if there is an error, the decorator will reset the auditor and won't checkout the record for this client call.
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
const ACLAuditor = getACLAuditor(wrapperOptions.request); | ||
const clientCallAuditor = getClientCallAuditor(wrapperOptions.request); |
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.
do we want to provide a flag to turn off aduit behavior?, could enabled by default.
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.
I was thinking that but there are too many feature flags now and I'd prefer to use the permission control feature flag. The auditor behavior won't add any impact to the UI or the server.
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts
Outdated
Show resolved
Hide resolved
* The catch here is required because unhandled promise will make server crashed, | ||
* and we will reset the auditor state when catch an error. | ||
*/ | ||
() => { |
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.
Do we need to return Promise.reject
here? Or the promise will be resolved after return.
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.
No, we already return the result, the result
will give the rejected error if the promise fails.
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
* feat: enable acl auditor Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR #8557 created/updated * feat: optmize code Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code Signed-off-by: SuZhou-Joe <[email protected]> * fix: update workspace metadata is giving error log Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: refactor clientCallAuditor Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: add comments Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize comment Signed-off-by: SuZhou-Joe <[email protected]> * fix: type error in workspace_saved_objects_client_wrapper.test.ts Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit c8f386e) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* feat: enable acl auditor * Changeset file for PR #8557 created/updated * feat: optmize code * feat: optimize code * fix: update workspace metadata is giving error log * feat: update * feat: refactor clientCallAuditor * feat: add unit test * feat: update * feat: optimize code and wording * feat: optimize code and wording * feat: add comments * feat: update * feat: optimize comment * fix: type error in workspace_saved_objects_client_wrapper.test.ts * feat: update * feat: add unit test --------- (cherry picked from commit c8f386e) Signed-off-by: SuZhou-Joe <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
* feat: enable acl auditor Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR opensearch-project#8557 created/updated * feat: optmize code Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code Signed-off-by: SuZhou-Joe <[email protected]> * fix: update workspace metadata is giving error log Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: refactor clientCallAuditor Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: add comments Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize comment Signed-off-by: SuZhou-Joe <[email protected]> * fix: type error in workspace_saved_objects_client_wrapper.test.ts Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
* feat: enable acl auditor Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR opensearch-project#8557 created/updated * feat: optmize code Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code Signed-off-by: SuZhou-Joe <[email protected]> * fix: update workspace metadata is giving error log Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: refactor clientCallAuditor Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code and wording Signed-off-by: SuZhou-Joe <[email protected]> * feat: add comments Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize comment Signed-off-by: SuZhou-Joe <[email protected]> * fix: type error in workspace_saved_objects_client_wrapper.test.ts Signed-off-by: SuZhou-Joe <[email protected]> * feat: update Signed-off-by: SuZhou-Joe <[email protected]> * feat: add unit test Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
This PR is mainly to add an auditor per request, if somehow a call to the saved objects client bypass the ACL, the auditor is supposed to audit a bypass error.
Issues Resolved
Screenshot
Testing the changes
savedObjects.permission.enabled: true
workspace.enabled: true
opensearchDashboards.dashboardAdmin.users: ["admin"]
[ACLCounterCheckoutFailed] counter state: xxx
Changelog
Check List
yarn test:jest
yarn test:jest_integration