Skip to content

Commit

Permalink
Merge pull request #117 from thisismyrobot/master
Browse files Browse the repository at this point in the history
2.13
  • Loading branch information
thisismyrobot committed Sep 15, 2019
2 parents 4d19550 + ba5afba commit 40696a8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IMPORTANT: Before requesting a change please check out https://github.com/thisismyrobot/dnstwister#current-state-of-dnstwisterplease-read-before-suggesting-changes

2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IMPORTANT: Before requesting a change please check out https://github.com/thisismyrobot/dnstwister#current-state-of-dnstwisterplease-read-before-suggesting-changes

33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Current state of dnstwister/please read before suggesting changes

__dnstwister__ was created four years ago, on the Google App Engine PaaS which
(from memory) only supported Python 2.x at the time.

Since then __dnstwister__ has moved to Heroku and the world has thoroughly
moved to Python 3. On [January 1 2020](https://www.python.org/doc/sunset-python-2/)
Python 2 will no longer be supported by the Python Software Foundation.

__dnstwister__ has generally kept up with the releases of Python 2.x but it is
well and truly time to move the codebase to Python 3.

As such, until January 2020 I will __not__ be performing any feature
development in __dnstwister__, the only changes made will be security patches
and fixes to functionality-critical bugs. This will give me the stable
platform needed to cut over the codebase and ensure it can be rigorously
tested before going live very early in 2020.

Upon that release going live __dnstwister__ will no longer by able to be ran
in Python 2 but I will leave a link to the last Python 2 commit on this README
for a reasonable period of time.

I will also take the opportunity at that point to more clearly differentiate
__dnstwister__ the Flask web application you can download here and the
[dnstwister.report](https://dnstwister.report) service (that uses this
codebase as its core) but also relies on other FaaS and PaaS offerings
including CloudFlare Workers. This split will allow this codebase and
[dnstwister.report](https://dnstwister.report) independently evolve to suit
the needs of their user bases, whilst still sharing relevant improvements.

# dnstwister

A Heroku-hosted version of the very excellent
Expand All @@ -23,7 +53,7 @@ RESTful API.
And it's 100% free.

__dnstwister__ is hosted at
[https://dnstwister.report](https://dnstwister.report).
[dnstwister.report](https://dnstwister.report).

## dnstwist module

Expand All @@ -44,6 +74,7 @@ dnstwist in my project.
* [@elceef](https://github.com/elceef) (dnstwist itself)
* [@peterwallhead](http://github.com/peterwallhead) (mobile UI assistance)
* [@prashant-shahi](https://github.com/prashant-shahi) (docker configuration)
* [@wesinator](https://github.com/wesinator) (file export improvements)

## A note on running dnstwister yourself

Expand Down
8 changes: 6 additions & 2 deletions dnstwister/views/www/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def json_render(domain):
"""
reports = dict([tools.analyse(domain)])

json_filename = 'dnstwister_report_{}.json'.format(domain.encode('idna'))

def generate():
"""Streaming download generator."""
indent_size = 4
Expand Down Expand Up @@ -77,7 +79,7 @@ def generate():
return flask.Response(
generate(),
headers={
'Content-Disposition': 'attachment; filename=dnstwister_report.json'
'Content-Disposition': 'attachment; filename=' + json_filename
},
content_type='application/json'
)
Expand All @@ -88,6 +90,8 @@ def csv_render(domain):
headers = ('Domain', 'Type', 'Tweak', 'IP', 'Error')
reports = dict([tools.analyse(domain)])

csv_filename = 'dnstwister_report_{}.csv'.format(domain.encode('idna'))

def generate():
"""Streaming download generator."""
yield ','.join(headers) + '\n'
Expand All @@ -108,7 +112,7 @@ def generate():
return flask.Response(
generate(),
headers={
'Content-Disposition': 'attachment; filename=dnstwister_report.csv'
'Content-Disposition': 'attachment; filename=' + csv_filename
},
mimetype='text/csv',
)
Expand Down
27 changes: 26 additions & 1 deletion tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def test_csv_export(webapp, monkeypatch):

response = webapp.get('/search/{}/csv'.format(hexdomain))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_a.com.csv'

assert response.body.strip() == textwrap.dedent("""
Domain,Type,Tweak,IP,Error
a.com,Original*,a.com,999.999.999.999,False
Expand Down Expand Up @@ -79,6 +81,8 @@ def test_json_export(webapp, monkeypatch):

response = webapp.get('/search/{}/json'.format(path))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_a.com.json'

assert response.json == {
u'a.com': {
u'fuzzy_domains': [
Expand Down Expand Up @@ -119,6 +123,8 @@ def test_json_export_one_domain(webapp, monkeypatch):

response = webapp.get('/search/{}/json'.format(path))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_a.com.json'

assert response.json == {
u'a.com': {
u'fuzzy_domains': [
Expand Down Expand Up @@ -159,6 +165,8 @@ def test_json_export_no_fuzzy(webapp, monkeypatch):

response = webapp.get('/search/{}/json'.format(path))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_a.com.json'

assert response.json == {
u'a.com': {
u'fuzzy_domains': [
Expand All @@ -176,7 +184,6 @@ def test_json_export_no_fuzzy(webapp, monkeypatch):
}



def test_json_export_formatting(webapp, monkeypatch):
"""Test JSON export looks nice :)"""
monkeypatch.setattr(
Expand All @@ -191,6 +198,8 @@ def test_json_export_formatting(webapp, monkeypatch):

response = webapp.get('/search/{}/json'.format(path))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_a.com.json'

assert response.body.strip() == textwrap.dedent("""
{
"a.com": {
Expand Down Expand Up @@ -238,6 +247,18 @@ def test_links_on_report(webapp):
assert '/search/{}/json'.format(hexdomain) in page_html


def test_links_on_search(webapp, monkeypatch):
"""Make sure the export links are working on the newer page."""
monkeypatch.setenv('feature.async_search', 'true')

domain = 'a.com'
hexdomain = binascii.hexlify(domain)
page_html = webapp.get('/search?ed={}'.format(hexdomain)).body

assert '/search/{}/csv'.format(hexdomain) in page_html
assert '/search/{}/json'.format(hexdomain) in page_html


def test_json_export_unicode_domain(webapp, monkeypatch):
"""Test JSON export when no reports"""
monkeypatch.setattr(
Expand All @@ -252,6 +273,8 @@ def test_json_export_unicode_domain(webapp, monkeypatch):

response = webapp.get('/search/{}/json'.format(hexdomain))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_xn--a-sfa.com.json'

assert response.json == {
u'xn--a-sfa.com': {
u'fuzzy_domains': [
Expand Down Expand Up @@ -289,6 +312,8 @@ def test_unicode_csv_export(webapp, monkeypatch):

response = webapp.get('/search/{}/csv'.format(hexdomain))

assert response.headers['Content-Disposition'] == 'attachment; filename=dnstwister_report_xn--a-sfa.com.csv'

assert response.body.strip() == textwrap.dedent("""
Domain,Type,Tweak,IP,Error
xn--a-sfa.com,Original*,xn--a-sfa.com,999.999.999.999,False
Expand Down

0 comments on commit 40696a8

Please sign in to comment.