Need test cases for PacmanAssessor, new in release 0.3.2.
|
class PacmanAssessor(Assessor): |
|
def __init__(self): |
|
super(PacmanAssessor, self).__init__() |
|
|
|
def assess(self): |
|
lines = [] |
|
# check dependencies |
|
has_audit_command = ["/usr/bin/pacman", "-Qi", "arch-audit"] |
|
p = subprocess.Popen(has_audit_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
p.communicate() |
|
if p.returncode == 1: |
|
_msg = "The optional argument --pacman requires arch-audit to be installed. Please install and try again." |
|
FRTLogger.error(_msg) |
|
sys.exit(1) |
|
# find CVEs |
|
command = ["arch-audit", "-f", "'%n %c'"] |
|
p = subprocess.Popen(command, |
|
stdout=subprocess.PIPE, |
|
stderr=subprocess.PIPE) |
|
out, err = p.communicate() |
|
|
|
if p.returncode != 0: |
|
raise OSError((p.returncode, err)) |
|
|
|
lines = out.split('\n') |
|
|
|
# assume that each line of output has the format "libtiff CVE-2019-7663,CVE-2019-6128" |
|
for line in lines: |
|
if not line: |
|
continue |
|
pkgname, cves = line.replace("'", "").split(" ") |
|
cves = RE_CVE.findall(cves) |
|
if not cves: |
|
continue |
|
self.cves.extend(cves) |
|
self.cves = list(set(self.cves)) |
Need test cases for PacmanAssessor, new in release 0.3.2.
lem/lem/host/assessor.py
Lines 210 to 245 in b463c90