Prevent logging of result of resources.string() method call

The result of resources.string() method is the content of the file
saved to string. Logging of binary file content causes
UnicodeDecode error. Moreover, logging of any file content can be
security issue. Finally, it is just not practical to fill the logs
with tons of text from the big files.

Change-Id: I87077b002f2a8888c22b4dfba1f7b9f0508fec69
Closes-bug: #1561522
This commit is contained in:
Valerii Kovalchuk 2016-09-14 15:18:40 +03:00 committed by Kirill Zaitsev
parent 4c93ad397e
commit ce8e2ec37a
2 changed files with 9 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import yaml as yamllib
from yaql.language import specs
from yaql.language import yaqltypes
from murano.dsl import constants
from murano.dsl import dsl
from murano.dsl import dsl_types
from murano.dsl import helpers
@ -52,6 +53,7 @@ class ResourceManager(object):
@staticmethod
@specs.parameter('owner', dsl.MuranoTypeParameter(nullable=True))
@specs.inject('receiver', yaqltypes.Receiver())
@specs.meta(constants.META_NO_TRACE, True)
def string(receiver, name, owner=None, binary=False):
path = ResourceManager._get_package(owner, receiver).get_resource(name)
mode = 'rb' if binary else 'rU'
@ -61,12 +63,14 @@ class ResourceManager(object):
@classmethod
@specs.parameter('owner', dsl.MuranoTypeParameter(nullable=True))
@specs.inject('receiver', yaqltypes.Receiver())
@specs.meta(constants.META_NO_TRACE, True)
def json(cls, receiver, name, owner=None):
return jsonlib.loads(cls.string(receiver, name, owner))
@classmethod
@specs.parameter('owner', dsl.MuranoTypeParameter(nullable=True))
@specs.inject('receiver', yaqltypes.Receiver())
@specs.meta(constants.META_NO_TRACE, True)
def yaml(cls, receiver, name, owner=None):
return yamllib.load(
cls.string(receiver, name, owner), Loader=yaml_loader)

View File

@ -0,0 +1,5 @@
---
fixes:
- Murano engine no longer logs methods ``string()``, ``json()``, and ``yaml()``
of the 'io.murano.system.Resources' class. This is done to prevent UnicodeDecodeError's
when transferring binary files to murano agent.