summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/cve.scm31
1 files changed, 18 insertions, 13 deletions
diff --git a/guix/cve.scm b/guix/cve.scm
index b3a8b13a067..9e1cf5b587d 100644
--- a/guix/cve.scm
+++ b/guix/cve.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -99,7 +99,9 @@
99 99
100(define (reference-data->cve-references alist) 100(define (reference-data->cve-references alist)
101 (map json->cve-reference 101 (map json->cve-reference
102 (vector->list (assoc-ref alist "reference_data")))) 102 ;; Normally "reference_data" is always present but rejected CVEs such
103 ;; as CVE-2020-10020 can lack it.
104 (vector->list (or (assoc-ref alist "reference_data") '#()))))
103 105
104(define %cpe-package-rx 106(define %cpe-package-rx
105 ;; For applications: "cpe:2.3:a:VENDOR:PACKAGE:VERSION", or sometimes 107 ;; For applications: "cpe:2.3:a:VENDOR:PACKAGE:VERSION", or sometimes
@@ -137,17 +139,20 @@ package."
137 (starte (assoc-ref alist "versionStartExcluding")) 139 (starte (assoc-ref alist "versionStartExcluding"))
138 (endi (assoc-ref alist "versionEndIncluding")) 140 (endi (assoc-ref alist "versionEndIncluding"))
139 (ende (assoc-ref alist "versionEndExcluding"))) 141 (ende (assoc-ref alist "versionEndExcluding")))
140 (let-values (((package version) (cpe->package-name cpe))) 142 ;; Normally "cpe23Uri" is here in each "cpe_match" item, but CVE-2020-0534
141 (and package 143 ;; has a configuration that lacks it.
142 `(,package 144 (and cpe
143 ,(cond ((and (or starti starte) (or endi ende)) 145 (let-values (((package version) (cpe->package-name cpe)))
144 `(and ,(if starti `(>= ,starti) `(> ,starte)) 146 (and package
145 ,(if endi `(<= ,endi) `(< ,ende)))) 147 `(,package
146 (starti `(>= ,starti)) 148 ,(cond ((and (or starti starte) (or endi ende))
147 (starte `(> ,starte)) 149 `(and ,(if starti `(>= ,starti) `(> ,starte))
148 (endi `(<= ,endi)) 150 ,(if endi `(<= ,endi) `(< ,ende))))
149 (ende `(< ,ende)) 151 (starti `(>= ,starti))
150 (else version))))))) 152 (starte `(> ,starte))
153 (endi `(<= ,endi))
154 (ende `(< ,ende))
155 (else version))))))))
151 156
152(define (configuration-data->cve-configurations alist) 157(define (configuration-data->cve-configurations alist)
153 "Given ALIST, a JSON dictionary for the baroque \"configurations\" 158 "Given ALIST, a JSON dictionary for the baroque \"configurations\"