Skip to content

eBPF-based security platform

docs: check the console examples of the generators and of a path

John Fastabend8a3b249b4be8
diff --git a/.github/scripts/check-docs.sh b/.github/scripts/check-docs.sh
index c06ab34b..3c74a8c0 100755
--- a/.github/scripts/check-docs.sh
+++ b/.github/scripts/check-docs.sh
@@ -3,7 +3,8 @@
# Copyright (c) 2026 Authors of shirudo
#
# .github/scripts/check-docs.sh -- check Documentation/ against the tree:
-# every option a console example passes to shirudo exists in a parser,
+# every option a console example passes to shirudo or to one of its
+# generators exists in a parser,
# every failure category the code emits, every tamper and integrity
# counter and every proof has its entry in the reference, every hook,
# counter, test, proof and unit a page names exists, every LSM program
@@ -44,9 +45,14 @@ find Documentation -name '*.rst' -not -path 'Documentation/output*' \
# in, as that one starts another. What a command hands to another
# program, after a pipe, in a list or in a substitution, is not
# shirudo's, and neither is a comment; a quote hides all of these, and
-# so does a placeholder such as <a|b>.
+# so does a placeholder such as <a|b>. shirudo is the binary under each
+# name it is installed as, with or without a path, and the image and
+# initrd generators, whose scripts are among the parsers below. A path
+# holds no =: NAME=dir/shirudo sets a variable for another command.
+shirudo='([^ \t=]*/)?shirudo(-runtime|-target|-gen-[a-z]+)?( |$)'
while IFS= read -r page; do
- awk '
+ awk -v prompt="^[ \t]+(operator[$]|target#|[$]|#) $shirudo" \
+ -v first="^[ \t]*$shirudo" '
# What of a command line shirudo runs, and in unfinished whether
# the line ends where the shell would read on. keep[d] says whether
# the command at nesting depth d is shirudo, quoted[d] whether it
@@ -64,7 +70,7 @@ while IFS= read -r page; do
next_c = substr(line, i + 1, 1)
prev_c = i > 1 ? substr(line, i - 1, 1) : " "
if (start) {
- keep[d] = substr(line, i) ~ /^[ \t]*shirudo( |$)/
+ keep[d] = substr(line, i) ~ first
start = 0
}
if (c == "\\") {
@@ -124,7 +130,7 @@ while IFS= read -r page; do
joined = 0
}
joined && /^[ \t]*$|^[ \t]+(operator\$|target#|\$|#) / { finish() }
- !joined && !/^[ \t]+(operator\$|target#|\$|#) shirudo( |$)/ { next }
+ !joined && $0 !~ prompt { next }
{
continued = sub(/\\[ \t]*$/, "")
command = command $0
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index d3acf388..6b9671cf 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -91,12 +91,13 @@ signed config image.
substitutes and of a comment, which are not shirudo's, a pipe,
list or comment inside a quote or a placeholder, a shirudo
command behind a pipe or in a substitution, one that goes on
- after a line ending inside a substitution, the whole of each
- field of a threat's fact box, a hook by its section, each tamper
- and integrity counter's entry on its page, the source files a
- proof reads or the proof coverage page lists as read by none, a
- figure against its TikZ source and one without a source, and the
- tree itself
+ after a line ending inside a substitution, the binary under a
+ path and its other names, a generator, the whole of each field
+ of a threat's fact box, a hook by its section, each tamper and
+ integrity counter's entry on its page, the source files a proof
+ reads or the proof coverage page lists as read by none, a figure
+ against its TikZ source and one without a source, and the tree
+ itself
* - ``t0009-check-unused``
- ``check-unused.sh``: an extern function nothing calls, with its
type on its line or the one above, a header's declaration that is
diff --git a/testing/ci-checks/t0008-check-docs.sh b/testing/ci-checks/t0008-check-docs.sh
index 0c979c4e..d1f6f619 100755
--- a/testing/ci-checks/t0008-check-docs.sh
+++ b/testing/ci-checks/t0008-check-docs.sh
@@ -3,11 +3,13 @@
# Copyright (c) 2026 Authors of shirudo
#
# t0008 -- .github/scripts/check-docs.sh: the options of a console
-# example on every line of its command and none of another program's,
-# the whole of each field of a threat's fact box, a hook by its section,
-# the programs and counters no threat names, the source files a proof
-# reads or the coverage page lists as read by none, and a figure against
-# its TikZ source, on a throwaway repository, and the tree itself.
+# example on every line of its command, under each name of the binary
+# and of a generator, and none of another program's, the whole of each
+# field of a threat's fact box, a hook by its section, the programs and
+# counters no threat names, the source files a proof reads or the
+# coverage page lists as read by none, and a figure against its TikZ
+# source, on a throwaway repository, and the tree itself.
+
cd "$(dirname "$0")/.."
. ./test-lib.sh
command -v git >/dev/null 2>&1 || test_skip_all "git not installed"
@@ -186,6 +188,30 @@ test_expect_success 'a command that ends inside a substitution goes on' '
check
'
+test_expect_success 'the binary is checked under its other names and a path' '
+ good && console " target# /usr/local/bin/shirudo status --bogus" &&
+ refuses "no parser accepts --bogus" &&
+ good && console " target# shirudo-runtime status --bogus" &&
+ refuses "no parser accepts --bogus" &&
+ good && console " \$ ./shirudo-target status --bogus" &&
+ refuses "no parser accepts --bogus" &&
+ good && console " \$ shirudoctl --bogus" " \$ myshirudo --bogus" &&
+ check &&
+ good && console " \$ SHIRUDO=build/shirudo make --bogus" &&
+ check
+'
+
+test_expect_success 'a generator is checked against its script' '
+ good && put tools/gen-initrd/gen "case \$1 in" "--kver) ;;" "esac" &&
+ console " target# shirudo-gen-initrd \\" " --kver 7.4" \
+ " operator\$ /usr/libexec/shirudo/shirudo-gen-image --kver 7.4" &&
+ check &&
+ console " target# shirudo-gen-initrd \\" " --kverr 7.4" &&
+ refuses "no parser accepts --kverr" &&
+ console " operator\$ tools/gen-image/shirudo-gen-image --bogus" &&
+ refuses "no parser accepts --bogus"
+'
+
test_expect_success 'a hook on a continuation line is checked, by its section' '
good && sed -i "s|lsm.s/inode_setattr|lsm.s/inode_setattrx|" "$R/$TM" &&
refuses "no BPF program has the section lsm.s/inode_setattrx" &&