dradis-projects 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/dradis/plugins/projects/export/package.rb +1 -1
- data/lib/dradis/plugins/projects/export/v4/template.rb +1 -0
- data/lib/dradis/plugins/projects/gem_version.rb +1 -1
- data/lib/dradis/plugins/projects/upload/v4/template.rb +32 -31
- metadata +2 -45
- data/.github/pull_request_template.md +0 -45
- data/.gitignore +0 -12
- data/.ruby-version +0 -1
- data/CHANGELOG.template +0 -12
- data/CONTRIBUTING.md +0 -3
- data/Gemfile +0 -17
- data/dradis-projects.gemspec +0 -29
- data/spec/fixtures/files/attachments_url.xml +0 -15
- data/spec/fixtures/files/invalid_byte_recoverable.xml +0 -19
- data/spec/fixtures/files/malformed_ids.xml +0 -14
- data/spec/fixtures/files/missing_node.xml +0 -11
- data/spec/fixtures/files/package_with_recoverable_error.zip +0 -0
- data/spec/fixtures/files/package_with_unrecoverable_error.zip +0 -0
- data/spec/fixtures/files/truncated_unrecoverable.xml +0 -9
- data/spec/fixtures/files/with_comments.xml +0 -110
- data/spec/fixtures/files/with_invalid_states.xml +0 -111
- data/spec/fixtures/files/with_states.xml +0 -111
- data/spec/fixtures/files/with_tags.xml +0 -64
- data/spec/lib/dradis/plugins/projects/export/v2/template_spec.rb +0 -72
- data/spec/lib/dradis/plugins/projects/export/v4/template_spec.rb +0 -84
- data/spec/lib/dradis/plugins/projects/upload/package_spec.rb +0 -58
- data/spec/lib/dradis/plugins/projects/upload/template_spec.rb +0 -80
- data/spec/lib/dradis/plugins/projects/upload/v1/template_spec.rb +0 -84
- data/spec/lib/dradis/plugins/projects/upload/v2/template_spec.rb +0 -65
- data/spec/lib/dradis/plugins/projects/upload/v4/template_spec.rb +0 -175
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# DEPRECATED - this class is v2 of the Template Importer and shouldn't be updated.
|
|
2
|
-
# V4 released on Apr 2022
|
|
3
|
-
# V2 can be removed on Apr 2024
|
|
4
|
-
#
|
|
5
|
-
# We're duplicating this file for v4, and even though the code lives in two
|
|
6
|
-
# places now, this file isn't expected to evolve and is now frozen to V2
|
|
7
|
-
# behavior.
|
|
8
|
-
|
|
9
|
-
require 'rails_helper'
|
|
10
|
-
|
|
11
|
-
describe 'Dradis::Plugins::Projects::Upload::V2::Template::Importer' do
|
|
12
|
-
let(:project) { create(:project) }
|
|
13
|
-
let(:user) { create(:user) }
|
|
14
|
-
let(:importer_class) { Dradis::Plugins::Projects::Upload::Template }
|
|
15
|
-
let(:file_path) do
|
|
16
|
-
File.join(
|
|
17
|
-
File.dirname(__FILE__),
|
|
18
|
-
'../../../../../../',
|
|
19
|
-
'fixtures',
|
|
20
|
-
'files',
|
|
21
|
-
'with_comments.xml'
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'uploading a template with comments' do
|
|
26
|
-
before do
|
|
27
|
-
importer = importer_class::Importer.new(
|
|
28
|
-
default_user_id: user.id,
|
|
29
|
-
plugin: importer_class,
|
|
30
|
-
project_id: project.id
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
importer.import(file: file_path)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
let(:node) { project.nodes.find_by(label: 'Node 1') }
|
|
37
|
-
|
|
38
|
-
it 'imports comments in issues' do
|
|
39
|
-
issue = project.issues.first
|
|
40
|
-
expect(issue.comments.first.content).to include('A comment on an issue')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'imports comments in notes' do
|
|
44
|
-
note = node.notes.first
|
|
45
|
-
expect(note.comments.first.content).to include('A comment on a note')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'imports comments in evidence' do
|
|
49
|
-
evidence = node.evidence.first
|
|
50
|
-
expect(evidence.comments.first.content).to include('A comment on an evidence')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'imports comments without user' do
|
|
54
|
-
issue = project.issues.first
|
|
55
|
-
note = node.notes.first
|
|
56
|
-
evidence = node.evidence.first
|
|
57
|
-
|
|
58
|
-
aggregate_failures do
|
|
59
|
-
expect(issue.comments.first.user).to be_nil
|
|
60
|
-
expect(note.comments.first.user).to be_nil
|
|
61
|
-
expect(evidence.comments.first.user).to be_nil
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Run the spec in CE/Pro context with:
|
|
2
|
-
# rspec <relative path to dradis-projects>/spec/lib/dradis/plugins/projects/upload/v4/template_spec.rb
|
|
3
|
-
|
|
4
|
-
require 'rails_helper'
|
|
5
|
-
|
|
6
|
-
describe 'Dradis::Plugins::Projects::Upload::V4::Template::Importer' do
|
|
7
|
-
let(:project) { create(:project) }
|
|
8
|
-
let(:user) { create(:user) }
|
|
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
|
|
17
|
-
|
|
18
|
-
context 'uploading a template with attachments url' do
|
|
19
|
-
let(:file_path) do
|
|
20
|
-
File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'attachments_url.xml')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'converts the urls' do
|
|
24
|
-
importer.import(file: file_path)
|
|
25
|
-
|
|
26
|
-
p_id = project.id
|
|
27
|
-
n_id = project.plugin_uploads_node.id
|
|
28
|
-
|
|
29
|
-
expect(project.issues.first.text).to include(
|
|
30
|
-
"!/pro/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
|
|
31
|
-
"!/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
|
|
32
|
-
"!/pro/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
|
|
33
|
-
"!/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!"
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context 'uploading a template malformed paths as ids' do
|
|
39
|
-
let(:file_path) do
|
|
40
|
-
File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'malformed_ids.xml')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'returns false' do
|
|
44
|
-
expect(importer.import(file: file_path)).to be false
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'uploading a template with attachment but missing node' do
|
|
49
|
-
let(:file_path) do
|
|
50
|
-
File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'missing_node.xml')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'does not modify the attachment' do
|
|
54
|
-
logger = double('logger')
|
|
55
|
-
allow(logger).to receive_messages(debug: nil, error: nil, fatal: nil, info: nil)
|
|
56
|
-
expect(logger).to receive(:error).once
|
|
57
|
-
|
|
58
|
-
importer = importer_class::Importer.new(
|
|
59
|
-
default_user_id: user.id,
|
|
60
|
-
logger: logger,
|
|
61
|
-
plugin: importer_class,
|
|
62
|
-
project_id: project.id
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
importer.import(file: file_path)
|
|
66
|
-
|
|
67
|
-
expect(project.issues.first.text).to include(
|
|
68
|
-
"!/pro/projects/222/nodes/12345/attachments/hello.jpg!"
|
|
69
|
-
)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context 'uploading a template with comments' do
|
|
74
|
-
let(:file_path) do
|
|
75
|
-
File.join(
|
|
76
|
-
File.dirname(__FILE__),
|
|
77
|
-
'../../../../../../',
|
|
78
|
-
'fixtures',
|
|
79
|
-
'files',
|
|
80
|
-
'with_comments.xml'
|
|
81
|
-
)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
before do
|
|
85
|
-
importer.import(file: file_path)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
let(:node) { project.nodes.find_by(label: 'Node 1') }
|
|
89
|
-
|
|
90
|
-
it 'imports comments in issues' do
|
|
91
|
-
issue = project.issues.first
|
|
92
|
-
expect(issue.comments.first.content).to include('A comment on an issue')
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'imports comments in notes' do
|
|
96
|
-
note = node.notes.first
|
|
97
|
-
expect(note.comments.first.content).to include('A comment on a note')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it 'imports comments in evidence' do
|
|
101
|
-
evidence = node.evidence.first
|
|
102
|
-
expect(evidence.comments.first.content).to include('A comment on an evidence')
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'imports comments without user' do
|
|
106
|
-
issue = project.issues.first
|
|
107
|
-
note = node.notes.first
|
|
108
|
-
evidence = node.evidence.first
|
|
109
|
-
|
|
110
|
-
aggregate_failures do
|
|
111
|
-
expect(issue.comments.first.user).to be_nil
|
|
112
|
-
expect(note.comments.first.user).to be_nil
|
|
113
|
-
expect(evidence.comments.first.user).to be_nil
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
describe 'states' do
|
|
120
|
-
let(:dir) do
|
|
121
|
-
File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files')
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context 'uploading a template without states' do
|
|
125
|
-
it 'imports issues with the published state' do
|
|
126
|
-
importer.import(file: File.join(dir, 'with_comments.xml'))
|
|
127
|
-
issue = project.issues.first
|
|
128
|
-
expect(issue.state).to eq('published')
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context 'uploading a template with states' do
|
|
133
|
-
context 'valid states' do
|
|
134
|
-
it 'imports issues with states from the template' do
|
|
135
|
-
importer.import(file: File.join(dir, 'with_states.xml'))
|
|
136
|
-
issue = project.issues.first
|
|
137
|
-
expect(issue.state).to eq('ready_for_review')
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
context 'invalid states' do
|
|
142
|
-
it 'does not import the issue' do
|
|
143
|
-
importer.import(file: File.join(dir, 'with_invalid_states.xml'))
|
|
144
|
-
expect(project.issues.count).to eq(0)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
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
|
|
175
|
-
end
|