diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-03-16 07:33:33 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-03-16 07:33:33 -0400 |
commit | c00a99805c35817b63ec195a97e211464f8a1f04 (patch) | |
tree | b80f36265521b13abb018f1ff70fdcab19373d95 | |
parent | 0c061e2f1acf856686df206f200c7769e4438ae1 (diff) | |
download | cvez-c00a99805c35817b63ec195a97e211464f8a1f04.tar.bz2 cvez-c00a99805c35817b63ec195a97e211464f8a1f04.zip |
bin/cisa-sizes.rb: add utility script
-rwxr-xr-x | bin/cisa-sizes.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/cisa-sizes.rb b/bin/cisa-sizes.rb new file mode 100755 index 0000000..88ec7d3 --- /dev/null +++ b/bin/cisa-sizes.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby + +# +# cisa-sizes.rb: get maximum field lengths from compressed cisa +# kev catalog. +# + +require 'json' +require 'zlib' + +# path to vulnerabilities +PATH = File.join(__dir__, '../cisa/testdata/cisa-kevc-20220313.json.gz') + +# read vulns +ROWS = JSON(Zlib::GzipReader.new(File.open(PATH)).read)['vulnerabilities'] + +# get/print json-encoded maximum field lengths +puts JSON(ROWS.each.with_object(Hash.new { |h, k| h[k] = 0 }) do |row, r| + row.each { |k, v| r[k] = v.size if v.size > r[k] } +end) |