You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by ev...@apache.org on 2017/03/29 16:51:52 UTC
[28/50] [abbrv] incubator-spot git commit: Bug fixing for DNS and
Proxy Edge Notebooks
Bug fixing for DNS and Proxy Edge Notebooks
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/7abbab2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/7abbab2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/7abbab2e
Branch: refs/heads/SPOT-35_graphql_api
Commit: 7abbab2ed82b8782210561618af20e20563ce161
Parents: a2026e1
Author: LedaLima <le...@apache.org>
Authored: Thu Mar 9 17:04:28 2017 -0600
Committer: Diego Ortiz Huerta <di...@intel.com>
Committed: Wed Mar 15 11:49:48 2017 -0700
----------------------------------------------------------------------
.../Edge_Investigation_master.ipynb | 42 ++++++++++++--------
.../Edge_Investigation_master.ipynb | 23 +++++++----
2 files changed, 41 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/7abbab2e/spot-oa/oa/dns/ipynb_templates/Edge_Investigation_master.ipynb
----------------------------------------------------------------------
diff --git a/spot-oa/oa/dns/ipynb_templates/Edge_Investigation_master.ipynb b/spot-oa/oa/dns/ipynb_templates/Edge_Investigation_master.ipynb
index 88f047e..8cca233 100644
--- a/spot-oa/oa/dns/ipynb_templates/Edge_Investigation_master.ipynb
+++ b/spot-oa/oa/dns/ipynb_templates/Edge_Investigation_master.ipynb
@@ -23,8 +23,7 @@
"# getting date from the parent path. \n",
"path = os.getcwd().split(\"/\") \n",
"date = path[len(path)-1] \n",
- "dsource = path[len(path)-2] \n",
- "dpath = '/'.join(['data' if var == 'ipynb' else var for var in path]) + '/' "
+ "dsource = path[len(path)-2]"
]
},
{
@@ -91,11 +90,16 @@
"scoring_form = widgets.HBox(width='90%', height=250)\n",
"scoring_form.children = [client_box,query_box,actions_box]\n",
"\n",
+ "global score_values \n",
+ "\n",
+ "score_values = []\n",
"\n",
"def data_loader(): \n",
" us_ips = []\n",
" us_dns = []\n",
- "\n",
+ " scored = []\n",
+ " \n",
+ " global score_values\n",
" query=\"\"\"query($date:SpotDateType!) {\n",
" dns{\n",
" suspicious(date:$date){\n",
@@ -107,12 +111,17 @@
" variables={\n",
" 'date': datetime.datetime.strptime(date, '%Y%m%d').strftime('%Y-%m-%d')\n",
" }\n",
+ " \n",
+ " for item in score_values:\n",
+ " scored.append(item[0])\n",
+ " scored.append(item[1])\n",
+ " \n",
" response = GraphQLClient.request(query, variables)\n",
" \n",
" for row in response['data']['dns']['suspicious']: \n",
- " if row['clientIp'] not in us_ips: \n",
+ " if row['clientIp'] not in us_ips and row['clientIp'] not in scored: \n",
" us_ips.append(row['clientIp'])\n",
- " if row['dnsQuery'] not in us_dns:\n",
+ " if row['dnsQuery'] not in us_dns and row['dnsQuery'] not in scored:\n",
" us_dns.append(row['dnsQuery']) \n",
" \n",
" fill_list(client_select,us_ips)\n",
@@ -144,14 +153,12 @@
"import csv\n",
"import datetime\n",
"import subprocess \n",
- "global score_values\n",
- "score_values = []\n",
"\n",
"\n",
"def assign_score(b):\n",
- "\n",
+ " clear_output()\n",
" sev = int(rating_btn.selected_label) \n",
- " \n",
+ "\n",
" if quick_text.value: \n",
" ip = \"\"\n",
" dns = quick_text.value\n",
@@ -164,17 +171,20 @@
" dns = query_select.value if not \"- Select -\" in query_select.value else \"\"\n",
" score_values.append((ip,dns,sev))\n",
" clear_output()\n",
- " \n",
- " if ip != \"- Select -\":\n",
- " display(Javascript(\"$(\\\"option[data-value='\" + ip +\"']\\\").remove();\"))\n",
+ " \n",
+ " if client_select.value != \"- Select -\": \n",
+ " display(Javascript(\"$(\\\"option:nth-of-type(0)[data-value='\" + client_select.value +\"']\\\").remove();\"))\n",
" if quick_text.value:\n",
- " display(Javascript(\"$(\\\"option[data-value$='\" + quick_text.value +\"']\\\").remove();\"))\n",
- " elif dns != \"- Select -\":\n",
- " display(Javascript(\"$(\\\"option[data-value='\" + dns +\"']\\\").remove();\"))\n",
+ " display(Javascript(\"$(\\\"option:nth-of-type(1)[data-value$='\" + dns +\"']\\\").remove();\"))\n",
+ " elif query_select.value != \"- Select -\":\n",
+ " display(Javascript(\"$(\\\"option:nth-of-type(1)[data-value='\" + query_select.value +\"']\\\").remove();\"))\n",
"\n",
" client_select.value = \"- Select -\"\n",
" query_select.value = \"- Select -\"\n",
- " quick_text.value = \"\"\n",
+ " quick_text.value = \"\" \n",
+ " \n",
+ " data_loader() \n",
+ " print \"Click the 'Save' button when you're finished scoring\" \n",
"\n",
"\n",
"def save(b): \n",
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/7abbab2e/spot-oa/oa/proxy/ipynb_templates/Edge_Investigation_master.ipynb
----------------------------------------------------------------------
diff --git a/spot-oa/oa/proxy/ipynb_templates/Edge_Investigation_master.ipynb b/spot-oa/oa/proxy/ipynb_templates/Edge_Investigation_master.ipynb
index 8eedc53..1251960 100644
--- a/spot-oa/oa/proxy/ipynb_templates/Edge_Investigation_master.ipynb
+++ b/spot-oa/oa/proxy/ipynb_templates/Edge_Investigation_master.ipynb
@@ -15,8 +15,7 @@
},
"outputs": [],
"source": [
- "import urllib2\n",
- "import json\n",
+ "import urllib\n",
"import os\n",
"import datetime\n",
"import csv \n",
@@ -86,6 +85,7 @@
"\n",
"def data_loader(): \n",
" us_uris = []\n",
+ " global score_values\n",
" \n",
" response = GraphQLClient.request(\n",
" query=\"\"\"query($date:SpotDateType!) {\n",
@@ -100,9 +100,14 @@
" }\n",
" )\n",
" \n",
- " if not 'errors' in response:\n",
+ " scored = []\n",
+ " for item in score_values:\n",
+ " scored.append(item[0])\n",
+ " \n",
+ " if not 'errors' in response: \n",
" for row in response['data']['proxy']['suspicious']:\n",
- " us_uris.append(row['uri'])\n",
+ " if not row['uri'] in scored:\n",
+ " us_uris.append(row['uri'])\n",
" else:\n",
" print 'An error occured : '+ response['errors'][0]['message']\n",
" \n",
@@ -138,19 +143,21 @@
" uri = quick_text.value or uri_select.value\n",
" uri_sev = int(rating_btn.selected_label) if not \"- Select -\" in uri_select.value else \"\"\n",
" \n",
- " clear_output()\n",
- " #Gets input values\n",
+ " clear_output() \n",
+ " \n",
" global score_values\n",
" \n",
" score_values.append((uri, uri_sev))\n",
- " \n",
+ " \n",
" if uri_select.value != \"- Select -\":\n",
- " display(Javascript(\"$(\\\"option[data-value='\" + uri_select.value +\"']\\\").remove();\"))\n",
+ " display(Javascript(\"$(\\\"option[data-value='\" + urllib.quote_plus(uri_select.value) +\"']\\\").remove();\"))\n",
" \n",
" clear_output()\n",
" data_loader()\n",
" uri_select.value = \"- Select -\"\n",
" quick_text.value = \"\"\n",
+ " \n",
+ " print \"Click the 'Save' button when you're finished scoring\" \n",
"\n",
"\n",
"def save(b): \n",