eBPF-based security platform
ci: allow Dependabot's DCO identity
Tobias Klauserd50ff705c52c
diff --git a/.github/scripts/check-dco.sh b/.github/scripts/check-dco.shindex 194621a3..73954c3e 100755--- a/.github/scripts/check-dco.sh+++ b/.github/scripts/check-dco.sh@@ -7,8 +7,8 @@# 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, 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.+# identity, as author, signer or co-developer, except for Dependabot's+# canonical author and sign-off identity. Merge commits are skipped.## .github/scripts/check-dco.sh [<rev-list arguments>]#@@ -47,6 +47,15 @@ impersonal() {return 1}+dependabot_identity() {+ printf '%s\n' "$(lower "$1")" |+ grep -Eq '^dependabot\[bot\] <[0-9]+\+dependabot\[bot\]@users\.noreply\.github\.com>$'+}++dependabot_signoff() {+ [ "$(lower "$1")" = 'dependabot[bot] <[email protected]>' ]+}+commits=$(git rev-list --no-merges "$@")for commit in $commits; do@@ -58,7 +67,7 @@ for commit in $commits; dosignoffs=$(printf '%s\n' "$message" | grep -i '^signed-off-by:' || :)codevs=$(printf '%s\n' "$message" | grep -i '^co-developed-by:' || :)- if impersonal "$author"; then+ if impersonal "$author" && ! dependabot_identity "$author"; thenreport "$id: the author is a noreply or bot identity, not a person: $author"bad=$((bad + 1))continue@@ -97,7 +106,8 @@ for commit in $commits; dowhile IFS= read -r line; dovalue=$(printf '%s' "$line" |sed 's/^[Ss][Ii][Gg][Nn][Ee][Dd]-[Oo][Ff][Ff]-[Bb][Yy]:[[:space:]]*//; s/[[:space:]]*$//')- if [ "$(lower "$value")" = "$(lower "$author")" ]; then+ if [ "$(lower "$value")" = "$(lower "$author")" ] ||+ { dependabot_identity "$author" && dependabot_signoff "$value"; }; thenby_author=1fi[ -z "$problem" ] || continue@@ -114,7 +124,8 @@ 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+ elif impersonal "$value" &&+ { ! dependabot_identity "$author" || ! dependabot_signoff "$value"; }; thenproblem="a noreply or bot identity cannot certify the DCO: $line"fidone <<EOTdiff --git a/Documentation/contribute/code/contributing.rst b/Documentation/contribute/code/contributing.rstindex 3f3d5877..bd924a59 100644--- a/Documentation/contribute/code/contributing.rst+++ b/Documentation/contribute/code/contributing.rst@@ -91,7 +91,7 @@ about which lines moved. The diff shows that.Sign your work---------------Every commit carries a ``Signed-off-by:`` line, with no exception. The+Every human-authored commit carries a ``Signed-off-by:`` line. Thesign-off certifies the Developer's Certificate of Origin, reproducedhere from the kernel's ``submitting-patches.rst``::@@ -129,8 +129,12 @@ using a known identity. Anonymous or pseudonymous sign-offs are notaccepted, and neither is an address nobody answers at: a GitHub noreplyaddress, 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.+``Co-developed-by:``. The sole exception is Dependabot's numbered+GitHub noreply author identity (the numeric prefix may vary) and+``dependabot[bot] <[email protected]>`` sign-off, which Dependabot+uses on generated commits. This is an automation exception, not a human+certification of the DCO.+``git commit -s`` and ``git revert -s`` add the line for you.A commit without a valid sign-off is not merged. A maintainer whoapplies a commit adds their own sign-off after the author's, so the@@ -146,7 +150,9 @@ merge commits:- The commit has a ``Signed-off-by:`` from its author, spelled exactlylike that and in the form ``Name <address>``.- No author, sign-off or ``Co-developed-by:`` names an identity that- contains ``noreply``, ``no-reply`` or ``[bot]``, in any case.+ contains ``noreply``, ``no-reply`` or ``[bot]``, in any case, except+ for Dependabot's numbered GitHub noreply author identity and+ ``dependabot[bot] <[email protected]>`` sign-off combination.CI runs it on every pull request and every push to ``main``, in the``DCO`` workflow.diff --git a/testing/ci-checks/t0001-check-dco.sh b/testing/ci-checks/t0001-check-dco.shindex 713a1e3a..f55b835d 100755--- a/testing/ci-checks/t0001-check-dco.sh+++ b/testing/ci-checks/t0001-check-dco.sh@@ -141,6 +141,28 @@ test_expect_success 'a range reports every failing commit once' 'grep -q "9 of 12 commits fail" "$W/err"'+test_expect_success 'Dependabot author and sign-off are accepted' '+ commit "a: Dependabot update++Why the change is made.++Signed-off-by: dependabot[bot] <[email protected]>" \+ --author="dependabot[bot] <123456789+dependabot[bot]@users.noreply.github.com>" &&+ check &&+ grep -q "DCO: 1 commits checked" "$W/out"+'++test_expect_success 'Dependabot cannot sign a human-authored commit' '+ commit "a: bot sign-off++Why the change is made.++Signed-off-by: Random J Developer <[email protected]>+Signed-off-by: dependabot[bot] <[email protected]>" &&+ ! check &&+ grep -q "cannot certify the DCO: Signed-off-by: dependabot\[bot\]" "$W/err"+'+test_expect_success 'merge commits are skipped' 'base=$(git -C "$R" rev-parse HEAD) &&git -C "$R" checkout -q -b side &&