Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
shell history: whitelist self
Browse files Browse the repository at this point in the history
addresses #24
  • Loading branch information
williballenthin committed Mar 25, 2020
1 parent f07cb6b commit d13ddb4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scanners/shell-history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ shell_history_paths[0]="/var/log/bash.log";
shell_history_paths[1]="/var/log/notice.log";
shell_history_paths[2]="/var/log/sh.log";

# addresses issue 24
readonly whitelist="declare -a notrobin_paths;";

scan_shell_history() {
for path in "${shell_history_paths[@]}"; do
if ! compgen -G "$root_directory/$path*" >/dev/null; then
Expand All @@ -66,7 +69,7 @@ scan_shell_history() {
local found=false;
for re in "${shell_history_blacklist[@]}"; do
# /dev/null to ensure at least one of these files exists so zgrep doesn't fail
local entries=$(zgrep -F "$re" "$root_directory/$path"* /dev/null);
local entries=$(zgrep -F "$re" "$root_directory/$path"* /dev/null | grep -v "$whitelist");
if [ -n "$entries" ]; then
found=true;
report_match "blacklisted content '$re'";
Expand Down

0 comments on commit d13ddb4

Please sign in to comment.