new: added basic auth, polling

pull/7/head
Hannah Ward 2017-03-30 16:26:46 +01:00
parent 5481ba4902
commit c4d1463577
No known key found for this signature in database
GPG Key ID: 6F3BAD60DE190290
2 changed files with 50 additions and 2 deletions

View File

@ -13,13 +13,16 @@ echo "FRIENDLY SERVER NAME:"
read SNAME read SNAME
cat >> $CONFIGDIR/servers.yml << EOF cat >> $CONFIGDIR/servers.yml << EOF
- name: '$SNAME': - name: '$SNAME'
host: localhost host: localhost
port: 9000 port: 9000
discovery_path: discovery_path:
use_https: False use_https: False
taxii_version: 1.1 taxii_version: '1.1'
headers: headers:
auth:
username:
password:
EOF EOF
echo "New server added to $CONFIGDIR/servers.yml - please go change the settings" echo "New server added to $CONFIGDIR/servers.yml - please go change the settings"

45
scripts/run-taxii-poll.py Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env python3
from cabby import create_client
from pyaml import yaml
import argparse
import os
import logging
import sys
parser = argparse.ArgumentParser(description='Run MISP taxii pull.')
parser.add_argument('-c', "--configdir", default="~/.misptaxii", help='Config directory')
parser.add_argument("-v", "--verbose", action="store_true", help="More verbose logging")
parser.add_argument("-s", "--stdout", action="store_true", help="Log to STDOUT")
args = parser.parse_args()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG if args.verbose else logging.INFO)
if args.stdout:
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch = logging.StreamHandler(sys.stdout)
ch.setFormatter(formatter)
log.addHandler(ch)
configFile = "{}/servers.yml".format(os.path.expanduser(args.configdir))
log.debug("Opening config file %s", configFile)
with open(configFile, "r") as f:
config = yaml.load(f.read())
log.debug("Config read %s", config)
for server in config:
log.info("== %s ==", server["name"])
cli = create_client(host = server["host"],
port = server["port"],
discovery_path = server["discovery_path"],
use_https = server["use_https"],
version = server["taxii_version"],
headers = server["headers"])
cli.username = server["auth"]["username"]
cli.password = server["auth"]["password"]
log.info(list(cli.poll("collection")))