dradis-projects 4.14.0 → 4.15.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/projects/gem_version.rb +1 -1
- data/lib/dradis/plugins/projects/upload/v4/template.rb +4 -1
- data/spec/fixtures/files/attachments_url.xml +1 -1
- data/spec/fixtures/files/with_tags.xml +64 -0
- data/spec/lib/dradis/plugins/projects/upload/v4/template_spec.rb +36 -29
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d6e976fe4ffd84c283a90f731eebe6bc4c080834e05054ca9c89402afcb994
|
4
|
+
data.tar.gz: d4415dd2c527f90ad4ed2e3faa28d7cedab9f319a7ffb1a176b88e50282a08dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc6816b6ed95bda3c4b53b77b61ba8cbc941e0515450e55397cd41eac01ccf41f5ea2faf14a583b6cc9ab3882e20e038f856234374b19495a4130e993ea74e3
|
7
|
+
data.tar.gz: f6a1d560f01235671ec3698ad03e365b814ccac8333f8ac808396b6b7264c197a1f69f37bb931d585955da7a158ca4d6708a7d7d83049d3a3224b5db59552cab
|
data/CHANGELOG.md
CHANGED
@@ -383,11 +383,14 @@ module Dradis::Plugins::Projects::Upload::V4
|
|
383
383
|
def parse_tags(template)
|
384
384
|
logger.info { 'Processing Tags...' }
|
385
385
|
|
386
|
-
template.xpath('dradis-template/tags/tag').each do |xml_tag|
|
386
|
+
template.xpath('dradis-template/tags/tag').each.with_index(1) do |xml_tag, index|
|
387
387
|
name = xml_tag.at_xpath('name').text()
|
388
388
|
tag_params = { name: name }
|
389
389
|
tag_params[:project_id] = project.id if Tag.has_attribute?(:project_id)
|
390
|
+
|
390
391
|
tag = Tag.where(tag_params).first_or_create
|
392
|
+
tag.update(position: index) unless tag.position == index
|
393
|
+
|
391
394
|
logger.info { "New tag detected: #{name}" }
|
392
395
|
|
393
396
|
xml_tag.xpath('./taggings/tagging').each do |xml_tagging|
|
@@ -12,4 +12,4 @@ Test Issue
|
|
12
12
|
!/nodes/5/attachments/hello.jpg!
|
13
13
|
|
14
14
|
]]></text><activities></activities><comments></comments></issue></issues><methodologies></methodologies><categories>
|
15
|
-
<category><id>2</id><name>Issue description</name></category></categories><tags
|
15
|
+
<category><id>2</id><name>Issue description</name></category></categories><tags/></dradis-template>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<dradis-template version="2">
|
3
|
+
<nodes>
|
4
|
+
<node>
|
5
|
+
<id>5</id>
|
6
|
+
<label>Uploaded files</label>
|
7
|
+
<parent-id />
|
8
|
+
<position>0</position>
|
9
|
+
<properties><![CDATA[{
|
10
|
+
}]]></properties>
|
11
|
+
<type-id>0</type-id>
|
12
|
+
<notes></notes>
|
13
|
+
<evidence></evidence>
|
14
|
+
<activities></activities>
|
15
|
+
</node>
|
16
|
+
</nodes>
|
17
|
+
<issues>
|
18
|
+
<issue>
|
19
|
+
<id>2</id>
|
20
|
+
<author>admin@securityroots.com</author>
|
21
|
+
<text><![CDATA[#[Title]#
|
22
|
+
Test Issue
|
23
|
+
#[Description]#
|
24
|
+
hello world]]>
|
25
|
+
</text>
|
26
|
+
<activities></activities>
|
27
|
+
<comments></comments>
|
28
|
+
</issue>
|
29
|
+
</issues>
|
30
|
+
<methodologies></methodologies>
|
31
|
+
<categories>
|
32
|
+
<category>
|
33
|
+
<id>2</id>
|
34
|
+
<name>Issue description</name>
|
35
|
+
</category>
|
36
|
+
</categories>
|
37
|
+
<tags>
|
38
|
+
<tag>
|
39
|
+
<id>1</id>
|
40
|
+
<name>!2ca02c_info</name>
|
41
|
+
<taggings></taggings>
|
42
|
+
</tag>
|
43
|
+
<tag>
|
44
|
+
<id>2</id>
|
45
|
+
<name>!ff7f0e_medium</name>
|
46
|
+
<taggings></taggings>
|
47
|
+
</tag>
|
48
|
+
<tag>
|
49
|
+
<id>3</id>
|
50
|
+
<name>!d62728_high</name>
|
51
|
+
<taggings></taggings>
|
52
|
+
</tag>
|
53
|
+
<tag>
|
54
|
+
<id>4</id>
|
55
|
+
<name>!6baed6_low</name>
|
56
|
+
<taggings></taggings>
|
57
|
+
</tag>
|
58
|
+
<tag>
|
59
|
+
<id>5</id>
|
60
|
+
<name>!9467bd_critical</name>
|
61
|
+
<taggings></taggings>
|
62
|
+
</tag>
|
63
|
+
</tags>
|
64
|
+
</dradis-template>
|
@@ -7,6 +7,13 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
7
7
|
let(:project) { create(:project) }
|
8
8
|
let(:user) { create(:user) }
|
9
9
|
let(:importer_class) { Dradis::Plugins::Projects::Upload::Template }
|
10
|
+
let(:importer) do
|
11
|
+
importer_class::Importer.new(
|
12
|
+
default_user_id: user.id,
|
13
|
+
plugin: importer_class,
|
14
|
+
project_id: project.id
|
15
|
+
)
|
16
|
+
end
|
10
17
|
|
11
18
|
context 'uploading a template with attachments url' do
|
12
19
|
let(:file_path) do
|
@@ -14,12 +21,6 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
14
21
|
end
|
15
22
|
|
16
23
|
it 'converts the urls' do
|
17
|
-
importer = importer_class::Importer.new(
|
18
|
-
default_user_id: user.id,
|
19
|
-
plugin: importer_class,
|
20
|
-
project_id: project.id
|
21
|
-
)
|
22
|
-
|
23
24
|
importer.import(file: file_path)
|
24
25
|
|
25
26
|
p_id = project.id
|
@@ -40,12 +41,6 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'returns false' do
|
43
|
-
importer = importer_class::Importer.new(
|
44
|
-
default_user_id: user.id,
|
45
|
-
plugin: importer_class,
|
46
|
-
project_id: project.id
|
47
|
-
)
|
48
|
-
|
49
44
|
expect(importer.import(file: file_path)).to be false
|
50
45
|
end
|
51
46
|
end
|
@@ -87,12 +82,6 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
87
82
|
end
|
88
83
|
|
89
84
|
before do
|
90
|
-
importer = importer_class::Importer.new(
|
91
|
-
default_user_id: user.id,
|
92
|
-
plugin: importer_class,
|
93
|
-
project_id: project.id
|
94
|
-
)
|
95
|
-
|
96
85
|
importer.import(file: file_path)
|
97
86
|
end
|
98
87
|
|
@@ -132,17 +121,9 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
132
121
|
File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files')
|
133
122
|
end
|
134
123
|
|
135
|
-
before do
|
136
|
-
@importer = importer_class::Importer.new(
|
137
|
-
default_user_id: user.id,
|
138
|
-
plugin: importer_class,
|
139
|
-
project_id: project.id
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
124
|
context 'uploading a template without states' do
|
144
125
|
it 'imports issues with the published state' do
|
145
|
-
|
126
|
+
importer.import(file: File.join(dir, 'with_comments.xml'))
|
146
127
|
issue = project.issues.first
|
147
128
|
expect(issue.state).to eq('published')
|
148
129
|
end
|
@@ -151,7 +132,7 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
151
132
|
context 'uploading a template with states' do
|
152
133
|
context 'valid states' do
|
153
134
|
it 'imports issues with states from the template' do
|
154
|
-
|
135
|
+
importer.import(file: File.join(dir, 'with_states.xml'))
|
155
136
|
issue = project.issues.first
|
156
137
|
expect(issue.state).to eq('ready_for_review')
|
157
138
|
end
|
@@ -159,10 +140,36 @@ describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
159
140
|
|
160
141
|
context 'invalid states' do
|
161
142
|
it 'does not import the issue' do
|
162
|
-
|
143
|
+
importer.import(file: File.join(dir, 'with_invalid_states.xml'))
|
163
144
|
expect(project.issues.count).to eq(0)
|
164
145
|
end
|
165
146
|
end
|
166
147
|
end
|
167
148
|
end
|
149
|
+
|
150
|
+
describe 'tags' do
|
151
|
+
let(:file_path) do
|
152
|
+
File.join(
|
153
|
+
File.dirname(__FILE__),
|
154
|
+
'../../../../../../',
|
155
|
+
'fixtures',
|
156
|
+
'files',
|
157
|
+
'with_tags.xml'
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'updates project tags according to the order in the template' do
|
162
|
+
importer.import(file: file_path)
|
163
|
+
|
164
|
+
tag_values = project.tags.pluck(:name, :position)
|
165
|
+
expected_values = [
|
166
|
+
["!2ca02c_info", 1],
|
167
|
+
["!ff7f0e_medium", 2],
|
168
|
+
["!d62728_high", 3],
|
169
|
+
["!6baed6_low", 4],
|
170
|
+
["!9467bd_critical", 5]
|
171
|
+
]
|
172
|
+
expect(tag_values).to eq(expected_values)
|
173
|
+
end
|
174
|
+
end
|
168
175
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dradis-projects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- spec/fixtures/files/with_comments.xml
|
142
142
|
- spec/fixtures/files/with_invalid_states.xml
|
143
143
|
- spec/fixtures/files/with_states.xml
|
144
|
+
- spec/fixtures/files/with_tags.xml
|
144
145
|
- spec/lib/dradis/plugins/projects/export/v2/template_spec.rb
|
145
146
|
- spec/lib/dradis/plugins/projects/export/v4/template_spec.rb
|
146
147
|
- spec/lib/dradis/plugins/projects/upload/v1/template_spec.rb
|
@@ -176,6 +177,7 @@ test_files:
|
|
176
177
|
- spec/fixtures/files/with_comments.xml
|
177
178
|
- spec/fixtures/files/with_invalid_states.xml
|
178
179
|
- spec/fixtures/files/with_states.xml
|
180
|
+
- spec/fixtures/files/with_tags.xml
|
179
181
|
- spec/lib/dradis/plugins/projects/export/v2/template_spec.rb
|
180
182
|
- spec/lib/dradis/plugins/projects/export/v4/template_spec.rb
|
181
183
|
- spec/lib/dradis/plugins/projects/upload/v1/template_spec.rb
|