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.shindex 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; doauthor=$(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; doif ! printf '%s\n' "$value" |grep -Eq '^[^<>]*[^<>[:space:]][^<>]* <[^<>@[:space:]]+@[^<>@[:space:]]+>$'; thenproblem="malformed sign-off, expected 'Name <email>', found: $line"+ elif impersonal "$value"; then+ problem="a noreply or bot identity cannot certify the DCO: $line"fidone <<EOT$signoffsEOT+ # 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" ]; thenreport "$id: $problem"elif [ "$by_author" -eq 0 ]; thendiff --git a/AGENTS.md b/AGENTS.mdindex 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 compilesand a Beefile ships. `.github/scripts/check-dco.sh <range>` checksthat 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 inthe workflow file.- `make -C packaging bindeb-pkg`, `make -C packaging binrpm-pkg` and `make -C packaging bintar-pkg` build thediff --git a/Documentation/contributing.rst b/Documentation/contributing.rstindex 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 whoapplies a commit adds their own sign-off after the author's, so thechain of ``Signed-off-by:`` lines records the real route the changetook. The first sign-off is the author's; the last is the person whosubmits the commit. ``.github/scripts/check-dco.sh`` verifies thatevery 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 automatedtools must never add a ``Signed-off-by:`` line; the human who reviewsdiff --git a/testing/t0041-check-dco.sh b/testing/t0041-check-dco.shindex 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'