Skip to content

Commit

Permalink
Merge pull request #283 from CybercentreCanada/hotfix/invalid_source_…
Browse files Browse the repository at this point in the history
…name

Allow deleteing of invalid source and block furthur invalid source
  • Loading branch information
cccs-sgaron authored Sep 27, 2021
2 parents b0bacbc + 34ea7ac commit e0b7025
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assemblyline_ui/api/v4/signature.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from flask import request
from hashlib import sha256

Expand Down Expand Up @@ -219,7 +221,7 @@ def add_signature_source(service, **_):
status_code=400)

# Ensure data source doesn't have spaces in name
data['name'] = data['name'].replace(" ", "_")
data['name'] = re.sub('[^0-9a-zA-Z_]+', '', data['name'].replace(" ", "_"))

# Ensure private_key (if any) ends with a \n
if data.get('private_key', None) and not data['private_key'].endswith("\n"):
Expand Down Expand Up @@ -356,7 +358,7 @@ def delete_signature(sid, **kwargs):
return make_api_response("", f"Signature not found. ({sid})", 404)


@signature_api.route("/sources/<service>/<name>/", methods=["DELETE"])
@signature_api.route("/sources/<service>/<path:name>/", methods=["DELETE"])
@api_login(audit=False, required_priv=['W'], allow_readonly=False, require_type=['admin', 'signature_manager'])
def delete_signature_source(service, name, **_):
"""
Expand Down

0 comments on commit e0b7025

Please sign in to comment.