Skip to content

Instantly share code, notes, and snippets.

@jerryaldrichiii
Last active June 21, 2019 18:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerryaldrichiii/e23f33db5878a4e1649419e28271d272 to your computer and use it in GitHub Desktop.
Save jerryaldrichiii/e23f33db5878a4e1649419e28271d272 to your computer and use it in GitHub Desktop.
# Many thanks to Steven Danna (@ssd) for making this 100x more awesome.
FAKE_STDOUT = <<-EOX
Client Version: v1.10.9
Server Version: v1.10.10
EOX
control 'kube-1.0' do
title 'CVE-2018-1002105'
impact 1.0
cmd_stdout = FAKE_STDOUT # Should be `command('kubectl version --short').stdout`
version = cmd_stdout.match(/Server Version: v(.*)/)[1]
expected_version = case version
when /1.[0-9]\./
'1.10.10'
when /1\.10/
'1.10.10'
when /1\.11/
'1.11.4'
when /1\.12/
'1.12.2'
else
'1.12.2'
end
describe "Kube version: #{version}" do
it "should be greater than #{expected_version}" do
expect(version).to cmp > expected_version
end
end
end
@jerryaldrichiii
Copy link
Author

Example output:

×  kube-1.0: CVE-2018-1002105
   ×  Kube version: 1.10.10 should be greater than 1.10.10

   expected it to be > "1.10.10"
        got: "1.10.10"

   (compared using `cmp` matcher)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment