-
Notifications
You must be signed in to change notification settings - Fork 949
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
[backend] secure organization deletion (#8838) #8903
Conversation
e7ee5a3
to
c7f09cb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8903 +/- ##
==========================================
+ Coverage 66.29% 66.65% +0.36%
==========================================
Files 597 597
Lines 61033 61087 +54
Branches 6276 6604 +328
==========================================
+ Hits 40460 40716 +256
+ Misses 20573 20371 -202 ☔ View full report in Codecov by Sentry. |
opencti-platform/opencti-graphql/tests/utils/testQueryHelper.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/modules/organization/organization-domain.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/modules/organization/organization-domain.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/modules/organization/organization-domain.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/modules/organization/organization-domain.ts
Outdated
Show resolved
Hide resolved
Behavior ok, working well 👍 |
6c24ab3
to
e959001
Compare
|
you're right, task manager calls directly deleteElementById, I need to change it as I did with retention manager => should be fixed now |
@@ -237,6 +238,9 @@ const executeDelete = async (context, user, element, scope) => { | |||
} | |||
if (scope === BackgroundTaskScope.Import) { | |||
await deleteFile(context, user, element.id); | |||
} else if (element.entity_type === ENTITY_TYPE_IDENTITY_ORGANIZATION) { | |||
// call organizationDelete which will ensure protections (for platform organization & members) | |||
await organizationDelete(context, user, element.internal_id); | |||
} else { | |||
await deleteElementById(context, user, element.internal_id, element.entity_type); |
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.
wouln't it be better to add the organization check in 'deleteElementById' ? to avoid forgetting to add the check when using it?
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.
That would probably make circle dependencies as organizationDelete
uses deleteElementById
. Maybe having a higher level function that make those kind of checks and then redirect to the correct delete function could be a thing? But it means some global refactoring at every delete resolver, maybe not relevant inside the scope of this PR idk
Proposed changes
Related issues
To test : organization can't be deleted if it is used as platform organization, or it has at least one member (user part of the organization), or has an organization admin (org admin is also a member, but the error message is different). Otherwise the deletion should work. Also error message is different for users depending on their capability : if user has set access, the message will explain the reason (members or orga admin reason).
Checklist