Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
Updating master

See merge request faradaysec/cloud/faraday_agent_dispatcher!18
  • Loading branch information
EricHorvat committed Dec 17, 2019
2 parents 2cbf1cf + 854a283 commit d12de7c
Show file tree
Hide file tree
Showing 26 changed files with 1,025 additions and 282 deletions.
13 changes: 8 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ variables:
FARADAY_PASSWORD: custom_pass
FARADAY_EMAIL: [email protected]
FARADAY_REF: white/dev
EXECUTOR_DIR: ./basic_executor.py

cache:
paths:
Expand Down Expand Up @@ -37,15 +38,17 @@ unit_tests:
- pip install pytest pytest-cov pytest-aiohttp
- python setup.py install
- mkdir run_from
- cd run_from && pytest ../tests/unittests --capture=sys -v --cov=../faraday_agent_dispatcher --color=yes --disable-warnings
- cd run_from && mkdir logs && pytest ../tests/unittests --capture=sys -v --cov=../faraday_agent_dispatcher --color=yes --disable-warnings
artifacts:
when: on_failure
paths:
- dist/*
when: on_failure
paths:
- dist/*
- run_from/logs/*
expire_in: 7 days
except:
variables:
- $INTEGRATION
- $CI_COMMIT_REF_NAME =~ /^.*ci.*$/
- $CI_COMMIT_REF_NAME =~ /^.*ci-int.*$/

integration_faraday:
stage: post_testing
Expand Down
24 changes: 12 additions & 12 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Types of Contributions
Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/EricHorvat/dummy_faraday_agent/issues.
Report bugs at https://github.com/faradaysec/faraday_agent_dispatcher/issues.

If you are reporting a bug, please include:

Expand All @@ -38,14 +38,14 @@ and "help wanted" is open to whoever wants to implement it.
Write Documentation
~~~~~~~~~~~~~~~~~~~

dummy_faraday_agent could always use more documentation, whether as part of the
official dummy_faraday_agent docs, in docstrings, or even on the web in blog posts,
faraday_agent_dispatcher could always use more documentation, whether as part of the
official faraday_agent_dispatcher docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/EricHorvat/dummy_faraday_agent/issues.
The best way to send feedback is to file an issue at https://github.com/faraday/faraday_agent_dispatcher/issues.

If you are proposing a feature:

Expand All @@ -57,17 +57,17 @@ If you are proposing a feature:
Get Started!
------------

Ready to contribute? Here's how to set up `dummy_faraday_agent` for local development.
Ready to contribute? Here's how to set up `faraday_agent_dispatcher` for local development.

1. Fork the `dummy_faraday_agent` repo on GitHub.
1. Fork the `faraday_agent_dispatcher` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/dummy_faraday_agent.git
$ git clone [email protected]:your_name_here/faraday_agent_dispatcher.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv dummy_faraday_agent
$ cd dummy_faraday_agent/
$ mkvirtualenv faraday_agent_dispatcher
$ cd faraday_agent_dispatcher/
$ python setup.py develop

4. Create a branch for local development::
Expand All @@ -79,7 +79,7 @@ Ready to contribute? Here's how to set up `dummy_faraday_agent` for local develo
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::

$ flake8 dummy_faraday_agent tests
$ flake8 faraday_agent_dispatcher tests
$ python setup.py test or py.test
$ tox

Expand All @@ -103,15 +103,15 @@ Before you submit a pull request, check that it meets these guidelines:
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check
https://travis-ci.org/EricHorvat/dummy_faraday_agent/pull_requests
https://travis-ci.org/faradaysec/faraday_agent_dispatcher/pull_requests
and make sure that the tests pass for all supported Python versions.

Tips
----

To run a subset of tests::

$ py.test tests.test_dummy_faraday_agent
$ py.test tests.faraday_agent_dispatcher


Deploying
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache

lint: ## check style with flake8
flake8 dummy_faraday_agent tests
flake8 faraday_agent_dispatcher tests

test: ## run tests quickly with the default Python
py.test
Expand All @@ -60,15 +60,15 @@ test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source dummy_faraday_agent -m pytest
coverage run --source faraday_agent_dispatcher -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/dummy_faraday_agent.rst
rm -f docs/faraday_agent_dispatcher.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ dummy_faraday_agent
sphinx-apidoc -o docs/ faraday_agent_dispatcher
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
Expand Down
6 changes: 4 additions & 2 deletions contrib/nmap.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env python
import os
import subprocess

"""Yo need to clone and install faraday plugins"""
from faraday_plugins.plugins.repo.nmap.plugin import NmapPlugin

cmd = [
"nmap",
"-p80,443",
"190.210.92.77",
"-p{}".format(os.environ.get('EXECUTOR_CONFIG_PORT_LIST')),
os.environ.get('EXECUTOR_CONFIG_TARGET'),
"-oX",
"-",
]


results = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
nmap = NmapPlugin()
nmap.parseOutputString(results.stdout)
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = dummy_faraday_agent
SPHINXPROJ = faraday_agent_dispatcher
SOURCEDIR = .
BUILDDIR = _build

Expand Down
20 changes: 10 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# faraday_dummy_agent documentation build configuration file, created by
# faraday_agent_dispatcher documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
Expand Down Expand Up @@ -47,7 +47,7 @@
master_doc = 'index'

# General information about the project.
project = u'faraday_dummy_agent'
project = u'faraday_agent_dispatcher'
copyright = u"2019, Eric Horvat"
author = u"Eric Horvat"

Expand Down Expand Up @@ -101,7 +101,7 @@
# -- Options for HTMLHelp output ---------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'dummy_faraday_agentdoc'
htmlhelp_basename = 'faraday_agent_dispatcher'


# -- Options for LaTeX output ------------------------------------------
Expand All @@ -128,8 +128,8 @@
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'faraday_dummy_agent.tex',
u'faraday_dummy_agent Documentation',
(master_doc, 'faraday_agent_dispatcher.tex',
u'faraday_agent_dispatcher Documentation',
u'Eric Horvat', 'manual'),
]

Expand All @@ -139,8 +139,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'faraday_dummy_agent',
u'faraday_dummy_agent Documentation',
(master_doc, 'faraday_agent_dispatcher',
u'faraday_agent_dispatcher Documentation',
[author], 1)
]

Expand All @@ -151,10 +151,10 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'faraday_dummy_agent',
u'faraday_dummy_agent Documentation',
(master_doc, 'faraday_agent_dispatcher',
u'faraday_agent_dispatcher Documentation',
author,
'faraday_dummy_agent',
'faraday_agent_dispatcher',
'One line description of project.',
'Miscellaneous'),
]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Welcome to dummy_faraday_agent's documentation!
Welcome to faraday_agent_dispatcher's documentation!
======================================

.. toctree::
Expand Down
16 changes: 8 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Installation
Stable release
--------------

To install dummy_faraday_agent, run this command in your terminal:
To install faraday_agent_dispatcher, run this command in your terminal:

.. code-block:: console
$ pip install dummy_faraday_agent
$ pip install faraday_agent_dispatcher
This is the preferred method to install dummy_faraday_agent, as it will always install the most recent stable release.
This is the preferred method to install faraday_agent_dispatcher, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
Expand All @@ -26,19 +26,19 @@ you through the process.
From sources
------------

The sources for dummy_faraday_agent can be downloaded from the `Github repo`_.
The sources for faraday_agent_dispatcher can be downloaded from the `Github repo`_.

You can either clone the public repository:

.. code-block:: console
$ git clone git://github.com/EricHorvat/dummy_faraday_agent
$ git clone git://github.com/faradaysec/faraday_agent_dispatcher
Or download the `tarball`_:

.. code-block:: console
$ curl -OL https://github.com/EricHorvat/dummy_faraday_agent/tarball/master
$ curl -OL https://github.com/faradaysec/faraday_agent_dispatcher/tarball/master
Once you have a copy of the source, you can install it with:

Expand All @@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with:
$ python setup.py install
.. _Github repo: https://github.com/EricHorvat/dummy_faraday_agent
.. _tarball: https://github.com/EricHorvat/dummy_faraday_agent/tarball/master
.. _Github repo: https://github.com/faradaysec/faraday_agent_dispatcher
.. _tarball: https://github.com/faradaysec/faraday_agent_dispatcher/tarball/master
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=dummy_faraday_agent
set SPHINXPROJ=faraday_agent_dispatcher

if "%1" == "" goto help

Expand Down
5 changes: 3 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Usage
=====

To use dummy_faraday_agent in a project::
To use faraday_agent_dispatcher in a project::

import faraday_agent_dispatcher

import dummy_faraday_agent
4 changes: 2 additions & 2 deletions faraday_agent_dispatcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.


"""Top-level package for faraday_dummy_agent."""
"""Top-level package for faraday_agent_dispatcher."""

__author__ = """Eric Horvat"""
__email__ = '[email protected]'
__version__ = '0.1.0'
__version__ = '1.0'
2 changes: 1 addition & 1 deletion faraday_agent_dispatcher/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""Console script for faraday_dummy_agent."""
"""Console script for faraday_agent_dispatcher."""
import os
import sys
import shutil
Expand Down
18 changes: 13 additions & 5 deletions faraday_agent_dispatcher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import logging
import configparser
from pathlib import Path
from configparser import DuplicateSectionError

try:
FARADAY_PATH = Path(os.environ['FARADAY_HOME'])
Expand All @@ -39,8 +40,11 @@

def reset_config(filepath):
instance.clear()
if not instance.read(filepath):
raise ValueError(f'Unable to read config file located at {filepath}')
try:
if not instance.read(filepath):
raise ValueError(f'Unable to read config file located at {filepath}')
except DuplicateSectionError as e:
raise ValueError(f'The config in {filepath} contains duplicated sections')


def check_filepath(filepath: str = None):
Expand All @@ -56,6 +60,10 @@ def save_config(filepath=None):
instance.write(configfile)


TOKENS_SECTION = "tokens"
SERVER_SECTION = "server"
EXECUTOR_SECTION = "executor"
class Sections:
TOKENS = "tokens"
SERVER = "server"
AGENT = "agent"
EXECUTOR_VARENVS = "{}_varenvs"
EXECUTOR_PARAMS = "{}_params"
EXECUTOR_DATA = "{}"
Loading

0 comments on commit d12de7c

Please sign in to comment.