Class: Gitlab::Ci::Parsers::Security::Common
- Inherits:
-
Object
- Object
- Gitlab::Ci::Parsers::Security::Common
- Defined in:
- lib/gitlab/ci/parsers/security/common.rb
Direct Known Subclasses
Constant Summary collapse
- SecurityReportParserError =
Class.new(Gitlab::Ci::Parsers::ParserError)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(json_data, report, signatures_enabled: false, validate: false) ⇒ Common
constructor
A new instance of Common.
- #parse! ⇒ Object
Constructor Details
#initialize(json_data, report, signatures_enabled: false, validate: false) ⇒ Common
Returns a new instance of Common.
14 15 16 17 18 19 20 |
# File 'lib/gitlab/ci/parsers/security/common.rb', line 14 def initialize(json_data, report, signatures_enabled: false, validate: false) @json_data = json_data @report = report @project = report.project @validate = validate @signatures_enabled = signatures_enabled end |
Class Method Details
.parse!(json_data, report, signatures_enabled: false, validate: false) ⇒ Object
10 11 12 |
# File 'lib/gitlab/ci/parsers/security/common.rb', line 10 def self.parse!(json_data, report, signatures_enabled: false, validate: false) new(json_data, report, signatures_enabled: signatures_enabled, validate: validate).parse! end |
Instance Method Details
#parse! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab/ci/parsers/security/common.rb', line 22 def parse! sanitize_json_data set_report_version return report_data unless valid? raise SecurityReportParserError, "Invalid report format" unless report_data.is_a?(Hash) create_scanner(top_level_scanner_data) create_scan create_analyzer create_findings report_data rescue JSON::ParserError raise SecurityReportParserError, 'JSON parsing failed' rescue StandardError raise SecurityReportParserError, "#{report.type} security report parsing failed" end |