dradis-projects 3.16.0 → 3.21.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: 8839b1deab4f196cf96c072b583ac661fd761b01e18a2cc66c5d87ac5ee54482
4
- data.tar.gz: ee8272cc0e30a4b18efbceef80ef9e8b1922f782e2e3848d4e550e14f9ce7fbd
3
+ metadata.gz: d19a3cf6f2164c69c08fd2fa151849338f50cd2756c85a004caee2b304a34019
4
+ data.tar.gz: ae3b507fa0d58612cdd148237e2bf5d3d61430ce83e6e4ae43efa40cc21c64d2
5
5
  SHA512:
6
- metadata.gz: d96ed218c6ac1dc4493ae8547ee53c775bb4829000aee94d093f4570158c1343c3b9b257f1026fcdceb2e8cb1eb8eb7dc4bd14227a53bfdc83ca66fd2be235ed
7
- data.tar.gz: a0ebd0fe5b2ef8681e081cfc63fd22b9f1a044b4aad1929085005dba19012bdacc8e811a9ca25523c3e4d083a7463fa780fb7b4bf83ebbf03e34d8ec95cd4455
6
+ metadata.gz: ab39dd0a946b71c978443de7f921c30edcba47e4485459247b4cd4565998066fd53b5511747e0723faf4773aebe5ee37e9ec4c5b632aa47d35c04d08e37c8f23
7
+ data.tar.gz: 4e6527f380b9baaf70d974eb6b54ced56e471d02874a77ca6b23a6c0a5b6f9fa3cb44ac56bbd5b0be00cc24189a279c7601014cf9ec2637fe0a3f6979be7fd09
data/.gitignore CHANGED
@@ -8,3 +8,5 @@ Gemfile.lock
8
8
 
9
9
  # Gem artifacts
10
10
  /pkg/
11
+
12
+ .DS_Store
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.4.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## Dradis Framework 3.21 (February, 2021) ##
2
+
3
+ * No changes
4
+
5
+ ## Dradis Framework 3.20 (Jan, 2020) ##
6
+
7
+ * Add views for the export view.
8
+ * Fix exporting projects with comments by deleted users.
9
+
10
+ ## Dradis Framework 3.19 (September, 2020) ##
11
+
12
+ * No changes
13
+
14
+ ## Dradis Framework 3.18 (July, 2020) ##
15
+
16
+ * No changes
17
+
18
+ ## Dradis Framework 3.17 (May, 2020) ##
19
+
20
+ * No changes
21
+
1
22
  ## Dradis Framework 3.16 (February, 2020) ##
2
23
 
3
24
  * No changes
@@ -39,19 +60,19 @@
39
60
 
40
61
  ## Dradis Framework 3.9 (January, 2018) ##
41
62
 
42
- * Fix nodes upload
63
+ * Fix nodes upload
43
64
 
44
65
  * Add default user id as fallback for activity user when importing
45
66
 
46
67
  ## Dradis Framework 3.8 (September, 2017) ##
47
68
 
48
- * Add version attribute to exported methodologies
69
+ * Add version attribute to exported methodologies
49
70
 
50
71
  * Add parse_report_content placeholders to import/export.
51
72
 
52
73
  ## Dradis Framework 3.7 (July, 2017) ##
53
74
 
54
- * Skip closing the logger in thorfile
75
+ * Skip closing the logger in thorfile
55
76
 
56
77
  ## Dradis Framework 3.6 (March, 2017) ##
57
78
 
@@ -0,0 +1,19 @@
1
+ <%= content_tag :div, id: 'plugin-projects', class: 'tab-pane fade' do %>
2
+ <%= form_tag project_export_manager_path(current_project), target: '_blank' do %>
3
+ <%= hidden_field_tag :plugin, 'projects' %>
4
+
5
+ <h4 class="header-underline">Choose an export option</h4>
6
+
7
+ <div class="custom-control custom-radio">
8
+ <%= radio_button_tag :route, :package, true, :class => 'custom-control-input' %>
9
+ <label class="custom-control-label" for='route_package'>Package</label>
10
+ </div>
11
+
12
+ <div class="custom-control custom-radio">
13
+ <%= radio_button_tag :route, :template, false, :class => 'custom-control-input' %>
14
+ <label class="custom-control-label" for='route_template'>Template</label>
15
+ </div>
16
+
17
+ <button id="export-button" class="btn btn-lg btn-primary mt-4">Export</button>
18
+ <% end %>
19
+ <% end%>
@@ -0,0 +1,3 @@
1
+ <li class='nav-item'>
2
+ <a href='#projects' class='nav-link' data-toggle='tab' data-target='#plugin-projects'>Save and restore project information</a>
3
+ </li>
@@ -1,8 +1,10 @@
1
1
  module Dradis
