check cve

news/2024/7/3 20:08:32

今天想检查一下 Gitlab 11.9.0 产品受哪些 cve 的影响。其实网上已经有很多网站可以查询产品的相关 cve,但就是粒度比较粗。我想在 cve 列表中筛选出特定的版本,已经特定的版本,比如是社区版还是旗舰版。找了一下,没有发现完全符合这个要求的。后来在网上我就看到了一个网站是可以提供 cve 的 API 查询的。可以通过网站 API 可以获取特定的数据。

640?wx_fmt=png

可以通过 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


http://www.niftyadmin.cn/n/4682524.html

相关文章

理解跨域资源共享

原文:Understanding CORS译者:neal1991welcome to star my articles-translator, providing you advanced articles translation. Any suggestion, please issue or contact meLICENSE: MITCORS 或跨域资源共享是一种 http 机制,它允许用户通…

09总结,10年计划

09年匆匆过去了,越来越感觉时间过得快了。09年有太多的目标没有实现,时间太忙,出差太多了,也许吧,更多的还是自己赖吧。09年成功的地方无非于掌握了更多的业务知识,社会经验更加丰富了,更加油腔…

html程序——简历

简介 我们可以用上一篇博客中讲到的html基础语法来写一篇自己的网页版简历 具体效果 代码 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge…

如何写一个 Burp 插件

Burp 是 Web 安全测试中不可或缺的神器。每一个师傅的电脑里面应该都有一个 Burp。同时 Burp 和很多其他神器一样&#xff0c;它也支持插件。但是目前总体来说网上 Burp 插件开发的资料不是特别特别的丰富。今天我也来讲讲自己如何从一个完全不会 Burp 插件开发的小白如何学习 …

html程序——填写简历

之前我们通过讲解的html基础知识&#xff0c;写出了自己的网页版的简历&#xff0c;现在来尝试写一下填写简历的网页版吧 网页展示 代码实现 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv&…

介绍一种零件分类编码系统【原】

目前介绍分类编码系统的资料&#xff0c;大多都是采用根据产品的管理属性或成本属性来进行分类的&#xff0c;这种方式往往缺乏分类的一致性&#xff0c;不具有相应的通行标准&#xff0c;不利于维护使用&#xff0c;针对零件的分类编码系统&#xff0c;在国际上是存在相应的标…

[收藏] 40 Beautiful Free Icon Sets

http://sixrevisions.com/resources/40-beautiful-free-icon-sets/转载于:https://www.cnblogs.com/wdpp/archive/2010/02/03/2386359.html

官宣!VS Code Python 全新功能在 PyCon China 全球首发!

北京时间 2019 年 9 月 21 日&#xff0c;PyCon China 2019 在上海举行。在下午的演讲中&#xff0c;来自微软开发工具事业部的资深研发工程师在演讲中&#xff0c;我们看到了 Azure Notebook 与 VS Code 对 Python 的强大的支持。然而&#xff0c;鱼和熊掌似乎不可兼得。Jupyt…