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

[enhancement] new method to determine the latest installed date #5

Open
username-is-already-taken2 opened this issue Dec 15, 2016 · 0 comments

Comments

@username-is-already-taken2

Hi there

This came up on the #compliance slack channel. The idea is that we create a method that would allow use to write a control where we can check the number of days since the last patch was installed.
i.e.

control 'os-patch-date-1.1' do
  impact 0.5
  title 'Check OS for last patching date - windows'
  desc 'This test will check windows applied a patch in the last 90 days'
  describe patch_date do
    its('days_since_last_patch_installed') { should be <= 90 }
  end
end

I've tried having ago to writing this myself but I've hit a gap in my ruby knowledge and would appreciate a steer.

You already did the ground work to get an array of hotfixes installed. I amended that to include InstalledOn property

I now have an array with items like this

{"Status"=>nil,
  "Description"=>"Security Update",
  "HotFixId"=>"KB3135173",
  "Caption"=>"http://support.microsoft.com/?kbid=3135173",
  "InstallDate"=>nil,
  "InstalledBy"=>"NT AUTHORITY\\SYSTEM",
  "InstalledOn"=>{"value"=>"/Date(1480636800000)/", "DateTime"=>"02 December 2016 00:00:00"}},
 {"Status"=>nil,
  "Description"=>"Update",
  "HotFixId"=>"KB3139907",
  "Caption"=>"http://support.microsoft.com/?kbid=3139907",
  "InstallDate"=>nil,
  "InstalledBy"=>"NT AUTHORITY\\SYSTEM",
  "InstalledOn"=>{"value"=>"/Date(1454457600000)/", "DateTime"=>"03 February 2016 00:00:00"}},
....

So I'm trying to find the lastest InstalledOn so I'm thinking I should sort the array and take the first one?

Once I have the date I was going to parse it and return the number of days.

Let me know what you think, I did think of getting powershell to do the sort for me but where's the fun in that :)

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

No branches or pull requests

1 participant