Sha256: 3345e8ec500b6f6a9183f2b2f2f98a87f12683888db884b96e268e18a105b0cf
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
module Yarn module Audit module Wrap class AuditParser attr_accessor :output def initialize opts: @opts = opts @ignored = { info: [], low: [], moderate: [], high: [], critical: [] } parse_json_audit end def parse_json_audit audit_json = @opts[:audit_json] @output = if File.exist?(audit_json) File.readlines(audit_json).map do |line| JSON.parse(line) end else [] end end def add_ignored(type:, val:) @ignored[type.to_sym] << val end def select(&blk) if @output @output.select do |item| yield item if item["type"] == "auditAdvisory" end else [] end end def get_summary @output.detect { |item| item["type"] == "auditSummary" } || {} end def print_summary puts "\nOriginal Yarn Audit:" s = get_summary["data"] || {} s.each { |k, v| puts "#{k.to_s.rjust(23)}: #{v.inspect}" } puts "\nSkipped vulnerabilities:" @ignored.each do |k, v| puts "#{k.to_s.rjust(23)}: #{v.size}" end end end # class end # Wrap end end
Version data entries
4 entries across 4 versions & 1 rubygems