diff --git a/fn_query_tar_network/MANIFEST.in b/fn_query_tar_network/MANIFEST.in deleted file mode 100644 index 799a4933f..000000000 --- a/fn_query_tar_network/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include README.md -include fn_query_tar_network/util/* -include fn_query_tar_network/LICENSE -include fn_query_tar_network/doc/* \ No newline at end of file diff --git a/fn_query_tar_network/fn_query_tar_network/util/customize.py b/fn_query_tar_network/fn_query_tar_network/util/customize.py deleted file mode 100644 index cfe29bbfd..000000000 --- a/fn_query_tar_network/fn_query_tar_network/util/customize.py +++ /dev/null @@ -1,99 +0,0 @@ -# (c) Copyright IBM Corp. 2010, 2018. All Rights Reserved. -# -*- coding: utf-8 -*- - -"""Generate the Resilient customizations required for fn_query_tar_network""" - -from __future__ import print_function -from resilient_circuits.util import * - -def codegen_reload_data(): - """Parameters to codegen used to generate the fn_query_tar_network package""" - reload_params = {"package": u"fn_query_tar_network", - "incident_fields": [], - "action_fields": [], - "function_params": [u"search_data"], - "datatables": [], - "message_destinations": [u"fn_querytar_network"], - "functions": [u"query_tor_network"], - "phases": [], - "automatic_tasks": [], - "scripts": [], - "workflows": [], - "actions": [] - } - return reload_params - - -def customization_data(client=None): - """Produce any customization definitions (types, fields, message destinations, etc) - that should be installed by `resilient-circuits customize` - """ - - # This import data contains: - # Function inputs: - # search_data - # Message Destinations: - # fn_querytar_network - # Functions: - # query_tor_network - - - yield ImportDefinition(u""" -eyJ0YXNrX29yZGVyIjogW10sICJ3b3JrZmxvd3MiOiBbXSwgImFjdGlvbnMiOiBbXSwgImxheW91 -dHMiOiBbXSwgImV4cG9ydF9mb3JtYXRfdmVyc2lvbiI6IDIsICJpZCI6IDIyLCAiaW5kdXN0cmll -cyI6IG51bGwsICJwaGFzZXMiOiBbXSwgImFjdGlvbl9vcmRlciI6IFtdLCAiZ2VvcyI6IG51bGws -ICJzZXJ2ZXJfdmVyc2lvbiI6IHsibWFqb3IiOiAzMCwgInZlcnNpb24iOiAiMzAuNC4yMzciLC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2lkIjogMTEsICJvcGVyYXRpb25fcGVybXMiOiB7fSwgInRleHQi -OiAic2VhcmNoX2RhdGEiLCAiYmxhbmtfb3B0aW9uIjogZmFsc2UsICJwcmVmaXgiOiBudWxsLCAi -Y2hhbmdlYWJsZSI6IHRydWUsICJpZCI6IDEzOSwgInJlYWRfb25seSI6IGZhbHNlLCAidXVpZCI6 -ICJmZjEyYzg1MC1mNDFkLTQwNGEtOTEzOC01ZTk4Y2MzN2JiMGMiLCAiY2hvc2VuIjogZmFsc2Us -ICJpbnB1dF90eXBlIjogInRleHQiLCAidG9vbHRpcCI6ICIiLCAiaW50ZXJuYWwiOiBmYWxzZSwg -InJpY2hfdGV4dCI6IGZhbHNlLCAidGVtcGxhdGVzIjogW10sICJleHBvcnRfa2V5IjogIl9fZnVu -Y3Rpb24vc2VhcmNoX2RhdGEiLCAiaGlkZV9ub3RpZmljYXRpb24iOiBmYWxzZSwgInBsYWNlaG9s -ZGVyIjogIiIsICJuYW1lIjogInNlYXJjaF9kYXRhIiwgImRlZmF1bHRfY2hvc2VuX2J5X3NlcnZl -ciI6IGZhbHNlLCAidmFsdWVzIjogW119XSwgIm92ZXJyaWRlcyI6IFtdLCAiZXhwb3J0X2RhdGUi -OiAxNTQ1MjEyMjU4NjI3fQ== -""" - ) \ No newline at end of file diff --git a/fn_query_tor_network/MANIFEST.in b/fn_query_tor_network/MANIFEST.in new file mode 100644 index 000000000..a74429463 --- /dev/null +++ b/fn_query_tor_network/MANIFEST.in @@ -0,0 +1,4 @@ +include README.md +include fn_query_tor_network/util/* +include fn_query_tor_network/LICENSE +include fn_query_tor_network/doc/* \ No newline at end of file diff --git a/fn_query_tar_network/README.md b/fn_query_tor_network/README.md similarity index 67% rename from fn_query_tar_network/README.md rename to fn_query_tor_network/README.md index a125cd784..28cb01cb4 100644 --- a/fn_query_tar_network/README.md +++ b/fn_query_tor_network/README.md @@ -4,7 +4,7 @@ Replace this with your own readme. This template project was generated by - resilient-circuits codegen -p fn_query_tar_network [-f query_tor_network] [-w ] + resilient-circuits codegen -p fn_query_tor_network [-f fn_tor] [-w ] You must edit the `setup.py` before distribution; @@ -12,19 +12,19 @@ it should contain your actual contact and license information. To install in "development mode" - pip install -e ./fn_query_tar_network/ + pip install -e ./fn_query_tor_network/ After installation, the package will be loaded by `resilient-circuits run`. To uninstall, - pip uninstall fn_query_tar_network + pip uninstall fn_query_tor_network To package for distribution, - python ./fn_query_tar_network/setup.py sdist + python ./fn_query_tor_network/setup.py sdist The resulting .tar.gz file can be installed using diff --git a/fn_query_tar_network/fn_query_tar_network/LICENSE b/fn_query_tor_network/fn_query_tor_network/LICENSE similarity index 100% rename from fn_query_tar_network/fn_query_tar_network/LICENSE rename to fn_query_tor_network/fn_query_tor_network/LICENSE diff --git a/fn_query_tar_network/fn_query_tar_network/__init__.py b/fn_query_tor_network/fn_query_tor_network/__init__.py similarity index 100% rename from fn_query_tar_network/fn_query_tar_network/__init__.py rename to fn_query_tor_network/fn_query_tor_network/__init__.py diff --git a/fn_query_tar_network/fn_query_tar_network/components/__init__.py b/fn_query_tor_network/fn_query_tor_network/components/__init__.py similarity index 100% rename from fn_query_tar_network/fn_query_tar_network/components/__init__.py rename to fn_query_tor_network/fn_query_tor_network/components/__init__.py diff --git a/fn_query_tar_network/fn_query_tar_network/components/query_tor_network.py b/fn_query_tor_network/fn_query_tor_network/components/fn_tor.py similarity index 69% rename from fn_query_tar_network/fn_query_tar_network/components/query_tor_network.py rename to fn_query_tor_network/fn_query_tor_network/components/fn_tor.py index b3f5c4fac..5ba4353c2 100644 --- a/fn_query_tar_network/fn_query_tar_network/components/query_tor_network.py +++ b/fn_query_tor_network/fn_query_tor_network/components/fn_tor.py @@ -5,43 +5,43 @@ import logging from resilient_circuits import ResilientComponent, function, handler, StatusMessage, FunctionResult, FunctionError -import fn_query_tar_network.util.selftest as selftest +import fn_query_tor_network.util.selftest as selftest import requests class FunctionComponent(ResilientComponent): - """Component that implements Resilient function 'query_tor_network""" + """Component that implements Resilient function 'fn_tor""" def __init__(self, opts): """constructor provides access to the configuration options""" super(FunctionComponent, self).__init__(opts) - self.options = opts.get("fn_query_tar_network", {}) + self.options = opts.get("fn_query_tor_network", {}) selftest.selftest_function(opts) @handler("reload") def _reload(self, event, opts): """Configuration options have changed, save new values""" - self.options = opts.get("fn_query_tar_network", {}) + self.options = opts.get("fn_query_tor_network", {}) - @function("query_tor_network") - def _query_tor_network_function(self, event, *args, **kwargs): - """Function: This Function to Search for Given Parameter in TOR Relay Exit Node""" + @function("fn_tor") + def _fn_tor_function(self, event, *args, **kwargs): + """Function: This TOR function searches for the given IP Address or host names in TOR exit node Network by using RESTful API""" try: # Get the function parameters: - search_data = kwargs.get("search_data") # text + tor_search_data = kwargs.get("tor_search_data") # text log = logging.getLogger(__name__) - log.info("search_data: %s", search_data) + log.info("tor_search_data: %s", tor_search_data) # PUT YOUR FUNCTION IMPLEMENTATION CODE HERE yield StatusMessage("starting...") __params_data = {'flag': self.options.get('flag'), 'fields': self.options.get('data_fields'), - 'search': search_data} + 'search': tor_search_data} __response_data = requests.get(self.options.get('base_url'), params=__params_data) __response_data = __response_data.text - if __response_data.find(search_data) != -1: + if __response_data.find(tor_search_data) != -1: results = {'status': 'success', 'data': __response_data, 'value': True} else: log.info("No Data found for given search element...!") diff --git a/fn_query_tar_network/fn_query_tar_network/util/__init__.py b/fn_query_tor_network/fn_query_tor_network/util/__init__.py similarity index 100% rename from fn_query_tar_network/fn_query_tar_network/util/__init__.py rename to fn_query_tor_network/fn_query_tor_network/util/__init__.py diff --git a/fn_query_tar_network/fn_query_tar_network/util/config.py b/fn_query_tor_network/fn_query_tor_network/util/config.py similarity index 69% rename from fn_query_tar_network/fn_query_tar_network/util/config.py rename to fn_query_tor_network/fn_query_tor_network/util/config.py index 80b82dedd..bf92e63ff 100644 --- a/fn_query_tar_network/fn_query_tar_network/util/config.py +++ b/fn_query_tor_network/fn_query_tor_network/util/config.py @@ -1,7 +1,7 @@ # (c) Copyright IBM Corp. 2010, 2018. All Rights Reserved. # -*- coding: utf-8 -*- -"""Generate a default configuration-file section for fn_query_tar_network""" +"""Generate a default configuration-file section for fn_query_tor_network""" from __future__ import print_function @@ -10,9 +10,9 @@ def config_section_data(): """Produce the default configuration section for app.config, when called by `resilient-circuits config [-c|-u]` """ - config_data = u"""[fn_query_tar_network] + config_data = u"""[fn_query_tor_network] base_url = https://onionoo.torproject.org/details flag = Exit -data_fields = exit_addresses,or_addresses,host_name - """ +data_fields = exit_addresses,or_addresses,host_name""" + return config_data \ No newline at end of file diff --git a/fn_query_tor_network/fn_query_tor_network/util/customize.py b/fn_query_tor_network/fn_query_tor_network/util/customize.py new file mode 100644 index 000000000..d26201aa7 --- /dev/null +++ b/fn_query_tor_network/fn_query_tor_network/util/customize.py @@ -0,0 +1,98 @@ +# (c) Copyright IBM Corp. 2010, 2018. All Rights Reserved. +# -*- coding: utf-8 -*- + +"""Generate the Resilient customizations required for fn_query_tor_network""" + +from __future__ import print_function +from resilient_circuits.util import * + +def codegen_reload_data(): + """Parameters to codegen used to generate the fn_query_tor_network package""" + reload_params = {"package": u"fn_query_tor_network", + "incident_fields": [], + "action_fields": [], + "function_params": [u"tor_search_data"], + "datatables": [], + "message_destinations": [u"fn_tor"], + "functions": [u"fn_tor"], + "phases": [], + "automatic_tasks": [], + "scripts": [], + "workflows": [], + "actions": [] + } + return reload_params + + +def customization_data(client=None): + """Produce any customization definitions (types, fields, message destinations, etc) + that should be installed by `resilient-circuits customize` + """ + + # This import data contains: + # Function inputs: + # tor_search_data + # Message Destinations: + # fn_tor + # Functions: + # fn_tor + + + yield ImportDefinition(u""" +eyJ0YXNrX29yZGVyIjogW10sICJ3b3JrZmxvd3MiOiBbXSwgImFjdGlvbnMiOiBbXSwgImxheW91 +dHMiOiBbXSwgImV4cG9ydF9mb3JtYXRfdmVyc2lvbiI6IDIsICJpZCI6IDI1LCAiaW5kdXN0cmll +cyI6IG51bGwsICJwaGFzZXMiOiBbXSwgImFjdGlvbl9vcmRlciI6IFt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ZlNWNhMzMw +OGNjYSJ9LCB7Im9wZXJhdGlvbnMiOiBbXSwgInR5cGVfaWQiOiAxMSwgIm9wZXJhdGlvbl9wZXJt +cyI6IHt9LCAidGV4dCI6ICJ0b3Jfc2VhcmNoX2RhdGEiLCAiYmxhbmtfb3B0aW9uIjogZmFsc2Us +ICJwcmVmaXgiOiBudWxsLCAiY2hhbmdlYWJsZSI6IHRydWUsICJpZCI6IDE0MCwgInJlYWRfb25s +eSI6IGZhbHNlLCAidXVpZCI6ICI5YTJhY2UxMS0zYWQwLTRiYjYtOTFlMy1mZDExNzA2OThiZmUi +LCAiY2hvc2VuIjogZmFsc2UsICJpbnB1dF90eXBlIjogInRleHQiLCAidG9vbHRpcCI6ICIiLCAi +aW50ZXJuYWwiOiBmYWxzZSwgInJpY2hfdGV4dCI6IGZhbHNlLCAidGVtcGxhdGVzIjogW10sICJl +eHBvcnRfa2V5IjogIl9fZnVuY3Rpb24vdG9yX3NlYXJjaF9kYXRhIiwgImhpZGVfbm90aWZpY2F0 +aW9uIjogZmFsc2UsICJwbGFjZWhvbGRlciI6ICIiLCAibmFtZSI6ICJ0b3Jfc2VhcmNoX2RhdGEi +LCAiZGVmYXVsdF9jaG9zZW5fYnlfc2VydmVyIjogZmFsc2UsICJ2YWx1ZXMiOiBbXX1dLCAib3Zl +cnJpZGVzIjogW10sICJleHBvcnRfZGF0ZSI6IDE1NDUzMTg4NjEzNjZ9 +""" + ) \ No newline at end of file diff --git a/fn_query_tar_network/fn_query_tar_network/util/selftest.py b/fn_query_tor_network/fn_query_tor_network/util/selftest.py similarity index 89% rename from fn_query_tar_network/fn_query_tar_network/util/selftest.py rename to fn_query_tor_network/fn_query_tor_network/util/selftest.py index 7be568985..55d62e512 100644 --- a/fn_query_tar_network/fn_query_tar_network/util/selftest.py +++ b/fn_query_tor_network/fn_query_tor_network/util/selftest.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # pragma pylint: disable=unused-argument, no-self-use """Function implementation - test with: resilient-circuits selftest -l fn_query_tar_network + test with: resilient-circuits selftest -l fn_query_tor_network """ import logging @@ -18,7 +18,7 @@ def selftest_function(opts): Placeholder for selftest function. An example use would be to test package api connectivity. Suggested return values are be unimplemented, success, or failure. """ - options = opts.get("fn_query_tar_network", {}) + options = opts.get("fn_query_tor_network", {}) try: connection_status = requests.get(options.get('base_url')) if not connection_status.status_code == 200: diff --git a/fn_query_tar_network/setup.py b/fn_query_tor_network/setup.py similarity index 66% rename from fn_query_tar_network/setup.py rename to fn_query_tor_network/setup.py index c4358c455..8a8f9490d 100644 --- a/fn_query_tar_network/setup.py +++ b/fn_query_tor_network/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup( - name='fn_query_tar_network', + name='fn_query_tor_network', version='1.0.0', license='MIT', author='Resilient Labs', @@ -13,9 +13,9 @@ url='https://github.com/ibmresilient/resilient-community-apps', description="Resilient Circuits Components for 'fn_query_tar_network'", long_description="""The Query TOR Network API is RESTful web service allowing query tar network customer - search for IP Addresses or host names in tor relay exit node database.and results - will be updated on the Dashboard. - """, + search for IP Addresses or host names in tor relay exit node database.and results + will be updated on the Incidents Notes Dashboard. + """, install_requires=[ 'resilient_circuits>=30.0.0' ], @@ -27,10 +27,10 @@ ], entry_points={ "resilient.circuits.components": [ - "QueryTorNetworkFunctionComponent = fn_query_tar_network.components.query_tor_network:FunctionComponent" + "FnTorFunctionComponent = fn_query_tor_network.components.fn_tor:FunctionComponent" ], - "resilient.circuits.configsection": ["gen_config = fn_query_tar_network.util.config:config_section_data"], - "resilient.circuits.customize": ["customize = fn_query_tar_network.util.customize:customization_data"], - "resilient.circuits.selftest": ["selftest = fn_query_tar_network.util.selftest:selftest_function"] + "resilient.circuits.configsection": ["gen_config = fn_query_tor_network.util.config:config_section_data"], + "resilient.circuits.customize": ["customize = fn_query_tor_network.util.customize:customization_data"], + "resilient.circuits.selftest": ["selftest = fn_query_tor_network.util.selftest:selftest_function"] } ) \ No newline at end of file diff --git a/fn_query_tar_network/tests/test_query_tor_network.py b/fn_query_tor_network/tests/test_fn_tor.py similarity index 66% rename from fn_query_tar_network/tests/test_query_tor_network.py rename to fn_query_tor_network/tests/test_fn_tor.py index 6bb855c5b..548030444 100644 --- a/fn_query_tar_network/tests/test_query_tor_network.py +++ b/fn_query_tor_network/tests/test_fn_tor.py @@ -7,8 +7,8 @@ from resilient_circuits.util import get_config_data, get_function_definition from resilient_circuits import SubmitTestFunction, FunctionResult -PACKAGE_NAME = "fn_query_tar_network" -FUNCTION_NAME = "query_tor_network" +PACKAGE_NAME = "fn_query_tor_network" +FUNCTION_NAME = "fn_tor" # Read the default configuration-data section from the package config_data = get_config_data(PACKAGE_NAME) @@ -17,33 +17,33 @@ resilient_mock = "pytest_resilient_circuits.BasicResilientMock" -def call_query_tor_network_function(circuits, function_params, timeout=10): +def call_fn_tor_function(circuits, function_params, timeout=10): # Fire a message to the function - evt = SubmitTestFunction("query_tor_network", function_params) + evt = SubmitTestFunction("fn_tor", function_params) circuits.manager.fire(evt) - event = circuits.watcher.wait("query_tor_network_result", parent=evt, timeout=timeout) + event = circuits.watcher.wait("fn_tor_result", parent=evt, timeout=timeout) assert event assert isinstance(event.kwargs["result"], FunctionResult) pytest.wait_for(event, "complete", True) return event.kwargs["result"].value -class TestQueryTorNetwork: - """ Tests for the query_tor_network function""" +class TestFnTor: + """ Tests for the fn_tor function""" def test_function_definition(self): """ Test that the package provides customization_data that defines the function """ func = get_function_definition(PACKAGE_NAME, FUNCTION_NAME) assert func is not None - @pytest.mark.parametrize("search_data, expected_results", [ + @pytest.mark.parametrize("tor_search_data, expected_results", [ ("text", {"value": "xyz"}), ("text", {"value": "xyz"}) ]) - def test_success(self, circuits_app, search_data, expected_results): + def test_success(self, circuits_app, tor_search_data, expected_results): """ Test calling with sample values for the parameters """ function_params = { - "search_data": search_data + "tor_search_data": tor_search_data } - results = call_query_tor_network_function(circuits_app, function_params) + results = call_fn_tor_function(circuits_app, function_params) assert(expected_results == results) \ No newline at end of file diff --git a/fn_query_tar_network/tox.ini b/fn_query_tor_network/tox.ini similarity index 100% rename from fn_query_tar_network/tox.ini rename to fn_query_tor_network/tox.ini