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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a813bfc94503db7e99d60fa8e4e3432c69d0e7f2109aaf6d345f344a1db5edc
4
- data.tar.gz: 06f7e78cf14c90dd4bf2a98b40a922d2e57ff6774c8bab2bcde86e6295c6fc38
3
+ metadata.gz: cbe906fb124f7a6013f5ee237f24029a0097a7113efdc47f6e6141bc90704c2f
4
+ data.tar.gz: f56aff91a38dc15ea4a2b887bb39b75642989988f84cba642e79fd0cef89992a
5
5
  SHA512:
6
- metadata.gz: 14d85f67d9f65cb21fb6c27bab5e6cb138b381c2bd5f113c6d4e2ce5e5743c8034e0a7b2f481b200b11a001d5340067737e02207af005812ef1ef57f6b4ca4fb
7
- data.tar.gz: 46759c7fe1b5afbd95451811e78f941a9d1c2d4497c4f994103104d5183f47e3ed67a79e073e5a66021d833313983bcb8e4db0f92cdf1171b0963fc6129c68f0
6
+ metadata.gz: f6dc6581dadccc848e09dae41e799c9cb856392b4dbeb8ca561eb0cf3d855c7f68ab06fb2d1812a6ad47c8397bfda23338e689e54d6ffd70af4ac294adf9096f
7
+ data.tar.gz: 936c511cd8423887ebbba1fb9c2c20ba976fa3781edfec2e7a08b78ddd93c430e209da3c66f5a9027333e2187d8d1a2ee72c03e05fb3d8a6d957bf10acbaf73a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ v5.0.0 (March 2026)
2
+ - No changes
3
+
4
+ v4.20.0 (Month 2026)
5
+ - Fix state selection not being applied correctly
6
+
7
+ v4.19.0 (November 2025)
8
+ - No changes
9
+
1
10
  v4.18.0 (September 2025)
2
11
  - No changes
3
12
 
@@ -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?attachment=' + attachment;
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 mb-0">
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', '~> 4.0'
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
@@ -7,8 +7,8 @@ module Dradis
7
7
  end
8
8
 
9
9
  module VERSION
10
- MAJOR = 4
11
- MINOR = 18
10
+ MAJOR = 5
11
+ MINOR = 0
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -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
- select 'Dradis::Plugins::CSV', from: 'uploader'
17
+ find('#state + .combobox').click
18
+ find('#state ~ .combobox-menu .combobox-option', text: 'Published').click
18
19
 
19
- within('.custom-file') do
20
- page.find('#file', visible: false).attach_file(file_path)
21
- end
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
- find('body.upload.new', wait: 30)
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
- select 'Dradis::Plugins::CSV', from: 'uploader'
287
+ find('#uploader + .combobox').click
288
+ find('#uploader ~ .combobox-menu .combobox-option', text: 'Dradis::Plugins::CSV').click
243
289
 
244
- within('.custom-file') do
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.18.0
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: 2025-09-26 00:00:00.000000000 Z
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.5.6
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: