diff --git a/.travis.yml b/.travis.yml index 35793f6..454d0a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,15 @@ language: python -sudo: false +sudo: required + +services: + - docker + +env: + global: + - IMAGE_NAME=dhsncats/trustymail + - DOCKER_USER=jsf9k + - secure: "IAbtmubLq2hL71aollQEfoV+t9Zbqn4rNVqi5YNerqxvXr6WiDzwmYUujOCnQiHli8xkIU0J8OSPX0aA4cOTxPGiZeNguGuVWmR2ZCB8SMyjbKJOEIpLZv/jG1Be6dVXiJwKwQM3yX4pqPfLIuYkE6S1GAodudPzcJ8xM/h1qzJijknJEqsCJQw43zSHZ/epYulgWcmnCAmaoehZTCjVcW4l8iyVHSNfgO7gu5iWC9y4AIIX96E9TZkSDeud1yqUcORMwfdOl2pHhDh3KnF8HZSOCetTHP7JacLUMJiiCpKN34Xn9RQgjbVKOrF/rcC8WEDrWKn14SFfgUP0dl6lCr6P9HE4aHKvrH/nCyflFOANbEKMywE8DzNA3zd7MC0HQkyb40LAiBSbTD58myUsc+WlmaZyvpJ7akukbmVjVPQWNvs1laz/bqyLdPh4WMqgOTbP7BrgDeIrCVedwdvhqq9KEaoak8RBs/Wb8LisI6j+vAY/HKlVnuIXRL0RNGTko96kBluEpAsWDjls39Hmu5hl1glbqCWDW9+dE0/Zx4MuSt4OVAywMW+lzxA16SdqDLCZqGv00vnPpxuBAvEEQbVtsmQ6lR+fwTYKFEDZM7axRwBlLzIDEzSoz4K0fSq3EuU4mkoVZKcHGnuHuRqaNhce0zzZx3lHdNTm7oa7b0U=" python: - '3.4' @@ -14,17 +23,22 @@ install: script: - pytest --cov=trustymail - flake8 . + # - bash travis_scripts/build_docker_image.sh after_success: - coveralls deploy: - provider: pypi - user: hmft - password: - secure: fhEGmCpVdBm/ae4RZXZL7hyiWzx8huFEWJe4YIF/2Qip0BgDlMDfQPoJ/8/DnsuG/+2GC3EEc0ZIl14RwBJ+bn0O+nfcNDsnKTK1ZNK5gtnd+AodHpROT5GUDxl6vb43BShDZm1nc7GaSI0udnpKKB/9xxGc6I1vF6O93VOSziGE7T2BKD1XeyiSHDHXfwT40KIUV8a8yEbjJYvAiVMLKsgxLA/m98Q2kzjqUoCwyAEsLMPaCHKo32DJNLULY+jJ6xTmXqtKRA/w+J5na1TY57RmXlp5kXs/1U44je4Brok0bKOghQfCYW23uB8q1M1GlduexwG6mgWvwJDNp4HKzKswrYG4VUd4SF07Bs7BFZbIuJONYN9xmD/obWQWwNmIoOWa89EOov6/Rp+d4yd15fm+IyO6vnkDBu6HmlyzJDVtIfXWsMnHKkCQtLb35g7CoRKOB6cnp9uvtixjity1caFFL6FnyRMaa2rXpD93Hgs65upAawMkuOROtYlkehBA/Pu2KglllPHpa/kXV6rw+YUKRpm/7sYc1ZykMwGFK2ZF0Rk1de49zrKP4fj1qj1jzD3nFalFi1JExRYwSbDPSVF/Q/ouSKzZ2HhvEPYXTW5E7YQhprDoNT889vNg1oSeTOh7Plk+L0Ukf+YFKMAZMxHn3W1QXnFV+dnCjINpLUY= - on: - tags: true - branch: master + - provider: pypi + user: jsf9k + password: + secure: "t3aZa5VibM+2rlVpPPrbFZ1A601V/IF0fjF6r6D1I8D19cgP3a5bGIuCQ/8Wd5X4JxQ3/5/kGbKiY2tNBPfu+X0Vo+5qgaDNpjumPsa/rsh2cTj1oMigp4mb60rDjChw35Pgl7p2J2u9FSA0zsMh13plgfO2bBYvwSVMNjk+MroUHAGw5af+TEWElJvmr3NvvHdTRWao1d4cSkiVesJx9xr90RBKKUgOa+rS9t2V5z/Q5i9enXK3BFzas3Kfayoset4xcE6azanuiqcJUEoAKhBBh2LrvckKg3oRY6Q7t/JXCgWPsYrAIe0KwfHAopBFoNoZRf2M35cg10lj7IHS2IThY1moaisdxWIOeWQPblTeDAUbXx6hzCCxPhWCVhUowpPU2/Kqu9vSVqPymcSy2+q7MOeEda0hobMl4qvQT6apzeIWoRY9YO45aFWtep2dz7NvWDV566K/UpyKrfdvVQNbc+DxBJ087Tm6SbplEYpz1SXHz9oYFLyp/19nEG/GkGYPWmRHawRN731lW2/1DRNieesf4aYpN3ykNOCWJk0ahFMlkiK4Q9EWxMzxJb3f73r+7yak0/g8t4c1Ga8uI6coKfRD84Lsld91LvyDi6RlXuumC9UtWHH2m6f+MPx7kcPyY6uTsJJBfjHyrZJGgMpm2thjdO+FObyNPEn2N44=" distributions: sdist bdist_wheel - repo: dhs-ncats/trustymail + on: + tags: true + python: '3.6' + # - provider: script + # script: bash travis_scripts/deploy_to_docker_hub.sh + # on: + # tags: true + # python: '3.6' diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..4772034 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +import README.md +import LICENSE.md diff --git a/README.md b/README.md index 343272a..9fa0320 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Trustworthy Mail +# Trustworthy Mail # [![Build Status](https://travis-ci.org/dhs-ncats/trustymail.svg?branch=master)](https://travis-ci.org/dhs-ncats/trustymail) [![Coverage Status](https://coveralls.io/repos/github/dhs-ncats/trustymail/badge.svg?branch=master)](https://coveralls.io/github/dhs-ncats/trustymail?branch=master) @@ -7,7 +7,12 @@ domain's DNS. It also checks the mail servers listed in a domain's MX records for STARTTLS support. It saves its results to CSV or JSON. -#### Installed as a module +## Getting Started ## + +`trustymail` can be installed as a module or run directly from the +repository. + +### Installed as a module ### `trustymail` can be installed directly via pip: @@ -21,7 +26,7 @@ It can then be run directly: trustymail [options] example.com ``` -#### Running directly +### Running directly ### To run the tool locally from the repository, without installing, first install the requirements: @@ -36,8 +41,7 @@ Then run the CLI: python scripts/trustymail [options] example.com ``` - -#### Usage and examples +### Usage and examples ### ```bash trustymail [options] INPUT @@ -50,7 +54,7 @@ trustymail agencies.csv Note: if INPUT ends with `.csv`, domains will be read from CSV. CSV output will always be written to disk, defaulting to `results.csv`. -#### Options +#### Options #### ```bash -h --help Show this message. @@ -92,14 +96,14 @@ output will always be written to disk, defaulting to `results.csv`. instance, where the local filesystem is read-only. ``` -## What's Checked? +## What's Checked? ## For a given domain, MX records, SPF records (TXT), DMARC (TXT, at \_dmarc.), and support for STARTTLS are checked. The following values are returned in `results.csv`: -#### Domain and redirect info +### Domain and redirect info ### * `Domain` - The domain you're scanning! * `Base Domain` - The base domain of `Domain`. For example, for a @@ -109,7 +113,7 @@ The following values are returned in `results.csv`: List](https://publicsuffix.org) when calculating the base domain. * `Live` - The domain is actually published in the DNS. -#### Mail sending +### Mail sending ### * `MX Record` - If an MX record was found that contains at least a single mail server. @@ -125,7 +129,7 @@ The following values are returned in `results.csv`: * `Domain Supports STARTTLS Results` - A list of the mail server and port combinations that support STARTTLS. -#### SPF +### SPF ### * `SPF Record` - Whether or not a SPF record was found. * `Valid SPF` - Whether the SPF record found is syntactically correct, @@ -133,7 +137,7 @@ The following values are returned in `results.csv`: * `SPF Results` - The textual representation of any SPF record found for the domain. -#### DMARC +### DMARC ### * `DMARC Record` - True/False whether or not a DMARC record was found. * `Valid DMARC` - Whether the DMARC record found is syntactically @@ -163,7 +167,7 @@ The following values are returned in `results.csv`: `DMARC Results` included `ruf` URIs that tell recipients where to send DMARC forensic reports . -#### Etc. +### Etc. ### * `Syntax Errors` - A list of syntax errors that were encountered when analyzing SPF records. @@ -172,7 +176,7 @@ The following values are returned in `results.csv`: `trustymail` reached its conclusions, and are indispensible for bug reports. -## Public domain +## Public domain ## This project is in the worldwide [public domain](LICENSE.md). diff --git a/bump_version.sh b/bump_version.sh new file mode 100755 index 0000000..8a35f05 --- /dev/null +++ b/bump_version.sh @@ -0,0 +1,39 @@ +#/usr/bin/env bash + +# bump_version.sh (show|major|minor|patch|prerelease|build) + +VERSION_FILE=trustymail/__init__.py + +HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)" + +old_version=$(sed -n "s/^__version__ = '\(.*\)'$/\1/p" $VERSION_FILE) + +if [[ $# -ne 1 ]] +then + echo $HELP_INFORMATION +else + case $1 in + major|minor|patch|prerelease|build) + new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))") + echo Changing version from $old_version to $new_version + sed -i "s/$old_version/$new_version/" $VERSION_FILE + git add $VERSION_FILE + git commit -m"Bumped version from $old_version to $new_version" + git push + ;; + finalize) + new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))") + echo Changing version from $old_version to $new_version + sed -i "s/$old_version/$new_version/" $VERSION_FILE + git add $VERSION_FILE + git commit -m"Bumped version from $old_version to $new_version" + git push + ;; + show) + echo $old_version + ;; + *) + echo $HELP_INFORMATION + ;; + esac +fi diff --git a/requirements.txt b/requirements.txt index a4af5aa..aefbcb6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ --e .[test] +-e .[dev] diff --git a/setup.py b/setup.py index 2bdac3f..a910ceb 100644 --- a/setup.py +++ b/setup.py @@ -9,10 +9,18 @@ from setuptools import setup from trustymail import __version__ + +def readme(): + with open('README.md') as f: + return f.read() + + setup( name='trustymail', version=__version__, description='Scan domains and return data based on trustworthy email best practices', + long_description=readme(), + long_description_content_type='text/markdown', # NCATS "homepage" url='https://www.dhs.gov/cyber-incident-response', @@ -55,19 +63,21 @@ packages=['trustymail'], install_requires=[ - 'requests', - 'docopt', - 'publicsuffix', - 'dnspython', - 'py3dns', + 'dnspython>=1.15.0', + 'docopt>=0.6.2', + 'publicsuffix>=1.1.0', + 'py3dns>=3.1.0', 'pyspf==2.0.11', + 'requests>=2.18.4' ], extras_require={ - # 'dev': ['check-manifest'], - 'test': [ - 'tox', - 'pytest' + 'dev': [ + 'check-manifest>=0.36', + 'pytest>=3.5.0', + 'semver>=2.7.9', + 'tox>=3.0.0', + 'wheel>=0.31.0' ], }, diff --git a/tag.sh b/tag.sh new file mode 100755 index 0000000..f72316d --- /dev/null +++ b/tag.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +version=$(./bump_version.sh show) + +git tag v$version && git push --tags diff --git a/travis_scripts/build_docker_image.sh b/travis_scripts/build_docker_image.sh new file mode 100644 index 0000000..13729ee --- /dev/null +++ b/travis_scripts/build_docker_image.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +version=$(./bump_version.sh show) +docker build -t ${IMAGE_NAME}:$version . diff --git a/travis_scripts/deploy_to_docker_hub.sh b/travis_scripts/deploy_to_docker_hub.sh new file mode 100644 index 0000000..1cb991e --- /dev/null +++ b/travis_scripts/deploy_to_docker_hub.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo "$DOCKER_PW" | docker login -u "$DOCKER_USER" --password-stdin +version=$(./bump_version.sh show) +docker push "$IMAGE_NAME":$version diff --git a/trustymail/__init__.py b/trustymail/__init__.py index 852e0a4..40b82aa 100644 --- a/trustymail/__init__.py +++ b/trustymail/__init__.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals, absolute_import, print_function -__version__ = '0.5.4-dev' +__version__ = '0.5.5' PublicSuffixListFilename = 'public_suffix_list.dat' PublicSuffixListReadOnly = False