Add trust_input option to postgresql_slot module (#298)

* Add trust_input option to postgresql_slot module

Have added a trust_input option to the postgresql_slot module. This
only checks the session_role since all other options are passed as
parameters.

* Add Changelog fragment

* Update docs following PR review
This commit is contained in:
Thomas O'Donnell 2020-05-07 17:26:15 +02:00 committed by GitHub
parent f340b39bb9
commit f887aff159
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 18 deletions

View file

@ -70,6 +70,12 @@ options:
- Permissions checking for SQL commands is carried out as though
the session_role were the one that had logged in originally.
type: str
trust_input:
description:
- If C(no), check the value of I(session_role) is potentially dangerous.
- It sense to use C(no) only when SQL injections via I(session_role) are possible.
type: bool
default: yes
notes:
- Physical replication slots were introduced to PostgreSQL with version 9.4,
@ -89,6 +95,7 @@ seealso:
author:
- John Scalia (@jscalia)
- Andrew Klychkov (@Andersson007)
- Thomas O'Donnell (@andytom)
extends_documentation_fragment:
- community.general.postgres
@ -147,6 +154,9 @@ except ImportError:
pass
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,
exec_sql,
@ -229,6 +239,7 @@ def main():
session_role=dict(type="str"),
output_plugin=dict(type="str", default="test_decoding"),
state=dict(type="str", default="present", choices=["absent", "present"]),
trust_input=dict(type="bool", default=True),
)
module = AnsibleModule(
@ -242,6 +253,9 @@ def main():
state = module.params["state"]
output_plugin = module.params["output_plugin"]
if not module.params["trust_input"]:
check_input(module, module.params['session_role'])
if immediately_reserve and slot_type == 'logical':
module.fail_json(msg="Module parameters immediately_reserve and slot_type=logical are mutually exclusive")