From 9e76fdc6684ca0f14419f9651b44875005441152 Mon Sep 17 00:00:00 2001 From: Mr Bleu <40758407+JGodin-C2C@users.noreply.github.com> Date: Thu, 16 Jul 2020 23:17:18 +0200 Subject: [PATCH] Add check for rundeck_acl_policy name (#612) * Add check for rundeck_acl_policy name * Update changelogs/fragments/add_argument_check_for_rundeck.yaml Co-authored-by: Andrew Klychkov Co-authored-by: Andrew Klychkov --- changelogs/fragments/add_argument_check_for_rundeck.yaml | 2 ++ plugins/modules/web_infrastructure/rundeck_acl_policy.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/add_argument_check_for_rundeck.yaml diff --git a/changelogs/fragments/add_argument_check_for_rundeck.yaml b/changelogs/fragments/add_argument_check_for_rundeck.yaml new file mode 100644 index 0000000000..7d918d0048 --- /dev/null +++ b/changelogs/fragments/add_argument_check_for_rundeck.yaml @@ -0,0 +1,2 @@ +minor_changes: +- rundeck_acl_policy - add check for rundeck_acl_policy name parameter (https://github.com/ansible-collections/community.general/pull/612). diff --git a/plugins/modules/web_infrastructure/rundeck_acl_policy.py b/plugins/modules/web_infrastructure/rundeck_acl_policy.py index 978e3da1dc..28f287ac73 100644 --- a/plugins/modules/web_infrastructure/rundeck_acl_policy.py +++ b/plugins/modules/web_infrastructure/rundeck_acl_policy.py @@ -118,6 +118,7 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url, url_argument_spec from ansible.module_utils._text import to_text import json +import re class RundeckACLManager: @@ -230,6 +231,9 @@ def main(): supports_check_mode=True ) + if not bool(re.match("[a-zA-Z0-9,.+_-]+", module.params["name"])): + module.fail_json(msg="Name contains forbidden characters. The policy can contain the characters: a-zA-Z0-9,.+_-") + if module.params["api_version"] < 14: module.fail_json(msg="API version should be at least 14")