Class: Finding
- Inherits:
-
Object
- Object
- Finding
- Defined in:
- lib/heimdall_tools/sonarqube_mapper.rb
Instance Attribute Summary collapse
-
#control_key ⇒ Object
readonly
Returns the value of attribute control_key.
Instance Method Summary collapse
- #get_result ⇒ Object
-
#initialize(vuln_data, sonar_api) ⇒ Finding
constructor
A new instance of Finding.
Constructor Details
#initialize(vuln_data, sonar_api) ⇒ Finding
Returns a new instance of Finding.
274 275 276 277 278 279 280 281 |
# File 'lib/heimdall_tools/sonarqube_mapper.rb', line 274 def initialize(vuln_data, sonar_api) @data = vuln_data @api = sonar_api @key = @data['key'] @control_key = @data['rule'] @project = @data['project'] end |
Instance Attribute Details
#control_key ⇒ Object (readonly)
Returns the value of attribute control_key.
271 272 273 |
# File 'lib/heimdall_tools/sonarqube_mapper.rb', line 271 def control_key @control_key end |
Instance Method Details
#get_result ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/heimdall_tools/sonarqube_mapper.rb', line 283 def get_result vuln_start = @data['textRange']['startLine'] vuln_end = @data['textRange']['endLine'] component = @data['component'] snip_start = [1, vuln_start - 3].max snip_end = vuln_end + 3 # api doesn't care if we request lines past end of file snip = @api.query_code_snippet(component, snip_start, snip_end) snip_html = "StartLine: #{snip_start}, EndLine: #{snip_end}<br>Code:<pre>#{snip}</pre>" { status: 'failed', code_desc: "Path:#{component}:#{vuln_start}:#{vuln_end} #{snip_html}", run_time: NA_FLOAT, start_time: Time.now.strftime('%a,%d %b %Y %X') } end |