def test_low_fail(self): test_uname = "Linux ubuntuexploit 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 " \ "x86_64 x86_64 x86_64 GNU/Linux" test_kernel = get_kernel_version(uname=test_uname) test_window_low_fail = KernelWindow(UBUNTU_GENERIC, BASE_VULNERABLE, 4, 10, 1, 4, 99, 99) low_fail_status = test_window_low_fail.kernel_in_window(test_kernel.distro, test_kernel.base) self.assertEqual(low_fail_status, None)
def test_base_vulnerable(self): test_uname = "Linux ubuntuexploit 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 " \ "x86_64 x86_64 x86_64 GNU/Linux" test_kernel = get_kernel_version(uname=test_uname) test_exact_window_pass = KernelWindow(UBUNTU_GENERIC, BASE_VULNERABLE, 4, 10, 0, 4, 10, 0) exact_pass_status = test_exact_window_pass.kernel_in_window(test_kernel.distro, test_kernel.base) self.assertEqual(exact_pass_status, BASE_VULNERABLE)
def test_digestible_json(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel) json_finds = convert_to_digestible(local_finds, digest="json") unjson_finds = json.loads(json_finds) self.assertEqual(len(unjson_finds[EXPLOIT_AVAILABLE]), len(local_finds[EXPLOIT_AVAILABLE]))
def test_dump_to_file(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel) json_finds = convert_to_digestible(local_finds, digest="json") test_outfile = os.path.join(ROOT_DIR, "output.json") if os.path.exists(test_outfile): os.remove(test_outfile) write_digestible_to_file(test_outfile, json_finds) self.assertTrue(os.path.exists(test_outfile)) # remove it so it's not in the project if os.path.exists(test_outfile): os.remove(test_outfile)
def test_digestible_xml(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel)