dradis-projects 3.19.0 → 3.20.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: 15e6f2944b32adc796476388e08a4526d78046d8c899b47c6d68dc7750b973cb
4
- data.tar.gz: 63b932c050ca7f3f1b40d9c7fd4d29f2eb8165d728c4314ed21e8bd7cd552919
3
+ metadata.gz: bfe5bf6cbe31094323147c20e04d6693fdb4c605c258a0b0755c09e366fb82ba
4
+ data.tar.gz: e9cd0afb9050999a5d08c0da67bb44469a5209707d81563f7851807db07c7e47
5
5
  SHA512:
6
- metadata.gz: '08cc871995bc3cf8a56b112a3b85729fa6d6561b2addbec65f6a0b0a9c69291825dff38e8458525a6c40a2b814114a9aef7428cf458d35ae4b13f61c07189551'
7
- data.tar.gz: 07e6b9fb5d85de664c3e3e91141961a73931a317bab525c0456c6f60f6b857dbf3167539ef112d2b9ff26e8947f36afacb9c2c93518f5b79dcc425c2d565dc39
6
+ metadata.gz: 856c6e4c02666794683e1fca0f9e70df6e1cf147d91daf510c7a988e189e7b7b73735b90a99586b22ca3b3ad3ecb496628397f8b79785e7c74262ab58a1d9ea7
7
+ data.tar.gz: 06a7b58d9fc4128240d00cffc9cac88587796717de132704db67b1476f3ec02d6a3f8774d5e72ceeeaa109ed2f7f5fa47fd5027c49bfbade48b941e6fad5757b
data/.gitignore CHANGED
@@ -8,3 +8,5 @@ Gemfile.lock
8
8
 
9
9
  # Gem artifacts
10
10
  /pkg/
11
+
12
+ .DS_Store
@@ -1,3 +1,7 @@
1
+ ## Dradis Framework 3.20 (Jan, 2020) ##
2
+
3
+ * Fix exporting projects with comments by deleted users.
4
+
1
5
  ## Dradis Framework 3.19 (September, 2020) ##
2
6
 
3
7
  * No changes
@@ -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 = 19
11
+ MINOR = 20
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.19.0
4
+ version: 3.20.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-09-04 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,7 +139,7 @@ homepage: http://dradisframework.org
139
139
  licenses:
140
140
  - GPL-2
141
141
  metadata: {}
142
- post_install_message:
142
+ post_install_message:
143
143
  rdoc_options: []
144
144
  require_paths:
145
145
  - lib
@@ -154,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.0.0
158
- signing_key:
157
+ rubygems_version: 3.2.4
158
+ signing_key:
159
159
  specification_version: 4
160
160
  summary: Project export/upload for the Dradis Framework.
161
161
  test_files: