dradis-veracode 4.13.0 → 4.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/dradis/plugins/veracode/field_processor.rb +4 -3
- data/lib/dradis/plugins/veracode/formats/flaw.rb +19 -0
- data/lib/dradis/plugins/veracode/formats/vulnerability.rb +17 -0
- data/lib/dradis/plugins/veracode/gem_version.rb +1 -1
- data/lib/dradis/plugins/veracode/importer.rb +18 -19
- data/lib/dradis/plugins/veracode/mapping.rb +29 -0
- data/lib/dradis/plugins/veracode.rb +2 -0
- data/lib/dradis-veracode.rb +1 -0
- data/lib/veracode/vulnerability.rb +58 -0
- data/spec/dradis/plugins/veracode/importer_spec.rb +6 -7
- data/templates/sca_evidence.sample +19 -0
- data/templates/sca_issue.sample +19 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 377e92adc3f11ee6e82f78c510986e3b39321d26810ae37f88630aa86f799684
|
4
|
+
data.tar.gz: 73d9d5ecac85b5b97b75525f6fc7f4e182e0f7742f917bd56444daecd0087284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4e88b7881297ffddecfb2c9e349e1e88cdfa5a84b4fd755bab1ccdc9a03c2569e513aaae874fd27324f33afb711255ab483cea456d94f3117e9a333ac0848b
|
7
|
+
data.tar.gz: 4007fbf71e3e6d5586947f51e54088712c1776af832b3ab4ab49d8612733355bbc0400767f3917fde38e2d8f363237e870eb5637a6b1c343b0d1a68396aa9574
|
data/CHANGELOG.md
CHANGED
@@ -4,14 +4,15 @@ module Dradis
|
|
4
4
|
class FieldProcessor < Dradis::Plugins::Upload::FieldProcessor
|
5
5
|
def post_initialize(args = {})
|
6
6
|
@record =
|
7
|
-
if
|
7
|
+
if data.is_a?(::Veracode::Flaw) || data.is_a?(::Veracode::Evidence) || data.is_a?(::Veracode::Vulnerability)
|
8
8
|
data
|
9
|
-
|
10
9
|
# Note: The evidence and flaw samples are the same but they need to
|
11
10
|
# be differentiated in the plugins manager preview. In that case,
|
12
11
|
# we're adding a "dradis_type" attribute in the evidence.sample file
|
13
|
-
elsif
|
12
|
+
elsif data['dradis_type'] == 'evidence'
|
14
13
|
::Veracode::Evidence.new(data.at_xpath('./staticflaws/flaw'))
|
14
|
+
elsif data.name == 'component'
|
15
|
+
::Veracode::Vulnerability.new(data.at_xpath('./vulnerabilities/vulnerability'))
|
15
16
|
else
|
16
17
|
::Veracode::Flaw.new(data.at_xpath('./staticflaws/flaw'))
|
17
18
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Dradis::Plugins::Veracode::Formats
|
2
|
+
module Flaw
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def parse_flaw(xml_flaw)
|
7
|
+
cwe_id = xml_flaw[:cweid]
|
8
|
+
logger.info { "\t\t => Creating issue and evidence (flaw cweid: #{ cwe_id })" }
|
9
|
+
|
10
|
+
flaw = ::Veracode::Flaw.new(xml_flaw)
|
11
|
+
issue_text = mapping_service.apply_mapping(source: 'issue', data: flaw)
|
12
|
+
issue = content_service.create_issue(text: issue_text, id: cwe_id)
|
13
|
+
|
14
|
+
evidence = ::Veracode::Evidence.new(xml_flaw)
|
15
|
+
evidence_text = mapping_service.apply_mapping(source: 'evidence', data: evidence)
|
16
|
+
content_service.create_evidence(content: evidence_text, issue: issue, node: node)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Dradis::Plugins::Veracode::Formats
|
2
|
+
module Vulnerability
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def parse_vulnerability(xml_vuln)
|
7
|
+
cve_id = xml_vuln[:cve_id]
|
8
|
+
vuln = ::Veracode::Vulnerability.new(xml_vuln)
|
9
|
+
issue_text = mapping_service.apply_mapping(source: 'sca_issue', data: vuln)
|
10
|
+
issue = content_service.create_issue(text: issue_text, id: cve_id)
|
11
|
+
|
12
|
+
evidence = ::Veracode::Vulnerability.new(xml_vuln)
|
13
|
+
evidence_text = mapping_service.apply_mapping(source: 'sca_evidence', data: evidence)
|
14
|
+
content_service.create_evidence(content: evidence_text, issue: issue, node: node)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Dradis::Plugins::Veracode
|
2
2
|
class Importer < Dradis::Plugins::Upload::Importer
|
3
|
+
attr_accessor :node
|
4
|
+
|
5
|
+
include Dradis::Plugins::Veracode::Formats::Flaw
|
6
|
+
include Dradis::Plugins::Veracode::Formats::Vulnerability
|
7
|
+
|
3
8
|
def self.templates
|
4
|
-
{ evidence: 'evidence', issue: 'issue' }
|
9
|
+
{ evidence: ['evidence', 'sca_evidence'], issue: ['issue', 'sca_issue'] }
|
5
10
|
end
|
6
11
|
|
7
12
|
# The framework will call this function if the user selects this plugin from
|
@@ -25,15 +30,22 @@ module Dradis::Plugins::Veracode
|
|
25
30
|
end
|
26
31
|
|
27
32
|
# create app_name, and parse attributes
|
28
|
-
node = parse_report_details(xml.root)
|
33
|
+
@node = parse_report_details(xml.root)
|
29
34
|
|
30
|
-
# parse each severity > category > cwe >
|
31
|
-
xml.root.xpath('
|
35
|
+
# parse each severity > category > cwe > staticflaws > flaw
|
36
|
+
xml.root.xpath('xmlns:severity').each do |xml_severity|
|
32
37
|
logger.info { "\t => Severity (level: #{ xml_severity[:level] })" }
|
33
|
-
xml_severity.xpath('
|
34
|
-
parse_flaw(xml_flaw
|
38
|
+
xml_severity.xpath('./xmlns:category/xmlns:cwe/xmlns:staticflaws/xmlns:flaw').each do |xml_flaw|
|
39
|
+
parse_flaw(xml_flaw)
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
43
|
+
# parse each software_composition_analysis > ... > vulnerability
|
44
|
+
xml.root.xpath(
|
45
|
+
'xmlns:software_composition_analysis/xmlns:vulnerable_components//xmlns:vulnerability'
|
46
|
+
).each do |xml_vuln|
|
47
|
+
parse_vulnerability(xml_vuln)
|
48
|
+
end
|
37
49
|
end
|
38
50
|
|
39
51
|
private
|
@@ -54,18 +66,5 @@ module Dradis::Plugins::Veracode
|
|
54
66
|
app_node.save
|
55
67
|
app_node
|
56
68
|
end
|
57
|
-
|
58
|
-
def parse_flaw(xml_flaw, node)
|
59
|
-
cwe_id = xml_flaw[:cweid]
|
60
|
-
logger.info { "\t\t => Creating issue and evidence (flaw cweid: #{ cwe_id })" }
|
61
|
-
|
62
|
-
flaw = ::Veracode::Flaw.new(xml_flaw)
|
63
|
-
issue_text = mapping_service.apply_mapping(source: 'issue', data: flaw)
|
64
|
-
issue = content_service.create_issue(text: issue_text, id: cwe_id)
|
65
|
-
|
66
|
-
veracode_evidence = ::Veracode::Evidence.new(xml_flaw)
|
67
|
-
evidence_text = mapping_service.apply_mapping(source: 'evidence', data: veracode_evidence)
|
68
|
-
evidence = content_service.create_evidence(content: evidence_text, issue: issue, node: node)
|
69
|
-
end
|
70
69
|
end
|
71
70
|
end
|
@@ -18,6 +18,18 @@ module Dradis::Plugins::Veracode
|
|
18
18
|
'Category' => '{{ veracode[issue.categoryname] }}',
|
19
19
|
'CWE' => '{{ veracode[issue.cweid] }}',
|
20
20
|
'RemediationStatus' => '{{ veracode[issue.remediation_status] }}'
|
21
|
+
},
|
22
|
+
sca_evidence: {
|
23
|
+
'File' => "{{ veracode[sca_evidence.file_name] }}\n{{ veracode[sca_evidence.file_path_value] }}",
|
24
|
+
'Library' => "{{ veracode[sca_evidence.library] }}\n{{ veracode[sca_evidence.library_id] }}",
|
25
|
+
'Mitigation' => "{{ veracode[sca_evidence.mitigation] }}"
|
26
|
+
},
|
27
|
+
sca_issue: {
|
28
|
+
'Title' => '{{ veracode[sca_issue.cve_id] }}',
|
29
|
+
'Description' => '{{ veracode[sca_issue.cve_summary] }}',
|
30
|
+
'Severity' => '{{ veracode[sca_issue.severity_desc] }}',
|
31
|
+
'Notes' => "CWE: {{ veracode[sca_issue.cwe_id] }}\nCVSS: {{ veracode[sca_issue.cvss_score] }}\nAffects policy compliance: {{ veracode[sca_issue.vulnerability_affects_policy_compliance] }}",
|
32
|
+
'Mitigation' => "{{ veracode[sca_issue.mitigation] }}"
|
21
33
|
}
|
22
34
|
}.freeze
|
23
35
|
|
@@ -53,6 +65,23 @@ module Dradis::Plugins::Veracode
|
|
53
65
|
'issue.severity',
|
54
66
|
'issue.sourcefile',
|
55
67
|
'issue.sourcefilepath'
|
68
|
+
],
|
69
|
+
sca_evidence: [
|
70
|
+
'sca_evidence.file_name',
|
71
|
+
'sca_evidence.file_path_value',
|
72
|
+
'sca_evidence.library',
|
73
|
+
'sca_evidence.library_id',
|
74
|
+
'sca_evidence.mitigation',
|
75
|
+
],
|
76
|
+
sca_issue: [
|
77
|
+
'sca_issue.cve_id',
|
78
|
+
'sca_issue.cve_summary',
|
79
|
+
'sca_issue.cvss_score',
|
80
|
+
'sca_issue.cwe_id',
|
81
|
+
'sca_issue.mitigation',
|
82
|
+
'sca_issue.severity',
|
83
|
+
'sca_issue.severity_desc',
|
84
|
+
'sca_issue.vulnerability_affects_policy_compliance'
|
56
85
|
]
|
57
86
|
}.freeze
|
58
87
|
end
|
@@ -7,6 +7,8 @@ end
|
|
7
7
|
|
8
8
|
require 'dradis/plugins/veracode/engine'
|
9
9
|
require 'dradis/plugins/veracode/field_processor'
|
10
|
+
require 'dradis/plugins/veracode/formats/vulnerability'
|
11
|
+
require 'dradis/plugins/veracode/formats/flaw'
|
10
12
|
require 'dradis/plugins/veracode/mapping'
|
11
13
|
require 'dradis/plugins/veracode/importer'
|
12
14
|
require 'dradis/plugins/veracode/version'
|
data/lib/dradis-veracode.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Veracode
|
2
|
+
class Vulnerability
|
3
|
+
attr_reader :xml_vulnerability
|
4
|
+
|
5
|
+
def initialize(xml_vulnerability)
|
6
|
+
@xml = xml_vulnerability
|
7
|
+
end
|
8
|
+
|
9
|
+
# List of supported tags. They can be attributes, simple descendans or
|
10
|
+
# collections (e.g. <references/>, <tags/>)
|
11
|
+
def supported_tags
|
12
|
+
[
|
13
|
+
:cve_id, :cve_summary, :cvss_score, :cwe_id, :file_name, :file_path,
|
14
|
+
:library, :library_id, :mitigation, :severity, :severity_desc,
|
15
|
+
:vulnerability_affects_policy_compliance
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
# This allows external callers (and specs) to check for implemented
|
20
|
+
# properties
|
21
|
+
def respond_to?(method, include_private = false)
|
22
|
+
return true if supported_tags.include?(method.to_sym)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
# This method is invoked by Ruby when a method that is not defined in this
|
27
|
+
# instance is called.
|
28
|
+
#
|
29
|
+
# In our case we inspect the @method@ parameter and try to find the
|
30
|
+
# attribute, simple descendent or collection that it maps to in the XML
|
31
|
+
# tree.
|
32
|
+
def method_missing(method, *args)
|
33
|
+
# We could remove this check and return nil for any non-recognized tag.
|
34
|
+
# The problem would be that it would make tricky to debug problems with
|
35
|
+
# typos. For instance: <>.potr would return nil instead of raising an
|
36
|
+
# exception
|
37
|
+
unless supported_tags.include?(method)
|
38
|
+
super
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
method_name = method.to_s
|
43
|
+
|
44
|
+
if method_name == 'mitigation'
|
45
|
+
return @xml.xpath('.//*:mitigation').map do |mitigation|
|
46
|
+
"#{mitigation.attr('action')}\n#{mitigation.attr('description')}\n#{mitigation.attr('date')}"
|
47
|
+
end.join("\n\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
# First we try the attributes
|
51
|
+
return @xml.attributes[method_name].value if @xml.attributes.key?(method_name)
|
52
|
+
|
53
|
+
# Next we try the parent <component> attributes
|
54
|
+
component = @xml.parent.parent
|
55
|
+
return component.attributes[method_name].value if component.attributes.key?(method_name)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -2,12 +2,13 @@ require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
describe Dradis::Plugins::Veracode::Importer do
|
5
|
-
|
6
5
|
before(:each) do
|
7
6
|
# Stub template service
|
8
7
|
templates_dir = File.expand_path('../../../../../templates', __FILE__)
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
mapping_service = double('Dradis::Plugins::MappingService')
|
10
|
+
allow(mapping_service).to receive(:apply_mapping).and_return('')
|
11
|
+
allow(Dradis::Plugins::MappingService).to receive(:new).and_return(mapping_service)
|
11
12
|
|
12
13
|
# Init services
|
13
14
|
plugin = Dradis::Plugins::Veracode
|
@@ -36,13 +37,11 @@ describe Dradis::Plugins::Veracode::Importer do
|
|
36
37
|
it 'creates nodes, issues, and, evidence' do
|
37
38
|
expect(@content_service).to receive(:create_node).with(hash_including label: 'Cybersecurity-Pilot').once
|
38
39
|
|
39
|
-
%w{ 117 382 }.each do |cweid|
|
40
|
+
%w{ 117 382 CVE-2022-41404 CVE-2022-36033 SRCCLR-SID-22742 CVE-2022-42889 }.each do |cweid|
|
40
41
|
expect(@content_service).to receive(:create_issue).with(hash_including id: cweid).at_least(:once)
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
expect(@content_service).to receive(:create_evidence).with(hash_including(content: a_string_matching(/#{line}/))).once
|
45
|
-
end
|
44
|
+
expect(@content_service).to receive(:create_evidence).with(hash_including(content: '')).at_least(7).times
|
46
45
|
|
47
46
|
# Run the import
|
48
47
|
@importer.import(file: 'spec/fixtures/files/veracode.xml')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<component component_id="hash" file_name="filename.jar" sha1="" vulnerabilities="1" max_cvss_score="5.0" version="0.1.1" library="library" library_id="library_id" vendor="library.org" description="Sample description" added_date="2022-12-12 08:19:55 UTC" component_affects_policy_compliance="false">
|
2
|
+
<file_paths>
|
3
|
+
<file_path value="file_path"/>
|
4
|
+
</file_paths>
|
5
|
+
<licenses>
|
6
|
+
<license name="License" spdx_id="Apache-2.0" license_url="example.com" risk_rating="2" mitigation="false" license_affects_policy_compliance="false">
|
7
|
+
<mitigations/>
|
8
|
+
</license>
|
9
|
+
</licenses>
|
10
|
+
<vulnerabilities>
|
11
|
+
<vulnerability cve_id="CVE-2022-11111" cvss_score="5.0" severity="3" cwe_id="" first_found_date="2022-12-12 08:19:55 UTC" cve_summary="CVE Summary" severity_desc="Medium" mitigation="true" mitigation_type="Mitigate by Design" mitigated_date="2022-12-12 16:00:29 UTC" vulnerability_affects_policy_compliance="false">
|
12
|
+
<mitigations>
|
13
|
+
<mitigation action="Approve Mitigation" description="asda" user="sample_user" date="2022-12-12 16:00:55 UTC"/>
|
14
|
+
<mitigation action="Mitigate by Design" description="fdsa" user="sample_user" date="2022-12-12 15:59:55 UTC"/>
|
15
|
+
</mitigations>
|
16
|
+
</vulnerability>
|
17
|
+
</vulnerabilities>
|
18
|
+
<violated_policy_rules/>
|
19
|
+
</component>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<component component_id="hash" file_name="filename.jar" sha1="" vulnerabilities="1" max_cvss_score="5.0" version="0.1.1" library="library" library_id="library_id" vendor="library.org" description="Sample description" added_date="2022-12-12 08:19:55 UTC" component_affects_policy_compliance="false">
|
2
|
+
<file_paths>
|
3
|
+
<file_path value="file_path"/>
|
4
|
+
</file_paths>
|
5
|
+
<licenses>
|
6
|
+
<license name="License" spdx_id="Apache-2.0" license_url="example.com" risk_rating="2" mitigation="false" license_affects_policy_compliance="false">
|
7
|
+
<mitigations/>
|
8
|
+
</license>
|
9
|
+
</licenses>
|
10
|
+
<vulnerabilities>
|
11
|
+
<vulnerability cve_id="CVE-2022-11111" cvss_score="5.0" severity="3" cwe_id="" first_found_date="2022-12-12 08:19:55 UTC" cve_summary="CVE Summary" severity_desc="Medium" mitigation="true" mitigation_type="Mitigate by Design" mitigated_date="2022-12-12 16:00:29 UTC" vulnerability_affects_policy_compliance="false">
|
12
|
+
<mitigations>
|
13
|
+
<mitigation action="Approve Mitigation" description="asda" user="sample_user" date="2022-12-12 16:00:55 UTC"/>
|
14
|
+
<mitigation action="Mitigate by Design" description="fdsa" user="sample_user" date="2022-12-12 15:59:55 UTC"/>
|
15
|
+
</mitigations>
|
16
|
+
</vulnerability>
|
17
|
+
</vulnerabilities>
|
18
|
+
<violated_policy_rules/>
|
19
|
+
</component>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dradis-veracode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dradis Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dradis-plugins
|
@@ -102,6 +102,8 @@ files:
|
|
102
102
|
- lib/dradis/plugins/veracode.rb
|
103
103
|
- lib/dradis/plugins/veracode/engine.rb
|
104
104
|
- lib/dradis/plugins/veracode/field_processor.rb
|
105
|
+
- lib/dradis/plugins/veracode/formats/flaw.rb
|
106
|
+
- lib/dradis/plugins/veracode/formats/vulnerability.rb
|
105
107
|
- lib/dradis/plugins/veracode/gem_version.rb
|
106
108
|
- lib/dradis/plugins/veracode/importer.rb
|
107
109
|
- lib/dradis/plugins/veracode/mapping.rb
|
@@ -109,11 +111,14 @@ files:
|
|
109
111
|
- lib/tasks/thorfile.rb
|
110
112
|
- lib/veracode/evidence.rb
|
111
113
|
- lib/veracode/flaw.rb
|
114
|
+
- lib/veracode/vulnerability.rb
|
112
115
|
- spec/dradis/plugins/veracode/importer_spec.rb
|
113
116
|
- spec/fixtures/files/veracode.xml
|
114
117
|
- spec/spec_helper.rb
|
115
118
|
- templates/evidence.sample
|
116
119
|
- templates/issue.sample
|
120
|
+
- templates/sca_evidence.sample
|
121
|
+
- templates/sca_issue.sample
|
117
122
|
homepage: https://dradis.com/integrations/veracode.html
|
118
123
|
licenses:
|
119
124
|
- GPL-2
|