dradis-csv 4.4.0 → 4.5.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -66
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +6 -0
  5. data/README.md +3 -18
  6. data/app/assets/javascripts/dradis/plugins/csv/manifests/tylium.js +1 -0
  7. data/app/assets/javascripts/dradis/plugins/csv/upload.js +114 -0
  8. data/app/assets/stylesheets/dradis/plugins/csv/manifests/tylium.scss +1 -0
  9. data/app/assets/stylesheets/dradis/plugins/csv/upload.scss +39 -0
  10. data/app/controllers/dradis/plugins/csv/upload_controller.rb +66 -0
  11. data/app/jobs/dradis/plugins/csv/mapping_import_job.rb +32 -0
  12. data/app/views/dradis/plugins/csv/upload/create.js.erb +4 -0
  13. data/app/views/dradis/plugins/csv/upload/new.html.erb +81 -0
  14. data/config/initializers/inflections.rb +3 -0
  15. data/config/routes.rb +3 -1
  16. data/dradis-csv.gemspec +12 -21
  17. data/lib/dradis/plugins/csv/engine.rb +5 -13
  18. data/lib/dradis/plugins/csv/gem_version.rb +4 -4
  19. data/lib/dradis/plugins/csv/importer.rb +76 -0
  20. data/lib/dradis/plugins/csv.rb +3 -2
  21. data/lib/dradis-csv.rb +1 -3
  22. data/spec/features/upload_spec.rb +267 -0
  23. data/spec/fixtures/files/simple.csv +2 -0
  24. data/spec/fixtures/files/simple_malformed.csv +2 -0
  25. data/spec/jobs/dradis/plugins/csv/mapping_import_job_spec.rb +30 -0
  26. data/spec/lib/dradis/plugins/csv/importer_spec.rb +140 -0
  27. metadata +25 -46
  28. data/.github/issue_template.md +0 -16
  29. data/.github/pull_request_template.md +0 -36
  30. data/.gitignore +0 -8
  31. data/.rspec +0 -2
  32. data/app/controllers/dradis/plugins/csv/base_controller.rb +0 -19
  33. data/app/views/dradis/plugins/csv/export/_index-content.html.erb +0 -10
  34. data/app/views/dradis/plugins/csv/export/_index-tabs.html.erb +0 -3
  35. data/lib/dradis/plugins/csv/exporter.rb +0 -60
  36. data/lib/tasks/thorfile.rb +0 -28
  37. data/spec/csv_export_spec.rb +0 -5
  38. data/spec/spec_helper.rb +0 -4
@@ -1,3 +0,0 @@
1
- <li class='nav-item'>
2
- <a href='#csv' class='nav-link' data-toggle='tab' data-target='#plugin-csv'>Export results in CSV format</a>
3
- </li>
@@ -1,60 +0,0 @@
1
- module Dradis::Plugins::CSV
2
- class Exporter < Dradis::Plugins::Export::Base
3
- def export(args={})
4
- issues = content_service.all_issues
5
-
6
- if issues.empty?
7
- return "The project didn't contain any issues"
8
- else
9
- # All fields from all Issues in the project
10
- issue_keys = issues.map(&:fields).map(&:keys).flatten.uniq
11
-
12
- # All fields from all Evidence in the project
13
- evidence_keys = issues.map do |issue|
14
- if issue.evidence.any?
15
- issue.evidence.map(&:fields).map(&:keys).flatten.uniq
16
- else
17
- []
18
- end
19
- end.flatten.uniq
20
-
21
- keys = issue_keys + evidence_keys
22
-
23
- issue_row = []
24
- evidence_row = []
25
-
26
- # Create the CSV data
27
- csv_string = ::CSV.generate do |csv|
28
-
29
- # Add the header line with all the field names. Remember note.field returns
30
- # a hash: {'Title' => 'Foo', 'Description' => 'Bar'}
31
- csv << keys
32
-
33
- # For each of the notes in our category, we dump the field values.
34
- # This assumes all notes have the same fields, in the same order
35
- issues.each do |issue|
36
- issue_row = issue_keys.map do |key|
37
- issue.fields.fetch(key, 'n/a')
38
- end
39
-
40
- # If we've got multiple Evidence, we add one row per Evidence
41
- if issue.evidence.any?
42
- issue.evidence.each do |evidence|
43
- evidence_row = evidence_keys.map do |key|
44
- evidence.fields.fetch(key, 'n/a')
45
- end
46
-
47
- csv << issue_row + evidence_row
48
- end
49
- else
50
- csv << issue_row
51
- end
52
- end
53
- end
54
-
55
- csv_string
56
- end
57
-
58
- end
59
- end
60
- end
@@ -1,28 +0,0 @@
1
- class CSVTasks < Thor
2
- include Rails.application.config.dradis.thor_helper_module
3
-
4
- namespace "dradis:plugins:csv"
5
-
6
- desc "export", "export issues to a CSV file"
7
- def export
8
- require 'config/environment'
9
-
10
- detect_and_set_project_scope
11
-
12
- exporter = Dradis::Plugins::CSV::Exporter.new(task_options)
13
- csv = exporter.export()
14
-
15
- date = DateTime.now.strftime("%Y-%m-%d")
16
- base_filename = "dradis-report_#{date}.csv"
17
-
18
- filename = NamingService.name_file(
19
- original_filename: base_filename,
20
- pathname: Rails.root
21
- )
22
-
23
- File.open(filename, 'w') { |f| f.write csv }
24
-
25
- logger.info "File written to ./#{ filename }"
26
- end
27
-
28
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'CsvExport plugin' do
4
- pending 'describe the behaviour of the CsvExport plugin'
5
- end
data/spec/spec_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- require File.expand_path("../../../../../config/environment", __FILE__)
2
-
3
- RSpec.configure do |config|
4
- end