Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated regex_find in utils.py and all the checkers using it #331

Merged
merged 23 commits into from
Feb 11, 2020
Merged

Updated regex_find in utils.py and all the checkers using it #331

merged 23 commits into from
Feb 11, 2020

Conversation

SinghHrmn
Copy link
Contributor

@SinghHrmn SinghHrmn commented Feb 4, 2020

Currently, the regex_find function in the utils.py initializes a string variable guess = "". And returns this empty string if it is unable to find the match. This change will help omit those empty string versions which were detected falsely by returning a False statement if guess == "".
Output will change from

cve_bin_tool - INFO - There are 6 files with known CVEs detected
cve_bin_tool - INFO - Known CVEs in ('gnutls-cli', '3.5.8'), ('gnutls-cli', ''), ('gnutls-serv', ''):
gnutls-cli,3.5.8,CVE-2009-1390,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3467,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3468,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3469,MEDIUM
gnutls-cli,3.5.8,CVE-2017-7507,HIGH
gnutls-cli,3.5.8,CVE-2017-7869,HIGH
gnutls-cli,3.5.8,CVE-2019-3829,HIGH
gnutls-cli,,CVE-2006-7239,MEDIUM
gnutls-cli,,CVE-2008-4989,MEDIUM
gnutls-cli,,CVE-2009-1390,MEDIUM
gnutls-cli,,CVE-2009-1415,MEDIUM
gnutls-cli,,CVE-2009-1417,MEDIUM
gnutls-cli,,CVE-2009-2409,MEDIUM
gnutls-cli,,CVE-2009-2730,HIGH
gnutls-cli,,CVE-2009-3555,MEDIUM
gnutls-cli,,CVE-2009-5138,MEDIUM
gnutls-cli,,CVE-2010-0731,HIGH
gnutls-cli,,CVE-2012-0390,MEDIUM
gnutls-cli,,CVE-2012-1569,MEDIUM
gnutls-cli,,CVE-2012-1573,MEDIUM
gnutls-cli,,CVE-2012-1663,HIGH
gnutls-cli,,CVE-2014-0092,MEDIUM
gnutls-cli,,CVE-2014-1959,MEDIUM
gnutls-cli,,CVE-2014-3466,MEDIUM
gnutls-cli,,CVE-2014-3467,MEDIUM
gnutls-cli,,CVE-2014-3468,MEDIUM
gnutls-cli,,CVE-2014-3469,MEDIUM
gnutls-cli,,CVE-2014-8155,MEDIUM
gnutls-cli,,CVE-2015-0282,MEDIUM
gnutls-cli,,CVE-2015-3308,HIGH
gnutls-cli,,CVE-2016-7444,HIGH
gnutls-cli,,CVE-2017-5334,CRITICAL
gnutls-cli,,CVE-2017-5335,HIGH
gnutls-cli,,CVE-2017-5336,CRITICAL
gnutls-cli,,CVE-2017-5337,CRITICAL
gnutls-cli,,CVE-2017-7507,HIGH
gnutls-cli,,CVE-2017-7869,HIGH
gnutls-serv,,CVE-2006-7239,MEDIUM
gnutls-serv,,CVE-2008-4989,MEDIUM
gnutls-serv,,CVE-2009-1390,MEDIUM
gnutls-serv,,CVE-2009-1415,MEDIUM
gnutls-serv,,CVE-2009-1417,MEDIUM
gnutls-serv,,CVE-2009-2409,MEDIUM
gnutls-serv,,CVE-2009-2730,HIGH
gnutls-serv,,CVE-2009-3555,MEDIUM
gnutls-serv,,CVE-2009-5138,MEDIUM
gnutls-serv,,CVE-2010-0731,HIGH
gnutls-serv,,CVE-2012-0390,MEDIUM
gnutls-serv,,CVE-2012-1569,MEDIUM
gnutls-serv,,CVE-2012-1573,MEDIUM
gnutls-serv,,CVE-2012-1663,HIGH
gnutls-serv,,CVE-2014-0092,MEDIUM
gnutls-serv,,CVE-2014-1959,MEDIUM
gnutls-serv,,CVE-2014-3466,MEDIUM
gnutls-serv,,CVE-2014-3467,MEDIUM
gnutls-serv,,CVE-2014-3468,MEDIUM
gnutls-serv,,CVE-2014-3469,MEDIUM
gnutls-serv,,CVE-2014-8155,MEDIUM
gnutls-serv,,CVE-2015-0282,MEDIUM
gnutls-serv,,CVE-2015-3308,HIGH
gnutls-serv,,CVE-2016-7444,HIGH
gnutls-serv,,CVE-2017-5334,CRITICAL
gnutls-serv,,CVE-2017-5335,HIGH
gnutls-serv,,CVE-2017-5336,CRITICAL
gnutls-serv,,CVE-2017-5337,CRITICAL
gnutls-serv,,CVE-2017-7507,HIGH
gnutls-serv,,CVE-2017-7869,HIGH

