prometheus / procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Apache License 2.0
769 stars 319 forks source link

Improve sysfs vulnerability parsing #568

Closed jopelima closed 1 year ago

jopelima commented 1 year ago

The existing sysfs vulnerability parsing routines expected the data provided by the kernel to start with either "Not Affected"/"Vulnerable"/"Mitigation"; however, there are a handful of vulnerabilities that can provide data not matching this expectation:

Testing the existing implementation of a VM results in a error being generated:

root@debian:~/node_exporter# ./node_exporter --collector.cpu_vulnerabilities &
root@debian:~/node_exporter# curl localhost:9100/metrics | grep cpu
2023-09-14T09:12:18.615Z caller=collector.go:169 level=error msg="collector failed" name=cpu_vulnerabilities duration_seconds=0.000116497 err="failed to get vulnerabilities: unknown vulnerability state for itlb_multihit: KVM: Mitigation: VMX unsupported"

This PR modifies the vulnerability parsing to make use of a 4th state ("Unknown"), which is used when the vulnerability information can't be parsed to any of the other vulnerability states, and output the information provided by the kernel, rather than erroring out.

Vulnerability parsing tests have been updated to include the aforementioned vulnerability data.

SuperQ commented 1 year ago

CI fix is here: https://github.com/prometheus/procfs/pull/573