2
2
  module Plugins
3
3
  module Projects
4
- module Export; end
5
- module Upload; end
4
+ module Export
5
+ end
6
+ module Upload
7
+ end
6
8
  end
7
9
  end
8
10
  end
@@ -16,4 +18,4 @@ require 'dradis/plugins/projects/version'
16
18
 
17
19
  module Dradis::Plugins::Projects
18
20
  ActiveSupport.run_load_hooks(:dradis_projects, self)
19
- end
21
+ end
@@ -11,7 +11,7 @@ module Dradis::Plugins::Projects::Export::V2
11
11
  comment_builder.content do
12
12
  comment_builder.cdata!(comment.content)
13
13
  end
14
- comment_builder.author(comment.user.email)
14
+ comment_builder.author(comment.user&.email)
15
15
  comment_builder.created_at(comment.created_at.to_i)
16
16
  end
17
17
  end
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 3
11
- MINOR = 16
11
+ MINOR = 21
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -3,7 +3,7 @@ module Dradis::Plugins::Projects::Upload::V1
3
3
 
4
4
  class Importer < Dradis::Plugins::Projects::Upload::Template::Importer
5
5
 
6
- attr_accessor :attachment_notes, :logger, :pending_changes
6
+ attr_accessor :attachment_notes, :logger, :pending_changes, :users
7
7
 
8
8
  ATTACHMENT_URL = %r{^!(/[a-z]+)?/(?:projects/\d+/)?nodes/(\d+)/attachments/(.+)!$}
9
9
 
@@ -394,15 +394,17 @@ module Dradis::Plugins::Projects::Upload::V1
394
394
  end
395
395
  end
396
396
 
397
- # Cache users to cut down on excess SQL requests
398
397
  def user_id_for_email(email)
399
- return @default_user_id if email.blank?
398
+ users[email] || @default_user_id
399
+ end
400
+
401
+ # Cache users to cut down on excess SQL requests
402
+ def users
400
403
  @users ||= begin
401
404
  User.select([:id, :email]).all.each_with_object({}) do |user, hash|
402
405
  hash[user.email] = user.id
403
406
  end
404
407
  end
405
- @users[email] || @default_user_id
406
408
  end
407
409
 
408
410
  def validate_and_save(instance)
@@ -13,16 +13,19 @@ module Dradis::Plugins::Projects::Upload::V2
13
13
  commentable_type: commentable.class.to_s,
14
14
  content: xml_comment.at_xpath('content').text,
15
15
  created_at: Time.at(xml_comment.at_xpath('created_at').text.to_i),
16
- user_id: user_id_for_email(author_email)
16
+ user_id: users[author_email]
17
17
  )
18
18
 
19
- if comment.user.email != author_email
19
+ if comment.user.nil?
20
20
  comment.content = comment.content +
21
21
  "\n\nOriginal author not available in this Dradis instance: "\
22
22
  "#{author_email}."
23
23
  end
24
24
 
25
- return false unless validate_and_save(comment)
25
+ unless validate_and_save(comment)
26
+ logger.info { "comment errors: #{comment.inspect}" }
27
+ return false
28
+ end
26
29
  end
27
30
  end
28
31
  end
@@ -71,7 +71,7 @@ A
71
71
  </nodes>
72
72
  <issues>
73
73
  <issue>
74
- <id>1</id>
74
+ <id>586</id>
75
75
  <author>xavi</author>
