opencti icon indicating copy to clipboard operation
opencti copied to clipboard

[backend] Improve entity type validation in deletion operations

Open maelv-filigran opened this issue 1 month ago • 1 comments

Proposed changes

  • Enforce type validation in stixDomainObjectDelete with expectedEntityType parameter for stricter entity type checking
  • Updated Individual resolver to use the new type-checking deletion method
  • Added comprehensive integration tests for entity type validation in deletion operations

Related issues

  • Improves data integrity by ensuring delete operations target the correct entity types
  • Prevents accidental deletion of wrong entities through type-specific endpoints

Checklist

  • [x] I consider the submitted work as finished
  • [x] I tested the code for its functionality
  • [x] I wrote test cases for the relevant uses case (coverage and e2e)
  • [ ] I added/update the relevant documentation (either on github or on notion)
  • [x] Where necessary I refactored code to improve the overall quality

maelv-filigran avatar Nov 27 '25 08:11 maelv-filigran

Codecov Report

:x: Patch coverage is 92.74194% with 9 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 30.83%. Comparing base (26a4bae) to head (65a6c88). :warning: Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...opencti-graphql/src/modules/case/case-resolvers.ts 77.77% 2 Missing :warning:
...i-platform/opencti-graphql/src/resolvers/report.js 66.66% 2 Missing :warning:
...ncti-platform/opencti-graphql/src/domain/report.js 0.00% 1 Missing :warning:
...orm/opencti-graphql/src/domain/stixDomainObject.js 96.29% 1 Missing :warning:
...platform/opencti-graphql/src/resolvers/identity.js 50.00% 1 Missing :warning:
...platform/opencti-graphql/src/resolvers/location.js 50.00% 1 Missing :warning:
...form/opencti-graphql/src/resolvers/observedData.js 50.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13356      +/-   ##
==========================================
+ Coverage   30.65%   30.83%   +0.18%     
==========================================
  Files        2906     2906              
  Lines      192005   192099      +94     
  Branches    39088    39254     +166     
==========================================
+ Hits        58851    59229     +378     
+ Misses     133154   132870     -284     
Flag Coverage Δ
opencti 30.83% <92.74%> (+0.18%) :arrow_up:
opencti-front 2.47% <ø> (ø)
opencti-graphql 68.24% <92.74%> (+0.37%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 12 '25 12:12 codecov[bot]