From patchwork Mon May 27 03:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1125 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 74D04EE9B8DA for ; Mon, 27 May 2019 03:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:40 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 141C812D9F753F; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id F357B2C61E; Mon, 27 May 2019 03:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1558928979; bh=IdJI36vHrfxSIvUYHPSnOzKwzvjgYhL6v0C/zbFpx7c=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=JUpZ0e1q9q2t07tQnC4ixd2QaA/yQgvvHbLY2S3jEbD2WPB/RW8lFv8XLErFhrBAP COQIuUkye7dIEQ5Xs3e9gi6vC2XZbWMIgRBZQAzoVYMwMMc+rUPjfUH04FImNThIK5 /03G3kugJrzp2KEra63WLbyv6oImGk9/Pr5HjOf5iaawWCGijVAujkDwXlqMQtVGSp 7kluHg+xGeLkxvNKdIkKgvJrIQ5WNGGqiVcqlbVPpB0L//hVHIcBHJJnxvFnPg0xAe 2ZJdyLuPi42+K2ZgNfxD6ozU7yh0r3bYXAseHb6cSnxgiuyqtqLQA9DjfWRbaD4UdK VO/3QqiibK8mVGIE/U83Xfr80XAQWvUn30GWIhTPhfTwJEbnl9rUBswxgIc53hLIUi kKn/Ghq9niIAFdncAkIr6JUDpTwFZRxmWRwL6p0o1VO6lVOMg7L3yivFDKKBjfZclf z3XKMfU4il3dp4NXA18G3bgmApGjPTQbSO9Vfs0oFlneHYgWVWMmPQfSPmSfUPbpQU gYa/ctE+2Tvy/zmFMshPWLPnLIj1rs2g1QA5RxhP21925zPevMh6gLq/y7UZVrw5rn cFDttQQv6fwBDysCnc4f4rh02AC2K7g1i4IAtyA+c/x9/kYlbzVGJCweGgLtYrYvjv Q8aZ0FQtFZgoFg7gbMvSTDOo= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id B1E2D2C5F8 for ; Mon, 27 May 2019 03:49:35 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:35 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id A831812D9F752D for ; Mon, 27 May 2019 03:49:34 +0000 (UTC) Received: from mail-it1-x143.google.com (mail-it1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:34 +0000 (UTC) Received: by mail-it1-x143.google.com with SMTP id m140so22228586itg.2 for ; Sun, 26 May 2019 20:49:34 -0700 (PDT) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EpLZedSCjD5xUdBSxlWSrOk/YfKzOo/FSVtbn70Ru/I=; b=W0Uf3YDxiaEcIgDTNEPEeK9kZNs5yxHfGXeF8B8shejQKn9SjKfO1/jLx87SmAUmSB reHhQFQuPgZlMVmRFE15GBpfl97XDdDZEFYSvhSexyfZVLO1evfhQ4VyUcG4bFFbR3rk nXH9BBOIJ1h+ZXV4d/vx8i9rPaEgwOV/Jgyh+qtDR00ghQuira+QfuoVqsAmSQ8nXUOe EGE0n++8noEODEGKk4KtaHmykiFs8n2RaDKXsxJKTPoABAUfl/pqFC4wUzE5+zKoqwQf 8bOawAsRJChIrOrvCgwUw5KJUfRCG4mtHBZ37YuHrFxz/Ffk2tFtbv5nSSnyLeM5MuER l8mg== X-Gm-Message-State: APjAAAVXK7IjPGldEq0yYOoefdOWhNAEu0YNyWzUrBEzPuyPRCqdcc/X 9MLUTBGHcQpvZsgPK4KpWWGf5U/p X-Google-Smtp-Source: APXvYqwfgyK8Bzu9tSvsxEKa4+5Ng9pq/HCs32eHrP+GX+q8o2Rob44loBZHpFrYq/NRUQ2x+BsefQ== X-Received: by 2002:a05:660c:105:: with SMTP id w5mr18208049itj.37.1558928973224; Sun, 26 May 2019 20:49:33 -0700 (PDT) Received: from newKvm.localdomain ([2601:402:4580:e98::9943]) by smtp.gmail.com with ESMTPSA id m64sm4414072itg.4.2019.05.26.20.49.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 20:49:32 -0700 (PDT) To: arch-projects@archlinux.org Date: Sun, 26 May 2019 23:49:19 -0400 Message-Id: <20190527034922.27316-2-jamespharvey20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190527034922.27316-1-jamespharvey20@gmail.com> References: <20190527034922.27316-1-jamespharvey20@gmail.com> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 1/4] Split warning for non-unique source filenames from pkginfo rules X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "James P. Harvey via arch-projects" Reply-To: Arch Linux projects development discussion Cc: "James P. Harvey" Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" This was originally here, because it used PkgInfoRule, but was changed to use PkgbuildRule and was left here. Signed-off-by: James P. Harvey --- Namcap/rules/__init__.py | 1 + Namcap/rules/nonuniquesources.py | 34 ++++++++++++++++++++++++++++++++ Namcap/rules/pkginfo.py | 11 +---------- 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 Namcap/rules/nonuniquesources.py diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py index dcc950f..111f08b 100644 --- a/Namcap/rules/__init__.py +++ b/Namcap/rules/__init__.py @@ -62,6 +62,7 @@ from . import ( makedepends, makepkgfunctions, missingvars, + nonuniquesources, pkginfo, pkgnameindesc, sfurl, diff --git a/Namcap/rules/nonuniquesources.py b/Namcap/rules/nonuniquesources.py new file mode 100644 index 0000000..a16f56e --- /dev/null +++ b/Namcap/rules/nonuniquesources.py @@ -0,0 +1,34 @@ +# +# namcap rules - package variables +# Copyright (C) 2018 Simon Doppler +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +"These rules checks basic sanity of source files" + +import re +import os +from Namcap.ruleclass import PkgbuildRule + +class nonuniquesources(PkgbuildRule): + name = "nonuniquesources" + description = "Verifies the downloaded sources have a unique filename" + def analyze(self, pkginfo, tar): + for source_file in pkginfo["source"]: + if '::' not in source_file and re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', os.path.basename(source_file)): + self.warnings.append(("non-unique-source-name %s", os.path.basename(source_file))) + +# vim: set ts=4 sw=4 noet: diff --git a/Namcap/rules/pkginfo.py b/Namcap/rules/pkginfo.py index 5a42810..216e417 100644 --- a/Namcap/rules/pkginfo.py +++ b/Namcap/rules/pkginfo.py @@ -20,8 +20,7 @@ "These rules checks basic sanity of package metadata" import re -import os -from Namcap.ruleclass import PkgInfoRule,PkgbuildRule +from Namcap.ruleclass import PkgInfoRule class CapsPkgnameRule(PkgInfoRule): name = "capsnamespkg" @@ -44,12 +43,4 @@ class LicenseRule(PkgInfoRule): if "license" not in pkginfo or len(pkginfo["license"]) == 0: self.errors.append(("missing-license", ())) -class NonUniqueSourcesRule(PkgbuildRule): - name = "non-unique-source" - description = "Verifies the downloaded sources have a unique filename" - def analyze(self, pkginfo, tar): - for source_file in pkginfo["source"]: - if '::' not in source_file and re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', os.path.basename(source_file)): - self.warnings.append(("non-unique-source-name %s", os.path.basename(source_file))) - # vim: set ts=4 sw=4 noet: From patchwork Mon May 27 03:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1126 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 7F1C8EE9B8E8 for ; Mon, 27 May 2019 03:49:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:44 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 1153B12D9F755E; Mon, 27 May 2019 03:49:42 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Mon, 27 May 2019 03:49:42 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 2E94B2C5F8; Mon, 27 May 2019 03:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1558928981; bh=ZwBjAZg0jusYf6rZ42P2/j6qDD8ftv8ETgEETLimikk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=BDcHL3JWpp4YdrWXx0BFLZMmYjCcX+BozLpkMOnDKphY5KajdiNFFkkJBKwcwUgLA 9/lnuJu0wz4EaG3YMFi5IO6UH+m8gM0dgusnKvu/ZkFFasREJyf73NhtwkJVoFhWMU KW3Dfo+b7cVIhPYaGhivtF5y2+uHBHU2WtTAjNG0YjPlPnlEm61Rk0nrzbusjx5C5K 2K35WwWyc0vRKWjlakpLx9uOA+Chy2p0EC9PKOEC/5L6GcOqUK2MBt7PP7u/Mygz4x hc6tnNx4Q29qrMqu8jxgtakNAdzamuJK9kurwPpE8L3L1GNmTlDvsbPD7kgtOoQZdB r+OV+ghjPZT7JCySzL4ycdgJrBw8EcdN7jA7Zz0HE/70Jl96aoqxGRET1BfWZ+NvkQ UZQ9bN6Po/ZiIamGK5UBgoc1HgVxcCsel+PROD10WaW2nqi9pUqCwbgLVD/8ghs1Ft MV+VVd9P6mjYIY9QhedadEn9hZbHTQvQq2EXIvPfr8AF+ccbOuZK7LZjpGiXv4LPnE wgb9+e6TgMT/IJ8VwC+mavnb4RHxFN0TkCCXznnhfuFG2driA5DoD8B4vSKcyw3f68 2IlhnaFSDK1OaAKJAUjxHhz35AhhLFJju8tsYFgFMofxyCQ+Fom6a/sgj0FN6z7F3y QeWPCJOLeOj/JbJj8N5n1XqI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 2D0BF2C5F8 for ; Mon, 27 May 2019 03:49:38 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:38 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id E5B2E12D9F752E for ; Mon, 27 May 2019 03:49:36 +0000 (UTC) Received: from mail-it1-x142.google.com (mail-it1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:36 +0000 (UTC) Received: by mail-it1-x142.google.com with SMTP id a186so14914680itg.0 for ; Sun, 26 May 2019 20:49:36 -0700 (PDT) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sRV+hYzJgPaXxn7BpCIFmVO73Zi/5aKSs8PWyLD0KUs=; b=P8lrd3dQ6q9/OTsbPe+isUTgES57WZtYdO5eS2cpdNeqFya/GlU/11fUTdZHQOYn9m cS2l7s+2WFiJHFopK/VXvB3qzhIMMLW09s4zSwxJeZSCE7Rpp6D4a0agGfxLFrbBAqBo Jsdjz0zC9fDsgP6aQTz9an877wVFdEHeBm1dOyZLxVBsRLkjqAUEfAaFl3yi48t4QM3U ROjeqKPbTxHjmEGAUobaGgZjrFKCDnSNWRYGSJbt1DhARgFzgwfQjYf9VWMhhjABtsfY 0Tu4HFDpW4exRw3vdTyOKCkrGD6KZlc2TtDhu391GTfwdROnUzcfxmy8c0OKYNEYDDgy HHYg== X-Gm-Message-State: APjAAAWv1at7oynTWwsaPMjfY5/qSxm2xelohXRXpV2y7heWyqGj2zj4 orXLQiERy2qTIk01lpN02w4FIvGc X-Google-Smtp-Source: APXvYqwzrZ2wrt3bFw3khHWtObc7gMZZ6IG4JBgYSesLH9oblF4eOd12XU6yHHvNx0JzFvLsSkqtEA== X-Received: by 2002:a05:660c:f8e:: with SMTP id x14mr26851573itl.156.1558928975511; Sun, 26 May 2019 20:49:35 -0700 (PDT) Received: from newKvm.localdomain ([2601:402:4580:e98::9943]) by smtp.gmail.com with ESMTPSA id m64sm4414072itg.4.2019.05.26.20.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 20:49:35 -0700 (PDT) To: arch-projects@archlinux.org Date: Sun, 26 May 2019 23:49:20 -0400 Message-Id: <20190527034922.27316-3-jamespharvey20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190527034922.27316-1-jamespharvey20@gmail.com> References: <20190527034922.27316-1-jamespharvey20@gmail.com> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 2/4] Add test for non-unique source filenames X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "James P. Harvey via arch-projects" Reply-To: Arch Linux projects development discussion Cc: "James P. Harvey" Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" Signed-off-by: James P. Harvey --- .../tests/pkgbuild/test_nonuniquesources.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Namcap/tests/pkgbuild/test_nonuniquesources.py diff --git a/Namcap/tests/pkgbuild/test_nonuniquesources.py b/Namcap/tests/pkgbuild/test_nonuniquesources.py new file mode 100644 index 0000000..1c6d75c --- /dev/null +++ b/Namcap/tests/pkgbuild/test_nonuniquesources.py @@ -0,0 +1,58 @@ +# +# namcap rules - non-unique sources +# Copyright (C) 2019 James P. Harvey +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +from Namcap.tests.pkgbuild_test import PkgbuildTest +import Namcap.rules.nonuniquesources as module + +class NamcapNonUniqueSourcesTest(PkgbuildTest): + pkgbuild_no_source = """ +pkgname=__namcap_test_uniquesources +pkgver=1.0 +pkgrel=1 +pkgdesc="A package" +arch=('i686' 'x86_64') +url="http://www.example.com/" +license=('GPL') +depends=('glibc') +build() { + true +} +package() { + true +} +""" + + test_valid = PkgbuildTest.valid_tests + + def preSetUp(self): + self.rule = module.nonuniquesources + + def test_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('a' 'b')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, []) + self.assertEqual(r.infos, []) + + def test_versioned_non_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('v1.2.3.tar.gz')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "v1.2.3.tar.gz")]) + self.assertEqual(r.infos, []) + +# vim: set ts=4 sw=4 noet: From patchwork Mon May 27 03:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1127 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 1A5ACEE9B8F7 for ; Mon, 27 May 2019 03:49:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:47 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 00AA312D9F7570; Mon, 27 May 2019 03:49:44 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Mon, 27 May 2019 03:49:44 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 595C82C68A; Mon, 27 May 2019 03:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1558928981; bh=+kQZs6zgvoIly3A3HTGKWk8IU4qdwPZQnkMd0Rgk2ZQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=VZG7B/9H+zvmN27BjaCpH7Mu4WNy225WM7KA2jDDKOaL1COTOeyIDwBxZCqZvZpzS z4r/Tag5JYA1iGwY85xOdoGzffT+NyLxFjoVI9H5eNysG5YBqPaQYYEIXGztJ5WHfS Qm7nUceUl1SITYsEGcPxYNhN1bWh+DeBj5CPUzrw+/KXzlHJ4uBeErymNlZAr7gzXV jyp0byB95fClb+f2ZLGSgdpZ7mj8TYC0QlncYa07aLGEahs0Io780AvEGyYLJoF/vh U2fCSwZGlReIuRR8q5vKTad/GMrGMtJ4K6HuMq6zqAJzFVzW9YBp5RXvlJpaKxJRnC LCq+HeNurfU85gpkMObFB2jirkANY6evODDw/gLieHJ+LAaLUrOTH5LWvPMxgjuJ4L TOCRipWzyjwjAB0Zo3fkWKEDsXVDyy3ggNrxrl/vbd0GE7B4JkWbWpbh6tsHOK7BA7 RRSulWJZLlhsWVnNF+DUME7OjemWWdUrYvjKnjR2AymUCSZQWxBRl7Rh3EnvjZNvKH 3wrHWS7cASzwC6kyJg4ZlAuYc0A3wsyL22OKFfEEYLgHcGjYZDKH5e4UpFUwCxfg50 usR2bDJHhh+/NqCVp3crJgZ0kAaXmf/oiNbnd1T5lonTiIyCRG/DsJUbf1jT9LFzJg nGCLQYQgBwCOUMUaIS+zhGLY= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 6F09C2C624 for ; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 7C10112D9F753A for ; Mon, 27 May 2019 03:49:38 +0000 (UTC) Received: from mail-it1-x143.google.com (mail-it1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:38 +0000 (UTC) Received: by mail-it1-x143.google.com with SMTP id a186so14914731itg.0 for ; Sun, 26 May 2019 20:49:38 -0700 (PDT) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B/OxLZzJy4l88AhbtWJ5ZgbfdfMV5HlVa783D8YNKZ4=; b=LjEIxAbje+Zzuns2bdrwILwFCN91caqg2XHOI/dy4d6rrFxNz5nzu7hcoZmRcCvW/s OCfwRpodkcp3L0fF6e+sNghYOaLWRg3mMiE+UC8ndn7Cc6B3f9lQ/yERftNW0iKApSIJ om5ZaYZUFRYGfaFh1dfDPM4Sds74H6lriCnxB5gZe3G971LSU5uPb8Ib1+n3LwqM3k11 TNtMUuWZOZ+r40/KS0Lcxkp1zX8AU80ig4h+SDSAeaxLoabLHFOOA5VscRoH9/fi5OR4 LON4Kg4n41N1xMwyv1HhyG7FtKouQMJ1erVnrkH+RBqkhpGaqVmrzw+hqp2YK+pf+8qC rJ7A== X-Gm-Message-State: APjAAAV6QhIhPhhtlUENgz9TvvHjz0sal0D1tG40VAQE3n3EBrFVu2cJ f5jor46YUhz2ZIrOajDFCMSuv8Tk X-Google-Smtp-Source: APXvYqzIKJ2/UnX/R6hbWXjS5xGybtkVE/kurnjiIs723Elnxv5Y7k6OMaIIqtd9JImEXhXB6jtW8w== X-Received: by 2002:a24:4453:: with SMTP id o80mr26510718ita.160.1558928977037; Sun, 26 May 2019 20:49:37 -0700 (PDT) Received: from newKvm.localdomain ([2601:402:4580:e98::9943]) by smtp.gmail.com with ESMTPSA id m64sm4414072itg.4.2019.05.26.20.49.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 20:49:36 -0700 (PDT) To: arch-projects@archlinux.org Date: Sun, 26 May 2019 23:49:21 -0400 Message-Id: <20190527034922.27316-4-jamespharvey20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190527034922.27316-1-jamespharvey20@gmail.com> References: <20190527034922.27316-1-jamespharvey20@gmail.com> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 3/4] nonuniquesources: Also warn on common filenames not overriding name to be unique X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "James P. Harvey via arch-projects" Reply-To: Arch Linux projects development discussion Cc: "James P. Harvey" Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" Filenames in source() are required to be unique. A common violation of this is from commonly named files (i.e. LICENSE) that aren't part of an upstream tarball. Warn if a source file doesn't have an overriding name, and has a commonly used name, ignoring extension and case. Signed-off-by: James P. Harvey --- Namcap/rules/nonuniquesources.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Namcap/rules/nonuniquesources.py b/Namcap/rules/nonuniquesources.py index a16f56e..8d8afcd 100644 --- a/Namcap/rules/nonuniquesources.py +++ b/Namcap/rules/nonuniquesources.py @@ -26,9 +26,27 @@ from Namcap.ruleclass import PkgbuildRule class nonuniquesources(PkgbuildRule): name = "nonuniquesources" description = "Verifies the downloaded sources have a unique filename" + def analyze(self, pkginfo, tar): + filename_begins_upper_case = [ + "AUTHORS", + "CHANGELOG", + "CONTRIBUTING", + "COPYING", + "COPYRIGHT", + "HACKING", + "HISTORY", + "LICENSE", + "NEWS", + "README", + "TODO" + ] + for source_file in pkginfo["source"]: - if '::' not in source_file and re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', os.path.basename(source_file)): - self.warnings.append(("non-unique-source-name %s", os.path.basename(source_file))) + if '::' not in source_file: + basename = os.path.basename(source_file) + if re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', basename) \ + or basename.upper().split('.')[0] in filename_begins_upper_case: + self.warnings.append(("non-unique-source-name %s", basename)) # vim: set ts=4 sw=4 noet: From patchwork Mon May 27 03:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1128 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id C7836EE9B944 for ; Mon, 27 May 2019 03:49:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:50 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 9667912D9F7587; Mon, 27 May 2019 03:49:48 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Mon, 27 May 2019 03:49:48 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 869282C6A4; Mon, 27 May 2019 03:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1558928986; bh=L0U4ndMDWLLmWYSVT+06z3oKT6CAfVW3ePsmj44ekpo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=SRcDqEACmnjk340+nyvbPMblQEjnDUG2doGC3pVODf85zZYrPQw1+N7s2tl03p3jO RegVncw/P7qxjgNtFdZhEw7AXnr6mxGusS4g/1kntLi+1W+HuKOTV1tGcGC0t6nlKe CXhbvxg6ax+tlj6k3jhFnIYrw1GqAiesw/TX+9YCBg3Uh5jdUSNL3eysGvW56UioP1 dpiqCKt58uCf43oReRqnvM0JJHUl8fBpw5hvsVR0AV2qdpP8UztOvM7EP8PrrYJq+P /OR8wVMGNF1PyhOqEedal0CLuin/01gD6t4OMd6KksNIW3jvAcfscghhNj4BT/cTf0 FIGDq89sow2Ejtv/AVB3ymptALF6jjZdX13b/1nbSAkSU0k6E9tu6iRWiARKRjJa2U 3IvQmScgsPELRdHCQ754SBGBU+Ucr+f/OmLMI5KkDFmCZdxD703BIYUeRqSeS5f23m ln42aiH4eFyMzpPeKXqDuEMdGpGnAe7g0DXZDiCJYnkPwkHX9pKx2N7HNuFOLEQxbd /3Yy4l4WxGY5F5KEjKSKvvNRql8Rl5X+q1pTbvd763YMjKbLNHzu0a9S3Gd7JgmQRN 6/AcEhLycJzlEYn+UsMP9i4cnkVIiFtlUu622UtniW/DDLTqSg2xv1UJuK1+ApSvpQ dVaHSlEXW/iLN58emUsTtZ30= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 19B272C689 for ; Mon, 27 May 2019 03:49:44 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:44 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id EE9B012D9F7545 for ; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: from mail-it1-x135.google.com (mail-it1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 May 2019 03:49:39 +0000 (UTC) Received: by mail-it1-x135.google.com with SMTP id m3so24828490itl.1 for ; Sun, 26 May 2019 20:49:39 -0700 (PDT) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UmwuSaHqrYpE81mGME1x4AmQ97Atli7nWTny0bWwdY8=; b=PyK9PDamH9q/aEPrvh307rOHXlxDemcVUVAs7qI+zlMS+dHo7QTLtlP3RH+psulItg ASuhqc5x4jXMtnc4virx4/LWylRq6xocKfhQReQ0iPRdfBDkfcDyxpkxKueBedXQUjHB 9YkM9f2ZeW4A9m2k0lxl7ao1je8Cy6ZqJ3ivXMIOpOlR2+8uNy1LHRiaJBxSBDCKO360 PNurVbmrPynjwYUPOmySV1TvNd/E7WKpdfAjpODQ87GUVhtriIcNssRJ68ZdNAShSZuq SihrPJDMFjHRo6aUWjcBkfzsBNjqUOUbm1tz+SCxyZ8onmIG50RCvcnmPXnbqYmb75Yj OiHA== X-Gm-Message-State: APjAAAV/xxOYefP+jML5tYhlzNHcttRFMZPeNXy5nttYp02WnrAbC7mf GfV9lDJTyLNuQzy0ZBc606oqXSxe X-Google-Smtp-Source: APXvYqyvdD6HgHpMzJtP0HvZYDO8rbaPTnKtMQSpBv1FxXM+Q2coMCK/ZDFpj3XayuixQriD28BUtw== X-Received: by 2002:a24:1796:: with SMTP id 144mr26127957ith.18.1558928978627; Sun, 26 May 2019 20:49:38 -0700 (PDT) Received: from newKvm.localdomain ([2601:402:4580:e98::9943]) by smtp.gmail.com with ESMTPSA id m64sm4414072itg.4.2019.05.26.20.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 20:49:38 -0700 (PDT) To: arch-projects@archlinux.org Date: Sun, 26 May 2019 23:49:22 -0400 Message-Id: <20190527034922.27316-5-jamespharvey20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190527034922.27316-1-jamespharvey20@gmail.com> References: <20190527034922.27316-1-jamespharvey20@gmail.com> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 4/4] nonuniquesources: Add test for common filenames X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "James P. Harvey via arch-projects" Reply-To: Arch Linux projects development discussion Cc: "James P. Harvey" Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" Signed-off-by: James P. Harvey --- .../tests/pkgbuild/test_nonuniquesources.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Namcap/tests/pkgbuild/test_nonuniquesources.py b/Namcap/tests/pkgbuild/test_nonuniquesources.py index 1c6d75c..b8f3542 100644 --- a/Namcap/tests/pkgbuild/test_nonuniquesources.py +++ b/Namcap/tests/pkgbuild/test_nonuniquesources.py @@ -55,4 +55,40 @@ package() { self.assertEqual(r.warnings, [("non-unique-source-name %s", "v1.2.3.tar.gz")]) self.assertEqual(r.infos, []) + def test_common_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' '${pkgname}-LICENSE::LICENSE.txt')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, []) + self.assertEqual(r.infos, []) + + def test_common_repo_non_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE")]) + self.assertEqual(r.infos, []) + + def test_common_repo_part_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE-pkgname.txt')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, []) + self.assertEqual(r.infos, []) + + def test_common_repo_part_non_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE.txt')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE.txt")]) + self.assertEqual(r.infos, []) + + def test_common_external_non_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'ftp://example.com/LICENSE.txt')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE.txt")]) + self.assertEqual(r.infos, []) + + def test_common_case_insensitive(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'ftp://example.com/license.txt')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "license.txt")]) + self.assertEqual(r.infos, []) + # vim: set ts=4 sw=4 noet: