1
0
mirror of https://github.com/ansible-collections/community.general.git synced 2025-08-12 23:02:47 +03:00

postgresql_lang: add trust_input parameter (#272)

* postgresql_lan: add trust_input parameter

* add changelog fragment
This commit is contained in:
Andrew Klychkov
2020-05-05 16:37:08 +03:00
committed by GitHub
parent e6b6c05bf7
commit 19cad71f25
3 changed files with 22 additions and 4 deletions

View File

@@ -104,6 +104,11 @@ options:
- Set an owner for the language.
- Ignored when I(state=absent).
type: str
trust_input:
description:
- If C(no), check whether values of some parameters are potentially dangerous.
type: bool
default: yes
seealso:
- name: PostgreSQL languages
description: General information about PostgreSQL languages.
@@ -176,6 +181,7 @@ queries:
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.database import check_input
from ansible_collections.community.general.plugins.module_utils.postgres import (
connect_to_db,
get_conn_params,
@@ -258,7 +264,7 @@ def set_lang_owner(cursor, lang, owner):
lang (str): language name.
owner (str): name of new owner.
"""
query = "ALTER LANGUAGE \"%s\" OWNER TO %s" % (lang, owner)
query = "ALTER LANGUAGE \"%s\" OWNER TO \"%s\"" % (lang, owner)
executed_queries.append(query)
cursor.execute(query)
return True
@@ -276,6 +282,7 @@ def main():
fail_on_drop=dict(type="bool", default="yes"),
session_role=dict(type="str"),
owner=dict(type="str"),
trust_input=dict(type="bool", default="yes")
)
module = AnsibleModule(
@@ -291,6 +298,12 @@ def main():
cascade = module.params["cascade"]
fail_on_drop = module.params["fail_on_drop"]
owner = module.params["owner"]
session_role = module.params["session_role"]
trust_input = module.params["trust_input"]
if not trust_input:
# Check input for potentially dangerous elements:
check_input(module, lang, session_role, owner)
conn_params = get_conn_params(module, module.params)
db_connection = connect_to_db(module, conn_params, autocommit=False)