To

(venvgsoc) mastervulcan@DESKTOP-DMEM457:~/gsoc-cve-bin-tool/cve-bin-tool$ python -m cve_bin_tool.cli -x ../testFilesCVE-bin-tool/gnutls-bin_3.5.8-6ubuntu3_amd64.deb
cve_bin_tool.CVEDB - INFO - Using cached CVE data (<24h old). Use -u now to update immediately.
cve_bin_tool.Scanner - INFO - Checkers: bluez, curl, expat, ffmpeg, gnutls, icu, kerberos, libcurl, libgcrypt, libjpeg, libnss, libtiff, node, openssh, openssl, png, sqlite, systemd, xerces, xml2, zlib
cve_bin_tool - INFO - None
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-_td_g4k9/data.tar.xz.extracted/usr/bin/gnutls-cli is gnutls-cli 3.5.8
cve_bin_tool.Scanner - INFO - Known CVEs in version 3.5.8
cve_bin_tool.Scanner - INFO - CVE-2009-1390, CVE-2014-3467, CVE-2014-3468, CVE-2014-3469, CVE-2017-7507, CVE-2017-7869, CVE-2019-3829
cve_bin_tool.Scanner - ERROR - error: no version info for 'gnutls-cli'
cve_bin_tool.Scanner - ERROR - error: no version info for 'gnutls-serv'
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-_td_g4k9/gnutls-bin_3.5.8-6ubuntu3_amd64.deb.extracted/usr/bin/gnutls-cli is gnutls-cli 3.5.8
cve_bin_tool.Scanner - INFO - Known CVEs in version 3.5.8
cve_bin_tool.Scanner - INFO - CVE-2009-1390, CVE-2014-3467, CVE-2014-3468, CVE-2014-3469, CVE-2017-7507, CVE-2017-7869, CVE-2019-3829
cve_bin_tool.Scanner - ERROR - error: no version info for 'gnutls-cli'
cve_bin_tool.Scanner - ERROR - error: no version info for 'gnutls-serv'
cve_bin_tool - INFO - 
cve_bin_tool - INFO - Overall CVE summary: 
cve_bin_tool - INFO - There are 2 files with known CVEs detected
cve_bin_tool - INFO - Known CVEs in ('gnutls-cli', '3.5.8'):
gnutls-cli,3.5.8,CVE-2009-1390,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3467,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3468,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3469,MEDIUM
gnutls-cli,3.5.8,CVE-2017-7507,HIGH
gnutls-cli,3.5.8,CVE-2017-7869,HIGH
gnutls-cli,3.5.8,CVE-2019-3829,HIGH

Even if the checker failed to check for a version. The default value of version = "UNKNOWN" will be used. Hence giving the below output

cve_bin_tool.Scanner - ERROR - error: no version info for 'bluetoothctl'
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-qs5rux9h/data.tar.xz.extracted/usr/bin/bluetoothctl is bluetoothctl UNKNOWN
cve_bin_tool.Scanner - INFO - Known CVEs in version UNKNOWN
cve_bin_tool.Scanner - INFO - CVE-2016-7837, CVE-2017-1000250, CVE-2018-10910
cve_bin_tool.Scanner - ERROR - error: no version info for 'bluetoothctl'
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-qs5rux9h/bluez_5.48-0ubuntu3.2_amd64.deb.extracted/usr/bin/bluetoothctl is bluetoothctl UNKNOWN
cve_bin_tool.Scanner - INFO - Known CVEs in version UNKNOWN
cve_bin_tool.Scanner - INFO - CVE-2016-7837, CVE-2017-1000250, CVE-2018-10910
cve_bin_tool - INFO - 
cve_bin_tool - INFO - Overall CVE summary: 
cve_bin_tool - INFO - There are 2 files with known CVEs detected
cve_bin_tool - INFO - Known CVEs in ('bluetoothctl', 'UNKNOWN'):
bluetoothctl,UNKNOWN,CVE-2016-7837,HIGH
bluetoothctl,UNKNOWN,CVE-2017-1000250,MEDIUM
bluetoothctl,UNKNOWN,CVE-2018-10910,LOW

