From: Stefan Berger <stefanb@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: zohar@linux.ibm.com, Stefan Berger <stefanb@linux.ibm.com>,
Roberto Sassu <roberto.sassu@huawei.com>
Subject: [ima-evm-utils PATCH v2 14/14] tests: Address issues raised by shellcheck SC2003
Date: Tue, 28 Nov 2023 13:16:12 -0500 [thread overview]
Message-ID: <20231128181613.1159958-15-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20231128181613.1159958-1-stefanb@linux.ibm.com>
Address issues detected by shellcheck SC2003:
expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
The following statement in portable_signatures.test causes the issue:
expr index "$TST_LIST" "check_evm_revalidate"
The man page for expr states:
index STRING CHARS
index in STRING where any CHARS is found, or 0
The intention is certainly not to find an index of any of the characters
in "check_evm_revalidate" in $TST_LIST but to find the word
"check_evm_revalidate" in $TST_LIST. Therefore, use grep -w to determine
whether the word is there.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Cc: Roberto Sassu <roberto.sassu@huawei.com>
---
tests/Makefile.am | 2 --
tests/portable_signatures.test | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7b3d92b..a95c4d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,8 +27,6 @@ distclean: distclean-keys
shellcheck:
shellcheck \
- -i SC2086,SC2181,SC2046,SC2320,SC2317,SC2034,SC2164,SC2166 \
- -i SC2294,SC2206,SC2196,SC2043,SC2295 \
functions.sh gen-keys.sh install-fsverity.sh \
install-mount-idmapped.sh install-openssl3.sh \
install-swtpm.sh install-tss.sh softhsm_setup \
diff --git a/tests/portable_signatures.test b/tests/portable_signatures.test
index 7ddd149..10b0ad8 100755
--- a/tests/portable_signatures.test
+++ b/tests/portable_signatures.test
@@ -1090,7 +1090,7 @@ if [ $((evm_value & EVM_INIT_X509)) -ne "$EVM_INIT_X509" ] && [ "$TST_EVM_CHANGE
echo "$EVM_INIT_X509" > /sys/kernel/security/evm 2> /dev/null
fi
-if [ "$(expr index "$TST_LIST" "check_evm_revalidate")" -gt 0 ] && [ "$TST_EVM_CHANGE_MODE" -eq 1 ]; then
+if echo "$TST_LIST" | grep -q -w check_evm_revalidate && [ "$TST_EVM_CHANGE_MODE" -eq 1 ]; then
echo "$EVM_ALLOW_METADATA_WRITES" > /sys/kernel/security/evm 2> /dev/null
fi
--
2.43.0
prev parent reply other threads:[~2023-11-28 18:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 18:15 [ima-evm-utils PATCH v2 00/14] Enable shellcheck and fix some issues Stefan Berger
2023-11-28 18:15 ` [ima-evm-utils PATCH v2 01/14] tests: Address issues raised by shellcheck SC2086 & enable shellcheck Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 02/14] tests: Address issues raised by shellcheck SC2181 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 03/14] tests: Address issues raised by shellcheck SC2046 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 04/14] tests: Address issues raised by shellcheck SC2320 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 05/14] tests: Address issues raised by shellcheck SC2317 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 06/14] tests: Address issues raised by shellcheck SC2034 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 07/14] tests: Address issues raised by shellcheck SC2164 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 08/14] tests: Address issues raised by shellcheck SC2166 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 09/14] tests: Address issues raised by shellcheck SC2294 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 10/14] tests: Address issues raised by shellcheck SC2206 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 11/14] tests: Address issues raised by shellcheck SC2196 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 12/14] tests: Address issues raised by shellcheck SC2043 Stefan Berger
2023-11-28 18:16 ` [ima-evm-utils PATCH v2 13/14] tests: Address issues raised by shellcheck SC2295 Stefan Berger
2023-11-28 18:16 ` Stefan Berger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231128181613.1159958-15-stefanb@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).