Skip to content

Commit

Permalink
Merge branch 'master' into add-ca-cert-in-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed Oct 9, 2019
2 parents 48f518d + 2738c68 commit e01ff69
Show file tree
Hide file tree
Showing 19 changed files with 442 additions and 201 deletions.
24 changes: 15 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
branches:
- master

language: python
dist: xenial
python:
- "2.7"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- pip install -r requirements-dev.txt
- pip install coveralls
# command to run tests, e.g. python setup.py test
script:
PYTHONPATH=.:$PYTHONPATH py.test --cov ./cabby
# coverage run --source=opentaxii setup.py test
- "3.5"
- "3.6"
- "3.7"

install:
- pip install coveralls -r requirements-dev.txt

script:
- py.test --cov cabby

after_success:
coveralls
- coveralls
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
=========

0.1.20 (2018-03-29)
-------------------

* Only include relevant files in release packages.

0.1.19 (2018-03-29)
-------------------

* Enable client key passphrase for JWT token authentication request
(`pr#50 <https://github.com/EclecticIQ/cabby/pull/50>`_)

0.1.18 (2017-06-19)
-------------------
* Dependencies upgraded (`changes <https://github.com/EclecticIQ/cabby/commit/be491ccf457b8b989982a8d49634e905d04bf31b>`_).
Expand Down
74 changes: 12 additions & 62 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
# Set the base image to Python
FROM alpine:3.4
MAINTAINER EclecticIQ <[email protected]>

# Volume for possible input
VOLUME [ "/input" ]

# Create the working dir and set the working directory
WORKDIR /

# Setup Python
RUN apk add --no-cache -U \
ca-certificates \
build-base \
libxml2 \
libxml2-dev \
libxslt \
libxslt-dev \
make \
python-dev \
py-pip \
python \
&& pip install --upgrade pip setuptools


# Setup Requirements
COPY ./ /cabby
RUN pip install -r /cabby/requirements.txt \
&& cd /cabby \
&& python setup.py install

# Cleanup
RUN apk del build-base \
libxml2-dev \
libxslt-dev \
python-dev \
build-base \
&& rm -rf /var/cache/apk/* \
&& rm -r /root/.cache \
&& rm -f requirements.txt \
&& rm -rf /cabby

RUN { echo '#!/bin/sh';\
echo 'echo "';\
echo ' Commands to be run:';\
echo ' taxii-discovery ';\
echo ' taxii-poll';\
echo ' taxii-collections';\
echo ' taxii-push ';\
echo ' taxii-subscription';\
echo ' taxii-proxy';\
echo '';\
echo 'e.g. docker run -ti eclecticiq/cabby taxii-discovery --path https://test.taxiistand.com/read-write/services/discovery';\
echo '';\
echo 'More information available at: http://cabby.readthedocs.org';\
echo 'Or you can choose to drop back into a shell by providing: bash as the command:';\
echo '';\
echo 'docker run -ti cabby bash"'; } > /help.sh && chmod 750 /help.sh

# Give help, unless command is given
CMD [ "/help.sh" ]

FROM python:3-slim-stretch
LABEL maintainer="EclecticIQ <[email protected]>"
RUN python3 -m venv --system-site-packages /venv
ENV PATH=/venv/bin:$PATH

COPY ./requirements.txt ./requirements-dev.txt /cabby/
RUN pip install -r /cabby/requirements-dev.txt
COPY . /cabby
RUN pip install -e /cabby

RUN sh -c "cat /cabby/docker-help.sh >> /root/.bashrc"
CMD ["/cabby/docker-help.sh"]
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include LICENSE.rst
include CHANGES.rst
include README.rst
include requirements.txt
recursive-include docs *
recursive-include docs *.rst
global-exclude *.pyc
31 changes: 13 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,36 @@ cabby

Python TAXII client implementation from `EclecticIQ <https://www.eclecticiq.com>`_.

:Source: https://github.com/EclecticIQ/cabby
:Source: https://github.com/eclecticiq/cabby
:Documentation: http://cabby.readthedocs.org
:Information: https://www.eclecticiq.com
:Download: https://pypi.python.org/pypi/cabby/

|travis badge| |landscape.io badge| |coveralls.io badge| |docs badge| |requirements badge|
|travis badge| |coveralls.io badge| |docs badge| |requirements badge|

.. |travis badge| image:: https://travis-ci.org/EclecticIQ/cabby.svg?branch=master
:target: https://travis-ci.org/EclecticIQ/cabby
.. |travis badge| image:: https://travis-ci.org/eclecticiq/cabby.svg?branch=master
:target: https://travis-ci.org/eclecticiq/cabby
:alt: Build Status
.. |landscape.io badge| image:: https://landscape.io/github/EclecticIQ/cabby/master/landscape.svg?style=flat
:target: https://landscape.io/github/EclecticIQ/cabby/master
:alt: Code Health
.. |coveralls.io badge| image:: https://coveralls.io/repos/EclecticIQ/cabby/badge.svg
:target: https://coveralls.io/r/EclecticIQ/cabby
.. |coveralls.io badge| image:: https://coveralls.io/repos/eclecticiq/cabby/badge.svg
:target: https://coveralls.io/r/eclecticiq/cabby
:alt: Coverage Status
.. |docs badge| image:: https://readthedocs.org/projects/cabby/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://readthedocs.org/projects/cabby/
.. |requirements badge| image:: https://requires.io/github/EclecticIQ/cabby/requirements.svg?branch=master
:target: https://requires.io/github/EclecticIQ/cabby/requirements/?branch=master
:alt: Requirements Status
:alt: Documentation Status
:scale: 100%
:target: https://readthedocs.org/projects/cabby/
.. |requirements badge| image:: https://requires.io/github/eclecticiq/cabby/requirements.svg?branch=master
:target: https://requires.io/github/eclecticiq/cabby/requirements/?branch=master
:alt: Requirements Status

A simple Python library for interacting with TAXII servers.


Docker
--------

From version 0.1.13, the docker image is based on 'Alpine' linux. This means the size of the Image was reduced from 311MB to 74MB

To run cabby using docker, execute the following:

docker run --rm=true eclecticiq/cabby:latest taxii-discovery --path https://test.taxiistand.com/read-only/services/discovery
docker run --rm eclecticiq/cabby taxii-discovery --path https://test.taxiistand.com/read-only/services/discovery

Feedback
--------
Expand Down
2 changes: 1 addition & 1 deletion cabby/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
This module defines the package version for use in __init__.py and setup.py.
"""

__version__ = '0.1.19a1'
__version__ = '0.1.20'
33 changes: 9 additions & 24 deletions cabby/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def prepare_generic_session(self):
password=self.password if not self.jwt_url else None,
cert_file=self.cert_file,
key_file=self.key_file,
verify_ssl=(self.ca_cert or self.verify_ssl))
key_password=self.key_password,
ca_cert=self.ca_cert,
verify_ssl=self.verify_ssl)

def _execute_request(self, request, uri=None, service_type=None):
'''
Expand All @@ -161,7 +163,6 @@ def _execute_request(self, request, uri=None, service_type=None):
A service is defined by ``uri`` parameter or is chosen from pre-cached
services by ``service_type``.
'''

if not uri and not service_type:
raise NoURIProvidedError('URI or service_type needed')
elif not uri:
Expand All @@ -181,28 +182,12 @@ def _execute_request(self, request, uri=None, service_type=None):
self.refresh_jwt_token(session=session)
session = dispatcher.set_jwt_token(session, self.jwt_token)

if self.key_password:
# If key_password is provided
message = dispatcher.send_taxii_request(
session,
self._prepare_url(uri),
request,
taxii_binding=self.taxii_binding,
# Details in case key_password is provided
tls_details={
'cert_file': self.cert_file,
'key_file': self.key_file,
'key_password': self.key_password,
'ca_cert': self.ca_cert
},
timeout=self.timeout)
else:
message = dispatcher.send_taxii_request(
session,
self._prepare_url(uri),
request,
taxii_binding=self.taxii_binding,
timeout=self.timeout)
message = dispatcher.send_taxii_request(
session,
self._prepare_url(uri),
request,
taxii_binding=self.taxii_binding,
timeout=self.timeout)

return message

Expand Down
Loading

0 comments on commit e01ff69

Please sign in to comment.