Commit 37a36a4
committed
debian-cve-check: Improve error handling when dst.json download fails
If the Debian Security Tracker json (dst.json) download fails or file is
invalid, the CVE check cannot be performed.
In this case, output backtrace [1] because there is insufficient error checking.
So improve to error handling.
When cve-check cannot be performed, there are two ways of thinking depending on
the purpose of bitbake:
1. The purpose is build, want to continue to build
e.g. `bitbake core-image-minimal`
2. The purpose is cve-check, want to immediately terminate with an error
e.g. `bitbake bash -c cve_check`
Add "CVE_CHECK_ERROR_ON_FAILURE" variable to satisfy these wants.
- Set "0" (is default): skip the CVE check and continue with build of bitbake
By disabling "CVE_CHECK_DB_FILE" variable, CVE check will be skipped in Poky's
do_cve_check() function.
This is the same behavior as if the NVD database download failed in Poky, skip
the CVE check and continue with build.
- Set "1": bitbake return fatal error immediately
Immediately exit with bb.fatal().
In summary, the following changes in this commit:
- Add exception handling to load_json()
Delete file exist check as they are handled by exception handling.
- Add check of the dst.json file
(Even if the dst.json download fails,) A successfully downloaded dst.json file
may still exist, so if the timestamp is today, it is considered a valid file.
- Add error handling logic for "CVE_CHECK_ERROR_ON_FAILURE" variable
Change the log output lebel to match behavior of this variable.
- Some code style fixes
Add spaces after comma.
[1]
```
File: '<path-to>/meta-debian/classes/debian-cve-check.bbclass', lineno: 33, function: debian_cve_check
0029: _pkg_file_name = os.path.basename(_pkg_uri)
0030: pkgname = _pkg_file_name.split(";")[0].split("_")[0]
0031: break
0032:
*** 0033: if pkgname not in dst_data.keys():
0034: bb.note("%s is not found in Debian Security Tracker." % pkgname)
0035: return
0036:
0037: deb_patched, deb_unpatched = deb_check_cves(d, dst_data[pkgname])
Exception: AttributeError: 'NoneType' object has no attribute 'keys'
```
Signed-off-by: Takahiro Terada <[email protected]>1 parent c0e0ebe commit 37a36a4
2 files changed
+34
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | | - | |
24 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
25 | 42 | | |
26 | 43 | | |
27 | 44 | | |
| |||
52 | 69 | | |
53 | 70 | | |
54 | 71 | | |
55 | | - | |
| 72 | + | |
56 | 73 | | |
57 | 74 | | |
58 | 75 | | |
| |||
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
82 | | - | |
| 99 | + | |
83 | 100 | | |
84 | 101 | | |
85 | 102 | | |
| |||
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
93 | | - | |
94 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
95 | 115 | | |
96 | | - | |
97 | | - | |
98 | 116 | | |
99 | 117 | | |
100 | 118 | | |
| |||
132 | 150 | | |
133 | 151 | | |
134 | 152 | | |
135 | | - | |
136 | | - | |
| 153 | + | |
| 154 | + | |
137 | 155 | | |
138 | 156 | | |
139 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments