From patchwork Thu Jun 24 12:57:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Thiery X-Patchwork-Id: 1496614 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ex2ysiIu; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G9gD71k1Qz9sXG for ; Thu, 24 Jun 2021 22:58:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 70438415D3; Thu, 24 Jun 2021 12:58:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sFUWHva6TQdP; Thu, 24 Jun 2021 12:58:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 95F914044B; Thu, 24 Jun 2021 12:58:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id F039E1BF355 for ; Thu, 24 Jun 2021 12:58:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E0537606F2 for ; Thu, 24 Jun 2021 12:58:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nnemjI9GBtXy for ; Thu, 24 Jun 2021 12:58:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by smtp3.osuosl.org (Postfix) with ESMTPS id 10CC260A42 for ; Thu, 24 Jun 2021 12:58:08 +0000 (UTC) Received: by mail-ej1-x62f.google.com with SMTP id bg14so9349763ejb.9 for ; Thu, 24 Jun 2021 05:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=64O1XsbeK1TMIiBS+ac9/NXISllhB1YDdbBF0KUfUvU=; b=ex2ysiIuxA4PyU0Q95+JNhfZ05/scIs+ddElcFtWO5MVAz6qsZsKA9cVDiawb+QRf9 Zaoff0auW091TejFcUTeXaIFD0IAlm0H+a9TZJuXaoWl7RraWA9A55eJeGS0dYXEf9iR seVh3H8etTvNbb931cg8DBENmqwovccxSOaLG91Qi4N15N8E69uyEXJAIZE4ALr4Rold TXco6BeiRd0fH+75vU+KzIHYCzXdjdd4VwL+UM6OUrSJaeU2XXbjutRCaoL3Pah6ek8i pOoPgum3sN0aGOkJc1UgRboB+uBV2u3oAamjR8JrBaDK0DtdiJ2sYWhfab4nEiseeJKx JThA== 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:mime-version :content-transfer-encoding; bh=64O1XsbeK1TMIiBS+ac9/NXISllhB1YDdbBF0KUfUvU=; b=t7Gj/jldW20Farjm+lLEHW3RtBYp45EmqHBJGjk3dru+silQX7YRTXrhXMWZLLWr+0 GjRSpsrztmbGgf6lroRct0ArBFJ2+/k0AEJBa915xkmIlVTgDJsU2mQcHuWsTuIi5Gpe /j9MeI9dPTAkfBDvral3AGrcvcXDQefVT/fEDrkCHYe8W0RNTU2St+h/6KCAQHWBCFrT vjLuwhS3qojJn+IpbjPqxE0oxm0j8nbIHWM6zTfvqsabORZCFthwYl7hcID+VMC7G6Ct h0lbyA8sGu9n5w/IWPwq3NnYSXV0VZpBVYNr58L35FasmqnHr4/znYD/VsCe+vSrcyrZ PGvQ== X-Gm-Message-State: AOAM5330fy4eSMsBxe36FtQFgB4OV1Mj04DXKwcnAdwwkEPDOPcnMBIK q3SY+5dNb0H0EptlynPUHEaS3ZwG19k= X-Google-Smtp-Source: ABdhPJwDZz/qQwsBnfgSrrTdiocVJRcxPZplVHfQd61aE8NLjFSBGM6pGZyLFUPPe+VyDckjtWi9CA== X-Received: by 2002:a17:907:9f0:: with SMTP id ce16mr5357997ejc.126.1624539487037; Thu, 24 Jun 2021 05:58:07 -0700 (PDT) Received: from hthiery.kontron.local ([213.135.10.150]) by smtp.gmail.com with ESMTPSA id mm27sm1184752ejb.67.2021.06.24.05.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 05:58:06 -0700 (PDT) From: Heiko Thiery To: buildroot@buildroot.org Date: Thu, 24 Jun 2021 14:57:03 +0200 Message-Id: <20210624125702.22106-1-heiko.thiery@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] support/scripts/pkg-stats: add infra_coinfig to json_output X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Weber , Heiko Thiery , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" When we use the statistics output to generate a CVE/CPE customer report showing whether a product is affected by CVEs, we are primarily interested in whether they are relevant to the target system. Currently we cannot see if the package is configured for the build (infra==host) and/or the target system (infra==target). Therefore, in case of a given configuration, this information is also stored in the JSON output. Signed-off-by: Heiko Thiery --- support/scripts/pkg-stats | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index cc91d13167..f4dd034bd9 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -89,6 +89,7 @@ class Package: self.path = path self.pkg_path = os.path.dirname(path) self.infras = None + self.infra_config = None self.license = None self.has_license = False self.has_license_files = False @@ -146,9 +147,9 @@ class Package: return False return True - def set_infra(self): + def set_infra(self, config_info): """ - Fills in the .infras field + Fills in the .infras and ..infra_config fields """ self.infras = list() with open(os.path.join(brpath, self.path), 'r') as f: @@ -163,6 +164,13 @@ class Package: else: self.infras.append(("target", infra)) + if config_info: + for pkg_name in config_info: + if config_info[pkg_name]['name'] == self.name: + if self.infra_config == None: + self.infra_config = list() + self.infra_config.append(config_info[pkg_name]['type']) + def set_license(self): """ Fills in the .status['license'] and .status['license-files'] fields @@ -369,8 +377,8 @@ def get_pkglist(npackages, package_list): def get_config_packages(): cmd = ["make", "--no-print-directory", "show-info"] - js = json.loads(subprocess.check_output(cmd)) - return set([v["name"] for v in js.values()]) + config_info = json.loads(subprocess.check_output(cmd)) + return (config_info, set([v["name"] for v in config_info.values()])) def package_init_make_info(): @@ -1115,10 +1123,11 @@ def __main__(): if args.nvd_path: import cve as cvecheck + config_info = None if args.packages: package_list = args.packages.split(",") elif args.configpackages: - package_list = get_config_packages() + (config_info, package_list) = get_config_packages() else: package_list = None date = datetime.datetime.utcnow() @@ -1137,7 +1146,7 @@ def __main__(): package_init_make_info() print("Getting package details ...") for pkg in packages: - pkg.set_infra() + pkg.set_infra(config_info) pkg.set_license() pkg.set_hash_info() pkg.set_patch_count()