dradis-projects 3.17.0 → 3.22.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
- SHA256:
3
- metadata.gz: 3a8be2f5a1ea984d74d0e2c0e1b8aa8234592b92bd580616afa5846f4e2c85f4
4
- data.tar.gz: 07a452e34dfa738a6cc206d24af3b89f3208002c1b73f12fc8c1b57c2e404cf2
2
+ SHA1:
3
+ metadata.gz: '0059854c4be15ee7482f2c8971b2d116448fdac3'
4
+ data.tar.gz: 274c11a56a4da9dd7aced8ce40d5733cebcd0fc2
5
5
  SHA512:
6
- metadata.gz: a4d192636cb52fd17926243cf9ed8123adffd15a7fa6653bf8634afef66ea515ab6fd667de20ddc9a55727aef4d7760963978c372a48d71af96d6e41c5d8e255
7
- data.tar.gz: 77167bb73e09422b5a016a09342d1f402e8ad7a5903beb03af3c260492a8102ebc38ee678c047d3a342d36890a0b208a5962868aff49c0b2b1ede6a3f8ee30c8
6
+ metadata.gz: e7f624ad8cedc09de23de97544715f95c44d696b83b685e25d2dede9f9222de99edba495964db7c554f7199b0d6bb2274d13239f9c40cd346703e24be0547721
7
+ data.tar.gz: 37e188178fad6f45c8e540e6e731c1422f49b4f0b58769f5005ac8be1c8d09ced41e4af9e0c4015e92c1bc74e091efe35924ab9d62dc97fa69d80c0c0b69ab31
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.22 (April, 2021) ##
2
+
3
+ * No changes
4
+
5
+ ## Dradis Framework 3.21 (February, 2021) ##
6
+
7
+ * No changes
8
+
9
+ ## Dradis Framework 3.20 (Jan, 2020) ##
10
+
11
+ * Add views for the export view.
12
+ * Fix exporting projects with comments by deleted users.
13
+
14
+ ## Dradis Framework 3.19 (September, 2020) ##
15
+
16
+ * No changes
17
+
18
+ ## Dradis Framework 3.18 (July, 2020) ##
19
+
20
+ * No changes
21
+
1
22
  ## Dradis Framework 3.17 (May, 2020) ##
2
23
 
3
24
  * No changes
@@ -43,19 +64,19 @@
43
64
 
44
65
  ## Dradis Framework 3.9 (January, 2018) ##
45
66
 
46
- * Fix nodes upload
67
+ * Fix nodes upload
47
68
 
48
69
  * Add default user id as fallback for activity user when importing
49
70
 
50
71
  ## Dradis Framework 3.8 (September, 2017) ##
51
72
 
52
- * Add version attribute to exported methodologies
73
+ * Add version attribute to exported methodologies
53
74
 
54
75
  * Add parse_report_content placeholders to import/export.
55
76
 
56
77
  ## Dradis Framework 3.7 (July, 2017) ##
57
78
 
58
- * Skip closing the logger in thorfile
79
+ * Skip closing the logger in thorfile
59
80
 
60
81
  ## Dradis Framework 3.6 (March, 2017) ##
61
82
 
@@ -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
@@ -13,43 +13,7 @@ module Dradis::Plugins::Projects::Export::V3
13
13
  node_id =
14
14
  board.node == project.methodology_library ? nil : board.node_id
15
15
 
16
- methodologies_builder.board(version: VERSION) do |board_builder|
17
- board_builder.id(board.id)
18
- board_builder.name(board.name)
19
- board_builder.node_id(node_id)
20
-
21
- board.ordered_items.each do |list|
22
-
23
- board_builder.list do |list_builder|
24
- list_builder.id(list.id)
25
- list_builder.name(list.name)
26
- list_builder.previous_id(list.previous_id)
27
-
28
- list.ordered_items.each do |card|
29
-
30
- list_builder.card do |card_builder|
31
- card_builder.id(card.id)
32
- card_builder.name(card.name)
33
- card_builder.description do
34
- card_builder.cdata!(card.description)
35
- end
36
- card_builder.due_date(card.due_date)
37
- card_builder.previous_id(card.previous_id)
38
-
39
- card_builder.assignees do |assignee_builder|
40
- card.assignees.each do |assignee|
41
- assignee_builder.assignee(assignee.email)
42
- end
43
- end
44
-
45
- build_activities_for(card_builder, card)
46
- build_comments_for(card_builder, card)
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
16
+ board.to_xml(methodologies_builder, includes: [:activities, :assignees, :comments], version: VERSION)
53
17
  end
54
18
  end
55
19
  end
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 3
11
- MINOR = 17
11
+ MINOR = 22
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.17.0
4
+ version: 3.22.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: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2021-04-02 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
@@ -154,7 +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
159
+ rubyforge_project:
160
+ rubygems_version: 2.6.11
158
161
  signing_key:
159
162
  specification_version: 4
160
163
  summary: Project export/upload for the Dradis Framework.