Skip to content

Commit c084707

Browse files
MichaIngandrewschleifer
authored andcommitted
discourse-doctor: prevent others from reading sensitive log content
The log file is world-readable until the script finished, while sensitive settings are written to it at the very start. If the container is not running, a rebuild is done, which can leave the file with sensitive content world-readable for quite a long time. This commit makes the log file readable to root only, while the script is running, and applies default mode only after sensitive content has been reducted, for convenience and to remain a non-breaking change. An alternative would be to redact sensitive content right after it was written, in the `get_discourse_config()` function, but it would require more code and sensitive content might be printed later as well if a rebuild is done. Signed-off-by: MichaIng <[email protected]>
1 parent 617a8ab commit c084707

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

discourse-doctor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ clean_up_log_file() {
310310
echo "Replacing: $VAR"
311311
sed -i -e 's/'"$VAR"'\([=: ]\)\S*/'"$VAR"'\1REDACTED /g' $LOG_FILE
312312
done
313+
# allow others to read the log for convenience, now that sensitive content has been redacted
314+
chmod 0644 $LOG_FILE
313315
}
314316

315317
print_done() {
@@ -350,7 +352,7 @@ print_done() {
350352

351353
initialize_log_file() {
352354
rm -f $LOG_FILE
353-
touch $LOG_FILE
355+
install -m 0600 /dev/null $LOG_FILE
354356
log DISCOURSE DOCTOR $(date)
355357
log -e "OS: $(uname -a)\n\n"
356358
}

0 commit comments

Comments
 (0)