dradis-csv 4.4.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -64
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +6 -0
- data/README.md +3 -18
- data/app/assets/javascripts/dradis/plugins/csv/manifests/tylium.js +1 -0
- data/app/assets/javascripts/dradis/plugins/csv/upload.js +114 -0
- data/app/assets/stylesheets/dradis/plugins/csv/manifests/tylium.scss +1 -0
- data/app/assets/stylesheets/dradis/plugins/csv/upload.scss +39 -0
- data/app/controllers/dradis/plugins/csv/upload_controller.rb +66 -0
- data/app/jobs/dradis/plugins/csv/mapping_import_job.rb +32 -0
- data/app/views/dradis/plugins/csv/upload/create.js.erb +4 -0
- data/app/views/dradis/plugins/csv/upload/new.html.erb +81 -0
- data/config/initializers/inflections.rb +3 -0
- data/config/routes.rb +3 -1
- data/dradis-csv.gemspec +12 -21
- data/lib/dradis/plugins/csv/engine.rb +5 -13
- data/lib/dradis/plugins/csv/gem_version.rb +4 -4
- data/lib/dradis/plugins/csv/importer.rb +76 -0
- data/lib/dradis/plugins/csv.rb +3 -2
- data/lib/dradis-csv.rb +1 -3
- data/spec/features/upload_spec.rb +267 -0
- data/spec/fixtures/files/simple.csv +2 -0
- data/spec/fixtures/files/simple_malformed.csv +2 -0
- data/spec/jobs/dradis/plugins/csv/mapping_import_job_spec.rb +30 -0
- data/spec/lib/dradis/plugins/csv/importer_spec.rb +140 -0
- metadata +25 -46
- data/.github/issue_template.md +0 -16
- data/.github/pull_request_template.md +0 -36
- data/.gitignore +0 -8
- data/.rspec +0 -2
- data/app/controllers/dradis/plugins/csv/base_controller.rb +0 -19
- data/app/views/dradis/plugins/csv/export/_index-content.html.erb +0 -10
- data/app/views/dradis/plugins/csv/export/_index-tabs.html.erb +0 -3
- data/lib/dradis/plugins/csv/exporter.rb +0 -60
- data/lib/tasks/thorfile.rb +0 -28
- data/spec/csv_export_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -4
@@ -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
|
data/lib/tasks/thorfile.rb
DELETED
@@ -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
|
data/spec/csv_export_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED