#!/usr/bin/env ruby # # cisa-sizes.rb: get min/max field lengths from cisa 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 min/max field lengths puts JSON(ROWS.each.with_object(Hash.new { |h, k| h[k] = {} }) do |row, r| row.each do |k, v| r[k][:min] = v.size if !r[k][:min] || v.size < r[k][:min] r[k][:max] = v.size if !r[k][:max] || v.size > r[k][:max] end end)