@SinghHrmn
Copy link
Contributor Author

SinghHrmn commented Feb 4, 2020

@terriko The checks are showing the following error. Tests were fine on my PC.

cve-bin-tool / Run tests (ubuntu-latest, 3.6) (pull_request)

======================================================================
FAIL: test_skips (test.test_cli.TestCLI)
Tests the skips option
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_cli.py", line 126, in test_skips
    self.assertTrue(checker in final_log)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 86 tests in 230.497s

FAILED (failures=1, skipped=25)
Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>

cve-bin-tool / Run tests (ubuntu-latest, 3.7) (pull_request)

same error
======================================================================
FAIL: test_skips (test.test_cli.TestCLI)
Tests the skips option
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_cli.py", line 126, in test_skips
    self.assertTrue(checker in final_log)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 86 tests in 232.881s

FAILED (failures=1, skipped=25)
Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>

cve-bin-tool / Long tests on python3.8 (pull_request)


======================================================================
FAIL: test_skips (test.test_cli.TestCLI)
Tests the skips option
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_cli.py", line 126, in test_skips
    self.assertTrue(checker in final_log)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 86 tests in 478.283s

FAILED (failures=1, skipped=2)
Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=86 errors=0 failures=1>

@PrajwalM2212
Copy link
Contributor

PrajwalM2212 commented Feb 5, 2020

@SinghHrmn Yes the test_skips is passing on local machines, but failing on actions. But #330 should fix the issue.

@SinghHrmn
Copy link
Contributor Author

@PrajwalM2212 Okay -- thanks for the reply.

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of this patch, but I think we'd be better served if regex_find returned "UNKNOWN" and then we do the correct thing with that in cli.py. Why? The giant "UNKNOWN" shows up nicely in all the debug logs and makes it easier for users to tell that the checker has failed to find a version . I know, I know, it makes it a string compare instead of a binary one, but we've had so many people confused about checker behaviours that I feel like it's worth it.

@SinghHrmn
Copy link
Contributor Author

SinghHrmn commented Feb 6, 2020

@terriko I agree on the point that it's making checkers look confusing. But you can see from the code that some checkers are using regex_find and expect it would return False or anything similar that makes the if statement logical. Like this code from kerberos.py

    new_guess = regex_find(lines, *signatures)
    if new_guess:
        return new_guess

will work even if the regex_find is returning an empty string "". Due to the following code reason.

x = ""
if x:
    print("it is working")
else:
    print("not working")

#prints not working

But according to your proposed changes. The changes will look something like.

