Skip to content

Commit 04f19f8

Browse files
committed
cra-kit: address Skoll review findings
Fail early when the wolfSSL tree version differs from the kit's pinned VERSION instead of a cryptic cp error, trap-clean the embedded temp defines file on all exit paths, add sh -n + shellcheck CI coverage for the scripts, and use the standard file:./ relative form in the product SBOM external references. Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
1 parent c003219 commit 04f19f8

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

.github/workflows/cra-kit.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ jobs:
2020
python-version: '3.x'
2121
- name: Validate pinned auditor packet
2222
run: ./cra-kit/scripts/validate.sh
23+
- name: Shell syntax check (sh -n)
24+
run: |
25+
for s in cra-kit/scripts/*.sh; do
26+
echo "sh -n $s"
27+
sh -n "$s"
28+
done
29+
- name: ShellCheck scripts
30+
run: shellcheck cra-kit/scripts/*.sh

cra-kit/auditor-packet/product-acme-connect-gateway.cdx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"externalReferences": [
3131
{
3232
"type": "bom",
33-
"url": "file:wolfssl-component/wolfssl-5.9.1.cdx.json",
33+
"url": "file:./wolfssl-component/wolfssl-5.9.1.cdx.json",
3434
"comment": "Component SBOM from wolfSSL; regenerate with scripts/generate-wolfssl-sbom.sh",
3535
"hashes": [
3636
{

cra-kit/auditor-packet/product-acme-connect-gateway.spdx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"externalDocumentRefs": [
1414
{
1515
"externalDocumentId": "DocumentRef-wolfssl",
16-
"spdxDocument": "file:wolfssl-component/wolfssl-5.9.1.spdx.json",
16+
"spdxDocument": "file:./wolfssl-component/wolfssl-5.9.1.spdx.json",
1717
"checksum": {
1818
"algorithm": "SHA256",
1919
"checksumValue": "36fdc0c8a192a0fadc4c5024ff75ecee3a56dd8a431dfb25bfa8afcf467cfdef"

cra-kit/scripts/generate-wolfssl-sbom.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,17 @@ _run_embedded() {
117117
echo " fallback reflects target macros, not the host's."
118118

119119
DEFINES_H="$OUT_DIR/.wolfssl-defines-$$.h"
120+
# Clean up the temp defines file on every exit path, including a failing
121+
# generator run (it previously leaked the dotfile under `set -e` if the
122+
# final gen-sbom invocation failed before the manual `rm -f`).
123+
trap 'rm -f "$DEFINES_H"' EXIT
120124
CC=${CC:-cc}
121125
if ! "$CC" -dM -E \
122126
-I"$WOLFSSL_DIR" \
123127
-I"$KIT_DIR" \
124128
-DWOLFSSL_USER_SETTINGS \
125129
-include "$SETTINGS_H" \
126130
-x c /dev/null >"$DEFINES_H" 2>/dev/null; then
127-
rm -f "$DEFINES_H"
128131
echo "ERROR: $CC -dM -E failed; install pcpp or set CC to your cross-compiler." >&2
129132
exit 1
130133
fi
@@ -137,11 +140,24 @@ _run_embedded() {
137140
--license-file "$WOLFSSL_DIR/LICENSING" \
138141
--options-h "$DEFINES_H" \
139142
--srcs $@
140-
rm -f "$DEFINES_H"
141143
}
142144

143145
_run_autotools() {
144146
echo "==> Autotools path: make sbom"
147+
# `make sbom` names its output after the wolfSSL TREE's version
148+
# (PACKAGE_VERSION), not the kit's pinned VERSION. If they differ, the
149+
# `cp` below would otherwise fail with a cryptic "No such file or
150+
# directory" under `set -eu`. Detect the mismatch early and explain it.
151+
_tree_ver=$(sed -n \
152+
's/.*LIBWOLFSSL_VERSION_STRING[[:space:]]*"\([^"]*\)".*/\1/p' \
153+
"$WOLFSSL_DIR/wolfssl/version.h" 2>/dev/null || true)
154+
if [ -n "$_tree_ver" ] && [ "$_tree_ver" != "$VERSION" ]; then
155+
echo "ERROR: wolfSSL tree is version $_tree_ver but the kit is pinned to $VERSION." >&2
156+
echo " 'make sbom' emits wolfssl-${_tree_ver}.* while the pinned auditor" >&2
157+
echo " packet references wolfssl-${VERSION}.*. Check out a wolfSSL $VERSION" >&2
158+
echo " tree, or update cra-kit/VERSION (and the pinned sample references)." >&2
159+
exit 1
160+
fi
145161
(cd "$WOLFSSL_DIR" && {
146162
if [ ! -f Makefile ]; then
147163
echo " Running ./configure first..."

0 commit comments

Comments
 (0)