check cve
今天想检查一下 Gitlab 11.9.0 产品受哪些 cve 的影响。其实网上已经有很多网站可以查询产品的相关 cve,但就是粒度比较粗。我想在 cve 列表中筛选出特定的版本,已经特定的版本,比如是社区版还是旗舰版。找了一下,没有发现完全符合这个要求的。后来在网上我就看到了一个网站是可以提供 cve 的 API 查询的。可以通过网站 API 可以获取特定的数据。
可以通过 https://cve.circl.lu/api/ 可以看到 API 文档。可以通过 cve id 以及 product 以及其他更多信息来查询。最有用的 API 就是这一个可以通过 vendor 以及 product 获取指定 vendor 和 product 的 cve 列表。这个 API 返回的结果是一个 JSON 数组,我们需要在这里面过滤出相应的版本号以及 edition 版本。另外由于请求的结果一般是一个很长的 json 数据,我的做法是第一次请求,可以吧结果保存成 JSON 文件,第二次请求的时候首先检查这个 JSON 文件的最近修改时间,如果最近修改时间小于指定的天数,比如 3 天,如果 3 天内修改过的话,直接从 JSON 文件加载数据,否则重新发送请求,加载数据。
# check if file modified in the last several days
def check_file_modified(filename, days):
file_modify_time = getmtime(filename)
return time() - file_modify_time < (days * 3600 * 1000)
def write_json(filename, result):
with open(filename, 'w') as f:
dump(result, f, indent=2)
def write_csv(filename, result, header):
with open(filename, 'w', newline='') as f:
writer = csv.writer(f, delimiter=',')
writer.writerow(header)
for ele in result:
writer.writerow([ele["id"], ele["last-modified"], ele["cvss"], ele["summary"]])
def search(params, options):
url = "https://cve.circl.lu/api/search/" + params
print(url)
filename = f"{params.replace('/', '-')}.json"
try:
if isfile(filename) and check_file_modified(filename, 3):
with open(filename, 'r') as f:
result = loads(f.read())
else:
res = get(url)
if res.status_code == 200:
with open(filename, 'w') as f:
f.write(res.text)
result = loads(res.text)
else:
print("Request failed: %d".format(res.status_code))
cve_result = []
for ele in result:
if has_cve(ele, options.vendor, options.product, options.version, options.edition):
obj = {
"id": ele["id"],
"last-modified": ele["last-modified"],
"cvss": ele["cvss"],
"summary": ele["summary"]
}
cve_result.append(obj)
else:
continue
print(f"{options.vendor}:{options.product}:{options.version}:{options.edition} "
f"has impacted by {len(cve_result)} cve")
if options.output is None or options.output == "csv":
write_csv("result.csv", cve_result, ["id", "last-modified", "cvss", "summary"])
else:
write_json("result.json", cve_result)
except Exception as e:
print(e)
完整的项目地址可以参考 https://github.com/neal1991/check-cve/blob/master/check-cve.py
可以扫描二维码或者搜索 mad_coder 关注微信公众号,点击阅读原文可以获取链接版原文。

check cve的更多相关文章
- How to exploit the x32 recvmmsg() kernel vulnerability CVE 2014-0038
http://blog.includesecurity.com/2014/03/exploit-CVE-2014-0038-x32-recvmmsg-kernel-vulnerablity.html ...
- 漏洞分析:CVE 2021-3156
漏洞分析:CVE 2021-3156 漏洞简述 漏洞名称:sudo堆溢出本地提权 漏洞编号:CVE-2021-3156 漏洞类型:堆溢出 漏洞影响:本地提权 利用难度:较高 基础权限:需要普通用户权限 ...
- -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HO 解决办法
最近在使用maven,项目测试的时候出现了这么一个错.-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2 ...
- SQL Server 合并复制遇到identity range check报错的解决
最近帮一个客户搭建跨洋的合并复制,由于数据库非常大,跨洋网络条件不稳定,因此只能通过备份初始化,在初始化完成后向海外订阅端插入数据时发现报出如下错误: Msg 548, Level 16, S ...
- SharePoint 2103 Check user permission on list
一.需求: check user 对SharePoint list 的permission 代码如下: private static string GetListPermission(SPList l ...
- 用SVN check out项目后第三方库丢失
曾经用Cornerstone check out 一份项目下来,但其中第三方.a库始终丢失,项目报错,研究后找到了以下解决方法: 首先,Xcode默认忽略.a 文件.所以无法提交到svn服务器,但是很 ...
- SQL Check
一款实时性能监测工具 SQL Check? 一款实时监测SQL数据库性能.实时排查的问题的免费工具. 可以实时监测20个左右的SQL关键性能指标,每个指标都已图形化动态直播形式展现. 适合DBA.数据 ...
- Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade
XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...
- check用户协议
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- jQuery 全选和反选demo
前段时间做了一个全选和反选的功能,最近不忙了,做了一个简化版的demo. 全部代码如下: <!DOCTYPE html> <html> <head> <tit ...
- C++入门经典-例2.2-使用格式输出函数printf
1:使用printf函数对不同类型变量进行输出,%符号,代表输出类型,\n代表换行,代码如下: // 2.2.cpp : 定义控制台应用程序的入口点. // #include "stdafx ...
- 套接字之msghdr结构
用户端在使用sendmsg/recvmsg发送或者接收数据时,会使用msghdr来构造消息,其对应的内核结构为user_msghdr:其中msg_iov向量指向了多个数据区,msg_iovlen标识了 ...
- Python中Counter统计数据输出具体办法
from collections import Counter # 列表 l_one = [1709020621, 1709020621, 1770603107, 1770603105, 177060 ...
- CopyOnWriteArrayList使用
1.在遍历操作数量大大超过可变操作是(add,set等等)使用.原因是其可变操作是通过对底层数据进行一次新的复制来实现的. 2.迭代器创建后,其不会反应列表的添加.移除或更改.其迭代器是”快照“风格的 ...
- JSP——隐式对象(implicit object)
Servlet容器将几个对象传递给它所运行的Servlet. 例如,在Servlet的service方法中获得HttpServletRequest和HttpServletResponse,并在init ...
- 初始化EPT
struct eptp_bits { unsigned memory_type :; /* 0: UC uncacheable, 6: WB writeback */ unsigned pagewal ...
- golang网络通信超时设置
网络通信中,为了防止长时间无响应的情况,经常会用到网络连接超时.读写超时的设置. 本文结合例子简介golang的连接超时和读写超时设置. 1.超时设置 1.1 连接超时 func DialTimeou ...
- Vs code工具汉化
官网为:https://code.visualstudio.com/ 看到中间有一些提示的命令 选择第一条,即Ctrl+shift+P,弹出命令行,选择"Configure Display ...
- committed与urgent的区别
Committed跟Urgent都是time automaton 中用来表示state的关键词. 它们的主要区别是: Committed前后的两个状态改变(transition)是串行发生,不可打断的 ...