saltstack-formulas / mysql-formula

Install the MySQL client and/or server
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
85 stars 366 forks source link

fix: hide passwords when applying states #269

Open an0nz opened 2 years ago

an0nz commented 2 years ago

PR progress checklist (to be filled in by reviewers)


What type of PR is this?

Primary type

Secondary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

https://github.com/saltstack-formulas/mysql-formula/issues/258 https://github.com/saltstack-formulas/mysql-formula/issues/75

Describe the changes you're proposing

Use environment variables and output_loglevel values to ensure passwords are not displayed during state runs or in log files for relevant cmd.run states

This is not perfect as the rendered YAML for the state in debug logs will still show the password, but it hides it from the standard output.

Pillar / config required to test the proposed changes

None, existing tests will be fine

Debug log showing how the proposed changes work

Running state [mysql -u root -hlocalhost -p$SALT_PASS smp < /etc/mysql/smp.schema] at time 22:56:03.198010
Executing state cmd.run for [mysql -u root -hlocalhost -p$SALT_PASS db < /etc/mysql/db.schema]
{'pid': 12967, 'retcode': 0, 'stdout': '', 'stderr': ''}
Completed state [mysql -u root -hlocalhost -p$SALT_PASS db < /etc/mysql/db.schema] at time 22:56:03.238271 (duration_in_ms=40.26)
LazyLoaded mysql_user.present

ID: mysql_db_0_load
Function: cmd.run
Name: mysql -u root -hlocalhost -p$SALT_PASS db < /etc/mysql/db.schema
Result: True
Comment: Command "mysql -u root -hlocalhost -p$SALT_PASS db < /etc/mysql/db.schema" run
Started: 22:56:03.198011
Duration: 40.26 ms
Changes:   
----------
pid:
  12967
retcode:
  0
stderr:
stdout:

Documentation checklist

Testing checklist

Additional context

Have been running a production environment with these changes for over a year without issue.