今天想检查一下 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的更多相关文章

  1. 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 ...

  2. 漏洞分析:CVE 2021-3156

    漏洞分析:CVE 2021-3156 漏洞简述 漏洞名称:sudo堆溢出本地提权 漏洞编号:CVE-2021-3156 漏洞类型:堆溢出 漏洞影响:本地提权 利用难度:较高 基础权限:需要普通用户权限 ...

  3. -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HO 解决办法

    最近在使用maven,项目测试的时候出现了这么一个错.-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2 ...

  4. SQL Server 合并复制遇到identity range check报错的解决

        最近帮一个客户搭建跨洋的合并复制,由于数据库非常大,跨洋网络条件不稳定,因此只能通过备份初始化,在初始化完成后向海外订阅端插入数据时发现报出如下错误: Msg 548, Level 16, S ...

  5. SharePoint 2103 Check user permission on list

    一.需求: check user 对SharePoint list 的permission 代码如下: private static string GetListPermission(SPList l ...

  6. 用SVN check out项目后第三方库丢失

    曾经用Cornerstone check out 一份项目下来,但其中第三方.a库始终丢失,项目报错,研究后找到了以下解决方法: 首先,Xcode默认忽略.a 文件.所以无法提交到svn服务器,但是很 ...

  7. SQL Check

    一款实时性能监测工具 SQL Check? 一款实时监测SQL数据库性能.实时排查的问题的免费工具. 可以实时监测20个左右的SQL关键性能指标,每个指标都已图形化动态直播形式展现. 适合DBA.数据 ...

  8. 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 ...

  9. check用户协议

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. java正则表达式详细总结

    Java 提供了功能强大的正则表达式API,在java.util.regex 包下.本教程介绍如何使用正则表达式API. 正则表达式 一个正则表达式是一个用于文本搜索的文本模式.换句话说,在文本中搜索 ...

  2. python3笔记三:运算符与表达式

    一:学习内容 算术运算符:+(加).-(减).*(乘)./(除).%(取模).**(求幂).//(取整) 赋值运算符:= 复合运算符:+=.-=.*=./=.%=.**=.//= 位运算符:& ...

  3. web长时间不激活 终止用户回话

    参考资料: http://web.jobbole.com/89072/ http://www.cnblogs.com/1175429393wljblog/p/5570606.html http://w ...

  4. 查询一个redis集群的大keys 脚本

    1. 把redis集群中的 master 节点信息记录在文件 redis_object_port.info 中, 方便下一步遍历各实例中的大 keys redis-cli -h 10.240.47.1 ...

  5. How to solve the error "Field service in com.xx.xxx.xxxx required a bean of type 'com.aa.bb.cc' that could not be found."

    When runung a SpringBoot demo, I  got a error as following: *************************** APPLICATION ...

  6. 整理ing

    RT 要学习的 专克bzoj权限题 钟神p系列

  7. 转 Go语言基本类型 —— 字符类型

    https://blog.csdn.net/FHD994603831/article/details/92435724 字符类型Golang中没有专门的字符类型,如果要存储单个字符(字母),一般使用b ...

  8. Mimikatz 攻防杂谈

    前几天看到了老外一篇讲 mimikatz 防御的文章,感觉行文思路还不错,但是内容稍有不足,国内也有一篇翻译,但是只是照着错误翻译的,所以就萌生了把那篇优秀文章,翻译复现,并加入其它一些内容,本文只是 ...

  9. 第三章 SpringCloud之Eureka-Client服务提供者

    1.Eureka-Client简介 #################接下来开始程序啦########################## 1.pom.xml <?xml version=&qu ...

  10. jQuery.validator.addMethod自定义验证

    jQuery.validator.addMethod("numOrLetter", function(value, element) { return this.optional( ...