CrowdStrike / container-image-scan

Code to scan a container with CrowdStrike and return response codes indicating pass/fail status.
MIT License
35 stars 23 forks source link

get severity fails for 1.1.12 splunk images #42

Closed jhuan4 closed 2 years ago

jhuan4 commented 2 years ago

splunk/k8s-metrics: (Docker Hub ) 1.1.12 (fails scan)

splunk/kube-objects: (Docker Hub ) 1.1.12 (fails scan)

  • when getting report, it fails with: INFO Authenticating with CrowdStrike Falcon API INFO Downloading Image Scan Report INFO Searching for vulnerabilities in scan report... WARNING MEDIUM CVE-2022-1586 Vulnerability detected affecting pcre2-10.32-2.el8.src.rpm WARNING MEDIUM CVE-2022-25313 Vulnerability detected affecting expat-2.2.5-4.el8_5.3.src.rpm ERROR Unknown error Traceback (most recent call last): File "/home/vmadmin/agent/_work/228/blueprints/templates/steps/script/cs_scanimage.py", line 368, in main f_vuln_score = int(scan_report.get_alerts_vuln()) File "/home/vmadmin/agent/_work/228/blueprints/templates/steps/script/cs_scanimage.py", line 181, in get_alerts_vuln cvss_v3 = details.get('cvss_v3_score', {}) AttributeError: 'NoneType' object has no attribute 'get'

    [error]Bash exited with code '10'.

  • seems details returned as None, was able to get working by adding condition:

λ git diff -r main diff --git a/cs_scanimage.py b/cs_scanimage.py index d97017e..c7a7172 100644 --- a/cs_scanimage.py +++ b/cs_scanimage.py @@ -181,11 +181,12 @@ class ScanReport(dict): vuln = vulnerability['Vulnerability'] cve = vuln.get('CVEID', 'CVE-unknown') details = vuln.get('Details', {}) - cvss_v3 = details.get('cvss_v3_score', {}) - severity = cvss_v3.get('severity') - if severity is None: - cvss_v2 = details.get('cvss_v2_score', {}) - severity = cvss_v2.get('severity') + if details is not None: + cvss_v3 = details.get('cvss_v3_score', {}) + severity = cvss_v3.get('severity') + if severity is None: + cvss_v2 = details.get('cvss_v2_score', {}) + severity = cvss_v2.get('severity') if severity is None: severity = details.get('severity', 'UNKNOWN') product = vuln.get('Product', {})

ffalor commented 2 years ago

@jhuan4 thanks for reporting this it looks like CVE-2022-2153 is returning a hash with a details key, but the value of the key is None

https://github.com/CrowdStrike/container-image-scan/blob/5258ea8b242173e47954bd723d6f7d1b71bda949/cs_scanimage.py#L183

Is checking if the Details key exists, but doesn't check if the value is None

I'll create a pr soon to address this issue

jhuan4 commented 2 years ago

awesome, thanks