{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from pymongo import MongoClient\n", "import pandas as pd\n", "import json\n", "from bson.json_util import dumps\n", "from pandas.io.json import json_normalize" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "ip = '127.0.0.1'\n", "port = 27017\n", "client = MongoClient(ip, port)\n", "db = client['Vulnerabilities']\n", "joinedVulnerabilitiesDateFormat = db['Vulnerabilities']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def getImpact():\n", " return joinedVulnerabilitiesDateFormat.aggregate([\n", " { \"$project\" : \n", " { \n", " \"_id\" : 0,\n", " \"CVE-ID\" : \"$cveId\",\n", " \"integrityImpact\" : \"$webScrapingInformation.cvssScoreCVED.integrityImpact\",\n", " \"availabilityImpact\" : \"$webScrapingInformation.cvssScoreCVED.availabilityImpact\",\n", " \"confidentialityImpact\": \"$webScrapingInformation.cvssScoreCVED.confidentialityImpact\",\n", " \"accessComplexity\" :\"$webScrapingInformation.cvssScoreCVED.accessComplexity\"\n", " \n", " }\n", " }])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ "MongoResponse = getImpact()\n", "dataFromMongoResponse = json.loads(dumps(MongoResponse))" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "with open(\"impactRelationEMSE.json\", \"w\") as fp:\n", " json.dump(dataFromMongoResponse, fp)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }