mirror of
https://github.com/ansible/awx.git
synced 2026-03-15 07:57:29 -02:30
replace usage of FullLoader w/ safe_load
This commit is contained in:
@@ -7,4 +7,4 @@ class HasVariables(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def variables(self):
|
def variables(self):
|
||||||
return PseudoNamespace(yaml.load(self.json.variables, Loader=yaml.FullLoader))
|
return PseudoNamespace(yaml.safe_load(self.json.variables))
|
||||||
|
|||||||
@@ -114,16 +114,16 @@ class UnifiedJob(HasStatus, base.Base):
|
|||||||
"""
|
"""
|
||||||
def attempt_yaml_load(arg):
|
def attempt_yaml_load(arg):
|
||||||
try:
|
try:
|
||||||
return yaml.load(arg, Loader=yaml.FullLoader)
|
return yaml.safe_load(arg)
|
||||||
except (yaml.parser.ParserError, yaml.scanner.ScannerError):
|
except (yaml.parser.ParserError, yaml.scanner.ScannerError):
|
||||||
return str(arg)
|
return str(arg)
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
if not self.json.job_args:
|
if not self.json.job_args:
|
||||||
return ""
|
return ""
|
||||||
for arg in yaml.load(self.json.job_args, Loader=yaml.FullLoader):
|
for arg in yaml.safe_load(self.json.job_args):
|
||||||
try:
|
try:
|
||||||
args.append(yaml.load(arg, Loader=yaml.FullLoader))
|
args.append(yaml.safe_load(arg))
|
||||||
except (yaml.parser.ParserError, yaml.scanner.ScannerError):
|
except (yaml.parser.ParserError, yaml.scanner.ScannerError):
|
||||||
if arg[0] == '@': # extra var file reference
|
if arg[0] == '@': # extra var file reference
|
||||||
args.append(attempt_yaml_load(arg))
|
args.append(attempt_yaml_load(arg))
|
||||||
|
|||||||
@@ -184,8 +184,7 @@ def load_credentials(filename=None):
|
|||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
with open(path) as credentials_fh:
|
with open(path) as credentials_fh:
|
||||||
credentials_dict = yaml.load(
|
credentials_dict = yaml.safe_load(credentials_fh)
|
||||||
credentials_fh, Loader=yaml.FullLoader)
|
|
||||||
return credentials_dict
|
return credentials_dict
|
||||||
else:
|
else:
|
||||||
msg = 'Unable to load credentials file at %s' % path
|
msg = 'Unable to load credentials file at %s' % path
|
||||||
@@ -200,7 +199,7 @@ def load_projects(filename=None):
|
|||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
with open(path) as projects_fh:
|
with open(path) as projects_fh:
|
||||||
projects_dict = yaml.load(projects_fh, Loader=yaml.FullLoader)
|
projects_dict = yaml.safe_load(projects_fh)
|
||||||
return projects_dict
|
return projects_dict
|
||||||
else:
|
else:
|
||||||
msg = 'Unable to load projects file at %s' % path
|
msg = 'Unable to load projects file at %s' % path
|
||||||
@@ -329,7 +328,7 @@ def to_bool(obj):
|
|||||||
|
|
||||||
def load_json_or_yaml(obj):
|
def load_json_or_yaml(obj):
|
||||||
try:
|
try:
|
||||||
return yaml.load(obj, Loader=yaml.FullLoader)
|
return yaml.safe_load(obj)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise TypeError("Provide valid YAML/JSON.")
|
raise TypeError("Provide valid YAML/JSON.")
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ file_pattern_cache = {}
|
|||||||
file_path_cache = {}
|
file_path_cache = {}
|
||||||
|
|
||||||
|
|
||||||
class Loader(yaml.FullLoader):
|
class Loader(yaml.SafeLoader):
|
||||||
|
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
self._root = os.path.split(stream.name)[0]
|
self._root = os.path.split(stream.name)[0]
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
PyYAML>=5.1
|
PyYAML
|
||||||
requests
|
requests
|
||||||
|
|||||||
Reference in New Issue
Block a user