From 40195dd999b72f0b3f825241f444ae9658024876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 15 Mar 2019 17:37:44 +0100 Subject: [PATCH] chg: Update IPASN View. --- Pipfile.lock | 2 +- website/web/__init__.py | 11 ++++++++++- website/web/templates/ipasn.html | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index ac983ba..dfe329b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -323,7 +323,7 @@ "pyipasnhistory": { "editable": true, "git": "https://github.com/D4-project/IPASN-History.git/", - "ref": "e846cd36fe1ed6b22f60890bba89f84e61b62e59", + "ref": "263fea1879267719093238d9bbd95b186b96948a", "subdirectory": "client" }, "pymispgalaxies": { diff --git a/website/web/__init__.py b/website/web/__init__.py index f252c43..97e89a1 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -169,7 +169,16 @@ def ipasn(): if not d or 'ip' not in d: return render_template('ipasn.html') ipasn = get_ipasn() - response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(), **d) + q = Querying() + response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(), + aggregate=True, **d) + for r in response['response']: + r['asn_description'] = [] + asn_descriptions = q.get_asn_descriptions(asn=r['asn'], all_descriptions=True) + for timestamp in sorted(asn_descriptions.keys()): + if r['first_seen'] <= timestamp <= r['last_seen']: + r['asn_description'].append(asn_descriptions[timestamp]) + return render_template('ipasn.html', ipasn_details=response['response'], **response['meta']) diff --git a/website/web/templates/ipasn.html b/website/web/templates/ipasn.html index 1bc6aa6..ee506af 100644 --- a/website/web/templates/ipasn.html +++ b/website/web/templates/ipasn.html @@ -25,15 +25,23 @@ {% if ipasn_details %} - + + + - {% for date, details in ipasn_details.items() %} + {% for entry in ipasn_details %} - - - + + + + + {% endfor %}
DateFirst SeenLast Seen ASNASN Description Prefix
{{ date }}{{ details['asn'] }}{{ details['prefix'] }}{{ entry['first_seen'] }}{{ entry['last_seen'] }}{{ entry['asn'] }} + {% for asn_description in entry['asn_descriptions'] %} + {{ asn_description }}
+ {% endfor %} +
{{ entry['prefix'] }}