sensitive-log.sh 511 B

123456789
  1. #!/bin/sh
  2. # Strips sensitive passwords from (Apache) logs
  3. # For e.g. GNU systems such as Debian
  4. # N.B.: `sed -u` is not available in BusyBox and without it there are buffering delays (even with stdbuf)
  5. sed -Eu 's/([?&])(Passwd|token)=[^& \t]+/\1\2=redacted/ig' 2>/dev/null ||
  6. # For systems with gawk (not available by default in Docker of Debian or Alpine) or with BuzyBox such as Alpine
  7. $(which gawk || which awk) -v IGNORECASE=1 '{ print gensub(/([?&])(Passwd|token)=[^& \t]+/, "\\1\\2=redacted", "g") }'