dradis-projects 3.10.0 → 3.11.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 +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/dradis/plugins/projects/export/v1/template.rb +7 -0
- data/lib/dradis/plugins/projects/export/v2/template.rb +0 -19
- data/lib/dradis/plugins/projects/gem_version.rb +1 -1
- data/lib/dradis/plugins/projects/upload/v1/template.rb +14 -1
- data/lib/dradis/plugins/projects/upload/v2/template.rb +0 -7
- data/spec/fixtures/files/with_comments.xml +110 -0
- data/spec/lib/dradis/plugins/projects/export/v2/template_spec.rb +52 -0
- data/spec/lib/dradis/plugins/projects/upload/v2/template_spec.rb +45 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594be647b3882ca2d8e0c56befaee84b41984ca7
|
4
|
+
data.tar.gz: 6eddd5014d88cf6ba493b0dfffc0622dd8fd96dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7df7bdbe490f458595460ea82853c1a1bc8f667672a3f684f98bd3c300b5f1a856f6cd82fea60da2e076d02e46a2fd68773417866f4bec9867c60175f88e688
|
7
|
+
data.tar.gz: 8127ca13c25cf5c42946f627103701e614031704d37cb348ff8c4f7e209276daac71b2f64c7db018c2ab1ffd93c92073ab1b12a9d39bf9a666b5ee68a89a04b5
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
## Dradis Framework 3.11 (November, 2018) ##
|
2
|
+
|
3
|
+
* Note and evidence comments in export/import
|
4
|
+
|
1
5
|
## Dradis Framework 3.10 (August, 2018) ##
|
2
6
|
|
3
7
|
* Use project scopes
|
4
8
|
|
5
9
|
* Check project existence for default user id
|
6
10
|
|
7
|
-
*
|
11
|
+
* Issue comments in export/import
|
8
12
|
|
9
13
|
* Replace Node methods that are now Project methods
|
10
14
|
|
@@ -33,6 +33,9 @@ module Dradis::Plugins::Projects::Export::V1
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# No-op here, overwritten in V2
|
37
|
+
def build_comments_for(builder, commentable); end
|
38
|
+
|
36
39
|
def build_evidence_for_node(builder, node)
|
37
40
|
builder.evidence do |evidences_builder|
|
38
41
|
node.evidence.each do |evidence|
|
@@ -44,6 +47,7 @@ module Dradis::Plugins::Projects::Export::V1
|
|
44
47
|
evidence_builder.cdata!(evidence.content)
|
45
48
|
end
|
46
49
|
build_activities_for(evidence_builder, evidence)
|
50
|
+
build_comments_for(evidence_builder, evidence)
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -61,6 +65,7 @@ module Dradis::Plugins::Projects::Export::V1
|
|
61
65
|
issue_builder.cdata!(issue.text)
|
62
66
|
end
|
63
67
|
build_activities_for(issue_builder, issue)
|
68
|
+
build_comments_for(issue_builder, issue)
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
@@ -117,11 +122,13 @@ module Dradis::Plugins::Projects::Export::V1
|
|
117
122
|
note_builder.cdata!(note.text)
|
118
123
|
end
|
119
124
|
build_activities_for(note_builder, note)
|
125
|
+
build_comments_for(note_builder, note)
|
120
126
|
end
|
121
127
|
end
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
131
|
+
# No-op here, overwritten in PRO
|
125
132
|
def build_report_content(builder); end
|
126
133
|
|
127
134
|
def build_tags(builder)
|
@@ -17,24 +17,5 @@ module Dradis::Plugins::Projects::Export::V2
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
def build_issues(builder)
|
22
|
-
@issues = Issue.where(node_id: project.issue_library).includes(:activities)
|
23
|
-
|
24
|
-
builder.issues do |issues_builder|
|
25
|
-
@issues.each do |issue|
|
26
|
-
issues_builder.issue do |issue_builder|
|
27
|
-
issue_builder.id(issue.id)
|
28
|
-
issue_builder.author(issue.author)
|
29
|
-
issue_builder.text do
|
30
|
-
issue_builder.cdata!(issue.text)
|
31
|
-
end
|
32
|
-
build_activities_for(issue_builder, issue)
|
33
|
-
build_comments_for(issue_builder, issue)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
20
|
end
|
40
21
|
end
|
@@ -28,8 +28,9 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
28
28
|
evidence: [],
|
29
29
|
|
30
30
|
# likewise we also need to hold on to the XML about evidence activities
|
31
|
-
# until after the evidence has been saved
|
31
|
+
# and comments until after the evidence has been saved
|
32
32
|
evidence_activity: [],
|
33
|
+
evidence_comments: [],
|
33
34
|
|
34
35
|
# all children nodes, we will need to find the ID of their new parents.
|
35
36
|
orphan_nodes: []
|
@@ -38,6 +39,11 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
38
39
|
|
39
40
|
private
|
40
41
|
|
42
|
+
# No-op here, overwritten in V2
|
43
|
+
def create_comments(commentable, xml_comments)
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
41
47
|
def create_activities(trackable, xml_trackable)
|
42
48
|
xml_trackable.xpath('activities/activity').each do |xml_activity|
|
43
49
|
# if 'validate_and_save(activity)' returns false, it needs
|
@@ -71,6 +77,8 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
71
77
|
|
72
78
|
return false unless create_activities(issue, xml_issue)
|
73
79
|
|
80
|
+
return false unless create_comments(issue, xml_issue.xpath('comments/comment'))
|
81
|
+
|
74
82
|
true
|
75
83
|
end
|
76
84
|
|
@@ -117,6 +125,9 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
117
125
|
pending_changes[:evidence_activity][i].each do |xml_activity|
|
118
126
|
raise "Couldn't create activity for Evidence ##{evidence.id}" unless create_activity(evidence, xml_activity)
|
119
127
|
end
|
128
|
+
|
129
|
+
xml_comments = pending_changes[:evidence_comments][i]
|
130
|
+
raise "Couldn't create comments for Evidence ##{evidence.id}" unless create_comments(evidence, xml_comments)
|
120
131
|
end
|
121
132
|
end
|
122
133
|
|
@@ -299,6 +310,7 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
299
310
|
|
300
311
|
pending_changes[:evidence] << evidence
|
301
312
|
pending_changes[:evidence_activity] << xml_evidence.xpath('activities/activity')
|
313
|
+
pending_changes[:evidence_comments] << xml_evidence.xpath('comments/comment')
|
302
314
|
|
303
315
|
logger.info { "\tNew evidence added." }
|
304
316
|
end
|
@@ -333,6 +345,7 @@ module Dradis::Plugins::Projects::Upload::V1
|
|
333
345
|
end
|
334
346
|
|
335
347
|
raise "Couldn't create activities for Note ##{note.id}" unless create_activities(note, xml_note)
|
348
|
+
raise "Couldn't create comments for Note ##{note.id}" unless create_comments(note, xml_note.xpath('comments/comment'))
|
336
349
|
|
337
350
|
logger.info { "\tNew note added." }
|
338
351
|
end
|
@@ -25,13 +25,6 @@ module Dradis::Plugins::Projects::Upload::V2
|
|
25
25
|
return false unless validate_and_save(comment)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
def create_issue(issue, xml_issue)
|
30
|
-
return false unless super
|
31
|
-
return false unless create_comments(issue, xml_issue.xpath('comments/comment'))
|
32
|
-
|
33
|
-
true
|
34
|
-
end
|
35
28
|
end
|
36
29
|
end
|
37
30
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<dradis-template version="2">
|
3
|
+
<nodes>
|
4
|
+
<node>
|
5
|
+
<id>3</id>
|
6
|
+
<label>Node 1</label>
|
7
|
+
<parent-id/>
|
8
|
+
<position>0</position>
|
9
|
+
<properties><![CDATA[{
|
10
|
+
}]]></properties>
|
11
|
+
<type-id>1</type-id>
|
12
|
+
<notes>
|
13
|
+
<note>
|
14
|
+
<id>2</id>
|
15
|
+
<author>xavi</author>
|
16
|
+
<category-id>2</category-id>
|
17
|
+
<text><![CDATA[#[Title]#
|
18
|
+
Note 1
|
19
|
+
|
20
|
+
#[Description]#
|
21
|
+
|
22
|
+
]]></text>
|
23
|
+
<activities>
|
24
|
+
<activity>
|
25
|
+
<action>create</action>
|
26
|
+
<user_email>xavi</user_email>
|
27
|
+
<created_at>1538467955</created_at>
|
28
|
+
</activity>
|
29
|
+
</activities>
|
30
|
+
<comments>
|
31
|
+
<comment>
|
32
|
+
<content><![CDATA[A comment on a note]]></content>
|
33
|
+
<author>xavi</author>
|
34
|
+
<created_at>1538467968</created_at>
|
35
|
+
</comment>
|
36
|
+
</comments>
|
37
|
+
</note>
|
38
|
+
</notes>
|
39
|
+
<evidence>
|
40
|
+
<evidence>
|
41
|
+
<id>386</id>
|
42
|
+
<author>xavi</author>
|
43
|
+
<issue-id>586</issue-id>
|
44
|
+
<content><![CDATA[#[Location]#
|
45
|
+
A
|
46
|
+
]]></content>
|
47
|
+
<activities>
|
48
|
+
<activity>
|
49
|
+
<action>create</action>
|
50
|
+
<user_email>xavi</user_email>
|
51
|
+
<created_at>1538549260</created_at>
|
52
|
+
</activity>
|
53
|
+
</activities>
|
54
|
+
<comments>
|
55
|
+
<comment>
|
56
|
+
<content><![CDATA[A comment on an evidence]]></content>
|
57
|
+
<author>xavi</author>
|
58
|
+
<created_at>1538549286</created_at>
|
59
|
+
</comment>
|
60
|
+
</comments>
|
61
|
+
</evidence>
|
62
|
+
</evidence>
|
63
|
+
<activities>
|
64
|
+
<activity>
|
65
|
+
<action>create</action>
|
66
|
+
<user_email>xavi</user_email>
|
67
|
+
<created_at>1538467945</created_at>
|
68
|
+
</activity>
|
69
|
+
</activities>
|
70
|
+
</node>
|
71
|
+
</nodes>
|
72
|
+
<issues>
|
73
|
+
<issue>
|
74
|
+
<id>1</id>
|
75
|
+
<author>xavi</author>
|
76
|
+
<text><![CDATA[#[Title]#
|
77
|
+
Issue 1
|
78
|
+
|
79
|
+
#[Description]#
|
80
|
+
|
81
|
+
]]></text>
|
82
|
+
<activities>
|
83
|
+
<activity>
|
84
|
+
<action>create</action>
|
85
|
+
<user_email>xavi</user_email>
|
86
|
+
<created_at>1538467938</created_at>
|
87
|
+
</activity>
|
88
|
+
</activities>
|
89
|
+
<comments>
|
90
|
+
<comment>
|
91
|
+
<content><![CDATA[A comment on an issue]]></content>
|
92
|
+
<author>xavi</author>
|
93
|
+
<created_at>1538467997</created_at>
|
94
|
+
</comment>
|
95
|
+
</comments>
|
96
|
+
</issue>
|
97
|
+
</issues>
|
98
|
+
<methodologies/>
|
99
|
+
<categories>
|
100
|
+
<category>
|
101
|
+
<id>1</id>
|
102
|
+
<name>Issue description</name>
|
103
|
+
</category>
|
104
|
+
<category>
|
105
|
+
<id>2</id>
|
106
|
+
<name>Default category</name>
|
107
|
+
</category>
|
108
|
+
</categories>
|
109
|
+
<tags/>
|
110
|
+
</dradis-template>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Dradis::Plugins::Projects::Export::V2::Template do
|
4
|
+
let(:project) { create(:project) }
|
5
|
+
let(:user) { create(:user) }
|
6
|
+
let(:export) do
|
7
|
+
described_class.new(
|
8
|
+
default_user_id: user.id,
|
9
|
+
plugin: Dradis::Plugins::Projects,
|
10
|
+
project_id: project.id
|
11
|
+
).export
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'exporting a project' do
|
15
|
+
before do
|
16
|
+
node = create(:node, project: project)
|
17
|
+
issue = create(:issue, text: 'Issue 1', node: project.issue_library)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with comments in an issue' do
|
21
|
+
before do
|
22
|
+
create(:comment, content: 'A comment on an issue', commentable: issue)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'exports comments in the issue' do
|
26
|
+
expect(export).to include('A comment on an issue')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with comments in a note' do
|
31
|
+
before do
|
32
|
+
note = create(:note, text: 'Note 1', node: node)
|
33
|
+
create(:comment, content: 'A comment on a note', commentable: note)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'exports comments in the note' do
|
37
|
+
expect(export).to include('A comment on a note')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with comments in an evidence' do
|
42
|
+
before do
|
43
|
+
evidence = create(:evidence, text: 'Test evidence', node: node, issue: issue)
|
44
|
+
create(:comment, content: 'A comment on an evidence', commentable: evidence)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'exports comments in the evidence' do
|
48
|
+
expect(export).to include('A comment on an evidence')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Dradis::Plugins::Projects::Upload::V2::Template::Importer do
|
4
|
+
let(:project) { create(:project) }
|
5
|
+
let(:user) { create(:user) }
|
6
|
+
let(:importer_class) { Dradis::Plugins::Projects::Upload::Template }
|
7
|
+
let(:file_path) do
|
8
|
+
File.join(
|
9
|
+
File.dirname(__FILE__),
|
10
|
+
'../../../../../../',
|
11
|
+
'fixtures',
|
12
|
+
'files',
|
13
|
+
'with_comments.xml'
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'uploading a template with comments' do
|
18
|
+
before do
|
19
|
+
importer = importer_class::Importer.new(
|
20
|
+
default_user_id: user.id,
|
21
|
+
plugin: importer_class,
|
22
|
+
project_id: project.id
|
23
|
+
)
|
24
|
+
|
25
|
+
importer.import(file: file_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:node) { project.nodes.find_by(label: 'Node 1') }
|
29
|
+
|
30
|
+
it 'imports comments in issues' do
|
31
|
+
issue = project.issues.first
|
32
|
+
expect(issue.comments.first.content).to include('A comment on an issue')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'imports comments in notes' do
|
36
|
+
note = node.notes.first
|
37
|
+
expect(note.comments.first.content).to include('A comment on a note')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'imports comments in evidence' do
|
41
|
+
evidence = node.evidence.first
|
42
|
+
expect(evidence.comments.first.content).to include('A comment on an evidence')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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.11.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: 2018-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,7 +129,10 @@ files:
|
|
129
129
|
- lib/dradis/plugins/projects/version.rb
|
130
130
|
- lib/tasks/thorfile.rb
|
131
131
|
- spec/fixtures/files/attachments_url.xml
|
132
|
+
- spec/fixtures/files/with_comments.xml
|
133
|
+
- spec/lib/dradis/plugins/projects/export/v2/template_spec.rb
|
132
134
|
- spec/lib/dradis/plugins/projects/upload/v1/template_spec.rb
|
135
|
+
- spec/lib/dradis/plugins/projects/upload/v2/template_spec.rb
|
133
136
|
homepage: http://dradisframework.org
|
134
137
|
licenses:
|
135
138
|
- GPL-2
|
@@ -156,4 +159,7 @@ specification_version: 4
|
|
156
159
|
summary: Project export/upload for the Dradis Framework.
|
157
160
|
test_files:
|
158
161
|
- spec/fixtures/files/attachments_url.xml
|
162
|
+
- spec/fixtures/files/with_comments.xml
|
163
|
+
- spec/lib/dradis/plugins/projects/export/v2/template_spec.rb
|
159
164
|
- spec/lib/dradis/plugins/projects/upload/v1/template_spec.rb
|
165
|
+
- spec/lib/dradis/plugins/projects/upload/v2/template_spec.rb
|