-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from LoRexxar/develop
Develop
- Loading branch information
Showing
16 changed files
with
305 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
''' | ||
@author: LoRexxar | ||
@contact: lorexxar@gmail.com | ||
@file: mofei.py | ||
@time: 2021/9/27 11:47 | ||
@desc: | ||
''' | ||
|
||
import json | ||
import requests | ||
|
||
from Kunlun_M.settings import MURPHYSEC_TOKEN | ||
from utils.log import logger | ||
|
||
__MURPHYSECAPI = "https://api.murphysec.com/cert/v1/check" | ||
__MURPHYSECVULAPI = "https://api.murphysec.com/cert/v1/latest" | ||
|
||
|
||
def get_vulns_from_murphysec(language, package_name, version): | ||
datas = { | ||
"comp_name": package_name, | ||
"version": version, | ||
"language": language, | ||
"filter":{ | ||
"level": "严重|高危|中危" | ||
} | ||
} | ||
|
||
headers = { | ||
"Authorization": "Bearer {}".format(MURPHYSEC_TOKEN), | ||
"Content-Type": "application/json" | ||
} | ||
result = [] | ||
|
||
r = requests.post(url=__MURPHYSECAPI, headers=headers, data=json.dumps(datas)) | ||
|
||
if r.status_code == 200: | ||
data = json.loads(r.content) | ||
|
||
if data['code'] == 400: | ||
logger.warning("[Vendor][Murphysec Scan] QPS limit.") | ||
return result | ||
|
||
elif data['code'] == 401: | ||
logger.error("[Vendor][Murphysec Scan] Api Token error.") | ||
|
||
else: | ||
vuls = data['data'] | ||
|
||
for vul in vuls: | ||
vuln = {} | ||
vuln["vuln_id"] = vul['no'] | ||
vuln["title"] = vul['title'] | ||
# reference | ||
urls = [] | ||
for u in vul['references']: | ||
urls.append(u["url"]) | ||
|
||
vuln["reference"] = json.dumps(urls) | ||
vuln["description"] = vul['description'] | ||
# get cve | ||
cves = [vul['cve_id'], vul['cnvd_id']] | ||
vuln["cves"] = json.dumps(cves) | ||
# get severity | ||
vuln["severity"] = int(vul['cvss']) | ||
|
||
# affected_versions | ||
# affected_versions = [] | ||
# for av in vul['effect']: | ||
# affected_versions.append(av['version_end_excluding']) | ||
|
||
vuln["affected_versions"] = [version] | ||
|
||
result.append(vuln) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.