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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1685749151.185639.1410884118738.open-xchange@webmail.nmp.skynet.be>
Date:	Tue, 16 Sep 2014 18:15:18 +0200 (CEST)
From:	Fabian Frederick <fabf@...net.be>
To:	Joe Perches <joe@...ches.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] checkpatch: check for subject uniqueness in git
 repository.



> On 16 September 2014 at 05:22 Joe Perches <joe@...ches.com> wrote:
>
>
> On Mon, 2014-09-15 at 20:43 +0200, Fabian Frederick wrote:
> > Adding patch subject uniqueness check in checkpatch --strict mode.
> > See Documentation/SubmittingPatches/globally-unique identifier.
>
> Perhaps something like this?
> ---
>  scripts/checkpatch.pl | 52
>+++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 0c520f7..e19c40b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -622,6 +622,27 @@ sub git_commit_info {
>       return ($id, $desc);
>  }
> 
> +my @git_commits = ();
> +my @previous_subjects = ();
> +
> +sub check_subject_duplication {
> +     my ($subject) = @_;
> +
> +     if ($check && $#git_commits < 1 && which("git") && -e ".git") {
> +             my $output = `git log --no-color --format='%H %s' 2>&1`;
> +             $output =~ s/^\s*//gm;
> +             @git_commits = split("\n", $output);
> +     }
> +
> +     return 1 if (grep(/^[a-f0-9]{40,40} $subject$/, @git_commits));
> +
> +     return 2 if (grep(/^$subject$/, @previous_subjects));
> +
> +     push(@previous_subjects, $subject);
> +
> +     return 0;
> +}
> +
>  $chk_signoff = 0 if ($file);
> 
>  my @rawlines = ();
> @@ -1264,6 +1285,20 @@ sub raw_line {
>       return $line;
>  }
> 
> +sub get_complete_header {
> +     my ($linenr) = @_;
> +
> +     my $offset = $linenr - 1;
> +
> +     my $line = $rawlines[$offset++];
> +     while (defined $rawlines[$offset] &&
> +            $rawlines[$offset] =~ /\s(\S.*)$/) {
> +             $line .= $rawlines[$offset++];
> +     }
> +
> +     return $line;
> +}
> +
>  sub cat_vet {
>       my ($vet) = @_;
>       my ($res, $coded);
> @@ -2047,6 +2082,23 @@ sub process {
>                       }
>               }
> 
> +# Check git commit and patch subject duplication
> +             if ($in_header_lines && $line =~ /^Subject:/) {
> +                     my $subject = get_complete_header($linenr);
> +                     if ($subject =~ /^Subject:\s*(?:\[[^\]]*\])?\s*(.*)$/) {
> +                             $subject = $1;
> +                     }
> +
> +                     my $subject_dup = check_subject_duplication($subject);
> +                     if ($subject_dup == 1) {
> +                             CHK("NOT_UNIQUE_SUBJECT",
> +                                 "Identical git commit subject found\n" .
> $herecurr);
> +                     } elsif ($subject_dup == 2) {
> +                             CHK("NOT_UNIQUE_SUBJECT",
> +                                 "Identical patch commit subject found\n" .
> $herecurr);
> +                     }
> +             }
> +
>  # Check the patch for a signoff:
>               if ($line =~ /^\s*signed-off-by:/i) {
>                       $signoff++;
>
>
Perfect ! :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