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 +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/dradis/plugins/projects/export/v2/template.rb +1 -1
- data/lib/dradis/plugins/projects/gem_version.rb +1 -1
- data/lib/dradis/plugins/projects/upload/v1/template.rb +6 -4
- data/lib/dradis/plugins/projects/upload/v2/template.rb +6 -3
- data/spec/fixtures/files/with_comments.xml +1 -1
- data/spec/lib/dradis/plugins/projects/export/v2/template_spec.rb +17 -5
- data/spec/lib/dradis/plugins/projects/upload/v2/template_spec.rb +12 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfe5bf6cbe31094323147c20e04d6693fdb4c605c258a0b0755c09e366fb82ba
|
4
|
+
data.tar.gz: e9cd0afb9050999a5d08c0da67bb44469a5209707d81563f7851807db07c7e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856c6e4c02666794683e1fca0f9e70df6e1cf147d91daf510c7a988e189e7b7b73735b90a99586b22ca3b3ad3ecb496628397f8b79785e7c74262ab58a1d9ea7
|
7
|
+
data.tar.gz: 06a7b58d9fc4128240d00cffc9cac88587796717de132704db67b1476f3ec02d6a3f8774d5e72ceeeaa109ed2f7f5fa47fd5027c49bfbade48b941e6fad5757b
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
14
|
+
comment_builder.author(comment.user&.email)
|
15
15
|
comment_builder.created_at(comment.created_at.to_i)
|
16
16
|
end
|
17
17
|
end
|
@@ -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
|
-
|
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:
|
16
|
+
user_id: users[author_email]
|
17
17
|
)
|
18
18
|
|
19
|
-
if comment.user.
|
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
|
-
|
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
|
@@ -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,
|
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.
|
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:
|
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.
|
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:
|