From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id qORGCS8VNGcRhAEA62LTzQ:P1 (envelope-from ) for ; Wed, 13 Nov 2024 02:55:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id qORGCS8VNGcRhAEA62LTzQ (envelope-from ) for ; Wed, 13 Nov 2024 03:55:43 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=TuDU1lHl; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=JSiMO2TN; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731466543; 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: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: dkim-signature; bh=LZOEUGkJrpBCBvLXdoQqjJF9wVhZto9BZ9sUzkG8Tk4=; b=jD8CYXYWCfdO4wkz0PbqOEfdIjVOz8J/O9kSuM98gl2SLh9GH/5GfZ/hQ4F6ylC/chflfq luBRUarD1AqpHM9qmSQUDn4RqEgNDrRQgUz4orsGOxXYOqFcxRBwc+GsRE7gTv6QmZCG5E vuGEmhy056j7LKhfdZOZfNZrlR9hVO+wRsJ5BKmpsy2fXt9vDK47kwWM3rXXpF5YyTPP6B 1xSa1vb2e2iG4/VQnJLYttYxf6dS+QQibkX20JGD7I6X0hhSBkgMDOKfJjmvYakk080nWw mgwOtDClfl0o20wsy28ukz8X+ygY6cGZjJXHg1mW9t34fhWkWHYBrF3Pk3X7NQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=TuDU1lHl; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=JSiMO2TN; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731466543; a=rsa-sha256; cv=none; b=XHO99/VsGfaDiCxHHmUZCB+d5EcNaT7jWbh85UAop6duFrrWJSJXrAaZyWi2o1540Ogjvh EH676IhS5ysrWuCJkccqumAQan/H19Lt9fOzeb/7BVJ9B62tjeOYf5Fyv52SjgvA1WKpfj 2/Rih5N3KswzNy+9ESC1QmGdphGwxv1EMoXoq2zvxOUUAtODYJ/eurETkm5dil3sFIReBm ZrtAEZIxjW3DPtM32WBYVlvZb/jeluETdXfssO0jI5qgvua5bLQpSxTenp/UCXJQDGGn/D uRo5ukJ8RwiSabq+ZtXHWDxMWUq1EGQAepQpFJOtFQNyfHZ8Or2WZoVPXz9+LA== 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 BD0377C4DB for ; Wed, 13 Nov 2024 03:55:41 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tB3X7-0000UK-Bw; Tue, 12 Nov 2024 21:55:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tB3X4-0000Rv-UK for guix-patches@gnu.org; Tue, 12 Nov 2024 21:55:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tB3X4-0002IY-LT for guix-patches@gnu.org; Tue, 12 Nov 2024 21:55:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=0WpImBmuv5+aJD8dfFrwInUB+ms7Nk9NC5OAuPzmW+0=; b=TuDU1lHllZ2QMJyASBcnwlN6baVZF54y9Bngtvh8yOKGswGGCgvdnukZYMceeJTobenKkLRwAWAmhI7KG0oEX4kEHG+gJVYd7jXHdAWxXe9Acjld5x826e/nnkFEsx1TJINcn19PwtpFRL/78Zj72rNK79W5LXsQkr4YZDZNQ8EygKpRrsTslCSRZ0bGlPF96rWqgnFqyVkZ/oCzrwInlDh0/5KfgxEe5Jrizw8Wb7CYBDArzXXZCEShZ3WrLSYAOFDaHcqAFPDZVNbzz1o96QRrohun5kiM2j9ImkqzDbPJCvlq4vfLRSDH7xexH02IV7K+HA1M9lwec6myrRqgXg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tB3X4-0003cv-F0 for guix-patches@gnu.org; Tue, 12 Nov 2024 21:55:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74034] [Nicolas Graves] [PATCH v3 02/17] cve: Separate vendor and string. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 13 Nov 2024 02:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74034 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Nicolas Graves Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 74034@debbugs.gnu.org Received: via spool by 74034-submit@debbugs.gnu.org id=B74034.173146647313885 (code B ref 74034); Wed, 13 Nov 2024 02:55:02 +0000 Received: (at 74034) by debbugs.gnu.org; 13 Nov 2024 02:54:33 +0000 Received: from localhost ([127.0.0.1]:40199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tB3Wa-0003bs-Cd for submit@debbugs.gnu.org; Tue, 12 Nov 2024 21:54:32 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]:58390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tB3WY-0003ba-0c for 74034@debbugs.gnu.org; Tue, 12 Nov 2024 21:54:30 -0500 Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-720c2db824eso6921975b3a.0 for <74034@debbugs.gnu.org>; Tue, 12 Nov 2024 18:54:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731466404; x=1732071204; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=0WpImBmuv5+aJD8dfFrwInUB+ms7Nk9NC5OAuPzmW+0=; b=JSiMO2TNFhc18j5Q1M5oupXy0seH2FjJvh6oTTNPtio8vChRfx0mcW6mP3WmtjM/ii Tbg9v5hnTXie8/DL4tTgiHDB6Q6wS0CyM5dGYoi1Uw7m1/um6aPfEkCNRbsl232jw15C 0v6fRWSmdIaHbq0E2+lXm8K94GmJKpaNnu1bZzqUGRiHkK3EU8oG18Sic1RqQxmMUknI nWpDYlt6q1axr+BzJZE1xZTbiuBz/0beuJJIvdhzq17JCCWX9sIxGXeuOOGaCLh36VID /0eU9wVJDn1U2zwgGLqT5q9xSXWbCO5NztfXWePejxlS3MyMApnFDRVwKv2Q99f6jyRo wGjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731466404; x=1732071204; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0WpImBmuv5+aJD8dfFrwInUB+ms7Nk9NC5OAuPzmW+0=; b=b/0MEbfJjTPASJ1Y3763Ws3u6Djp5PyixSYPNR/XtjxEawC/+qjnO9YOlkZ+Flg7qd 2mBRL1MYhLBbCtE1neqbqDVkE5vSGc2pqA67mGQdHKPKS/6CNsus9Co8fVGs6Ihv8bAK rXzDpNzMAQOPcf+3OrKTrxsMfrsvBtVbAz+oiWq8/9E1I4sfudHBW/uNZkqcq+BiKA36 ACUAWyJEUDcP0sWoNINBqb1wXMRTaMBZNyxW/H6riQ4Nogul1ZdIKXmNmTCKg0q6a0v7 YT5HWa8PMgO9/AIUZLv9Po9QsVRiRSIhsWDlQG88gZ5vS54ZrHmIn432QG5YymdIf3Je +vng== X-Forwarded-Encrypted: i=1; AJvYcCU3ZYdnjy5ppm9nxdKuuJjJopgypVerli9XmaEJZkehZ6ZeuJ09bSbt3GdfS/t1Hvo+5FeXXw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzwOMoub0Cil7QHGlaLHHgdIm5McIFIJYNZiIiJ0pMYcenPpX04 TQ6PeKxG3KOZxzJBFogFv81G5fAWxlB3keGjIltHQUlAbJwdcWJf8zFMuIDW X-Google-Smtp-Source: AGHT+IEkl2G2+EMMyya8q7vgxXXmA7ZVy2Lj0BXdkOKV5yoDJGijvLQmcgdLfeICuNyVq+LGEoj8eQ== X-Received: by 2002:a05:6a20:3d84:b0:1db:eff0:6ae7 with SMTP id adf61e73a8af0-1dc22b57616mr27786932637.33.1731466403506; Tue, 12 Nov 2024 18:53:23 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72407862efesm12024859b3a.1.2024.11.12.18.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 18:53:22 -0800 (PST) From: Maxim Cournoyer In-Reply-To: <87wmhd4mrk.fsf@ngraves.fr> (Nicolas Graves's message of "Fri, 08 Nov 2024 19:13:19 +0100") References: <20241108180330.18126-2-ngraves@ngraves.fr> <87wmhd4mrk.fsf@ngraves.fr> Date: Wed, 13 Nov 2024 11:53:15 +0900 Message-ID: <878qtn26as.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam: Yes X-Migadu-Spam: Yes X-Migadu-Spam-Score: 9.58 X-Spam-Score: 9.58 X-Migadu-Queue-Id: BD0377C4DB X-Migadu-Scanner: mx11.migadu.com X-TUID: lKCnSVZ9zCPt Hi Nicolas, Nicolas Graves writes: > This commit has currently no proper commit message, but it's because it > should probably be squashed if we want to go this way. > > In the end, I've done it, quite tedious (for me at least!) but done. > I'm not super sure however that it's clearer (vulnerability-matches? > definitely is, but the whole, I doubt that). Just pick your preference > I guess! I think this one looks nicer without the parsing of colons every time we need to extract the vendor/package name, thanks for having taken the time to adjust it based on Ludovic's feedback. [...] > (define (configuration-data->cve-configurations alist) > "Given ALIST, a JSON dictionary for the baroque \"configurations\" > @@ -232,18 +234,12 @@ (define (vulnerability-matches? vuln vendor hidden-vendors) > "Checks if a VENDOR matches at least one of VULN > packages. When VENDOR is #f, ignore packages that have a vendor among > HIDDEN-VENDORS." > - (define (vendor-matches? vendor+name) > - (if vendor > - (string-prefix? (string-append vendor ":") vendor+name) > - (or (null? hidden-vendors) > - (not (any (cut string-prefix? (string-append <> ":") vendor+name) > - hidden-vendors))))) > - > (match vuln > (($ id packages) > (any (match-lambda > - (((? vendor-matches? vendor+name) . _) #t) > - (_ #f)) > + (((? (cut string=? <> vendor)) _) #t) > + (((? (cut member <> hidden-vendors)) _) #t) We are comparing packages to the vendor strings; is this correct? At least I'd expect a hidden-vendors match to return #f, since I assume we do not want to process these further? > + (_ #f)) > packages)))) > > > @@ -290,39 +286,47 @@ (define sexp->vulnerability > (vulnerability id packages)))) > > (define (cve-configuration->package-list config) > - "Parse CONFIG, a config sexp, and return a list of the form (P SEXP) > -where P is a package name and SEXP expresses constraints on the matching > -versions." > + "Parse CONFIG, a config sexp, and return a list of the form (V P SEXP) > +where V is a CPE vendor, P is a package name and SEXP expresses constraints on > +the matching versions." > (let loop ((config config) > - (packages '())) > + (vendor+package-list '())) nitpick: I'm not too found of using the variable type in its name (here, 'list'). Perhaps just 'results' could do (plural to denote it's a list). > (match config > (('or configs ...) > - (fold loop packages configs)) > - (('and config _ ...) ;XXX > - (loop config packages)) > - (((? string? package) '_) ;any version > - (cons `(,package _) > - (alist-delete package packages))) > - (((? string? package) sexp) > - (let ((previous (assoc-ref packages package))) > - (if previous > - (cons `(,package (or ,sexp ,@previous)) > - (alist-delete package packages)) > - (cons `(,package ,sexp) packages))))))) > + (fold loop vendor+package-list configs)) > + (('and config _ ...) ;XXX > + (loop config vendor+package-list)) > + (((? string? vendor) (? string? package) sexp) > + (let ((filtered-list (filter (match-lambda > + ((vendor package _) #f) I'd use 'remove' to inverse the negative logic. Assuming 'vendor+package-list' becomes 'results', the let-bound variable could be named (let ((pruned-results (remove ...))) ...)). Also, shouldn't the '_' in the match-lambda be quoted to denote it's a literal underscore character, not a "don't-care" pattern? > + (otherwise otherwise)) > + vendor+package-list))) > + (match sexp > + ('_ ;any version > + (cons `(,vendor ,package _) filtered-list)) > + (_ > + (match (assoc-ref (assoc-ref vendor+package-list vendor) package) > + ((previous) > + (cons `(,vendor ,package (or ,sexp ,previous)) filtered-list)) > + (_ > + (cons `(,vendor ,package ,sexp) vendor+package-list)))))))))) I find the logic expressed in this procedure a bit hard to follow, but that's been inherited from the previous code, so OK. > (define (merge-package-lists lst) > - "Merge the list in LST, each of which has the form (p sexp), where P > -is the name of a package and SEXP is an sexp that constrains matching > -versions." > + "Merge the list in LST, each of which has the form (V P SEXP), where V is a > +CPE vendor, P is the name of a package and SEXP is an sexp that constrains > +matching versions." > (fold (lambda (plist result) ;XXX: quadratic > (fold (match-lambda* > - (((package version) result) > - (match (assoc-ref result package) > - (#f > - (cons `(,package ,version) result)) > - ((previous) > - (cons `(,package (or ,version ,previous)) > - (alist-delete package result)))))) > + (((vendor package version) result) > + (match (assoc-ref result vendor) > + (((? (cut string=? package <>)) previous) > + (cons `(,vendor ,package (or ,version ,previous)) > + (filter (match-lambda > + ((vendor package _) #f) > + (otherwise otherwise)) > + result))) This should use SRFI 1's 'remove' instead of 'filter'. The rest looks good to me. Could you please address my questions/suggestions and squash this into the previous commit (with the accompanied changelog commit message adjustment) ? -- Thanks, Maxim