-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Preload hooks for delete case and task #619
Open
Vladimir-A
wants to merge
31
commits into
dfir-iris:develop
Choose a base branch
from
Vladimir-A:preload_for_case_and_task
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c2313a3
Fix ref POSTGRES_USER
tvandenabbeel-spotit 5904a30
[MRG] Merge pull request #606 from tvandenabbeel-spotit/patch-1
whikernel 88eb441
[FIX] realization on_preload_task_delete
Vladimir-A d02fe07
[FIX] realization on_preload_case_delete
Vladimir-A e7d7c5f
[FIX] Memory issue in alerts
whikernel be4d6cb
[ADD] Added source reference as filter in alerts
whikernel 966d01d
[ADD] Alerts indexes
whikernel bb5c8cc
[ADD] Added index for alert source ref
whikernel 4e6e4d5
[ADD] Possibility to unassigne alert from API
whikernel 72a7f31
[UPD] Updated IRIS webhook module
whikernel 0933a3c
[ADD] Alerts graph zoom
whikernel 178df5f
[ADD] Possibility to check alerts
whikernel 0fba01d
Bump version: 2.4.14 → 2.4.15-beta
whikernel 7895516
[FIX] Deletion of alerts with new relations
whikernel e2e0266
Bump version: 2.4.15-beta → 2.4.15-rc1
whikernel fd6f8fe
[FIX] report template language
Vladimir-A 45bd397
Merge pull request #632 from Vladimir-A/fix_report_template_language
whikernel 1e5e805
[ADD] Better visibility of commented elements
whikernel d31acf1
[ADD] Possibility to unset owner from alerts from API
whikernel 8d03428
[ADD] Possibility to copy values from alerts table
whikernel 70767b6
Bump version: 2.4.15-rc1 → 2.4.15-rc2
whikernel 5299bfb
Bump version: 2.4.15-rc2 → 2.4.15
whikernel 2c7f55e
[MRG] Merge pull request #630 from dfir-iris/hotfix_2.4.15-beta
whikernel 50cf190
[FIX] Issue with hybrid OIDC / Local auth
whikernel 6046f85
Bump version: 2.4.15 → 2.4.15
whikernel e379781
[FIX] Bump issue
whikernel 9f3a725
Bump version: 2.4.15 → 2.4.16
whikernel a533e61
[MRG] Merge pull request #635 from dfir-iris/hotfix_2.4.16
whikernel de67335
[FIX] Docker compose issue due to bump
whikernel 37f2eeb
[FIX] Fixed readme
whikernel 6e735ce
Merge branch 'dfir-iris:master' into preload_for_case_and_task
Vladimir-A File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
source/app/alembic/versions/d5a720d1b99b_add_alerts_indexes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Add alerts indexes | ||
|
||
Revision ID: d5a720d1b99b | ||
Revises: 11aa5b725b8e | ||
Create Date: 2024-10-28 12:54:22.782313 | ||
|
||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy import and_, or_, text | ||
from sqlalchemy.orm import Session | ||
|
||
from app.alembic.alembic_utils import _has_table, index_exists | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd5a720d1b99b' | ||
down_revision = '11aa5b725b8e' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# Adding indexes to the Alerts table | ||
if _has_table('alerts'): | ||
if not index_exists('alerts', 'idx_alerts_title'): | ||
op.create_index('idx_alerts_title', 'alerts', ['alert_title']) | ||
if not index_exists('alerts', 'idx_alerts_creation_time'): | ||
op.create_index('idx_alerts_creation_time', 'alerts', ['alert_creation_time']) | ||
if not index_exists('alerts', 'idx_alerts_source_event_time'): | ||
op.create_index('idx_alerts_source_event_time', 'alerts', ['alert_source_event_time']) | ||
if not index_exists('alerts', 'idx_alerts_customer_id'): | ||
op.create_index('idx_alerts_customer_id', 'alerts', ['alert_customer_id']) | ||
if not index_exists('alerts', 'alert_source_ref'): | ||
op.create_index('idx_alert_source_ref', 'alerts', ['alert_source_ref']) | ||
|
||
# Adding indexes to the Ioc table | ||
if _has_table('ioc'): | ||
if not index_exists('ioc', 'idx_ioc_value_hash'): | ||
# Create an index on the MD5 hash of ioc_value to handle large values | ||
op.execute(text("CREATE INDEX idx_ioc_value_hash ON ioc (md5(ioc_value::text))")) | ||
if not index_exists('ioc', 'idx_ioc_tags'): | ||
op.create_index('idx_ioc_tags', 'ioc', ['ioc_tags']) | ||
|
||
# Adding indexes to the CaseAssets table | ||
if _has_table('case_assets'): | ||
if not index_exists('case_assets', 'idx_case_assets_name'): | ||
op.create_index('idx_case_assets_name', 'case_assets', ['asset_name']) | ||
if not index_exists('case_assets', 'idx_case_assets_case_id'): | ||
op.create_index('idx_case_assets_case_id', 'case_assets', ['case_id']) | ||
if not index_exists('case_assets', 'idx_case_assets_date_added'): | ||
op.create_index('idx_case_assets_date_added', 'case_assets', ['date_added']) | ||
if not index_exists('case_assets', 'idx_case_assets_date_update'): | ||
op.create_index('idx_case_assets_date_update', 'case_assets', ['date_update']) | ||
|
||
|
||
def downgrade(): | ||
# Drop indexes | ||
op.drop_index('ix_alert_similarity_alert_id', table_name='alert_similarity') | ||
op.drop_index('ix_alert_similarity_similar_alert_id', table_name='alert_similarity') | ||
op.drop_index('ix_alert_similarity_matching_asset_id', table_name='alert_similarity') | ||
op.drop_index('ix_alert_similarity_matching_ioc_id', table_name='alert_similarity') | ||
op.drop_index('ix_alert_similarity_similarity_type', table_name='alert_similarity') | ||
|
||
# Drop AlertSimilarity table | ||
op.drop_table('alert_similarity') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 then we should update all preload deletions to work with a dump of the object? Normally preload hooks are only working with raw data, nothing from the DB, to avoid any conflicts.
I was acutally thinking of removing all preload in future versions. Do you have any use cases where working with preload instead of postload?
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.
In our case, there is no difference between preload and postload. We need to track the deletion of cases and tasks. Since postload works after the deletion of object and it is impossible to process a non-existent object with a webhook module, so I tried to restore the correct operation of preload, of course we need information about the object in the output to work with it.