Skip to content

Commit

Permalink
Merge pull request #240 from CybercentreCanada/hotfix/preserve_signat…
Browse files Browse the repository at this point in the history
…ure_stats

Hotfix/preserve signature stats (dev)
  • Loading branch information
cccs-sgaron authored Jul 26, 2021
2 parents 1f26d86 + 7139255 commit 47fd532
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 47fd532

Please sign in to comment.