-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[ML] Space permision checks for job deletion #83871
[ML] Space permision checks for job deletion #83871
Conversation
} | ||
|
||
if ( | ||
mlCapabilities.canDeleteJob === false || |
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.
Is it possible that the user could have one permission and not the other? Or is job deletion a single permission across ML?
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.
at the moment no, we only have ML viewer or ML admin roles.
But just in case we ever allow fine grained capabilities i'll change this check to be more explicit.
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.
Changed in 5951246
results[jobId] = { | ||
canDelete: true, | ||
canUnTag: false, | ||
// GLOBAL JOB BOOL???? |
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.
Is this comment needed?
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.
it was a reminder that we might need information in this endpoint that the UI can use to inform the user why they can't untag or delete the job.
I'll remove the comment for now, but when the UI work is done we may need to add in flags like isGlobalJob
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.
fixed ceb41ea
Code LGTM but having trouble testing it. Will update first thing monday. |
@elasticmachine merge upstream |
|
||
export interface DeleteJobPermission { | ||
canDelete: boolean; | ||
canUnTag: boolean; |
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.
Looking for this word online, it seems untag
is the generally accepted spelling, rather than un-tag
. In which case, I think it makes sense to go with canUntag
here.
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.
fixed ceb41ea
* | ||
* @api {get} /api/ml/saved_objects/delete_job_check Check whether user can delete a job | ||
* @apiName DeleteJobCheck | ||
* @apiDescription Check the users ability to delete jobs. Returns whether they are able |
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.
Nit - user's
.
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.
fixed ceb41ea
|
||
// jobs with are in individual spaces can only be untagged | ||
// from current space if the job is in more than 1 space | ||
const canUnTag = namespaces.length > 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.
As above, should probably be canUntag
.
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.
fixed ceb41ea
* @apiSchema (body) jobIdsSchema (params) jobTypeSchema | ||
* | ||
*/ | ||
router.post( |
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.
Should be DELETE
instead
router.post( | |
router.delete( |
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.
it's not deleting anything. it's checking whether you can delete
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.
Sorry, I read it wrong! It'd be more straightforward to start the method with Check
then :)
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.
yes, i can see how this could be confused.
we could change this to check_delete_job_ability
or something like that?
@peteharverson
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.
Or perhaps can_delete_job
or check_can_delete_job
?
path: '/api/ml/saved_objects/delete_job_check/{jobType}', | ||
validate: { | ||
params: jobTypeSchema, | ||
body: jobIdsSchema, | ||
}, |
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.
maybe it's worth putting everything in params, e.g. '/api/ml/saved_objects/delete_job_check/{jobType}/{jobId}'
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.
jobIds
is an array of ids, for all other similar kibana endpoints we pass the ids as an array in the body (not including endpoints which are simple wrappers around es endpoints)
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.
ok, I recall some endpoints with comma-separated job ids
…elastic/kibana into delete-job-space-permission-check
@elasticmachine merge upstream |
…elastic/kibana into delete-job-space-permission-check
Pinging @elastic/ml-ui (:ml) |
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.
LGTM
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.
LGTM ⚡
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.
LGTM
@elasticmachine merge upstream |
* [ML] Space permision checks for job deletion * updating spaces dependency * updating endpoint comments * adding delete job capabilities check * small change based on review * improving permissions checks * renaming function and endpoint Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* master: (41 commits) [Maps] fix code-owners (elastic#84265) [@kbn/utils] Clean target before build (elastic#84253) [code coverage] collect for oss integration tests (elastic#83907) [APM] Use `asTransactionRate` consistently everywhere (elastic#84213) Attempt to fix incremental build error (elastic#84152) Unskip "Copy dashboards to space" (elastic#84115) Remove expressions.legacy from README (elastic#79681) Expression: Add render mode and use it for canvas interactivity (elastic#83559) [deb/rpm] Move systemd service to /usr/lib/systemd/system (elastic#83571) [Security Solution][Resolver] Allow a configurable entity_id field (elastic#81679) [ML] Space permision checks for job deletion (elastic#83871) [build] Provide ARM build of RE2 (elastic#84163) TSVB should use "histogram:maxBars" and "histogram:barTarget" settings for auto instead of a default 100 buckets (elastic#83628) [Workplace Search] Initial rendering of Org Sources (elastic#84164) update geckodriver to 0.28 (elastic#84085) Fix timelion vis escapes single quotes (elastic#84196) [Security Solution] Fix incorrect time for dns histogram (elastic#83532) [DX] Bump TS version to v4.1 (elastic#83397) [Security Solution] Add endpoint policy revision number (elastic#83982) [Fleet] Integration Policies List view (elastic#83634) ...
💔 Build Failed
Failed CI StepsTest FailuresX-Pack API Integration Tests.x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data·ts.apis Machine Learning ResultsService GetAnomaliesTableData should fetch anomalies table dataStandard Out
Stack Trace
X-Pack API Integration Tests.x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data·ts.apis Machine Learning ResultsService GetAnomaliesTableData should fetch anomalies table dataStandard Out
Stack Trace
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Endpoint to check what delete job tasks the user is able to perform on a specified list of jobs.
Endpoint returns a list of jobs with
canDelete
andcanUnTag
flags for each.This check will be performed in the UI when a user attempts to delete a job.
UI work is coming in a different PR.
API test will be added in a follow up PR.
Job is in individual spaces, user cannot see all of them
Job can only be untagged from the current space
Job is individual spaces, which the user can see all of
Job can be deleted or untagged from current space
Job is in * space, user cannot see all spaces
Job cannot be untagged from space or deleted.
Job is in * space, user can see all spaces
Delete job only, no option to untag
Spaces plugin is disabled
Delete job only, no option to untag
User does not have
canDeleteJob
orcanDeleteDataFrameAnalytics
capabilitiesJob cannot be untagged from space or deleted.
Checklist
Unit or functional tests were updated or added to match the most common scenarios
This was checked for breaking API changes and was labeled appropriately