76
76
  <text><![CDATA[#[Title]#
77
77
  Issue 1
@@ -13,13 +13,13 @@ describe Dradis::Plugins::Projects::Export::V2::Template do
13
13
 
14
14
  context 'exporting a project' do
15
15
  before do
16
- node = create(:node, project: project)
17
- issue = create(:issue, text: 'Issue 1', node: project.issue_library)
16
+ @node = create(:node, project: project)
17
+ @issue = create(:issue, text: 'Issue 1', node: project.issue_library)
18
18
  end
19
19
 
20
20
  context 'with comments in an issue' do
21
21
  before do
22
- create(:comment, content: 'A comment on an issue', commentable: issue)
22
+ create(:comment, content: 'A comment on an issue', commentable: @issue)
23
23
  end
24
24
 
25
25
  it 'exports comments in the issue' do
@@ -29,7 +29,7 @@ describe Dradis::Plugins::Projects::Export::V2::Template do
29
29
 
30
30
  context 'with comments in a note' do
31
31
  before do
32
- note = create(:note, text: 'Note 1', node: node)
32
+ note = create(:note, text: 'Note 1', node: @node)
33
33
  create(:comment, content: 'A comment on a note', commentable: note)
34
34
  end
35
35
 
@@ -40,7 +40,7 @@ describe Dradis::Plugins::Projects::Export::V2::Template do
40
40
 
41
41
  context 'with comments in an evidence' do
42
42
  before do
43
- evidence = create(:evidence, text: 'Test evidence', node: node, issue: issue)
43
+ evidence = create(:evidence, content: 'Test evidence', node: @node, issue: @issue)
44
44
  create(:comment, content: 'A comment on an evidence', commentable: evidence)
45
45
  end
46
46
 
@@ -48,5 +48,17 @@ describe Dradis::Plugins::Projects::Export::V2::Template do
48
48
  expect(export).to include('A comment on an evidence')
49
49
  end
50
50
  end
51
+
52
+ context 'with comments with a deleted author' do
53
+ before do
54
+ note = create(:note, text: 'Note 1', node: @node)
55
+ comment = create(:comment, content: 'Deleted user', commentable: note)
56
+ comment.update_attribute :user, nil
57
+ end
58
+
59
+ it 'exports the comment without errors' do
60
+ expect(export).to include('Deleted user')
61
+ end
62
+ end
51
63
  end
52
64
  end
@@ -41,5 +41,17 @@ describe Dradis::Plugins::Projects::Upload::V2::Template::Importer do
41
41
  evidence = node.evidence.first
42
42
  expect(evidence.comments.first.content).to include('A comment on an evidence')
43
43
  end
44
+
45
+ it 'imports comments without user' do
46
+ issue = project.issues.first
47
+ note = node.notes.first
48
+ evidence = node.evidence.first
49
+
50
+ aggregate_failures do
51
+ expect(issue.comments.first.user).to be_nil
52
+ expect(note.comments.first.user).to be_nil
53
+ expect(evidence.comments.first.user).to be_nil
54
+ end
55
+ end
44
56
  end
45
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-projects
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.16.0
4
+ version: 3.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,8 @@ files:
112
112
  - Rakefile
113
113
  - app/controllers/dradis/plugins/projects/packages_controller.rb
114
114
  - app/controllers/dradis/plugins/projects/templates_controller.rb
115
+ - app/views/dradis/plugins/projects/export/_index-content.html.erb
116
+ - app/views/dradis/plugins/projects/export/_index-tabs.html.erb
115
117
  - config/routes.rb
116
118
  - dradis-projects.gemspec
117
119
  - lib/dradis-projects.rb
@@ -139,7 +141,7 @@ homepage: http://dradisframework.org
139
141
  licenses:
140
142
  - GPL-2
141
143
  metadata: {}
142
- post_install_message:
144
+ post_install_message:
143
145
  rdoc_options: []
144
146
  require_paths:
145
147
  - lib
@@ -154,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  - !ruby/object:Gem::Version
155
157
  version: '0'
156
158
  requirements: []
157
- rubygems_version: 3.0.1
158
- signing_key:
159
+ rubygems_version: 3.2.4
160
+ signing_key:
159
161
  specification_version: 4
160
162
  summary: Project export/upload for the Dradis Framework.
161
163
  test_files: