Class: GitlabBundlerAuditParser::Parser
- Inherits:
-
Object
- Object
- GitlabBundlerAuditParser::Parser
- Includes:
- ScanSection, VulnerabilitiesSection
- Defined in:
- lib/gitlab_bundler_audit_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_audit ⇒ Object
-
#initialize(outfile: nil) ⇒ Parser
constructor
A new instance of Parser.
- #ouput_audit ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(outfile: nil) ⇒ Parser
Returns a new instance of Parser.
12 13 14 |
# File 'lib/gitlab_bundler_audit_parser.rb', line 12 def initialize(outfile: nil) @outfile = outfile || 'gl-dependency-scanning-report.json' end |
Class Method Details
.run(outfile: nil) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gitlab_bundler_audit_parser.rb', line 16 def self.run(outfile: nil) parser = new outfile: outfile parser.parse parser.create_audit parser.ouput_audit end |
Instance Method Details
#create_audit ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/gitlab_bundler_audit_parser.rb', line 28 def create_audit @audit = { version: @parsed_audit['version'] } @audit.merge! create_vulnerabilities_section(@parsed_audit) @audit.merge! create_scan_section(@parsed_audit) end |
#ouput_audit ⇒ Object
36 37 38 39 40 |
# File 'lib/gitlab_bundler_audit_parser.rb', line 36 def ouput_audit encoded = JSON.generate(@audit) File.write(@outfile, encoded) @audit[:vulnerabilities].any? end |
#parse ⇒ Object
23 24 25 26 |
# File 'lib/gitlab_bundler_audit_parser.rb', line 23 def parse input = $stdin.read @parsed_audit = JSON.parse(input) end |