diff --git "a/CVECNAMap.ipynb" "b/CVECNAMap.ipynb" new file mode 100644--- /dev/null +++ "b/CVECNAMap.ipynb" @@ -0,0 +1,7927 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# CNA MAP\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-06T00:19:15.200839Z", + "iopub.status.busy": "2023-04-06T00:19:15.200264Z", + "iopub.status.idle": "2023-04-06T00:19:15.773602Z", + "shell.execute_reply": "2023-04-06T00:19:15.773034Z" + }, + "tags": [ + "remove-cell" + ] + }, + "outputs": [], + "source": [ + "from IPython.core.magic import register_cell_magic\n", + "from IPython.display import Markdown\n", + "import datetime\n", + "from datetime import date\n", + "import folium\n", + "from folium.plugins import MarkerCluster\n", + "from geopy.geocoders import Nominatim\n", + "import json\n", + "import pandas as pd\n", + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-06T00:19:15.776446Z", + "iopub.status.busy": "2023-04-06T00:19:15.776046Z", + "iopub.status.idle": "2023-04-06T00:21:37.439355Z", + "shell.execute_reply": "2023-04-06T00:21:37.438831Z" + }, + "tags": [ + "remove-cell" + ] + }, + "outputs": [], + "source": [ + "\n", + "\n", + "with open('CNAsList.json') as f:\n", + " data = json.load(f)\n", + "\n", + "CNA = pd.json_normalize(data)\n", + "\n", + "geolocator = Nominatim(user_agent=\"CNALookup\")\n", + "latitude = []\n", + "long = []\n", + "for i in CNA[\"country\"]:\n", + " if i != None:\n", + " location = geolocator.geocode(i, timeout=None)\n", + " if location!=None:\n", + " latitude.append(location.latitude)#, location.longitude)\n", + " long.append(location.longitude)\n", + " else:\n", + " latitude.append(float(\"Nan\"))#, location.longitude)\n", + " long.append(float(\"Nan\"))\n", + " else:\n", + " latitude.append(float(\"Nan\"))#, location.longitude)\n", + " long.append(float(\"Nan\"))\n", + "\n", + "CNA[\"Latitude\"] = latitude\n", + "CNA[\"Longitude\"] = long" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-06T00:21:37.442406Z", + "iopub.status.busy": "2023-04-06T00:21:37.441954Z", + "iopub.status.idle": "2023-04-06T00:21:37.449249Z", + "shell.execute_reply": "2023-04-06T00:21:37.448695Z" + }, + "tags": [ + "remove-cell" + ] + }, + "outputs": [], + "source": [ + "pattern = r'(https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}[-a-zA-Z0-9()@:%_+.~#?&/=]*)' \n", + "CNA['securityAdvisories.advisories'] = CNA['securityAdvisories.advisories'].astype(str)\n", + "CNA['URL'] = CNA['securityAdvisories.advisories'].str.extract(pattern, expand=False).str.strip()\n", + "CNA['URL'] = CNA['URL'].astype(str)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-06T00:21:37.451423Z", + "iopub.status.busy": "2023-04-06T00:21:37.451126Z", + "iopub.status.idle": "2023-04-06T00:21:37.860482Z", + "shell.execute_reply": "2023-04-06T00:21:37.859982Z" + }, + "tags": [ + "remove-input" + ] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "map = folium.Map(location=[10, 0], tiles='cartodb positron', zoom_start=2.25)\n", + "\n", + "mcluster = MarkerCluster().add_to(map)\n", + "\n", + "for index, row in CNA.iterrows():\n", + " folium.Marker(location=[row['Latitude'],row['Longitude']], popup=(\"\"+row.organizationName+\"\" +\"\\n\"+\"
\"+row.URL),icon=folium.Icon(color='lightgray', icon='bug', prefix='fa')).add_to(mcluster)\n", + "\n", + "map\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This map is built from the data on [this page](https://www.cve.org/PartnerInformation/ListofPartners). More infomration about CNA's can be found [here](https://www.cve.org/ProgramOrganization/CNAs). " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-06T00:21:37.901871Z", + "iopub.status.busy": "2023-04-06T00:21:37.901231Z", + "iopub.status.idle": "2023-04-06T00:21:37.905415Z", + "shell.execute_reply": "2023-04-06T00:21:37.904926Z" + }, + "tags": [ + "remove-input" + ] + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "This report is updated automatically every day, last generated on: **2023-04-06 00:21:37.902782**" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Markdown(f\"This report is updated automatically every day, last generated on: **{datetime.datetime.now()}**\")" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}