Skip to content

Commit

Permalink
Merge pull request #75 from dhs-ncats/improvement/automatic_deployment
Browse files Browse the repository at this point in the history
Automatic deployment to Docker Hub via TravisCI
  • Loading branch information
jsf9k authored Apr 6, 2018
2 parents da98d8c + 8be7437 commit aead20c
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 33 deletions.
32 changes: 23 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import README.md
import LICENSE.md
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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:

Expand All @@ -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:
Expand All @@ -36,8 +41,7 @@ Then run the CLI:
python scripts/trustymail [options] example.com
```


#### Usage and examples
### Usage and examples ###

```bash
trustymail [options] INPUT
Expand All @@ -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.
Expand Down Expand Up @@ -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.<domain>), 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
Expand All @@ -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.
Expand All @@ -125,15 +129,15 @@ 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,
per RFC 4408.
* `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
Expand Down Expand Up @@ -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.
Expand All @@ -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).
Expand Down
39 changes: 39 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-e .[test]
-e .[dev]
28 changes: 19 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
],
},

Expand Down
5 changes: 5 additions & 0 deletions tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

version=$(./bump_version.sh show)

git tag v$version && git push --tags
4 changes: 4 additions & 0 deletions travis_scripts/build_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

version=$(./bump_version.sh show)
docker build -t ${IMAGE_NAME}:$version .
5 changes: 5 additions & 0 deletions travis_scripts/deploy_to_docker_hub.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion trustymail/__init__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aead20c

Please # to comment.