Commit 72b7ba42 authored by Gilbert Roulot's avatar Gilbert Roulot

Add file and line numbers to vuln issues

Add file and line numbers to the issues created from the
vulnerability modal in the security dashboards.
parent 1a629751
...@@ -8,6 +8,12 @@ ...@@ -8,6 +8,12 @@
<% if vulnerability.confidence.present? %> <% if vulnerability.confidence.present? %>
* Confidence: <%= vulnerability.confidence %> * Confidence: <%= vulnerability.confidence %>
<% end %> <% end %>
<% if defined?(vulnerability.file) && vulnerability.file.present?
location_text = [vulnerability.file, vulnerability.line].compact.join(':')
location_link = [vulnerability.file, vulnerability.line].compact.join('#L')
%>
* Location: [<%= location_text %>](<%= location_link %>)
<% end %>
<% if vulnerability.solution.present? %> <% if vulnerability.solution.present? %>
### Solution: ### Solution:
......
---
title: Add file and line numbers to issues created from SAST vulnerabilities
merge_request: 8578
author:
type: changed
...@@ -18,6 +18,14 @@ module Gitlab ...@@ -18,6 +18,14 @@ module Gitlab
def description def description
@data[:description].presence || @data[:title] @data[:description].presence || @data[:title]
end end
def file
@data[:file].presence || @data[:location]&.[](:file)
end
def line
@data[:line].presence || @data[:location]&.[](:start_line)
end
end end
end end
end end
...@@ -32,6 +32,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -32,6 +32,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
severity: 'Low', confidence: 'High', severity: 'Low', confidence: 'High',
solution: 'Please do something!', solution: 'Please do something!',
file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java', file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java',
line: '15',
cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM', cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM',
title: 'Predictable pseudorandom number generator', title: 'Predictable pseudorandom number generator',
description: 'Description of Predictable pseudorandom number generator', description: 'Description of Predictable pseudorandom number generator',
...@@ -69,6 +70,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -69,6 +70,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
* Severity: Low * Severity: Low
* Confidence: High * Confidence: High
* Location: [subdir/src/main/java/com/gitlab/security_products/tests/App.java:15](subdir/src/main/java/com/gitlab/security_products/tests/App.java#L15)
### Solution: ### Solution:
...@@ -97,6 +99,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -97,6 +99,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
severity: 'Low', confidence: 'High', severity: 'Low', confidence: 'High',
solution: 'Please do something!', solution: 'Please do something!',
file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java', file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java',
line: '15',
cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM', cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM',
title: 'Predictable pseudorandom number generator', title: 'Predictable pseudorandom number generator',
tool: 'find_sec_bugs' tool: 'find_sec_bugs'
...@@ -111,6 +114,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -111,6 +114,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
* Severity: Low * Severity: Low
* Confidence: High * Confidence: High
* Location: [subdir/src/main/java/com/gitlab/security_products/tests/App.java:15](subdir/src/main/java/com/gitlab/security_products/tests/App.java#L15)
### Solution: ### Solution:
...@@ -130,6 +134,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -130,6 +134,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
severity: 'Low', confidence: 'High', severity: 'Low', confidence: 'High',
solution: 'Please do something!', solution: 'Please do something!',
file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java', file: 'subdir/src/main/java/com/gitlab/security_products/tests/App.java',
line: '15',
cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM', cve: '818bf5dacb291e15d9e6dc3c5ac32178:PREDICTABLE_RANDOM',
title: 'Predictable pseudorandom number generator', title: 'Predictable pseudorandom number generator',
description: 'Description of Predictable pseudorandom number generator', description: 'Description of Predictable pseudorandom number generator',
...@@ -166,6 +171,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -166,6 +171,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
* Severity: Low * Severity: Low
* Confidence: High * Confidence: High
* Location: [subdir/src/main/java/com/gitlab/security_products/tests/App.java:15](subdir/src/main/java/com/gitlab/security_products/tests/App.java#L15)
### Solution: ### Solution:
...@@ -209,6 +215,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do ...@@ -209,6 +215,7 @@ describe Issues::CreateFromVulnerabilityDataService, '#execute' do
* Severity: Low * Severity: Low
* Confidence: High * Confidence: High
* Location: [subdir/src/main/java/com/gitlab/security_products/tests/App.java:41](subdir/src/main/java/com/gitlab/security_products/tests/App.java#L41)
### Solution: ### Solution:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment