dradis-csv 4.18.0 → 5.0.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 +9 -0
- data/app/assets/javascripts/dradis/plugins/csv/upload.js +3 -1
- data/app/controllers/dradis/plugins/csv/upload_controller.rb +6 -0
- data/app/jobs/dradis/plugins/csv/mapping_import_job.rb +3 -2
- data/app/views/dradis/plugins/csv/upload/new.html.erb +3 -2
- data/dradis-csv.gemspec +1 -1
- data/lib/dradis/plugins/csv/gem_version.rb +2 -2
- data/spec/features/upload_spec.rb +53 -19
- metadata +5 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbe906fb124f7a6013f5ee237f24029a0097a7113efdc47f6e6141bc90704c2f
|
|
4
|
+
data.tar.gz: f56aff91a38dc15ea4a2b887bb39b75642989988f84cba642e79fd0cef89992a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6dc6581dadccc848e09dae41e799c9cb856392b4dbeb8ca561eb0cf3d855c7f68ab06fb2d1812a6ad47c8397bfda23338e689e54d6ffd70af4ac294adf9096f
|
|
7
|
+
data.tar.gz: 936c511cd8423887ebbba1fb9c2c20ba976fa3781edfec2e7a08b78ddd93c430e209da3c66f5a9027333e2187d8d1a2ee72c03e05fb3d8a6d957bf10acbaf73a
|
data/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,14 @@ window.addEventListener('job-done', function () {
|
|
|
3
3
|
var uploader = document.getElementById('uploader');
|
|
4
4
|
|
|
5
5
|
if (uploader.value === 'Dradis::Plugins::CSV') {
|
|
6
|
+
var state = document.getElementById('state').value;
|
|
6
7
|
var path = window.location.pathname;
|
|
7
8
|
var project_path = path.split('/').slice(0, -1).join('/');
|
|
8
9
|
var attachment = $('#attachment').val();
|
|
9
10
|
|
|
11
|
+
var params = new URLSearchParams({ attachment: attachment, state: state });
|
|
10
12
|
var redirectPath =
|
|
11
|
-
project_path + '/addons/csv/upload/new?
|
|
13
|
+
project_path + '/addons/csv/upload/new?' + params.toString();
|
|
12
14
|
Turbo.visit(redirectPath);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -20,6 +20,7 @@ module Dradis::Plugins::CSV
|
|
|
20
20
|
file: @attachment.fullpath.to_s,
|
|
21
21
|
mappings: mappings_params[:field_attributes].to_h,
|
|
22
22
|
project_id: current_project.id,
|
|
23
|
+
state: state,
|
|
23
24
|
uid: params[:log_uid].to_i
|
|
24
25
|
)
|
|
25
26
|
end
|
|
@@ -63,5 +64,10 @@ module Dradis::Plugins::CSV
|
|
|
63
64
|
def mappings_params
|
|
64
65
|
params.require(:mappings).permit(field_attributes: [:field, :type])
|
|
65
66
|
end
|
|
67
|
+
|
|
68
|
+
def state
|
|
69
|
+
@state ||=
|
|
70
|
+
Issue.states.key?(params[:state]) ? params[:state] : 'draft'
|
|
71
|
+
end
|
|
66
72
|
end
|
|
67
73
|
end
|
|
@@ -13,7 +13,7 @@ module Dradis::Plugins::CSV
|
|
|
13
13
|
# '2' => { 'type' => 'identifier' },
|
|
14
14
|
# '3' => { 'type' => 'evidence', 'field' => 'Port' }
|
|
15
15
|
# }
|
|
16
|
-
def perform(default_user_id:, file:, mappings:, project_id:, uid:)
|
|
16
|
+
def perform(default_user_id:, file:, mappings:, project_id:, state:, uid:)
|
|
17
17
|
logger = Log.new(uid: uid)
|
|
18
18
|
logger.write { "Job id is #{job_id}." }
|
|
19
19
|
|
|
@@ -21,7 +21,8 @@ module Dradis::Plugins::CSV
|
|
|
21
21
|
default_user_id: default_user_id,
|
|
22
22
|
logger: logger,
|
|
23
23
|
plugin: self.class.module_parent,
|
|
24
|
-
project_id: project_id
|
|
24
|
+
project_id: project_id,
|
|
25
|
+
state: state
|
|
25
26
|
)
|
|
26
27
|
|
|
27
28
|
importer.import_csv(file: file, mappings: mappings)
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
<%= form_with url: project_upload_index_path(current_project, format: :js), method: :post, data: { behavior: 'mapping-form' } do |f| %>
|
|
25
|
+
<%= form_with url: project_upload_index_path(current_project, format: :js), method: :post, local: false, data: { behavior: 'mapping-form' } do |f| %>
|
|
26
26
|
<%= hidden_field_tag 'log_uid', @log_uid %>
|
|
27
27
|
<%= hidden_field_tag 'job_id', params[:job_id] %>
|
|
28
28
|
<%= hidden_field_tag 'attachment', params[:attachment] %>
|
|
29
|
+
<%= hidden_field_tag 'state', params[:state] %>
|
|
29
30
|
|
|
30
|
-
<table class="table table-striped
|
|
31
|
+
<table class="table table-striped">
|
|
31
32
|
<thead>
|
|
32
33
|
<tr>
|
|
33
34
|
<th>Column Header</th>
|
data/dradis-csv.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
|
21
21
|
|
|
22
|
-
spec.add_dependency 'dradis-plugins', '
|
|
22
|
+
spec.add_dependency 'dradis-plugins', '>= 4.0'
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
24
24
|
spec.add_development_dependency 'rake'
|
|
25
25
|
end
|
|
@@ -14,13 +14,15 @@ describe 'upload feature', js: true do
|
|
|
14
14
|
before do
|
|
15
15
|
@headers = CSV.open(file_path, &:readline)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
find('#state + .combobox').click
|
|
18
|
+
find('#state ~ .combobox-menu .combobox-option', text: 'Published').click
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
find('#uploader + .combobox').click
|
|
21
|
+
find('#uploader ~ .combobox-menu .combobox-option', text: 'Dradis::Plugins::CSV').click
|
|
22
|
+
|
|
23
|
+
attach_file 'file', file_path, visible: false, disabled: false
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
expect(page).to have_text('CSV Upload Mapping', wait: 30)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it 'redirects to the mapping page' do
|
|
@@ -62,6 +64,49 @@ describe 'upload feature', js: true do
|
|
|
62
64
|
end
|
|
63
65
|
end
|
|
64
66
|
|
|
67
|
+
context 'valid states' do
|
|
68
|
+
it 'imports the issues based on the selected state' do
|
|
69
|
+
select 'Issue ID', from: 'mappings[field_attributes][0][type]'
|
|
70
|
+
select 'Node', from: 'mappings[field_attributes][3][type]'
|
|
71
|
+
select 'Evidence Field', from: 'mappings[field_attributes][4][type]'
|
|
72
|
+
select 'Evidence Field', from: 'mappings[field_attributes][5][type]'
|
|
73
|
+
|
|
74
|
+
perform_enqueued_jobs do
|
|
75
|
+
click_button 'Import CSV'
|
|
76
|
+
|
|
77
|
+
find('#console .log', wait: 30, match: :first)
|
|
78
|
+
|
|
79
|
+
expect(page).to have_text('Worker process completed.')
|
|
80
|
+
|
|
81
|
+
expect(Issue.published.count).to eq(1)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'invalid states' do
|
|
87
|
+
it 'imports the issues as draft' do
|
|
88
|
+
select 'Issue ID', from: 'mappings[field_attributes][0][type]'
|
|
89
|
+
select 'Node', from: 'mappings[field_attributes][3][type]'
|
|
90
|
+
select 'Evidence Field', from: 'mappings[field_attributes][4][type]'
|
|
91
|
+
select 'Evidence Field', from: 'mappings[field_attributes][5][type]'
|
|
92
|
+
|
|
93
|
+
page.execute_script(<<~JS)
|
|
94
|
+
const select = document.querySelector('#state');
|
|
95
|
+
select.value = 'tampered_value';
|
|
96
|
+
JS
|
|
97
|
+
|
|
98
|
+
perform_enqueued_jobs do
|
|
99
|
+
click_button 'Import CSV'
|
|
100
|
+
|
|
101
|
+
find('#console .log', wait: 30, match: :first)
|
|
102
|
+
|
|
103
|
+
expect(page).to have_text('Worker process completed.')
|
|
104
|
+
|
|
105
|
+
expect(Issue.published.count).to eq(0)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
65
110
|
context 'when project does not have RTP' do
|
|
66
111
|
it 'imports all columns as fields' do
|
|
67
112
|
select 'Issue ID', from: 'mappings[field_attributes][0][type]'
|
|
@@ -239,11 +284,10 @@ describe 'upload feature', js: true do
|
|
|
239
284
|
|
|
240
285
|
describe 'CSV file samples' do
|
|
241
286
|
before do
|
|
242
|
-
|
|
287
|
+
find('#uploader + .combobox').click
|
|
288
|
+
find('#uploader ~ .combobox-menu .combobox-option', text: 'Dradis::Plugins::CSV').click
|
|
243
289
|
|
|
244
|
-
|
|
245
|
-
page.find('#file', visible: false).attach_file(file_path)
|
|
246
|
-
end
|
|
290
|
+
attach_file 'file', file_path, visible: false, disabled: false
|
|
247
291
|
end
|
|
248
292
|
|
|
249
293
|
context 'uploading a malformed CSV file' do
|
|
@@ -267,15 +311,5 @@ describe 'upload feature', js: true do
|
|
|
267
311
|
expect(current_path).to eq(main_app.project_upload_manager_path(@project))
|
|
268
312
|
end
|
|
269
313
|
end
|
|
270
|
-
|
|
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
|
|
279
|
-
end
|
|
280
314
|
end
|
|
281
315
|
end
|
metadata
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dradis-csv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Martin
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: dradis-plugins
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '4.0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '4.0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
@@ -53,7 +52,6 @@ dependencies:
|
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
55
54
|
description: This add-on allows you to upload and parse CSV output into Dradis.
|
|
56
|
-
email:
|
|
57
55
|
executables: []
|
|
58
56
|
extensions: []
|
|
59
57
|
extra_rdoc_files: []
|
|
@@ -94,7 +92,6 @@ homepage: http://dradis.com
|
|
|
94
92
|
licenses:
|
|
95
93
|
- GPL-2
|
|
96
94
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
98
95
|
rdoc_options: []
|
|
99
96
|
require_paths:
|
|
100
97
|
- lib
|
|
@@ -109,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
106
|
- !ruby/object:Gem::Version
|
|
110
107
|
version: '0'
|
|
111
108
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
113
|
-
signing_key:
|
|
109
|
+
rubygems_version: 3.6.9
|
|
114
110
|
specification_version: 4
|
|
115
111
|
summary: CSV add-on for the Dradis Framework.
|
|
116
112
|
test_files:
|