diff --git a/muranoconductor/app.py b/muranoconductor/app.py index 6907d86..65afbff 100644 --- a/muranoconductor/app.py +++ b/muranoconductor/app.py @@ -27,7 +27,7 @@ from config import Config import reporting from muranocommon.messaging import MqClient, Message from muranoconductor import config as cfg -from muranoconductor.helpers import secure_data +from muranocommon.helpers.token_sanitizer import TokenSanitizer import windows_agent import cloud_formation @@ -80,8 +80,9 @@ class ConductorWorkflowService(service.Service): message_id = message.id with self.create_rmq_client() as mq: try: + secure_task = TokenSanitizer().sanitize(task) log.info('Starting processing task {0}: {1}'.format( - message_id, anyjson.dumps(secure_data(task)))) + message_id, anyjson.dumps(secure_task))) reporter = reporting.Reporter(mq, message_id, task['id']) config = Config() @@ -136,7 +137,7 @@ class ConductorWorkflowService(service.Service): mq.send(message=result_msg, key='task-results') message.ack() log.info('Finished processing task {0}. Result = {1}'.format( - message_id, anyjson.dumps(secure_data(task)))) + message_id, anyjson.dumps(TokenSanitizer().sanitize(task)))) def cleanup(self, model, reporter): try: diff --git a/muranoconductor/commands/windows_agent.py b/muranoconductor/commands/windows_agent.py index 6f275e0..88759ae 100644 --- a/muranoconductor/commands/windows_agent.py +++ b/muranoconductor/commands/windows_agent.py @@ -6,6 +6,7 @@ from muranoconductor.openstack.common import log as logging from muranocommon.messaging import Message import muranoconductor.helpers from command import CommandBase +from muranocommon.helpers.token_sanitizer import TokenSanitizer log = logging.getLogger(__name__) @@ -44,7 +45,7 @@ class WindowsAgentExecutor(CommandBase): self._rmqclient.declare(queue) self._rmqclient.send(message=msg, key=queue) log.info('Sending RMQ message {0} to {1} with id {2}'.format( - template_data, queue, msg_id)) + TokenSanitizer().sanitize(template_data), queue, msg_id)) def encode_scripts(self, json_data, template_path): scripts_folder = 'data/templates/agent/scripts' diff --git a/muranoconductor/helpers.py b/muranoconductor/helpers.py index 3bba836..b5cdc72 100644 --- a/muranoconductor/helpers.py +++ b/muranoconductor/helpers.py @@ -15,7 +15,6 @@ import deep import types -from muranocommon.helpers.token_sanitizer import TokenSanitizer def transform_json(json, mappings): @@ -101,8 +100,3 @@ def str2unicode(obj): elif isinstance(obj, types.ListType): return [str2unicode(t) for t in obj] return obj - - -def secure_data(data): - sanitizer = TokenSanitizer() - return sanitizer.sanitize(data) diff --git a/muranoconductor/workflow.py b/muranoconductor/workflow.py index 4a56d0e..1c0faf1 100644 --- a/muranoconductor/workflow.py +++ b/muranoconductor/workflow.py @@ -20,7 +20,7 @@ import types import function_context import xml_code_engine -from muranoconductor.helpers import secure_data +from muranocommon.helpers.token_sanitizer import TokenSanitizer log = logging.getLogger(__name__) object_id = id @@ -137,6 +137,9 @@ class Workflow(object): @staticmethod def _set_func(path, context, body, engine, target=None, **kwargs): + def secure_data(*args): + return TokenSanitizer().sanitize(args) + body_data = engine.evaluate_content(body, context) if path.startswith('##'): @@ -145,7 +148,7 @@ class Workflow(object): context_path = ':' + path[1:] log.debug( "Setting context variable '{0}' to '{1}'".format( - *secure_data((context_path, body_data)))) + *secure_data(context_path, body_data))) context[context_path] = body_data return if target: @@ -153,7 +156,7 @@ class Workflow(object): position = path.split('.') if Workflow._get_path(data, position) != body_data: log.debug("Setting '{0}' to '{1}'".format( - *secure_data((path, body_data)))) + *secure_data(path, body_data))) Workflow._set_path(data, position, body_data) context['/hasSideEffects'] = True @@ -162,7 +165,7 @@ class Workflow(object): new_position = Workflow._correct_position(path, context) if Workflow._get_path(data, new_position) != body_data: log.debug("Setting '{0}' to '{1}'".format( - *secure_data((path, body_data)))) + *secure_data(path, body_data))) Workflow._set_path(data, new_position, body_data) context['/hasSideEffects'] = True @@ -231,8 +234,9 @@ class Workflow(object): context['__dataSource_currentObj'] = cur_obj context['__dataSource_currentObj_id'] = current_object_id + secure_obj = TokenSanitizer().sanitize(cur_obj) log.debug("Rule '{0}' with ID = {2} matches on '{1}'" - .format(desc, secure_data(cur_obj), full_rule_id)) + .format(desc, secure_obj, full_rule_id)) if current_object_id != '#': log.debug('Muting {0} in rule {1}'.format( current_object_id, full_rule_id)) diff --git a/requirements.txt b/requirements.txt index aab3bf1..9f9a005 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pbr>=0.5.21,<1.0 +pbr>=0.5,<0.6 anyjson eventlet>=0.9.12 jsonpath @@ -11,4 +11,4 @@ netaddr oslo.config deep -murano-common>=0.2.2 \ No newline at end of file +murano-common>=0.2.2 diff --git a/setup.cfg b/setup.cfg index 344da89..06f3815 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = murano-conductor summary = The Conductor is orchestration engine server -version = 2013.1 +version = 0.2 description-file = README.rst license = Apache License, Version 2.0 @@ -61,4 +61,4 @@ output_file = muranoconductor/locale/conductor.pot verbosity=2 cover-package = muranoconductor cover-html = true -cover-erase = true \ No newline at end of file +cover-erase = true diff --git a/setup.py b/setup.py index 14f18d1..d0f89e4 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import setuptools setuptools.setup( setup_requires=[ 'd2to1>=0.2.10,<0.3', - 'pbr>=0.5.21,<1.0' + 'pbr>=0.5,<0.6' ], d2to1=True, pbr=True