Fix password masking by collect for gzipped files

The zgrep syntax for a regex search was incorrect.
The -E argument is required.

This meant that if a gzipped file (ie: bash.log.gz)
was included in a collect, then its passwords would
not be redacted.

Closes-Bug: 1981101

Test Plan:
 Verify that a gzipped bash log has its password
 redacted when running collect on CentOS and Debian.

Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I497813949b65137a93a91bf58ede2c591fb15f62
This commit is contained in:
Al Bailey 2022-07-08 18:36:57 +00:00
parent 0584e3d7b0
commit 1763064edc
2 changed files with 2 additions and 2 deletions

View File

@ -123,7 +123,7 @@ for f in ${COLLECT_NAME_DIR}/var/log/bash.log.*.gz \
${COLLECT_NAME_DIR}/var/log/user.log.*.gz \
${COLLECT_NAME_DIR}/var/log/ldapscripts.log.*.gz
do
zgrep -q 'snmp|password' $f || continue
zgrep -q -E 'snmp|password' $f || continue
gunzip $f
unzipped=${f%%.gz}
sed -i -r 's/(snmp-comm-(delete|show)) *((\"[^\"]*\"|'\''[^'"'"']*'"'"'|[^ ]*) *){1,}/\1 xxxxxx/;

View File

@ -123,7 +123,7 @@ for f in ${COLLECT_NAME_DIR}/var/log/bash.log.*.gz \
${COLLECT_NAME_DIR}/var/log/user.log.*.gz \
${COLLECT_NAME_DIR}/var/log/ldapscripts.log.*.gz
do
zgrep -q 'snmp|password' $f || continue
zgrep -q -E 'snmp|password' $f || continue
gunzip $f
unzipped=${f%%.gz}
sed -i -r 's/(snmp-comm-(delete|show)) *((\"[^\"]*\"|'\''[^'"'"']*'"'"'|[^ ]*) *){1,}/\1 xxxxxx/;