cve_bin_tool - INFO - There are 6 files with known CVEs detected
cve_bin_tool - INFO - Known CVEs in ('gnutls-cli', '3.5.8'), ('gnutls-cli', ''), ('gnutls-serv', ''):
gnutls-cli,3.5.8,CVE-2009-1390,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3467,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3468,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3469,MEDIUM
gnutls-cli,3.5.8,CVE-2017-7507,HIGH
gnutls-cli,3.5.8,CVE-2017-7869,HIGH
gnutls-cli,3.5.8,CVE-2019-3829,HIGH
gnutls-cli,,CVE-2006-7239,MEDIUM
gnutls-cli,,CVE-2008-4989,MEDIUM
gnutls-cli,,CVE-2009-1390,MEDIUM
gnutls-cli,,CVE-2009-1415,MEDIUM
gnutls-cli,,CVE-2009-1417,MEDIUM
gnutls-cli,,CVE-2009-2409,MEDIUM
gnutls-cli,,CVE-2009-2730,HIGH
gnutls-cli,,CVE-2009-3555,MEDIUM
gnutls-cli,,CVE-2009-5138,MEDIUM
gnutls-cli,,CVE-2010-0731,HIGH
gnutls-cli,,CVE-2012-0390,MEDIUM
gnutls-cli,,CVE-2012-1569,MEDIUM
gnutls-cli,,CVE-2012-1573,MEDIUM
gnutls-cli,,CVE-2012-1663,HIGH
gnutls-cli,,CVE-2014-0092,MEDIUM
gnutls-cli,,CVE-2014-1959,MEDIUM
gnutls-cli,,CVE-2014-3466,MEDIUM
gnutls-cli,,CVE-2014-3467,MEDIUM
gnutls-cli,,CVE-2014-3468,MEDIUM
gnutls-cli,,CVE-2014-3469,MEDIUM
gnutls-cli,,CVE-2014-8155,MEDIUM
gnutls-cli,,CVE-2015-0282,MEDIUM
gnutls-cli,,CVE-2015-3308,HIGH
gnutls-cli,,CVE-2016-7444,HIGH
gnutls-cli,,CVE-2017-5334,CRITICAL
gnutls-cli,,CVE-2017-5335,HIGH
gnutls-cli,,CVE-2017-5336,CRITICAL
gnutls-cli,,CVE-2017-5337,CRITICAL
gnutls-cli,,CVE-2017-7507,HIGH
gnutls-cli,,CVE-2017-7869,HIGH
gnutls-serv,,CVE-2006-7239,MEDIUM
gnutls-serv,,CVE-2008-4989,MEDIUM
gnutls-serv,,CVE-2009-1390,MEDIUM
gnutls-serv,,CVE-2009-1415,MEDIUM
gnutls-serv,,CVE-2009-1417,MEDIUM
gnutls-serv,,CVE-2009-2409,MEDIUM
gnutls-serv,,CVE-2009-2730,HIGH
gnutls-serv,,CVE-2009-3555,MEDIUM
gnutls-serv,,CVE-2009-5138,MEDIUM
gnutls-serv,,CVE-2010-0731,HIGH
gnutls-serv,,CVE-2012-0390,MEDIUM
gnutls-serv,,CVE-2012-1569,MEDIUM
gnutls-serv,,CVE-2012-1573,MEDIUM
gnutls-serv,,CVE-2012-1663,HIGH
gnutls-serv,,CVE-2014-0092,MEDIUM
gnutls-serv,,CVE-2014-1959,MEDIUM
gnutls-serv,,CVE-2014-3466,MEDIUM
gnutls-serv,,CVE-2014-3467,MEDIUM
gnutls-serv,,CVE-2014-3468,MEDIUM
gnutls-serv,,CVE-2014-3469,MEDIUM
gnutls-serv,,CVE-2014-8155,MEDIUM
gnutls-serv,,CVE-2015-0282,MEDIUM
gnutls-serv,,CVE-2015-3308,HIGH
gnutls-serv,,CVE-2016-7444,HIGH
gnutls-serv,,CVE-2017-5334,CRITICAL
gnutls-serv,,CVE-2017-5335,HIGH
gnutls-serv,,CVE-2017-5336,CRITICAL
gnutls-serv,,CVE-2017-5337,CRITICAL
gnutls-serv,,CVE-2017-7507,HIGH
gnutls-serv,,CVE-2017-7869,HIGH

to

cve_bin_tool - INFO - Known CVEs in ('gnutls-cli', '3.5.8'), ('gnutls-cli', 'UNKNOWN'), ('gnutls-serv', 'UNKNOWN'):
gnutls-cli,3.5.8,CVE-2009-1390,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3467,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3468,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3469,MEDIUM
gnutls-cli,3.5.8,CVE-2017-7507,HIGH
gnutls-cli,3.5.8,CVE-2017-7869,HIGH
gnutls-cli,3.5.8,CVE-2019-3829,HIGH
gnutls-cli,UNKNOWN,CVE-2006-7239,MEDIUM
gnutls-cli,UNKNOWN,CVE-2008-4989,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-1390,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-1415,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-1417,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-2409,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-2730,HIGH
gnutls-cli,UNKNOWN,CVE-2009-3555,MEDIUM
gnutls-cli,UNKNOWN,CVE-2009-5138,MEDIUM
gnutls-cli,UNKNOWN,CVE-2010-0731,HIGH
gnutls-cli,UNKNOWN,CVE-2012-0390,MEDIUM
gnutls-cli,UNKNOWN,CVE-2012-1569,MEDIUM
gnutls-cli,UNKNOWN,CVE-2012-1573,MEDIUM
gnutls-cli,UNKNOWN,CVE-2012-1663,HIGH
gnutls-cli,UNKNOWN,CVE-2014-0092,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-1959,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-3466,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-3467,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-3468,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-3469,MEDIUM
gnutls-cli,UNKNOWN,CVE-2014-8155,MEDIUM
gnutls-cli,UNKNOWN,CVE-2015-0282,MEDIUM
gnutls-cli,UNKNOWN,CVE-2015-0294,HIGH
gnutls-cli,UNKNOWN,CVE-2015-3308,HIGH
gnutls-cli,UNKNOWN,CVE-2016-7444,HIGH
gnutls-cli,UNKNOWN,CVE-2017-5334,CRITICAL
gnutls-cli,UNKNOWN,CVE-2017-5335,HIGH
gnutls-cli,UNKNOWN,CVE-2017-5336,CRITICAL
gnutls-cli,UNKNOWN,CVE-2017-5337,CRITICAL
gnutls-cli,UNKNOWN,CVE-2017-7507,HIGH
gnutls-cli,UNKNOWN,CVE-2017-7869,HIGH
gnutls-serv,UNKNOWN,CVE-2006-7239,MEDIUM
gnutls-serv,UNKNOWN,CVE-2008-4989,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-1390,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-1415,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-1417,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-2409,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-2730,HIGH
gnutls-serv,UNKNOWN,CVE-2009-3555,MEDIUM
gnutls-serv,UNKNOWN,CVE-2009-5138,MEDIUM
gnutls-serv,UNKNOWN,CVE-2010-0731,HIGH
gnutls-serv,UNKNOWN,CVE-2012-0390,MEDIUM
gnutls-serv,UNKNOWN,CVE-2012-1569,MEDIUM
gnutls-serv,UNKNOWN,CVE-2012-1573,MEDIUM
gnutls-serv,UNKNOWN,CVE-2012-1663,HIGH
gnutls-serv,UNKNOWN,CVE-2014-0092,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-1959,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-3466,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-3467,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-3468,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-3469,MEDIUM
gnutls-serv,UNKNOWN,CVE-2014-8155,MEDIUM
gnutls-serv,UNKNOWN,CVE-2015-0282,MEDIUM
gnutls-serv,UNKNOWN,CVE-2015-0294,HIGH
gnutls-serv,UNKNOWN,CVE-2015-3308,HIGH
gnutls-serv,UNKNOWN,CVE-2016-7444,HIGH
gnutls-serv,UNKNOWN,CVE-2017-5334,CRITICAL
gnutls-serv,UNKNOWN,CVE-2017-5335,HIGH
gnutls-serv,UNKNOWN,CVE-2017-5336,CRITICAL
gnutls-serv,UNKNOWN,CVE-2017-5337,CRITICAL
gnutls-serv,UNKNOWN,CVE-2017-7507,HIGH
gnutls-serv,UNKNOWN,CVE-2017-7869,HIGH

But after this, I have to update the if logic to

if match != "UNKNOWN":

After this, what should we use?

  1. Make regex_find to return False. Then always check in all checkers file the function returns anything other than False
  2. Make regex_find return "UNKNOWN". Then cli.py will automatically take care of it.

@SinghHrmn
Copy link
Contributor Author

SinghHrmn commented Feb 6, 2020

@terriko Submitting a PR with regex_find returning "UNKNOWN".

Long tests as well simple tests were fine.

@terriko
Copy link
Contributor

terriko commented Feb 6, 2020

I guess I wasn't clear in what I was suggesting. Yes, cli.py doesn't do the right thing yet. I was trying to suggest that this patch should fix cli.py as well. You pretty much had the right idea in #326 already, I think.

