From patchwork Thu Mar 11 00:14:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 27600 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 316F927BC51; Thu, 11 Mar 2021 00:18:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4B52227BC50 for ; Thu, 11 Mar 2021 00:18:11 +0000 (GMT) Received: from localhost ([::1]:50898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK91m-0004BN-CH for patchwork@mira.cbaines.net; Wed, 10 Mar 2021 19:18:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK91e-0004BF-Nf for guix-patches@gnu.org; Wed, 10 Mar 2021 19:18:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lK91e-00089P-GI for guix-patches@gnu.org; Wed, 10 Mar 2021 19:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lK91e-0006f8-AT for guix-patches@gnu.org; Wed, 10 Mar 2021 19:18:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46182] [PATCH] lint: Add 'check-git-protocol' checker. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 11 Mar 2021 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46182 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Leo Famulari Cc: 46182@debbugs.gnu.org Received: via spool by 46182-submit@debbugs.gnu.org id=B46182.161542185225574 (code B ref 46182); Thu, 11 Mar 2021 00:18:02 +0000 Received: (at 46182) by debbugs.gnu.org; 11 Mar 2021 00:17:32 +0000 Received: from localhost ([127.0.0.1]:52254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lK91A-0006eP-5l for submit@debbugs.gnu.org; Wed, 10 Mar 2021 19:17:32 -0500 Received: from mail-wm1-f44.google.com ([209.85.128.44]:41725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lK914-0006e8-QM for 46182@debbugs.gnu.org; Wed, 10 Mar 2021 19:17:30 -0500 Received: by mail-wm1-f44.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso11749144wmi.0 for <46182@debbugs.gnu.org>; Wed, 10 Mar 2021 16:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=CwvPDYND/f2qTozWtPmCEpv0xPZi4aAGpzPr2qGxogI=; b=rzRSQRIxlS079ObdnUk+ZW9+FFFiQpHD1mhe8QHxPfRZEWSXN3tQUxaunXWVTinGo/ eVKkE5ZIHde+f9LM3TPGCt+zQ60gsSf/+974Kn9eDEcnGvO1uqqy1bKczwQC9BxNE5I8 pAMOjbWzGX5DBNQVBco8lN1hzP+JnDCerCOiDWyecaDKgnvOk9kzmWeSfjKuf6XsJ/z2 oZJr0TByQYjE0XEEdY8tWsYEB5EcwG8JHlIXGffagWwF2Uxad+mAeJQ9YS4sY3kqiiON tDBN1BbMxmhEecf7LoO5BmEvkgkjSGrZymCmLXhXJFgAftlbZBSvJ+c56ebC4+H8RRIa X6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=CwvPDYND/f2qTozWtPmCEpv0xPZi4aAGpzPr2qGxogI=; b=aSd2xrC6YPzyT8Eh8+zDk7yWHYHrde+NwIFjOszCQndAfO9L+4AhrTHTTe0ZPsO9AK ObzPm6xzLueQMyOQKV7Y07RzY1l6+fcNn2RrG+BmsNKW7wWjMxjKTx9BvG2caDebHvPZ TCTQoVrvwJB0FPmjkgmuanLftl+BzkcinKa1KbdFUatkxGNIif4TVKj7t4PmDSpplceG 455MNvUHEJyzLIufJgpeCzB1FmZZ1zTp5viIWGYZcKtRD1GQ9riU4g8CgOkzbQtcg5jX 66wX+A/FJN15Gc649P5mJV0NCyPdMdF6wnIqRrEcXwxVg0Eg0hh2279qSSCq46tTIF2C 55zg== X-Gm-Message-State: AOAM532Db8CrLZIxggFL52jGe45le8WHNpMoz5eahXzfxGXQw70p7zPG HNl4rFP4Hqdb70PujyJYsCkWitNZdeA= X-Google-Smtp-Source: ABdhPJwJ9AZDoxf3gLm9Glc/1zRhK5wvXxGjWgSIwKRcYZm/x+2Z//af6aYuPRKOi+KJM5dO3T4Rlg== X-Received: by 2002:a05:600c:4844:: with SMTP id j4mr5548344wmo.179.1615421840911; Wed, 10 Mar 2021 16:17:20 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id 12sm965322wmw.43.2021.03.10.16.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 16:17:20 -0800 (PST) From: zimoun References: Date: Thu, 11 Mar 2021 01:14:33 +0100 In-Reply-To: (Leo Famulari's message of "Fri, 29 Jan 2021 20:04:06 -0500") Message-ID: <86a6rabl7a.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Leo, Giving a look to the bug tracker for the next release, I see this bug. :-) On Fri, 29 Jan 2021 at 20:04, Leo Famulari wrote: > We could also make it warn about use of the HTTP protocol (as opposed to > HTTPS). Your thoughts? > > * guix/lint.scm (check-git-protocol): New procedure. > (%local-checkers): Add 'git-protocol' checker. > * doc/guix.texi (Invoking guix lint): Document it. The doc/ does not apply anymore. Instead of these ’eqv?’ > +(define (check-git-protocol package) > + "Emit a warning if PACKAGE's source URI protocol is 'git://'." > + (define (check-source-uri-scheme uri) > + (if (eqv? (uri-scheme uri) 'git) [...] > + (let ((origin (package-source package))) > + (if (and (origin? origin) > + (eqv? (origin-method origin) git-fetch)) > + (check-source-uri-scheme > + (string->uri (git-reference-url (origin-uri origin)))) > + '()))) I propose ’match’ which is more coherent with the Guix style. Well, from my understanding. :-) Patch attached. Well, it could be nice to add a test in tests/guix-lint.sh for that. WDYT? Cheers, simon diff --git a/guix/lint.scm b/guix/lint.scm index 311bc94cc3..980f77c736 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -51,7 +51,7 @@ #:use-module (guix gnu-maintenance) #:use-module (guix cve) #:use-module ((guix swh) #:hide (origin?)) - #:autoload (guix git-download) (git-reference? + #:autoload (guix git-download) (git-reference? git-fetch git-reference-url git-reference-commit) #:use-module (guix import stackage) #:use-module (ice-9 match) @@ -84,6 +84,7 @@ check-source check-source-file-name check-source-unstable-tarball + check-git-protocol check-mirror-url check-github-url check-license @@ -918,6 +919,26 @@ descriptions maintained upstream." (origin-uris origin)) '()))) +(define (check-git-protocol package) + "Emit a warning if PACKAGE's source URI protocol is 'git://'." + (define (check-source-uri-scheme uri) + (match (uri-scheme uri) + ('git + (list + (make-warning package + (G_ "the source URI should not use the git:// protocol") + #:field 'source))) + (_ '()))) + + (match (package-source package) + ((? origin? origin) + (match (origin-method origin) + (git-fetch + (check-source-uri-scheme + (string->uri (git-reference-url (origin-uri origin))))) + (_ '()))) + (_ '()))) + (define (check-mirror-url package) "Check whether PACKAGE uses source URLs that should be 'mirror://'." (define (check-mirror-uri uri) ;XXX: could be optimized @@ -1476,6 +1497,10 @@ or a list thereof") (name 'source-unstable-tarball) (description "Check for autogenerated tarballs") (check check-source-unstable-tarball)) + (lint-checker + (name 'git-protocol) + (description "Check for use of the git:// protocol") + (check check-git-protocol)) (lint-checker (name 'derivation) (description "Report failure to compile a package to a derivation")