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

Feature/SubmissionProfiles (master) #1106

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7b889b6
Guard submit & ingest API from unauthorized submission customization
cccs-rs Jul 10, 2024
4592c65
Setup using submission profiles on submission
cccs-rs Jul 22, 2024
c01daec
Use a method function for setting user-specified submission parameters
cccs-rs Jul 30, 2024
a494340
Rename parameter to deconflict with pre-existing `profile` parameter
cccs-rs Jul 31, 2024
f8806b7
Update tests
cccs-rs Jul 31, 2024
40a1434
Rename parameter for clarity
cccs-rs Jul 31, 2024
c8c8fc7
Allow users to set parameters that aren't enforced by profile
cccs-rs Jul 31, 2024
f718e55
Expand service categories to make it easier for the UI to lock down c…
cccs-rs Aug 9, 2024
ea02e03
Patch testing
cccs-rs Aug 9, 2024
091ac37
Modify APIs to allow editing/fetching of user submission profiles
cccs-rs Oct 11, 2024
8c2aa0d
Merge branch 'master' into AL-2646
cccs-nr Oct 15, 2024
747d946
Merge branch 'master' into AL-2646
cccs-nr Oct 22, 2024
ab1e33d
Merge branch 'master' into AL-2646
cccs-nr Oct 24, 2024
b117ae3
Changed the submission profile's loading and setting methods
cccs-nr Dec 17, 2024
08d9121
Set the preferred_submission_profile if it doesn't exist in the exist…
cccs-nr Dec 17, 2024
7d13a5b
Fixed the loading of the preferred_submission_profile
cccs-nr Dec 17, 2024
8a3486b
Added the max file size to the /whoami path
cccs-nr Jan 3, 2025
716809d
minor change to the load_user_settings
cccs-nr Jan 17, 2025
a3bb254
Bugfix: New users should use default settings
cccs-rs Jan 23, 2025
876500c
Update APIs to handle changes to submission profiles
cccs-rs Feb 1, 2025
3ef5eaf
Guard submit & ingest API from unauthorized submission customization
cccs-rs Jul 10, 2024
f2769f0
Setup using submission profiles on submission
cccs-rs Jul 22, 2024
1f33917
Use a method function for setting user-specified submission parameters
cccs-rs Jul 30, 2024
54763a0
Rename parameter to deconflict with pre-existing `profile` parameter
cccs-rs Jul 31, 2024
8926578
Update tests
cccs-rs Jul 31, 2024
5bc9810
Rename parameter for clarity
cccs-rs Jul 31, 2024
3d4c6f1
Allow users to set parameters that aren't enforced by profile
cccs-rs Jul 31, 2024
792c293
Expand service categories to make it easier for the UI to lock down c…
cccs-rs Aug 9, 2024
e541c0f
Patch testing
cccs-rs Aug 9, 2024
8aeb0a6
Modify APIs to allow editing/fetching of user submission profiles
cccs-rs Oct 11, 2024
9aa736b
Changed the submission profile's loading and setting methods
cccs-nr Dec 17, 2024
8eb4c04
Set the preferred_submission_profile if it doesn't exist in the exist…
cccs-nr Dec 17, 2024
cba0c6d
Fixed the loading of the preferred_submission_profile
cccs-nr Dec 17, 2024
5e49153
Added the max file size to the /whoami path
cccs-nr Jan 3, 2025
dcfe398
minor change to the load_user_settings
cccs-nr Jan 17, 2025
2b3db82
Bugfix: New users should use default settings
cccs-rs Jan 23, 2025
fbfd2fe
Update APIs to handle changes to submission profiles
cccs-rs Feb 1, 2025
e6406a2
Merge remote-tracking branch 'refs/remotes/origin/AL-2646' into AL-2646
cccs-rs Feb 1, 2025
24b6d07
Merge pull request #1107 from CybercentreCanada/master
cccs-nr Feb 4, 2025
5e819da
Remove unused imports
cccs-rs Feb 4, 2025
00b4208
Fix pre-existing tests
cccs-rs Feb 5, 2025
d91a112
Update testing for setting user's settings
cccs-rs Feb 5, 2025
cc4ea6e
More fixes
cccs-rs Feb 5, 2025
64c9b8f
Add testing for submission profiles with a preset ingestion type for …
cccs-rs Feb 5, 2025
7c11f9a
Add profile to testing pipeline configuration
cccs-rs Feb 6, 2025
42018c7
Retry random testing errors with Badlist
cccs-rs Feb 6, 2025
c8e50bd
Patch save_user_settings API to account for actual changes made to su…
cccs-rs Feb 7, 2025
9697be5
Update API for UI submissions
cccs-rs Feb 8, 2025
416f423
Add API for resubmitting file/submission with a submission profile
cccs-rs Feb 11, 2025
cd31213
Fix for 3.9 compatibility
cccs-rs Feb 13, 2025
ba7a491
Allow the API to correct the name of the file if the downloaded conte…
cccs-rs Feb 14, 2025
3e5071a
Re-apply changes to the default profile settings
cccs-rs Mar 6, 2025
a63f749
Merge pull request #1122 from CybercentreCanada/master
cccs-rs Mar 6, 2025
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
2 changes: 1 addition & 1 deletion assemblyline_ui/api/v4/badlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def remove_attribution(qhash, attrib_type, value, **_):
while True:
current_badlist, version = STORAGE.badlist.get_if_exists(qhash, as_obj=False, version=True)
if not current_badlist:
return make_api_response({}, "The badlist ietm your are trying to modify does not exists", 404)
return make_api_response({}, "The badlist item you are trying to modify does not exists", 404)

