From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id ENTAMmdzZGDMHAEAgWs5BA (envelope-from ) for ; Wed, 31 Mar 2021 15:04:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id UNiqLGdzZGCKeAAA1q6Kng (envelope-from ) for ; Wed, 31 Mar 2021 13:04:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 328CC2F1A6 for ; Wed, 31 Mar 2021 15:04:39 +0200 (CEST) Received: from localhost ([::1]:58622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRaWU-00033i-CC for larch@yhetil.org; Wed, 31 Mar 2021 09:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRaVu-0002pc-RL for guix-patches@gnu.org; Wed, 31 Mar 2021 09:04:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRaVu-0005bc-JS for guix-patches@gnu.org; Wed, 31 Mar 2021 09:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lRaVu-0002CC-FZ for guix-patches@gnu.org; Wed, 31 Mar 2021 09:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47193] Fancify guix lint -c cve output Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 31 Mar 2021 13:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47193 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Tobias Geerinckx-Rice Cc: 47193@debbugs.gnu.org Received: via spool by 47193-submit@debbugs.gnu.org id=B47193.16171958348418 (code B ref 47193); Wed, 31 Mar 2021 13:04:02 +0000 Received: (at 47193) by debbugs.gnu.org; 31 Mar 2021 13:03:54 +0000 Received: from localhost ([127.0.0.1]:53808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lRaVl-0002Bi-K7 for submit@debbugs.gnu.org; Wed, 31 Mar 2021 09:03:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lRaVi-0002BN-H0 for 47193@debbugs.gnu.org; Wed, 31 Mar 2021 09:03:53 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59213) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRaVc-0005Qk-RP; Wed, 31 Mar 2021 09:03:44 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=60242 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lRaVb-0002Ni-Q6; Wed, 31 Mar 2021 09:03:44 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210316160653.9891-1-me@tobias.gr> <20210316160653.9891-2-me@tobias.gr> Date: Wed, 31 Mar 2021 15:03:42 +0200 In-Reply-To: <20210316160653.9891-2-me@tobias.gr> (Tobias Geerinckx-Rice's message of "Tue, 16 Mar 2021 17:06:53 +0100") Message-ID: <87h7kra30x.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617195879; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=6XcVnPpb2oQGEqPMKP1zqSH/Uj8wKQ9my3S7HsdQV7A=; b=VdoUbZ62ny4yDMcRJSdyTLDQ2D7nh22PGT9x4EQWbsCowr6LXxAPrQPvRDQqBDHP3iFUKs ZicLMQy2UJfbZF3OnwpfeRdIVPlSpwPFwQjVal2C9kmC1F1jTEH3jDaHpOggxlezmkQ1FV h2EMY9t1MmKWLEEGSyBMq1sfCo8Xlzr43kjkSY4QufotjgMv9baE2gGhsv26KxmbSoqbSm U/FmCMiTFlPtGYAzYkgkje/icKEMjGQdXdnphvRzsplSDRLv9YO8wojPFE0sTV4W5K03du yjFMZVCgZzM4vOytLSD+6S4eICwyjtRvSoEegtZcr+6Ok330zB2ZrUXHeXKTJw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617195879; a=rsa-sha256; cv=none; b=eQIVQjvvQmkv8hkSjD14Rez1Q4qqYc7mkAp86czYHWWO6MgskHl8NwuQrCFQJCJeFe+bbv i/EkMnH32hk5E9rkAl5QgL+tRwiHFDNM79L7hB99KzvNSQGsdBrIhZkqZ1GuKfLzcepEmA pbzDT7R8icURSMH/+uV0aGjD2Ic4Fw6onWHiNauzPvHT5dEoWxN4xE3uqfnmYmPtC6pXtY HP2PAj5bWu90JRZy+zrkmNHd8c9NeOYsjKZn1tp8yhlL9Y0wcWUhRCekeCSgI9byO4vTaP wPKOG6QJVVYq9ZUJ57udnufxeuWSyVN2Ub6vgo7LfueLClgQujzBmwzLhoEjFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 328CC2F1A6 X-Spam-Score: -2.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: ROMiEQBtjPKa Hi, Tobias Geerinckx-Rice skribis: > * guix/cve.scm [cvss3-base-severity]: New field. > (impact-data->cve-cvss3-base-severity): New procedure. > [severity]: New field. > (vulnerability->sexp, sexp->vulnerability, cve-item->vulnerability) > (write-cache): Bump the format version to 2. > (vulnerabilities->lookup-proc): Adjust accordingly. > * guix/lint.scm (check-vulnerabilities): Indicate CVE severity according > to the output port's terminal capabilities. I would move the lint.scm bit to a separate patch. Please also add a short test for =E2=80=98vulnerability-severity=E2=80=99 in tests/cve.scm. [...] > + (cvssv3-base-severity cve-item-cvssv3-base-severity ;string > + "impact" impact-data->cve-cvssv3-base-severity) > + (published-date cve-item-published-date > + "publishedDate" string->date*) > + (last-modified-date cve-item-last-modified-date > + "lastModifiedDate" string->date*)) >=20=20 > (define-json-mapping cve cve? > json->cve > @@ -183,6 +188,15 @@ element found in CVEs, return an sexp such as (\"bin= utils\" (< > (let ((nodes (vector->list (assoc-ref alist "nodes")))) > (filter-map node->configuration nodes))) >=20=20 > +(define (impact-data->cve-cvssv3-base-severity alist) > + "Given ALIST, a JSON dictionary for the \"impact\" element found in > +CVEs, return a string indicating its CVSSv3 severity. This should be > +one of \"NONE\", \"LOW\", \"MEDIUM\", \"HIGH\", or \"CRITICAL\", but we > +return whatever we find, or #F if the severity cannot be determined." > + (let* ((base-metric-v3 (assoc-ref alist "baseMetricV3")) > + (cvss-v3 (assoc-ref base-metric-v3 "cvssV3"))) > + (assoc-ref cvss-v3 "baseSeverity"))) I would pass the result through (string->symbol (string-downcase =E2=80=A6)= ). For clarity, perhaps we can do: (define-json-mapping cvss cvss? json->cvss (vector-string cvss-vector-string =E2=80=9Cvector_String") (base-severity cvss-severity "base_Severity" (compose string->symbol string-downcase))) =E2=80=A6 and use that instead of the last =E2=80=98assoc-ref=E2=80=99 call= above. The rest LGTM. Thanks for this pleasant improvement! Ludo=E2=80=99.