-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add roleEnableLogsAttr to prevent password leakage in logs #231
base: main
Are you sure you want to change the base?
Add roleEnableLogsAttr to prevent password leakage in logs #231
Conversation
@cyrilgdn I have also tested all the |
@cyrilgdn Any updates on when you can take a look at this? Thanks |
@cyrilgdn Hopefully we are all set to merge since all the checks passed :) |
@cyrilgdn Are there any updates on this? I'm also being affected by the log leaks. |
@cyrilgdn This password leakage is dangerous, and should be controlled. Can you please take a look at this ASAP? |
We're seeing this behaviour as well - would be great to have this fixed. |
Hey @cyrilgdn have you had a chance to review this? |
1 similar comment
Hey @cyrilgdn have you had a chance to review this? |
9de07a9
to
cd56239
Compare
cd56239
to
451de68
Compare
@cyrilgdn have you had a chance to review this yet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MatthewPugliese ,
Sorry for the lack of response over the years.
Apart the comment I posted on the code, I have a concern on the fact that when you disabled the logs, unless the transaction is rollback, the logs will be disabled for the life of the connection so potentially for other resources during the same apply.
Is it expected for you? I wonder if people would not complain later about this unexpected behavior.
I wonder if it should not be a provider settings instead 🤔
Let me know what do you think.
areLogsEnabled := d.Get(roleEnableLogsAttr).(bool) | ||
if areLogsEnabled { | ||
sql := "SET log_statement TO 'none'; SET log_min_duration_statement TO -1; SET log_min_error_statement TO 'log'; SET pg_stat_statements.track_utility = 'off';" | ||
|
||
if _, err := txn.Exec(sql); err != nil { | ||
return fmt.Errorf("could not disable logs for %s: %w", roleName, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like you inverse the boolean no?
if areLogsEnabled
is set to true, you disable the logs
Another solution would be to get the current values of all settings you are changing and and reset to these values just after the create role actually. |
f2c2e47
to
dea1401
Compare
Currently, when a new role is created, the logs output the password
2022-07-25 18:53:15.069 UTC [49] LOG: statement: CREATE ROLE "my_role" WITH ENCRYPTED PASSWORD 'mypass' VALID UNTIL 'infinity' CONNECTION LIMIT -1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOBYPASSRLS NOREPLICATION
This new attribute,
enable_logs
, allows the user to determine whether or not they want the logs of any roles being created to be included or skipped, as shown below.The attribute is defaulted to
false
for improved security. For those who want to enable these logs, when defining a new role, includeenable_logs = true
besides the other included attributes.