mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
Updated blacklist/rules for environment variables that can be set by source_vars for a custom inventory script. Fixes https://trello.com/c/CWbeHJ0L
This commit is contained in:
@@ -1062,7 +1062,7 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
pass
|
pass
|
||||||
elif inventory_update.source == 'custom':
|
elif inventory_update.source == 'custom':
|
||||||
for env_k in inventory_update.source_vars_dict:
|
for env_k in inventory_update.source_vars_dict:
|
||||||
if str(env_k) not in os.environ and str(env_k) not in settings.INV_ENV_VARIABLE_BLACKLIST:
|
if str(env_k) not in env and str(env_k) not in settings.INV_ENV_VARIABLE_BLACKLIST:
|
||||||
env[str(env_k)] = unicode(inventory_update.source_vars_dict[env_k])
|
env[str(env_k)] = unicode(inventory_update.source_vars_dict[env_k])
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|||||||
@@ -1756,7 +1756,9 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
|||||||
custom_inv_update = reverse('api:inventory_source_update_view',
|
custom_inv_update = reverse('api:inventory_source_update_view',
|
||||||
args=(custom_group.inventory_source.pk,))
|
args=(custom_group.inventory_source.pk,))
|
||||||
inv_src_opts = {'source': 'custom',
|
inv_src_opts = {'source': 'custom',
|
||||||
'source_script': script_data["id"]}
|
'source_script': script_data["id"],
|
||||||
|
'source_vars': json.dumps({'HOME': 'no-place-like', 'USER': 'notme', '_': 'nope', 'INVENTORY_SOURCE_ID': -1})
|
||||||
|
}
|
||||||
with self.current_user(self.super_django_user):
|
with self.current_user(self.super_django_user):
|
||||||
response = self.put(custom_inv_src, inv_src_opts, expect=200)
|
response = self.put(custom_inv_src, inv_src_opts, expect=200)
|
||||||
self.check_inventory_source(custom_group.inventory_source)
|
self.check_inventory_source(custom_group.inventory_source)
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ RAX_GROUP_FILTER = r'^(?!instance-.+).+$'
|
|||||||
RAX_HOST_FILTER = r'^.+$'
|
RAX_HOST_FILTER = r'^.+$'
|
||||||
RAX_EXCLUDE_EMPTY_GROUPS = True
|
RAX_EXCLUDE_EMPTY_GROUPS = True
|
||||||
|
|
||||||
INV_ENV_VARIABLE_BLACKLIST = ("HOME", "_")
|
INV_ENV_VARIABLE_BLACKLIST = ("HOME", "USER", "_")
|
||||||
|
|
||||||
# ----------------
|
# ----------------
|
||||||
# -- Amazon EC2 --
|
# -- Amazon EC2 --
|
||||||
|
|||||||
Reference in New Issue
Block a user