-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[backend] Adapt changes and build history on top (#8237) #13775
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #13775 +/- ##
==========================================
+ Coverage 31.12% 31.13% +0.01%
==========================================
Files 2923 2927 +4
Lines 193813 194227 +414
Branches 39564 39596 +32
==========================================
+ Hits 60317 60468 +151
- Misses 133496 133759 +263
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9d54d10 to
c98855f
Compare
cbbaf80 to
199235e
Compare
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.
Pull request overview
This PR refactors the history and audit system to use a new change tracking structure (history_changes with history_added/history_removed) replacing the previous changes structure (previous/new/added/removed). The changes enable better tracking of modifications with both raw and translated values, improved permission filtering for history entries, and enhanced UI components for displaying audit details.
Key changes:
- Replaced
Changeinterface fields (previous,new,added,removed) withhistory_addedandhistory_removedarrays containingChangeValueobjects withrawand optionaltranslatedfields - Updated GraphQL schema to reflect new
HistoryChangeandDataChangetypes - Added permission-based filtering for history entries through
historyFilteringoption - Refactored frontend components to use new drawer components and query individual logs by ID
Reviewed changes
Copilot reviewed 41 out of 43 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| opencti-platform/opencti-graphql/src/types/event.d.ts | Updated Change interface structure |
| opencti-platform/opencti-graphql/src/database/middleware.js | Refactored buildChanges and removed generateUpdateMessage |
| opencti-platform/opencti-graphql/src/database/generate-message.ts | Completely rewritten message generation logic |
| opencti-platform/opencti-graphql/src/database/engine.ts | Added history filtering restrictions and inner hits support |
| opencti-platform/opencti-graphql/src/domain/log.ts | Added new query functions with history filtering |
| opencti-platform/opencti-graphql/config/schema/opencti.graphql | Updated GraphQL schema types |
| opencti-platform/opencti-front/src/private/components/common/drawer/HistoryDrawer.tsx | Complete rewrite to use lazy loading with new schema |
| opencti-platform/opencti-front/src/private/components/settings/activity/audit/AuditDrawer.tsx | New component for audit detail display |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
opencti-platform/opencti-graphql/src/database/generate-message.ts
Outdated
Show resolved
Hide resolved
bd69a54 to
6c93f1e
Compare
1c222ef to
2cb4539
Compare
d893806 to
f37f5e5
Compare
...rm/opencti-graphql/src/modules/attributes/stixSightingRelationship-registrationAttributes.ts
Outdated
Show resolved
Hide resolved
|
The messaging refacto is great ! It will improve lots of things and make readability better. We are ok that this PR does not fix any attribute access rights in history messages? |
7e4e3ab to
6c17d34
Compare
0815b29 to
f981f73
Compare
|
@Archidoit, global approach is now changed. You can review again. Thanks |
opencti-platform/opencti-graphql/src/modules/workflow/workflow-types.ts
Outdated
Show resolved
Hide resolved
| filters: FilterGroup | ||
| search: String | ||
| ): LogConnection @auth(for: [SETTINGS_SETACCESSES, SETTINGS_SECURITYACTIVITY, VIRTUAL_ORGANIZATION_ADMIN]) | ||
| audit(id: ID!): Log @auth(for: [SETTINGS_SETACCESSES, SETTINGS_SECURITYACTIVITY, VIRTUAL_ORGANIZATION_ADMIN]) |
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 think a user with SETACCESSES or ACTIVITY can't view audit logs (but only history logs) if he has not the SECURITYACTIVITY capability.
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 apply the same security as audits, i dont think there is any issue with that
d3f8f7b to
6bf46d8
Compare










Target
The primary target of this pull request is the History and Audit system within the OpenCTI backend and frontend. It aims to standardize how data changes are tracked, stored, and visualized, shifting the resolution of human-readable messages from write-time to read-time.
Improvements
logContextDataBatchLoader). This significantly improves write performance by removing the need to synchronously resolve entity names during ingestion.changes_addedandchanges_removed) replacing the legacy mix ofprevious,new,added, andremoved.generate-message.js.engine.ts) to support searching within the new history structure, including specific fields likechanges_added.rawandchanges_removed.raw.HistoryDrawerand related components to consume the new data structure, simplifying the view to "Added" vs "Removed" columns and using GraphQL queries for data fetching.attribute-definition.ts(e.g., specificIdAttribute,TextAttribute), enhancing code reliability.Impact Analysis
Backend
context_data.history_changesin logs now strictly follows the{ field, changes_added, changes_removed }format.context_data.history_changesstructure.Frontend
HistoryDrawerQueryusing the log ID, reducing initial load weight.