dradis-csv 4.8.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/app/controllers/dradis/plugins/csv/upload_controller.rb +12 -11
- data/app/views/dradis/plugins/csv/upload/new.html.erb +6 -6
- data/dradis-csv.gemspec +3 -2
- data/lib/dradis/plugins/csv/gem_version.rb +1 -1
- data/spec/features/upload_spec.rb +32 -18
- data/spec/fixtures/files/simple (copy).csv +2 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b72a29b3c7c57b0b65426b584d3a88f7557089b26c0c1da43fc897e7b17d30
|
4
|
+
data.tar.gz: 67eb6934d1b164e7e97925d6c38cfa3149ce580c59453f20c9759bfea94fb089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7a721f5ab932bf17efb2f39debfb42145374504ecfb2b1cd7147197284e3ca943678be2ce49f16b990873a3e40dbb0c5f9956d35fd9967714e5136819841033
|
7
|
+
data.tar.gz: 651af8822ababb6b238d6b31fe30ea6f979b8ed4e89e1401c9ae9afbeb7827f9d61a83cd7f1d0610c283b776f42c281ad519ca018d10e2b601d05f18dfb50834
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/CHANGELOG.md
CHANGED
@@ -30,15 +30,9 @@ module Dradis::Plugins::CSV
|
|
30
30
|
@job_logger ||= Log.new(uid: params[:log_uid].to_i)
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
35
|
-
@
|
36
|
-
unless rtp.nil?
|
37
|
-
{
|
38
|
-
evidence: rtp.evidence_fields.map(&:name),
|
39
|
-
issue: rtp.issue_fields.map(&:name)
|
40
|
-
}
|
41
|
-
end
|
33
|
+
def load_attachment
|
34
|
+
filename = CGI::escape params[:attachment]
|
35
|
+
@attachment = Attachment.find(filename, conditions: { node_id: current_project.plugin_uploads_node.id })
|
42
36
|
end
|
43
37
|
|
44
38
|
def load_csv_headers
|
@@ -55,8 +49,15 @@ module Dradis::Plugins::CSV
|
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
58
|
-
def
|
59
|
-
|
52
|
+
def load_rtp_fields
|
53
|
+
rtp = current_project.report_template_properties
|
54
|
+
@rtp_fields =
|
55
|
+
unless rtp.nil?
|
56
|
+
{
|
57
|
+
evidence: rtp.evidence_fields.map(&:name),
|
58
|
+
issue: rtp.issue_fields.map(&:name)
|
59
|
+
}
|
60
|
+
end
|
60
61
|
end
|
61
62
|
|
62
63
|
def mappings_params
|
@@ -41,19 +41,19 @@
|
|
41
41
|
<td><%= header %></td>
|
42
42
|
<td>
|
43
43
|
<div class="form-group m-0">
|
44
|
-
<%= f.select "mappings[field_attributes][#{index}][type]", [['Issue Field', 'issue'], ['Issue ID', 'identifier'], ['Evidence Field', 'evidence'], ['Node', 'node'], ['─'.html_safe, 'divider'], ['Do Not Import','skip']], { disabled: 'divider' }, class: 'form-
|
44
|
+
<%= f.select "mappings[field_attributes][#{index}][type]", [['Issue Field', 'issue'], ['Issue ID', 'identifier'], ['Evidence Field', 'evidence'], ['Node', 'node'], ['─'.html_safe, 'divider'], ['Do Not Import','skip']], { disabled: 'divider' }, class: 'form-select w-75', data: { behavior: 'type-select' } %>
|
45
45
|
</div>
|
46
46
|
</td>
|
47
47
|
<td>
|
48
48
|
<% if @rtp_fields %>
|
49
|
-
<div
|
49
|
+
<div>
|
50
50
|
<% issue_options = @rtp_fields[:issue].any? ? options_for_select(@rtp_fields[:issue]) : options_for_select([[header, header]], disabled: header, selected: header) %>
|
51
|
-
<%= f.select "mappings[field_attributes][#{index}][field]", issue_options, {}, class: 'form-
|
51
|
+
<%= f.select "mappings[field_attributes][#{index}][field]", issue_options, {}, class: 'form-select w-75 field-select', data: { behavior: 'issue-field-select', header: header } %>
|
52
52
|
|
53
53
|
<% evidence_options = @rtp_fields[:evidence].any? ? options_for_select(@rtp_fields[:evidence]) : options_for_select([[header, header]], disabled: header, selected: header) %>
|
54
|
-
<%= f.select "mappings[field_attributes][#{index}][field]", evidence_options, {}, disabled: true, class: 'form-
|
54
|
+
<%= f.select "mappings[field_attributes][#{index}][field]", evidence_options, {}, disabled: true, class: 'form-select w-75 field-select d-none', data: { behavior: 'evidence-field-select', header: header } %>
|
55
55
|
|
56
|
-
<%= f.select "mappings[field_attributes][#{index}][field]", [['N/A', '']], {}, disabled: true, class: 'form-
|
56
|
+
<%= f.select "mappings[field_attributes][#{index}][field]", [['N/A', '']], {}, disabled: true, class: 'form-select w-75 field-select d-none', data: { behavior: 'empty-field-select', header: header } %>
|
57
57
|
</div>
|
58
58
|
<% else %>
|
59
59
|
<span data-behavior="field-label" data-header="<%= header.delete(" \t\r\n") %>" ><%= header.delete(" \t\r\n") %></span>
|
@@ -64,7 +64,7 @@
|
|
64
64
|
</tbody>
|
65
65
|
</table>
|
66
66
|
<div class="form-actions">
|
67
|
-
<%= f.submit 'Import CSV', class: 'btn btn-primary
|
67
|
+
<%= f.submit 'Import CSV', class: 'btn btn-primary me-1', data: { disable_with: false } %> or
|
68
68
|
<%= link_to 'Cancel', main_app.project_upload_manager_path(current_project) %>
|
69
69
|
</div>
|
70
70
|
<% end %>
|
data/dradis-csv.gemspec
CHANGED
@@ -16,10 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.email = ['etd@nomejortu.com']
|
17
17
|
spec.homepage = 'http://dradisframework.org'
|
18
18
|
|
19
|
-
spec.files = `git ls-files`.split(
|
20
|
-
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
spec.files = `git ls-files`.split("\n")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
21
21
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
22
22
|
|
23
23
|
spec.add_dependency 'dradis-plugins', '~> 4.0'
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
25
26
|
end
|
@@ -199,12 +199,16 @@ describe 'upload feature', js: true do
|
|
199
199
|
let (:issue_fields) { [] }
|
200
200
|
|
201
201
|
it 'still creates evidence record' do
|
202
|
+
within all('tbody tr')[0] do
|
203
|
+
select 'Issue ID'
|
204
|
+
end
|
205
|
+
|
202
206
|
within all('tbody tr')[1] do
|
203
|
-
select '
|
207
|
+
select 'Issue Field'
|
204
208
|
end
|
205
209
|
|
206
|
-
within all('tbody tr')[
|
207
|
-
select '
|
210
|
+
within all('tbody tr')[3] do
|
211
|
+
select 'Node'
|
208
212
|
end
|
209
213
|
|
210
214
|
within all('tbody tr')[5] do
|
@@ -233,8 +237,7 @@ describe 'upload feature', js: true do
|
|
233
237
|
end
|
234
238
|
end
|
235
239
|
|
236
|
-
|
237
|
-
let(:file_path) { File.expand_path('../fixtures/files/simple_malformed.csv', __dir__) }
|
240
|
+
describe 'CSV file samples' do
|
238
241
|
before do
|
239
242
|
select 'Dradis::Plugins::CSV', from: 'uploader'
|
240
243
|
|
@@ -243,25 +246,36 @@ describe 'upload feature', js: true do
|
|
243
246
|
end
|
244
247
|
end
|
245
248
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
+
context 'uploading a malformed CSV file' do
|
250
|
+
let(:file_path) { File.expand_path('../fixtures/files/simple_malformed.csv', __dir__) }
|
251
|
+
|
252
|
+
it 'redirects to upload manager with error' do
|
253
|
+
find('.alert.alert-danger', wait: 30)
|
254
|
+
|
255
|
+
expect(page).to have_text('The uploaded file is not a valid CSV file')
|
256
|
+
expect(current_path).to eq(main_app.project_upload_manager_path(@project))
|
257
|
+
end
|
249
258
|
end
|
250
|
-
end
|
251
259
|
|
252
|
-
|
253
|
-
|
254
|
-
before do
|
255
|
-
select 'Dradis::Plugins::CSV', from: 'uploader'
|
260
|
+
context 'uploading any file other than CSV' do
|
261
|
+
let(:file_path) { Rails.root.join('spec/fixtures/files/rails.png') }
|
256
262
|
|
257
|
-
|
258
|
-
|
263
|
+
it 'redirects to upload manager with error' do
|
264
|
+
find('.alert.alert-danger', wait: 30)
|
265
|
+
|
266
|
+
expect(page).to have_text('The uploaded file is not a CSV file.')
|
267
|
+
expect(current_path).to eq(main_app.project_upload_manager_path(@project))
|
259
268
|
end
|
260
269
|
end
|
261
270
|
|
262
|
-
|
263
|
-
|
264
|
-
|
271
|
+
context 'uploading file with special characters in the filename' do
|
272
|
+
let(:file_path) { File.expand_path('../fixtures/files/simple (copy).csv', __dir__) }
|
273
|
+
|
274
|
+
it 'redirects to upload manager' do
|
275
|
+
find('body.upload.new', wait: 30)
|
276
|
+
|
277
|
+
expect(current_path).to eq(csv.new_project_upload_path(@project))
|
278
|
+
end
|
265
279
|
end
|
266
280
|
end
|
267
281
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dradis-csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.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: 2023-
|
11
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dradis-plugins
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: This add-on allows you to upload and parse CSV output into Dradis.
|
42
56
|
email:
|
43
57
|
- etd@nomejortu.com
|
@@ -45,6 +59,7 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
62
|
+
- ".gitignore"
|
48
63
|
- CHANGELOG.md
|
49
64
|
- CHANGELOG.template
|
50
65
|
- CONTRIBUTING.md
|
@@ -70,6 +85,7 @@ files:
|
|
70
85
|
- lib/dradis/plugins/csv/importer.rb
|
71
86
|
- lib/dradis/plugins/csv/version.rb
|
72
87
|
- spec/features/upload_spec.rb
|
88
|
+
- spec/fixtures/files/simple (copy).csv
|
73
89
|
- spec/fixtures/files/simple.csv
|
74
90
|
- spec/fixtures/files/simple_malformed.csv
|
75
91
|
- spec/jobs/dradis/plugins/csv/mapping_import_job_spec.rb
|
@@ -99,6 +115,7 @@ specification_version: 4
|
|
99
115
|
summary: CSV add-on for the Dradis Framework.
|
100
116
|
test_files:
|
101
117
|
- spec/features/upload_spec.rb
|
118
|
+
- spec/fixtures/files/simple (copy).csv
|
102
119
|
- spec/fixtures/files/simple.csv
|
103
120
|
- spec/fixtures/files/simple_malformed.csv
|
104
121
|
- spec/jobs/dradis/plugins/csv/mapping_import_job_spec.rb
|