Skip to content
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

Hotfix/preserve signature stats (dev) #240

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assemblyline_ui/api/v4/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ def add_update_signature(**_):
# If rule has been deprecated/disabled after initial deployment, then disable it
if not (data['status'] != old['status'] and data['status'] == "DISABLED"):
data['status'] = old['status']

# Preserve last state change
data['state_change_date'] = old['state_change_date']
data['state_change_user'] = old['state_change_user']

# Preserve signature stats
data['stats'] = old['stats']

# Save the signature
return make_api_response({"success": STORAGE.signature.save(key, data), "id": key})

Expand Down Expand Up @@ -161,9 +166,14 @@ def add_update_many_signature(**_):
# If rule has been deprecated/disabled after initial deployment, then disable it
if not (rule['status'] != old_data[key]['status'] and rule['status'] == "DISABLED"):
rule['status'] = old_data[key]['status']

# Preserve last state change
rule['state_change_date'] = old_data[key]['state_change_date']
rule['state_change_user'] = old_data[key]['state_change_user']

# Preserve signature stats
rule['stats'] = old_data[key]['stats']

plan.add_upsert_operation(key, rule)

if not plan.empty:
Expand Down