ima-evm-utils: tests: fix finding the "boot_aggregate" value
diff mbox series

Message ID 1592964652-30446-1-git-send-email-zohar@linux.ibm.com
State New
Headers show
Series
  • ima-evm-utils: tests: fix finding the "boot_aggregate" value
Related show

Commit Message

Mimi Zohar June 24, 2020, 2:10 a.m. UTC
Searching for the last "boot_aggregate" record in the measurement list
could inadvertently match a filename containing the string
"boot_aggregate".  Prevent this from happening.

Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 tests/boot_aggregate.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bruno Meneguele June 24, 2020, 9:52 p.m. UTC | #1
On Tue, Jun 23, 2020 at 10:10:52PM -0400, Mimi Zohar wrote:
> Searching for the last "boot_aggregate" record in the measurement list
> could inadvertently match a filename containing the string
> "boot_aggregate".  Prevent this from happening.
> 
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> ---
>  tests/boot_aggregate.test | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/boot_aggregate.test b/tests/boot_aggregate.test
> index 3e961ce5f9aa..fe0c9aa1898e 100755
> --- a/tests/boot_aggregate.test
> +++ b/tests/boot_aggregate.test
> @@ -121,7 +121,7 @@ check() {
>  		if [ "$VERBOSE" != "0" ]; then
>  			echo "$hash"
>  		fi
> -		if grep -e "boot_aggregate$" -e "boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then
> +		if grep -e " boot_aggregate$" -e " boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then
>  			echo "${GREEN}SUCCESS: boot_aggregate ${hash} found${NORM}"
>  			return "$OK"
>  		fi
> -- 
> 2.7.5
> 

Considering whitespaces in between file name words are translated to "_"
(underscore) in measurement file:

Reviewed-by: Bruno Meneguele <bmeneg@redhat.com>

Patch
diff mbox series

diff --git a/tests/boot_aggregate.test b/tests/boot_aggregate.test
index 3e961ce5f9aa..fe0c9aa1898e 100755
--- a/tests/boot_aggregate.test
+++ b/tests/boot_aggregate.test
@@ -121,7 +121,7 @@  check() {
 		if [ "$VERBOSE" != "0" ]; then
 			echo "$hash"
 		fi
-		if grep -e "boot_aggregate$" -e "boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then
+		if grep -e " boot_aggregate$" -e " boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then
 			echo "${GREEN}SUCCESS: boot_aggregate ${hash} found${NORM}"
 			return "$OK"
 		fi