From patchwork Mon May 27 12:01: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: 1130 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 1EFC3EECC9AF for ; Mon, 27 May 2019 12:01:45 +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 12:01:45 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 6630212DDB50DD; Mon, 27 May 2019 12:01:42 +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 12:01:42 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 547682CD21; Mon, 27 May 2019 12:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1558958502; bh=FdzlY/DowS+A7mehlWB2u8BX6EgqdUCmQZDYn/rDMZo=; 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=pHGLHncocmUlx+L+8qnDVCdkInV0mSdkBIxSjFwccgDCoDzYS7ZY/yUOjO15OzED4 Kno0W8AC2dzprZFngTBn3nP5EHuK9OWiNwF75w6Fa6yRYUeJcmw564HbdfLbeZKDrt 8LDnEYghuUQvFuDweVIbyjx2t0NAXZJKb0f4ejimrw3voxdNj+VXGOf49UA+rLB5AS q56c3FUyQkwjQGXmKGiZ6sUn26/zinmQydanFPn0X+zXyD2yCOb6jKk2xUdQefBu7x lrUqJjav+BMDdZB+0UwtlfO/dvgz1XsZTpHaiml2n+WyjJ0kKwrVvGplEux9M0HkaI abIbInF7+vivQqiDxs4bEkkEWKGP79TdlOuxm27Ml3izZNOClv8unUEsNmC3dYAFh3 6QJg0FK/ttOUY6wfWzZ9UD9qXGzeDhH4msr39OD46YXEAM35/muTxo0vVFVdVstMWU PrZ8qXcmPxEygkr+921+BVbOHqhjIEaZzwWjwlhX60Jl5yk8cdIuvLpYb84YaOLrja 9hmLXWi7qDVpcmKAcY27FNLk260w9EOSo4N2DCNW2mSSYeK/0+lKoO4JDTOvN2ip8o j1i3iQZC6t1wie2l1RWFfb5ve3XnVqwkPwIPSkfZXkpb6TdogPDGw3NQ07Rq3nnnq0 DbCs95v4/wTV5HeqBWH3qjlc= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 172FB2CD07 for ; Mon, 27 May 2019 12:01:40 +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 12:01:31 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id DFE0612DDB50D9; Mon, 27 May 2019 12:01:30 +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; Mon, 27 May 2019 12:01:30 +0000 (UTC) Received: by mail-it1-x143.google.com with SMTP id j17so17207198itk.0; Mon, 27 May 2019 05:01:30 -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=ti1/R6/ZFZ7/MDni2zw7f5MwJt1inhrkd+qWO8QgTFg=; b=XcQDamdyUJziqx6b3p/ULH/YInx0Cg3R9C/ZYVoHokFHwsIVOHRmrwVtuaNy+HtCv+ qAUREC6tWHmCeRRsB9t6sI1WDTGYGoZ4gAQjI7F21sT/i9/+i/2hPPk3ZjCu04py5nsz OQIRw72Dx0/KNEKsyET9CFE2WQhIKuyAIkpjYFgxQmU/vD1igQHY++ChiF71Z27ScFE4 +Hj8fWQ1gRcHaraoyRKAguAmt6KARG8BckL9LtZtLZzY713DjN4L56a3Qu/hvcZVTizk ik9cKk/VezGmi5R11X5NtIORAXcsC2jNCWdI++g53uI0s5Y/g7wFYd+00/3pkih7psTA gAfQ== X-Gm-Message-State: APjAAAWJjTG/tJRzXjACybJEjf3BlXAmaXtDukPRG9t16xVQXD0xyzx3 nTF7uE5FsDnXWJRkGFlWlyaIlJVK X-Google-Smtp-Source: APXvYqzyT+TS2YTqGPPeEGZ+j/Vpo+rCQnqt4todkh9ShG2JV2Rekk5u6x+6rKpNV9hqzgEuuZsUAA== X-Received: by 2002:a24:f946:: with SMTP id l67mr27515533ith.43.1558958489229; Mon, 27 May 2019 05:01:29 -0700 (PDT) Received: from newKvm.localdomain ([2601:402:4580:e98::9943]) by smtp.gmail.com with ESMTPSA id s70sm5488069itb.16.2019.05.27.05.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 05:01:28 -0700 (PDT) To: arch-projects@archlinux.org Date: Mon, 27 May 2019 08:01:22 -0400 Message-Id: <20190527120123.21356-1-jamespharvey20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <797984ae-fcd2-439b-bf76-1d41b1c7ac29@archlinux.org> References: <797984ae-fcd2-439b-bf76-1d41b1c7ac29@archlinux.org> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH v2 3/4] nonuniquesources: Also warn on downloaded 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" Downloaded files in source() are required to be unique. A common violation of this is from community named files (i.e. LICENSE) that aren't part of an upstream tarball. Warn if a source file is downloaded, 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..216ae82 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 ('://' in source_file and 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: