Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Bug/package sha1 and vul level bug (#128)
Browse files Browse the repository at this point in the history
* Update entrypoint.sh

* merge main

* fix: python package sha1  and vul_level bug

* fix: python package sha1  and vul_level bug
  • Loading branch information
Bidaya0 authored Jan 19, 2022
1 parent a1f88d2 commit e13edc7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from core.plugins.export_report import ExportPort
from dongtai.models.project_report import ProjectReport
import requests
from hashlib import sha1

LANGUAGE_MAP = {
"JAVA": 1,
Expand Down Expand Up @@ -399,7 +400,7 @@ def sca_scan_asset(asset):

if len(levels) > 0:

if 'high' in levels:
if 'critical' in levels:
level = 'high'
elif 'high' in levels:
level = 'high'
Expand All @@ -409,7 +410,8 @@ def sca_scan_asset(asset):
level = 'low'
else:
level = 'info'

else:
level = 'info'
new_level = IastVulLevel.objects.get(name=level)
if asset.level != new_level:
asset.level = IastVulLevel.objects.get(name=level)
Expand Down Expand Up @@ -450,6 +452,7 @@ def update_one_sca(agent_id, package_path, package_signature, package_name, pack
asset_count = Asset.objects.values("id").filter(signature_value=package_signature,
agent__in=current_version_agents).count()
else:
package_signature = sha_1('-'.join([package_name, version]))
asset_count = Asset.objects.values("id").filter(package_name=package_name,
version=version,
agent__in=current_version_agents).count()
Expand Down Expand Up @@ -499,6 +502,10 @@ def update_all_sca():
except Exception as e:
logger.error(f'SCA离线检测出错,错误原因:{e}')

def sha_1(raw):
h = sha1()
h.update(raw.encode('utf-8'))
return h.hexdigest()

def is_alive(agent_id, timestamp):
"""
Expand Down

0 comments on commit e13edc7

Please sign in to comment.