khulnasoft commited on
Commit
8c5b54f
1 Parent(s): c9a1256

Delete cisa_enriched.ipynb

Browse files
Files changed (1) hide show
  1. cisa_enriched.ipynb +0 -126
cisa_enriched.ipynb DELETED
@@ -1,126 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "metadata": {},
7
- "outputs": [],
8
- "source": [
9
- "import pandas as pd\n",
10
- "import requests\n",
11
- "import json"
12
- ]
13
- },
14
- {
15
- "cell_type": "code",
16
- "execution_count": null,
17
- "metadata": {},
18
- "outputs": [],
19
- "source": [
20
- "cisa_df = pd.read_json(\"https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json\")\n",
21
- "cisa_df = pd.json_normalize(cisa_df['vulnerabilities'])\n",
22
- "cisa_df = cisa_df.rename(columns={'cveID': 'CVE'})\n"
23
- ]
24
- },
25
- {
26
- "cell_type": "code",
27
- "execution_count": null,
28
- "metadata": {},
29
- "outputs": [],
30
- "source": [
31
- "cisa_df = cisa_df\n",
32
- "cves = cisa_df[\"CVE\"].to_list()\n",
33
- "cves\n",
34
- "\n",
35
- "CISA_List = []\n",
36
- "\n",
37
- "for cve in cves:\n",
38
- " base_url = 'https://cve.circl.lu/api/cve/'\n",
39
- " url = ''.join([base_url, cve])\n",
40
- " r = requests.get(url)\n",
41
- " try:\n",
42
- " data = r.json()\n",
43
- " CVEPublished = data['Published']\n",
44
- " CVEModified = data['Modified']\n",
45
- " cvss = data['cvss']\n",
46
- " cwe = data['cwe']\n",
47
- " references = data['references']\n",
48
- " vulnerable_product = data['vulnerable_product']\n",
49
- "\n",
50
- " except:\n",
51
- " pass\n",
52
- " CISA_List_Temp = (cve, CVEPublished, CVEModified, cvss, cwe, references, vulnerable_product)\n",
53
- " CISA_List.append(CISA_List_Temp)"
54
- ]
55
- },
56
- {
57
- "cell_type": "code",
58
- "execution_count": null,
59
- "metadata": {},
60
- "outputs": [],
61
- "source": [
62
- "cisa_enriched_df = pd.DataFrame(CISA_List, columns = [\"CVE\", \"CVE_Published\", \"CVE_Modified\", \"CVSS\", \"CWE\", \"References\", \"Vulnerable_Products\"])"
63
- ]
64
- },
65
- {
66
- "cell_type": "code",
67
- "execution_count": null,
68
- "metadata": {},
69
- "outputs": [],
70
- "source": [
71
- "cisa_data = cisa_enriched_df.merge(cisa_df, on='CVE', how='outer')\n",
72
- "cisa_data = cisa_data.rename(columns={'dueDate': 'CISA_Due_Date', 'requiredAction' : 'Required_Action', 'shortDescription' : \"Description\", 'vendorProject': 'Vendor', 'product' : 'Product', 'vulnerabilityName' : 'Vulnerability_Name', 'dateAdded' : 'CISA_Date_Added'})\n",
73
- "cisa_data= cisa_data[[ 'CVE', 'Vulnerability_Name', 'Description', 'Vendor', 'Product', 'CVSS', 'CWE', 'Required_Action', 'CVE_Published', 'CVE_Modified', 'CISA_Date_Added', 'CISA_Due_Date', 'References', 'Vulnerable_Products']]"
74
- ]
75
- },
76
- {
77
- "cell_type": "code",
78
- "execution_count": null,
79
- "metadata": {},
80
- "outputs": [],
81
- "source": [
82
- "\n",
83
- "cisa_data.to_csv('cisa_enriched.csv', index=False)"
84
- ]
85
- },
86
- {
87
- "cell_type": "code",
88
- "execution_count": null,
89
- "metadata": {},
90
- "outputs": [],
91
- "source": [
92
- "result = cisa_data.to_json(orient=\"records\")\n",
93
- "parsed = json.loads(result)\n",
94
- "print(json.dumps(parsed, indent=4))\n",
95
- "\n",
96
- "with open('cisa_enriched.json', 'w', encoding='utf-8') as f:\n",
97
- " json.dump(parsed, f, ensure_ascii=False, indent=4)\n"
98
- ]
99
- }
100
- ],
101
- "metadata": {
102
- "interpreter": {
103
- "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
104
- },
105
- "kernelspec": {
106
- "display_name": "Python 3.9.9 64-bit",
107
- "language": "python",
108
- "name": "python3"
109
- },
110
- "language_info": {
111
- "codemirror_mode": {
112
- "name": "ipython",
113
- "version": 3
114
- },
115
- "file_extension": ".py",
116
- "mimetype": "text/x-python",
117
- "name": "python",
118
- "nbconvert_exporter": "python",
119
- "pygments_lexer": "ipython3",
120
- "version": "3.9.9"
121
- },
122
- "orig_nbformat": 4
123
- },
124
- "nbformat": 4,
125
- "nbformat_minor": 2
126
- }