patchman icon indicating copy to clipboard operation
patchman copied to clipboard

Add a list hosts CSV output with security/bugfix broken out.

Open garbled1 opened this issue 6 years ago • 10 comments

Patch 4/4: Create a CSV output report with the addition of bugfix and security patches needed broken out.

garbled1 avatar Aug 22 '19 14:08 garbled1

What is the use-case for this PR?

furlongm avatar Aug 27 '19 23:08 furlongm

Current report format is not easily machine parsable. I need to be able to archive reports for audit purposes. Current report also does not separate out bugfix/security whereas the web interface does. The web interface is useful for quick looks, but I need reporting features and the ability to parse the data.

garbled1 avatar Aug 28 '19 22:08 garbled1

However, there is a REST API that could be used to produce machine-parsable output.

furlongm avatar Aug 28 '19 23:08 furlongm

However, there is a REST API that could be used to produce machine-parsable output.

When calling /api/hosts, can it return the list of updates into separate sections?

For example:

{
  "updates": {
    "bugfix": [
      "http://localhost/patchman/api/package-update/173/"
    ],
    "security": [
      "http://localhost/patchman/api/package-update/182/"
    ]
  ]
}

Otherwise, I'll have to do something like this (psuedo-code), which I expect to take much longer (at least, I assume...this is untested):

hosts = get "/api/hosts"

for host in hosts:
  updates = {
    "bugfix": [],
    "security": []
  }

  for update_url in host.updates
    update = get "update_url"

    if update.security:
      updates['security'].append( update )
    else
      updates['bugfix'].append( update )

    host['updates'] = updates # overwrite flat list with more detailed dict

For me, I want to be alerted only when there are security updates available. And right now, my script only alerts me when the list of updates is not empty since I don't have the knowledge of update "type".

dandunckelman avatar Mar 09 '20 20:03 dandunckelman

Hi,

just to reinforce that this in general would be nice to have.

My usecase is that I have multiple Patchman instances, and I want to create a basic dashboard for those.

I'd love to have basically a summary for the hosts (at least hostname, additional host information, number of critical updates, updates).

The current API would require me to crawl all the update-URLs, which is prohibitively expensive.

CSV is good common format, however I'd prefer it to be JSON like the rest of the API. Another API approach would be to allow 'joining' Models before serializing them, however that'd make the API-Responses even more heavyweight.

BuJo avatar Oct 12 '20 12:10 BuJo

Hi,

just to reinforce that this in general would be nice to have.

My usecase is that I have multiple Patchman instances, and I want to create a basic dashboard for those.

I'd love to have basically a summary for the hosts (at least hostname, additional host information, number of critical updates, updates).

The current API would require me to crawl all the update-URLs, which is prohibitively expensive.

CSV is good common format, however I'd prefer it to be JSON like the rest of the API. Another API approach would be to allow 'joining' Models before serializing them, however that'd make the API-Responses even more heavyweight.

I am looking at updating the API to give the info requested.

This script might be useful for anyone who wants to test: https://gist.github.com/furlongm/a194697b7aa171411b7fffe2a64b06cc

Crawling the update urls is expensive so trying to think of the best way of representing the updates in the current API? I think the API could probably give info about the number of security and bugfix updates per host, and that might be enough, or maybe just a list of package names that are out of date?

furlongm avatar Oct 14 '20 21:10 furlongm

I'd think the backwards compatibility of the current API should largely be retained. I'd avoid removing the current fields, however adding fields shouldn't be a problem.

I would be happy with just new count fields as a kind of 'summary'. I think the OP only needed the counts as well?

BuJo avatar Oct 15 '20 12:10 BuJo

c9f29f1af835ffe794fdfc5c5dcf2926d61724e9 adds the counts for security and bugfix updates to the API. Let me know if that works

furlongm avatar Feb 14 '21 23:02 furlongm

Very cool, I will try it out, thank you @furlongm

BuJo avatar Feb 19 '21 12:02 BuJo

@furlongm I rolled out the newest Version, it works perfectly for my usecase. Thank you so much!

BuJo avatar Feb 26 '21 08:02 BuJo