Skip to content

Commit

Permalink
Fix classification propagation and display
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-sgaron committed May 1, 2020
1 parent 369ee29 commit 1e74e36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions assemblyline_ui/api/v4/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ def get_file_results(sha256, **kwargs):
return make_api_response({}, "This file does not exists", 404)

if user and Classification.is_accessible(user['classification'], file_obj['classification']):
max_c12n = file_obj['classification']
output = {
"file_info": {},
"file_info": file_obj,
"results": [],
"tags": {},
"attack_matrix": {},
Expand All @@ -455,13 +456,13 @@ def get_file_results(sha256, **kwargs):
output['childrens'] = res_children.result()
output['metadata'] = res_meta.result()

output['file_info'] = file_obj
output['results'] = []
output['alternates'] = {}
res = STORAGE.result.multiget(active_keys, as_dictionary=False, as_obj=False)
for r in res:
res = format_result(user['classification'], r, file_obj['classification'], build_hierarchy=True)
if res:
max_c12n = Classification.max_classification(max_c12n, res['classification'])
output['results'].append(res)

for i in alternates:
Expand Down Expand Up @@ -526,6 +527,7 @@ def get_file_results(sha256, **kwargs):

output['signatures'] = list(output['signatures'])

output['file_info']['classification'] = max_c12n
return make_api_response(output)
else:
return make_api_response({}, "You are not allowed to view this file", 403)
Expand Down
3 changes: 3 additions & 0 deletions assemblyline_ui/api/v4/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ def get_file_submission_results(sid, sha256, **kwargs):
if not Classification.is_accessible(user['classification'], temp_file['classification']):
return make_api_response("", "You are not allowed to view the data of this file", 403)
output['file_info'] = temp_file
max_c12n = output['file_info']['classification']

temp_results = list(STORAGE.get_multiple_results([x for x in res_keys if x.startswith(sha256)],
cl_engine=Classification, as_obj=False).values())
results = []
for r in temp_results:
r = format_result(user['classification'], r, temp_file['classification'], build_hierarchy=True)
if r:
max_c12n = Classification.max_classification(max_c12n, r['classification'])
results.append(r)
output['results'] = results

Expand Down Expand Up @@ -186,6 +188,7 @@ def get_file_submission_results(sid, sha256, **kwargs):

output['signatures'] = list(output['signatures'])

output['file_info']['classification'] = max_c12n
return make_api_response(output)
else:
return make_api_response("", "You are not allowed to view the data of this submission", 403)
Expand Down
4 changes: 2 additions & 2 deletions assemblyline_ui/static/ng-template/file_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h5 ng-show="current_file.name" class="text-muted">{{current_file.name | split}}
<li class="small" ng-repeat="a in current_file.alternates[res.response.service_name]" ng-class="{disabled: a.created==res.created}"><a ng-click="select_alternate(a.response.service_name, a.created);$event.stopPropagation();">{{a.response.service_name}} :: {{a.response.service_version}} :: [{{a.result.score}}] @ {{a.created | date:"yyyy-MM-dd HH:mm:ss"}}</a></li>
</ul>
</div>
<strong><span ng-if="res.result.classification" class="{{res.result.classification | class_text_color }}" >({{res.result.classification | class_sm}})&nbsp;</span>{{res.response.service_name}}</strong>&nbsp;[<span class="{{res.result.score | score_color}}"><strong>{{res.result.score}}</strong></span>]&nbsp;<span class="text-muted">:: {{res.response.service_version}}<span ng-show="res.response.service_context"> ({{res.response.service_context}})</span></span>
<strong><span ng-if="res.classification" class="{{res.classification | class_text_color }}" >({{res.classification | class_sm}})&nbsp;</span>{{res.response.service_name}}</strong>&nbsp;[<span class="{{res.result.score | score_color}}"><strong>{{res.result.score}}</strong></span>]&nbsp;<span class="text-muted">:: {{res.response.service_version}}<span ng-show="res.response.service_context"> ({{res.response.service_context}})</span></span>
</div>
<div id="{{res.response.service_name}}_content" class="content collapse" ng-class="{'in': res.result.score >= settings.expand_min_score || res.response.service_name == switch_service }">
<div ng-if="res.result.sections.length == 0" >
Expand Down Expand Up @@ -286,7 +286,7 @@ <h5 ng-show="current_file.name" class="text-muted">{{current_file.name | split}}
<li class="small" ng-repeat="a in current_file.alternates[res.response.service_name]" ng-class="{disabled: a.created==res.created}"><a ng-click="select_alternate(a.response.service_name, a.created);$event.stopPropagation();">{{a.response.service_name}} :: {{a.response.service_version}} <span ng-show="a.response.service_context"> ({{a.response.service_context}}) </span>:: [{{a.result.score}}] @ {{a.created | date:"yyyy-MM-dd HH:mm:ss"}}</a></li>
</ul>
</div>
<strong><span ng-if="res.result.classification" class="{{res.result.classification | class_text_color }}" >({{res.result.classification | class_sm}})&nbsp;</span>{{res.response.service_name}}</strong>&nbsp;[<span class="{{res.result.score | score_color}}"><strong>{{res.result.score}}</strong></span>]&nbsp;<span class="text-muted">:: {{res.response.service_version}}<span ng-show="res.response.service_context"> ({{res.response.service_context}})</span></span>
<strong><span ng-if="res.classification" class="{{res.classification | class_text_color }}" >({{res.classification | class_sm}})&nbsp;</span>{{res.response.service_name}}</strong>&nbsp;[<span class="{{res.result.score | score_color}}"><strong>{{res.result.score}}</strong></span>]&nbsp;<span class="text-muted">:: {{res.response.service_version}}<span ng-show="res.response.service_context"> ({{res.response.service_context}})</span></span>
</div>
<div id="{{res.response.service_name}}_content" class="content collapse" ng-class="{'in': res.result.score >= settings.expand_min_score || res.response.service_name == switch_service }">
<div ng-if="res.result.sections.length == 0" >
Expand Down

0 comments on commit 1e74e36

Please sign in to comment.