lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 08 Aug 2018 14:03:14 -0700
From:   Joe Perches <joe@...ches.com>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Andy Whitcroft <apw@...onical.com>
Cc:     Greg KH <gregkh@...uxfoundation.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH] checkpatch: Attempt to validate patch email subject
 lines

Patch subject lines should follow the form described in
Documentation/process/submitting-patches.rst, so attempt
to validate the "Subject: " lines.

Signed-off-by: Joe Perches <joe@...ches.com>
---

I tested it against the LKML "Subject:" lines I had around
(attached as subjects.gz).

I believe it's OK as many of those subjects aren't really
patches but acks and such.

Dunno if this works all that well, but perhaps it's a start.

Feedback welcomed.

 scripts/checkpatch.pl | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ce72cc4784e6..b529d8bcc2a4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -860,6 +860,25 @@ sub is_SPDX_License_valid {
 	return 1;
 }
 
+sub validate_patch_subject {
+	my ($line) = @_;
+
+	$line =~ s/^Subject:\s*//i;
+
+	return 0 if ($line =~ /^\s*\[\s*git\s+pull\s*\]/i);
+
+	# remove [RFC] or [TRIVIAL] prefix
+	$line =~ s/^\[\s*(?i:RFC|TRIVIAL)\s*\]\s*//;
+
+	# not ok if unlike [<rfc|trivial> PATCH <some tree> <vN> <x/y>]
+	return -1 if (0 == $line =~ s/^\[(?:(?i:rfc\s+trivial|rfc|trivial\s+rfc|trivial)\s+)?PATCH(?:\s+(?i:(?i:v\d+\s+[a-z-]+|v\d+|[a-z-]+)\s*))?(?:\s*\d+\/\d+)?\]\s+//);
+
+	# not ok if doesn't have 'subsystem:'
+	return -2 if (0 == $line =~ s/[\w\/\.\-]+:\s+//);
+
+	return 0;
+}
+
 my $camelcase_seeded = 0;
 sub seed_camelcase_includes {
 	return if ($camelcase_seeded);
@@ -2648,6 +2667,14 @@ sub process {
 			     "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
 		}
 
+# Check email subject [PATCH] style
+		if ($in_header_lines &&
+		    $line =~ /^Subject:/i &&
+		    (my $error = validate_patch_subject($line)) < 0) {
+			WARN("PATCH_SUBJECT",
+			     "A patch subject line should use the form described in 'Documentation/process/submitting-patches.rst'\n" . $herecurr);
+		}
+
 # Check for unwanted Gerrit info
 		if ($in_commit_log && $line =~ /^\s*change-id:/i) {
 			ERROR("GERRIT_CHANGE_ID",


Download attachment "subjects.gz" of type "application/gzip" (307209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