if 'attribution' not in current_badlist:
return make_api_response({'success': False})
Expand Down
58 changes: 35 additions & 23 deletions assemblyline_ui/api/v4/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
STORAGE, config, FILESTORE, metadata_validator, LOGGER
from assemblyline_ui.helper.service import ui_to_submission_params
from assemblyline_ui.helper.submission import FileTooBigException, submission_received, refang_url, fetch_file, \
FETCH_METHODS, URL_GENERATORS
FETCH_METHODS, URL_GENERATORS, update_submission_parameters

from assemblyline_ui.helper.user import check_async_submission_quota, decrement_submission_ingest_quota, \
load_user_settings

Expand All @@ -37,6 +38,16 @@
port=config.core.redis.persistent.port)
MAX_SIZE = config.submission.max_file_size

DEFAULT_INGEST_PARAMS = {
'deep_scan': False,
"priority": 150,
"ignore_cache": False,
# the following one line can be removed after assemblyline 4.6+
"ignore_dynamic_recursion_prevention": False,
"ignore_recursion_prevention": False,
"ignore_filtering": False,
"type": "INGEST"
}

# noinspection PyUnusedLocal
@ingest_api.route("/get_message/<notification_queue>/", methods=["GET"])
Expand Down Expand Up @@ -151,15 +162,17 @@ def ingest_single_file(**kwargs):
"base64": "<BINARY DATA OF THE FILE TO SCAN... ENCODED AS BASE64 STRING>",

// OPTIONAL VALUES
"name": "file.exe", # Name of the file to scan otherwise the sha256 or base file of the url
"name": "file.exe", # Name of the file to scan otherwise the sha256 or base file of the url

"submission_profile": "Static Analysis", # Name of submission profile to use

"metadata": { # Submission metadata
"key": val, # Key/Value pair for metadata parameters
"metadata": { # Submission metadata
"key": val, # Key/Value pair for metadata parameters
},

"params": { # Submission parameters
"key": val, # Key/Value pair for params that differ from the user's defaults
}, # Default params can be fetch at /api/v3/user/submission_params/<user>/
"params": { # Submission parameters
"key": val, # Key/Value pair for params that differ from the user's defaults
}, # Default params can be fetch at /api/v3/user/submission_params/<user>/

"generate_alert": False, # Generate an alert in our alerting system or not
"notification_queue": None, # Name of the notification queue
Expand Down Expand Up @@ -256,22 +269,21 @@ def ingest_single_file(**kwargs):
default_external_sources = user_settings.pop('default_external_sources', [])

# Load default user params from user settings
s_params = ui_to_submission_params(user_settings)
if ROLES.submission_customize in user['roles']:
s_params = ui_to_submission_params(user_settings)
else:
s_params = {}

# Reset dangerous user settings to safe values
s_params.update({
'deep_scan': False,
"priority": 150,
"ignore_cache": False,
# the following one line can be removed after assemblyline 4.6+
"ignore_dynamic_recursion_prevention": False,
"ignore_recursion_prevention": False,
"ignore_filtering": False,
"type": "INGEST"
})
# Update submission parameters as specified by the user
try:
s_params = update_submission_parameters(s_params, data, user)
except Exception as e:
return make_api_response({}, str(e), 400)

# Apply provided params
s_params.update(data.get("params", {}))
# Set any dangerous user settings to safe values (if wasn't set in request)
for k, v in DEFAULT_INGEST_PARAMS.items():
if k not in s_params:
s_params[k] = v

# Use the `default_external_sources` if specified as a param in request otherwise default to user's settings
default_external_sources = s_params.pop('default_external_sources', []) or default_external_sources
Expand All @@ -283,8 +295,8 @@ def ingest_single_file(**kwargs):
if not binary:
if string_type:
try:
found, fileinfo = fetch_file(string_type, string_value, user, s_params, metadata, out_file,
default_external_sources)
found, fileinfo, name = fetch_file(string_type, string_value, user, s_params, metadata, out_file,
default_external_sources, name)
if not found:
raise FileNotFoundError(
f"{string_type.upper()} does not exist in Assemblyline or any of the selected sources")
Expand Down
2 changes: 0 additions & 2 deletions assemblyline_ui/api/v4/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def get_full_results(sid, **kwargs):
},
"state": "completed", # State of the submission
"submission": { # Submission Block
"profile": true, # Should keep stats about execution?
"description": "", # Submission description
"ttl": 30, # Submission days to live
"ignore_filtering": false, # Ignore filtering services?
Expand Down Expand Up @@ -451,7 +450,6 @@ def get_submission(sid, **kwargs):
["FNAME", "sha256"], ...], # Each file = List of name/sha256
"errors": [], # List of error keys (sha256.ServiceName)
"submission": { # Submission Block
"profile": true, # Should keep stats about execution?
"description": "", # Submission description
"ttl": 30, # Submission days to live
"ignore_filtering": false, # Ignore filtering services?
Expand Down
Loading