linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Don't count URLs for "line too long"
@ 2022-09-27  2:15 Kees Cook
  2022-09-27  5:40 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2022-09-27  2:15 UTC (permalink / raw)
  To: Andy Whitcroft
  Cc: Kees Cook, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel, linux-hardening

URLs (not in a Link: field) should be ignored for "line too long"
warnings. Allow any line containing "https://" or "http://".

Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 scripts/checkpatch.pl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 79e759aac543..d4dec90673b7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3175,6 +3175,8 @@ sub process {
 					# file delta changes
 		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
 					# filename then :
+		      $line =~ /https?:\/\// ||
+					# URLs
 		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
 					# A Fixes: or Link: line or signature tag line
 		      $commit_log_possible_stack_dump)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Don't count URLs for "line too long"
  2022-09-27  2:15 [PATCH] checkpatch: Don't count URLs for "line too long" Kees Cook
@ 2022-09-27  5:40 ` Joe Perches
  2022-09-27 14:07   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2022-09-27  5:40 UTC (permalink / raw)
  To: Kees Cook, Andy Whitcroft, yashsri421
  Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel, linux-hardening

On Mon, 2022-09-26 at 19:15 -0700, Kees Cook wrote:
> URLs (not in a Link: field) should be ignored for "line too long"
> warnings. Allow any line containing "https://" or "http://".

More generally, this should be for any URI

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3175,6 +3175,8 @@ sub process {
>  					# file delta changes
>  		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
>  					# filename then :
> +		      $line =~ /https?:\/\// ||
> +					# URLs
>  		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
>  					# A Fixes: or Link: line or signature tag line
>  		      $commit_log_possible_stack_dump)) {

And I don't recollect why this wasn't applied, but I think it's a rather better,
more complete, patch:

https://lore.kernel.org/lkml/20210114073513.15773-2-yashsri421@gmail.com/

I believe I did ack it and forward it to Andrew Morton, but I don't
see it on a lore list.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Don't count URLs for "line too long"
  2022-09-27  5:40 ` Joe Perches
@ 2022-09-27 14:07   ` Kees Cook
  2022-09-27 20:39     ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2022-09-27 14:07 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andy Whitcroft, yashsri421, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel, linux-hardening

On Mon, Sep 26, 2022 at 10:40:50PM -0700, Joe Perches wrote:
> On Mon, 2022-09-26 at 19:15 -0700, Kees Cook wrote:
> > URLs (not in a Link: field) should be ignored for "line too long"
> > warnings. Allow any line containing "https://" or "http://".
> 
> More generally, this should be for any URI
> 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -3175,6 +3175,8 @@ sub process {
> >  					# file delta changes
> >  		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
> >  					# filename then :
> > +		      $line =~ /https?:\/\// ||
> > +					# URLs
> >  		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
> >  					# A Fixes: or Link: line or signature tag line
> >  		      $commit_log_possible_stack_dump)) {
> 
> And I don't recollect why this wasn't applied, but I think it's a rather better,
> more complete, patch:
> 
> https://lore.kernel.org/lkml/20210114073513.15773-2-yashsri421@gmail.com/
> 
> I believe I did ack it and forward it to Andrew Morton, but I don't
> see it on a lore list.

Many patches have internal references in the commit log (that aren't
appropriate for "Link:") like:

[1] https://some.domain/path/

It seems more flexible to just ignore lines with "http" in it...

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Don't count URLs for "line too long"
  2022-09-27 14:07   ` Kees Cook
@ 2022-09-27 20:39     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2022-09-27 20:39 UTC (permalink / raw)
  To: Kees Cook, ditya Srivastava
  Cc: Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn, linux-kernel,
	linux-hardening

On Tue, 2022-09-27 at 07:07 -0700, Kees Cook wrote:
> On Mon, Sep 26, 2022 at 10:40:50PM -0700, Joe Perches wrote:
> > On Mon, 2022-09-26 at 19:15 -0700, Kees Cook wrote:
> > > URLs (not in a Link: field) should be ignored for "line too long"
> > > warnings. Allow any line containing "https://" or "http://".
> > 
> > More generally, this should be for any URI
> > 
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > []
> > > @@ -3175,6 +3175,8 @@ sub process {
> > >  					# file delta changes
> > >  		      $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
> > >  					# filename then :
> > > +		      $line =~ /https?:\/\// ||
> > > +					# URLs
> > >  		      $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
> > >  					# A Fixes: or Link: line or signature tag line
> > >  		      $commit_log_possible_stack_dump)) {
> > 
> > And I don't recollect why this wasn't applied, but I think it's a rather better,
> > more complete, patch:
> > 
> > https://lore.kernel.org/lkml/20210114073513.15773-2-yashsri421@gmail.com/
> > 
> > I believe I did ack it and forward it to Andrew Morton, but I don't
> > see it on a lore list.
> 
> Many patches have internal references in the commit log (that aren't
> appropriate for "Link:") like:
> 
> [1] https://some.domain/path/
> 
> It seems more flexible to just ignore lines with "http" in it...

URLs vs URIs which can have multiple forms.

Take a look at the results of this grep:

$ git log -1000000 --format=email --no-merges --grep='://' | grep '://' | \
  grep -v -P 'https?://' | grep -P -oh '\b\w+://' | \
  sort | uniq -c | sort -rn
    422 git://
     46 ftp://
     15 file://
     10 smb://
      5 c://
      3 usbip://
      2 svn://
      2 rsync://
      2 pvr://
      1 ttp://
      1 systemd://
      1 server://
      1 radio://
      1 nbd://
      1 irc://
      1 intel_bts://
      1 htp://
      1 40176://

The more inclusve search pattern finds many uses of git:// and ftp:// 
(and probably a few typos too)

Assuming the URI scheme uses ://, it's perhaps reasonable to change the
suggested search in Aditya's patch from

+			if ($line =~ /^\s*([a-z][\w\.\+\-]*:\/\/\S+)/i) {

to maybe something like this so the URI's use of :// is more obvious

+			if ($line =~ m@^.*\b([a-z][\w\.\+\-]*://\S+)@i) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-27 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27  2:15 [PATCH] checkpatch: Don't count URLs for "line too long" Kees Cook
2022-09-27  5:40 ` Joe Perches
2022-09-27 14:07   ` Kees Cook
2022-09-27 20:39     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).