Class: Package::Audit::Npm::VulnerabilityFinder
- Inherits:
-
Object
- Object
- Package::Audit::Npm::VulnerabilityFinder
- Defined in:
- lib/package/audit/npm/vulnerability_finder.rb
Constant Summary collapse
- AUDIT_ADVISORY_REGEX =
/^{"type":"auditAdvisory".*$/
Instance Method Summary collapse
-
#initialize(dir, pkgs) ⇒ VulnerabilityFinder
constructor
A new instance of VulnerabilityFinder.
- #run ⇒ Object
Constructor Details
#initialize(dir, pkgs) ⇒ VulnerabilityFinder
Returns a new instance of VulnerabilityFinder.
10 11 12 13 14 |
# File 'lib/package/audit/npm/vulnerability_finder.rb', line 10 def initialize(dir, pkgs) @dir = dir @pkg_hash = pkgs.to_h { |pkg| [pkg.name, pkg] } @vuln_hash = {} end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/package/audit/npm/vulnerability_finder.rb', line 16 def run json_string_lines = `#{format(Const::Cmd::YARN_AUDIT_JSON, @dir)}` array = json_string_lines.scan(AUDIT_ADVISORY_REGEX) vulnerability_json_array = JSON.parse("[#{array.join(',')}]", symbolize_names: true) vulnerability_json_array.each do |vulnerability_json| (vulnerability_json) end @vuln_hash.values end |