Skip to content

eBPF-based security platform

ci: reject noreply and bot identities in the DCO check

Daniel Borkmannfaaa7d56d4a8
diff --git a/.github/scripts/check-dco.sh b/.github/scripts/check-dco.sh
index ff8292a9..d11af21f 100755
--- a/.github/scripts/check-dco.sh
+++ b/.github/scripts/check-dco.sh
@@ -5,8 +5,10 @@
# .github/scripts/check-dco.sh -- verify that every commit in a range has the
# message Documentation/contributing.rst asks for: a one-line subject, a
# body that says more than its tags, and the Signed-off-by of its author,
-# the Developer's Certificate of Origin. Merge commits are not signed in
-# the kernel's process and are skipped.
+# the Developer's Certificate of Origin, from an identity a person answers
+# at: a noreply address or a bot is no identity, as author, signer or
+# co-developer. Merge commits are not signed in the kernel's process and
+# are skipped.
#
# .github/scripts/check-dco.sh [<rev-list arguments>]
#
@@ -34,6 +36,17 @@ lower() {
printf '%s' "$1" | tr '[:upper:]' '[:lower:]'
}
+# The noreply addresses GitHub and the coding agents write with, and
+# anything called [bot], can neither be reached nor certify the DCO.
+impersonal() {
+ case "$(lower "$1")" in
+ *noreply*|*no-reply*|*'[bot]'*)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
commits=$(git rev-list --no-merges "$@")
for commit in $commits; do
@@ -43,6 +56,13 @@ for commit in $commits; do
author=$(git log -1 --format='%an <%ae>' "$commit")
message=$(git log -1 --format=%B "$commit")
signoffs=$(printf '%s\n' "$message" | grep -i '^signed-off-by:' || :)
+ codevs=$(printf '%s\n' "$message" | grep -i '^co-developed-by:' || :)
+
+ if impersonal "$author"; then
+ report "$id: the author is a noreply or bot identity, not a person: $author"
+ bad=$((bad + 1))
+ continue
+ fi
# The subject is the first paragraph and one line; the body follows
# the blank line after it, and tag lines alone do not make one.
@@ -94,11 +114,25 @@ for commit in $commits; do
if ! printf '%s\n' "$value" |
grep -Eq '^[^<>]*[^<>[:space:]][^<>]* <[^<>@[:space:]]+@[^<>@[:space:]]+>$'; then
problem="malformed sign-off, expected 'Name <email>', found: $line"
+ elif impersonal "$value"; then
+ problem="a noreply or bot identity cannot certify the DCO: $line"
fi
done <<EOT
$signoffs
EOT
+ # A co-developer is an author too.
+ if [ -z "$problem" ] && [ -n "$codevs" ]; then
+ while IFS= read -r line; do
+ if impersonal "${line#*:}"; then
+ problem="a noreply or bot identity cannot be a co-developer: $line"
+ break
+ fi
+ done <<EOT
+$codevs
+EOT
+ fi
+
if [ -n "$problem" ]; then
report "$id: $problem"
elif [ "$by_author" -eq 0 ]; then
diff --git a/AGENTS.md b/AGENTS.md
index 7c9fc8c5..e04f4fd4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -301,8 +301,9 @@ one usually still compiles and passes tests.
the expression, the dual licence for everything a BPF object compiles
and a Beefile ships. `.github/scripts/check-dco.sh <range>` checks
that every commit has a one-line subject, a body beyond its tags and
- the author's sign-off. CI runs both on every pull request; run them
- before handing work over.
+ the author's sign-off from a real address: a noreply address or a
+ `[bot]` is rejected as author, signer or co-developer. CI runs both
+ on every pull request; run them before handing work over.
- Shell that a workflow runs lives in `.github/scripts/`, not inline in
the workflow file.
- `make -C packaging bindeb-pkg`, `make -C packaging binrpm-pkg` and `make -C packaging bintar-pkg` build the
diff --git a/Documentation/contributing.rst b/Documentation/contributing.rst
index b54a6c39..d3ed7983 100644
--- a/Documentation/contributing.rst
+++ b/Documentation/contributing.rst
@@ -121,15 +121,19 @@ If you can certify that, add::
Signed-off-by: Random J Developer <[email protected]>
using a known identity; anonymous or pseudonymous sign-offs are not
-accepted. ``git commit -s`` and ``git revert -s`` add the line for you.
+accepted, and neither is an address nobody answers at: a GitHub noreply
+address, the address a coding agent writes with, or anything called
+``[bot]`` is rejected as the author, in a ``Signed-off-by:`` and in a
+``Co-developed-by:``. ``git commit -s`` and ``git revert -s`` add the
+line for you.
A commit without a valid sign-off is not merged, and a maintainer who
applies a commit adds their own sign-off after the author's, so the
chain of ``Signed-off-by:`` lines records the real route the change
took. The first sign-off is the author's; the last is the person who
submits the commit. ``.github/scripts/check-dco.sh`` verifies that
every commit in a range has a one-line subject, a body that says more
-than its tags and its author's sign-off, and CI runs it on every pull
-request as the ``DCO`` check.
+than its tags and its author's sign-off from a real address, and CI
+runs it on every pull request as the ``DCO`` check.
Only a person can certify the DCO. Coding agents and other automated
tools must never add a ``Signed-off-by:`` line; the human who reviews
diff --git a/testing/t0041-check-dco.sh b/testing/t0041-check-dco.sh
index 88a5face..f1dd3ef7 100755
--- a/testing/t0041-check-dco.sh
+++ b/testing/t0041-check-dco.sh
@@ -156,6 +156,50 @@ Why the change is made." -s &&
grep -q "DCO: 2 commits checked" "$W/out"
'
+test_expect_success 'a bot is not an author' '
+ commit "a: bot author
+
+Why the change is made.
+
+Signed-off-by: helper[bot] <[email protected]>" \
+ --author="helper[bot] <[email protected]>" &&
+ ! check &&
+ grep -q "the author is a noreply or bot identity, not a person: helper\[bot\] <[email protected]>" "$W/err"
+'
+
+test_expect_success 'a noreply sign-off cannot certify the DCO' '
+ commit "a: noreply sign-off
+
+Why the change is made.
+
+Signed-off-by: Random J Developer <[email protected]>
+Signed-off-by: Some Agent <[email protected]>" &&
+ ! check &&
+ grep -q "cannot certify the DCO: Signed-off-by: Some Agent <[email protected]>" "$W/err"
+'
+
+test_expect_success 'a GitHub privacy address is no identity either' '
+ commit "a: privacy address
+
+Why the change is made.
+
+Signed-off-by: Random J Developer <[email protected]>" \
+ --author="Random J Developer <[email protected]>" &&
+ ! check &&
+ grep -q "the author is a noreply or bot identity" "$W/err"
+'
+
+test_expect_success 'a noreply co-developer is rejected' '
+ commit "a: noreply co-developer
+
+Why the change is made.
+
+Co-developed-by: Some Agent <[email protected]>
+Signed-off-by: Random J Developer <[email protected]>" &&
+ ! check &&
+ grep -q "cannot be a co-developer: Co-developed-by: Some Agent <[email protected]>" "$W/err"
+'
+
test_expect_success 'an unknown range fails' '
! check nonexistent..HEAD
'