Basically, what I was trying to suggest is probably 3 things:

  1. Change regex_find to return UNKNOWN when we think we found something but can't find a version. (done!)
  2. Change cli.py so it prints something at warning log level explicitly stating "found $product with version UNKNOWN" (not being done at all)
  3. Change cli.py so it doesn't try to run get_cves on any version string UNKNOWN (because it's going to be junk results anyhow) (basically the same idea as you had in Updated cli.py file  #326 already)

I think that'll get us improved output and maybe a little performance improvement for not looking up meaningless data.

Great work on this, by the way! This is a really great place for an improvement.

@SinghHrmn
Copy link
Contributor Author

@terriko Updated cli.py now the output will be like

(venvgsoc) mastervulcan@DESKTOP-DMEM457:~/gsoc-cve-bin-tool/cve-bin-tool$ python -m cve_bin_tool.cli -x ../testFilesCVE-bin-tool/bluez_5.48-0ubuntu3.2_amd64.deb 
cve_bin_tool.CVEDB - INFO - Using cached CVE data (<24h old). Use -u now to update immediately.
cve_bin_tool.Scanner - INFO - Checkers: bluez, curl, expat, ffmpeg, gnutls, icu, kerberos, libcurl, libgcrypt, libjpeg, libnss, libtiff, node, openssh, openssl, png, sqlite, systemd, xerces, xml2, zlib
cve_bin_tool - INFO - None
cve_bin_tool.Scanner - ERROR - No version info for 'bluetoothctl'
cve_bin_tool.Scanner - WARNING - 'bluetoothctl' was detected with version UNKNOWN
cve_bin_tool.Scanner - ERROR - No version info for 'bluetoothctl'
cve_bin_tool.Scanner - WARNING - 'bluetoothctl' was detected with version UNKNOWN
cve_bin_tool - INFO - 
cve_bin_tool - INFO - Overall CVE summary: 
cve_bin_tool - INFO - There are 0 files with known CVEs detected


(venvgsoc) mastervulcan@DESKTOP-DMEM457:~/gsoc-cve-bin-tool/cve-bin-tool$ python -m cve_bin_tool.cli -x ../testFilesCVE-bin-tool/gnutls-bin_3.5.8-6ubuntu3_amd64.deb 
cve_bin_tool.CVEDB - INFO - Using cached CVE data (<24h old). Use -u now to update immediately.
cve_bin_tool.Scanner - INFO - Checkers: bluez, curl, expat, ffmpeg, gnutls, icu, kerberos, libcurl, libgcrypt, libjpeg, libnss, libtiff, node, openssh, openssl, png, sqlite, systemd, xerces, xml2, zlib
cve_bin_tool - INFO - None
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-yv_yiqu2/data.tar.xz.extracted/usr/bin/gnutls-cli is gnutls-cli 3.5.8
cve_bin_tool.Scanner - INFO - Known CVEs in version 3.5.8
cve_bin_tool.Scanner - INFO - CVE-2009-1390, CVE-2014-3467, CVE-2014-3468, CVE-2014-3469, CVE-2017-7507, CVE-2017-7869, CVE-2019-3829
cve_bin_tool.Scanner - ERROR - No version info for 'gnutls-cli'
cve_bin_tool.Scanner - WARNING - 'gnutls-cli' was detected with version UNKNOWN
cve_bin_tool.Scanner - ERROR - No version info for 'gnutls-serv'
cve_bin_tool.Scanner - WARNING - 'gnutls-serv' was detected with version UNKNOWN
cve_bin_tool.Scanner - INFO - /tmp/cve-bin-tool-yv_yiqu2/gnutls-bin_3.5.8-6ubuntu3_amd64.deb.extracted/usr/bin/gnutls-cli is gnutls-cli 3.5.8
cve_bin_tool.Scanner - INFO - Known CVEs in version 3.5.8
cve_bin_tool.Scanner - INFO - CVE-2009-1390, CVE-2014-3467, CVE-2014-3468, CVE-2014-3469, CVE-2017-7507, CVE-2017-7869, CVE-2019-3829
cve_bin_tool.Scanner - ERROR - No version info for 'gnutls-cli'
cve_bin_tool.Scanner - WARNING - 'gnutls-cli' was detected with version UNKNOWN
cve_bin_tool.Scanner - ERROR - No version info for 'gnutls-serv'
cve_bin_tool.Scanner - WARNING - 'gnutls-serv' was detected with version UNKNOWN
cve_bin_tool - INFO - 
cve_bin_tool - INFO - Overall CVE summary: 
cve_bin_tool - INFO - There are 2 files with known CVEs detected
cve_bin_tool - INFO - Known CVEs in ('gnutls-cli', '3.5.8'):
gnutls-cli,3.5.8,CVE-2009-1390,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3467,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3468,MEDIUM
gnutls-cli,3.5.8,CVE-2014-3469,MEDIUM
gnutls-cli,3.5.8,CVE-2017-7507,HIGH
gnutls-cli,3.5.8,CVE-2017-7869,HIGH
gnutls-cli,3.5.8,CVE-2019-3829,HIGH

you can suggest me if to only show warning or error (or both). But one thing is for sure if the error happens it will satisfy both and will print both.
github actions didn't run any test. I don't know why.

@SinghHrmn
Copy link
Contributor Author

@terriko closing this one and trying a new pull request

@SinghHrmn SinghHrmn closed this Feb 7, 2020
@SinghHrmn SinghHrmn reopened this Feb 7, 2020
@SinghHrmn
Copy link
Contributor Author

@terriko tests were fine at my system. But I don't know why I got this error I didn't even touch that file. more over I didn't find that test either

======================================================================
FAIL: test_icu_dos (test.test_scanner.TestScanner)
Test a pathologically long version string for icu
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_scanner.py", line 161, in test_icu_dos
    ["CVE-2019-3823"],
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_scanner.py", line 95, in _binary_test
    self.assertIn(version, list(cves[package].keys()))
AssertionError: '3.8.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1' not found in ['3.8.1']

----------------------------------------------------------------------
Ran 91 tests in 205.641s

FAILED (failures=1, skipped=26)
Test failed: <unittest.runner.TextTestResult run=91 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=91 errors=0 failures=1>

Screenshot (17)

@terriko
Copy link
Contributor

terriko commented Feb 7, 2020

That is weird. That's one of the new tests I just put in on the more open-ended regular expressions, but it looks like it's getting a truncated, more normal-looking version number instead of the ridiculous fake one I sent it. That would make sense if you'd still had changes in icu, but you don't so I'm confused.

As for error vs warning: I think warning is better, since we know there's a few cases where we're just not finding data and that's just going to happen. The error was something I put in there pretty recently so I doubt anyone's relying on it; it should be safe to remove it in favour of a if version/elif version==unknown/else construction.

@terriko
Copy link
Contributor

terriko commented Feb 7, 2020

Double-checked on my local machine by merging this branch against master, and I'm seeing this test fail now too, so it's definitely not a quirk of the CI system. Something here has changed it so we're getting a truncated version result.

cve_bin_tool/checkers/bluez.py Outdated Show resolved Hide resolved
cve_bin_tool/checkers/gnutls.py Outdated Show resolved Hide resolved
cve_bin_tool/checkers/kerberos.py Show resolved Hide resolved
@SinghHrmn
Copy link
Contributor Author

@terriko tests were fine at my system. But I don't know why I got this error I didn't even touch that file. more over I didn't find that test either

======================================================================
FAIL: test_icu_dos (test.test_scanner.TestScanner)
Test a pathologically long version string for icu
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_scanner.py", line 161, in test_icu_dos
    ["CVE-2019-3823"],
  File "/home/runner/work/cve-bin-tool/cve-bin-tool/test/test_scanner.py", line 95, in _binary_test
    self.assertIn(version, list(cves[package].keys()))
AssertionError: '3.8.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1' not found in ['3.8.1']

----------------------------------------------------------------------
Ran 91 tests in 205.641s

FAILED (failures=1, skipped=26)
Test failed: <unittest.runner.TextTestResult run=91 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=91 errors=0 failures=1>

Screenshot (17)

@terriko Please help and look into this error. Is there any way how we can remove this error. It's making my PR fail every time.

@SinghHrmn
Copy link
Contributor Author

@terriko Found the error. It was same as kerberos.py. icu.py was not returning UNKNOWN which was making cli.py inconsistent. You can see that in file changes.

@SinghHrmn
Copy link
Contributor Author

@terriko Finally I'm feeling happy. I hope this PR will be beneficial for our tool. :)

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! I'm so excited to finally get this merged.

@terriko terriko merged commit 58ac20a into intel:master Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants