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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 426293d8c721f9922fff09466b331af1387e3637dc39d3655976b079657de327
4
- data.tar.gz: 4e18680b1764145a85826f6613307e22c44b88b8026203906804dd725c4fb9a7
3
+ metadata.gz: 73b72a29b3c7c57b0b65426b584d3a88f7557089b26c0c1da43fc897e7b17d30
4
+ data.tar.gz: 67eb6934d1b164e7e97925d6c38cfa3149ce580c59453f20c9759bfea94fb089
5
5
  SHA512:
6
- metadata.gz: b0c51aaba321b1ed9b6eb01f5ea059604f4c6201a38360b456a015419f7f6e2225d980016dbf231f94f24b8bfd5c0816ad820a3a289fa6b999962fd1aac3b5c1
7
- data.tar.gz: '011549871879a0cc0edcd4240b2c139bc1b19c8ae0e850bfd61ca14e48837d22ce4e21893efb43ad296e55f83a7fcac6f50ff73fef9c575c96ce266458933d38'
6
+ metadata.gz: e7a721f5ab932bf17efb2f39debfb42145374504ecfb2b1cd7147197284e3ca943678be2ce49f16b990873a3e40dbb0c5f9956d35fd9967714e5136819841033
7
+ data.tar.gz: 651af8822ababb6b238d6b31fe30ea6f979b8ed4e89e1401c9ae9afbeb7827f9d61a83cd7f1d0610c283b776f42c281ad519ca018d10e2b601d05f18dfb50834
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .DS_Store
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v4.9.0 (June 2023)
2
+ - Fix CSV upload for files with special characters
3
+ - Update views for compatibility with Bootstrap 5
4
+
1
5
  v4.8.0 (April 2023)
2
6
  - No changes
3
7
 
@@ -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 load_rtp_fields
34
- rtp = current_project.report_template_properties
35
- @rtp_fields =
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 load_attachment
59
- @attachment = Attachment.find(params[:attachment], conditions: { node_id: current_project.plugin_uploads_node.id })
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'], ['&#9472;'.html_safe, 'divider'], ['Do Not Import','skip']], { disabled: 'divider' }, class: 'form-control custom-select w-75', data: { behavior: 'type-select' } %>
44
+ <%= f.select "mappings[field_attributes][#{index}][type]", [['Issue Field', 'issue'], ['Issue ID', 'identifier'], ['Evidence Field', 'evidence'], ['Node', 'node'], ['&#9472;'.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 class="form-group m-0">
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-control custom-select w-75 field-select', data: { behavior: 'issue-field-select', header: header } %>
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-control custom-select w-75 field-select d-none', data: { behavior: 'evidence-field-select', header: header } %>
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-control custom-select w-75 field-select d-none', data: { behavior: 'empty-field-select', header: header } %>
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 mr-1', data: { disable_with: false } %> or
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
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 8
11
+ MINOR = 9
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -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 'Node'
207
+ select 'Issue Field'
204
208
  end
205
209
 
206
- within all('tbody tr')[2] do
207
- select 'Issue ID'
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
- context 'uploading a malformed CSV file' do
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
- it 'redirects to upload manager' do
247
- expect(page).to have_text('The uploaded file is not a valid CSV file')
248
- expect(current_path).to eq(main_app.project_upload_manager_path(@project))
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
- context 'uploading any file other than CSV' do
253
- let(:file_path) { Rails.root.join('spec/fixtures/files/rails.png') }
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
- within('.custom-file') do
258
- page.find('#file', visible: false).attach_file(file_path)
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
- it 'redirects to upload manager' do
263
- expect(page).to have_text('The uploaded file is not a CSV file.')
264
- expect(current_path).to eq(main_app.project_upload_manager_path(@project))
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
@@ -0,0 +1,2 @@
1
+ "Id","Title","Description","Host","Location","Port","Vulnerability Category"
2
+ "1","SQL Injection","Test CSV","10.0.0.1","10.0.0.1","443","High"
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.8.0
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-04-12 00:00:00.000000000 Z
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