dradis-projects 5.2.0 → 5.4.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.
@@ -1,111 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dradis-template version="4">
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>586</id>
75
- <author>xavi</author>
76
- <state>fakestate</state>
77
- <text><![CDATA[#[Title]#
78
- Issue 1
79
-
80
- #[Description]#
81
-
82
- ]]></text>
83
- <activities>
84
- <activity>
85
- <action>create</action>
86
- <user_email>xavi</user_email>
87
- <created_at>1538467938</created_at>
88
- </activity>
89
- </activities>
90
- <comments>
91
- <comment>
92
- <content><![CDATA[A comment on an issue]]></content>
93
- <author>xavi</author>
94
- <created_at>1538467997</created_at>
95
- </comment>
96
- </comments>
97
- </issue>
98
- </issues>
99
- <methodologies/>
100
- <categories>
101
- <category>
102
- <id>1</id>
103
- <name>Issue description</name>
104
- </category>
105
- <category>
106
- <id>2</id>
107
- <name>Default category</name>
108
- </category>
109
- </categories>
110
- <tags/>
111
- </dradis-template>
@@ -1,111 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dradis-template version="4">
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>586</id>
75
- <author>xavi</author>
76
- <state>ready_for_review</state>
77
- <text><![CDATA[#[Title]#
78
- Issue 1
79
-
80
- #[Description]#
81
-
82
- ]]></text>
83
- <activities>
84
- <activity>
85
- <action>create</action>
86
- <user_email>xavi</user_email>
87
- <created_at>1538467938</created_at>
88
- </activity>
89
- </activities>
90
- <comments>
91
- <comment>
92
- <content><![CDATA[A comment on an issue]]></content>
93
- <author>xavi</author>
94
- <created_at>1538467997</created_at>
95
- </comment>
96
- </comments>
97
- </issue>
98
- </issues>
99
- <methodologies/>
100
- <categories>
101
- <category>
102
- <id>1</id>
103
- <name>Issue description</name>
104
- </category>
105
- <category>
106
- <id>2</id>
107
- <name>Default category</name>
108
- </category>
109
- </categories>
110
- <tags/>
111
- </dradis-template>
@@ -1,64 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dradis-template version="2">
3
- <nodes>
4
- <node>
5
- <id>5</id>
6
- <label>Uploaded files</label>
7
- <parent-id />
8
- <position>0</position>
9
- <properties><![CDATA[{
10
- }]]></properties>
11
- <type-id>0</type-id>
12
- <notes></notes>
13
- <evidence></evidence>
14
- <activities></activities>
15
- </node>
16
- </nodes>
17
- <issues>
18
- <issue>
19
- <id>2</id>
20
- <author>admin@securityroots.com</author>
21
- <text><![CDATA[#[Title]#
22
- Test Issue
23
- #[Description]#
24
- hello world]]>
25
- </text>
26
- <activities></activities>
27
- <comments></comments>
28
- </issue>
29
- </issues>
30
- <methodologies></methodologies>
31
- <categories>
32
- <category>
33
- <id>2</id>
34
- <name>Issue description</name>
35
- </category>
36
- </categories>
37
- <tags>
38
- <tag>
39
- <id>1</id>
40
- <name>!2ca02c_info</name>
41
- <taggings></taggings>
42
- </tag>
43
- <tag>
44
- <id>2</id>
45
- <name>!ff7f0e_medium</name>
46
- <taggings></taggings>
47
- </tag>
48
- <tag>
49
- <id>3</id>
50
- <name>!d62728_high</name>
51
- <taggings></taggings>
52
- </tag>
53
- <tag>
54
- <id>4</id>
55
- <name>!6baed6_low</name>
56
- <taggings></taggings>
57
- </tag>
58
- <tag>
59
- <id>5</id>
60
- <name>!9467bd_critical</name>
61
- <taggings></taggings>
62
- </tag>
63
- </tags>
64
- </dradis-template>
@@ -1,72 +0,0 @@
1
- # DEPRECATED - this class is v2 of the Template Importer and shouldn't be updated.
2
- # V4 released on Apr 2022
3
- # V2 can be removed on Apr 2024
4
- #
5
- # We're duplicating this file for v4, and even though the code lives in two
6
- # places now, this file isn't expected to evolve and is now frozen to V2
7
- # behavior.
8
-
9
- require 'rails_helper'
10
-
11
- describe 'Dradis::Plugins::Projects::Export::V2::Template' do
12
- let(:project) { create(:project) }
13
- let(:user) { create(:user) }
14
- let(:export) do
15
- described_class.new(
16
- default_user_id: user.id,
17
- plugin: Dradis::Plugins::Projects,
18
- project_id: project.id
19
- ).export
20
- end
21
-
22
- context 'exporting a project' do
23
- before do
24
- @node = create(:node, project: project)
25
- @issue = create(:issue, text: 'Issue 1', node: project.issue_library)
26
- end
27
-
28
- context 'with comments in an issue' do
29
- before do
30
- create(:comment, content: 'A comment on an issue', commentable: @issue)
31
- end
32
-
33
- it 'exports comments in the issue' do
34
- expect(export).to include('A comment on an issue')
35
- end
36
- end
37
-
38
- context 'with comments in a note' do
39
- before do
40
- note = create(:note, text: 'Note 1', node: @node)
41
- create(:comment, content: 'A comment on a note', commentable: note)
42
- end
43
-
44
- it 'exports comments in the note' do
45
- expect(export).to include('A comment on a note')
46
- end
47
- end
48
-
49
- context 'with comments in an evidence' do
50
- before do
51
- evidence = create(:evidence, content: 'Test evidence', node: @node, issue: @issue)
52
- create(:comment, content: 'A comment on an evidence', commentable: evidence)
53
- end
54
-
55
- it 'exports comments in the evidence' do
56
- expect(export).to include('A comment on an evidence')
57
- end
58
- end
59
-
60
- context 'with comments with a deleted author' do
61
- before do
62
- note = create(:note, text: 'Note 1', node: @node)
63
- comment = create(:comment, content: 'Deleted user', commentable: note)
64
- comment.update_attribute :user, nil
65
- end
66
-
67
- it 'exports the comment without errors' do
68
- expect(export).to include('Deleted user')
69
- end
70
- end
71
- end
72
- end
@@ -1,84 +0,0 @@
1
- # Run the spec in CE/Pro context with:
2
- # rspec <relative path to dradis-projects>/spec/lib/dradis/plugins/projects/export/v4/template_spec.rb
3
-
4
- require 'rails_helper'
5
-
6
- describe 'Dradis::Plugins::Projects::Export::V4::Template' do
7
- let(:project) { create(:project) }
8
- let(:user) { create(:user) }
9
- let(:exporter) { 'Dradis::Plugins::Projects::Export::V4::Template' }
10
- let(:export) do
11
- exporter.constantize.new(
12
- default_user_id: user.id,
13
- plugin: Dradis::Plugins::Projects,
14
- project_id: project.id
15
- ).export
16
- end
17
-
18
- context 'exporting a project' do
19
- before do
20
- @node = create(:node, project: project)
21
- @issue = create(:issue, text: 'Issue 1', node: project.issue_library)
22
- end
23
-
24
- describe 'comments' do
25
- context 'with comments in an issue' do
26
- before do
27
- create(:comment, content: 'A comment on an issue', commentable: @issue)
28
- end
29
-
30
- it 'exports comments in the issue' do
31
- expect(export).to include('A comment on an issue')
32
- end
33
- end
34
-
35
- context 'with comments in a note' do
36
- before do
37
- note = create(:note, text: 'Note 1', node: @node)
38
- create(:comment, content: 'A comment on a note', commentable: note)
39
- end
40
-
41
- it 'exports comments in the note' do
42
- expect(export).to include('A comment on a note')
43
- end
44
- end
45
-
46
- context 'with comments in an evidence' do
47
- before do
48
- evidence = create(:evidence, content: 'Test evidence', node: @node, issue: @issue)
49
- create(:comment, content: 'A comment on an evidence', commentable: evidence)
50
- end
51
-
52
- it 'exports comments in the evidence' do
53
- expect(export).to include('A comment on an evidence')
54
- end
55
- end
56
-
57
- context 'with comments with a deleted author' do
58
- before do
59
- note = create(:note, text: 'Note 1', node: @node)
60
- comment = create(:comment, content: 'Deleted user', commentable: note)
61
- comment.update_attribute :user, nil
62
- end
63
-
64
- it 'exports the comment without errors' do
65
- expect(export).to include('Deleted user')
66
- end
67
- end
68
- end
69
-
70
- describe 'states' do
71
- before do
72
- Issue.states.each do |state|
73
- create(:issue, text: 'Issue 1', node: project.issue_library, state: state[0])
74
- end
75
- end
76
-
77
- it 'export issues with states' do
78
- Issue.states.each do |state|
79
- expect(export).to include("<state>#{state[0]}</state>")
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,84 +0,0 @@
1
- # DEPRECATED - this class is v1 of the Template Importer and shouldn't be updated.
2
- # V4 released on Apr 2022
3
- # V1 can be removed on Apr 2024
4
- #
5
- # We're duplicating this file for v4, and even though the code lives in two
6
- # places now, this file isn't expected to evolve and is now frozen to V1
7
- # behavior.
8
-
9
- # frozen_string_literal: true
10
-
11
- require 'rails_helper'
12
-
13
- describe Dradis::Plugins::Projects::Upload::V1::Template::Importer do
14
- let(:project) { create(:project) }
15
- let(:user) { create(:user) }
16
- let(:importer_class) { Dradis::Plugins::Projects::Upload::Template }
17
-
18
- context 'uploading a template with attachments url' do
19
- let(:file_path) do
20
- File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'attachments_url.xml')
21
- end
22
-
23
- it 'converts the urls' do
24
- importer = importer_class::Importer.new(
25
- default_user_id: user.id,
26
- plugin: importer_class,
27
- project_id: project.id
28
- )
29
-
30
- importer.import(file: file_path)
31
-
32
- p_id = project.id
33
- n_id = project.plugin_uploads_node.id
34
-
35
- expect(project.issues.first.text).to include(
36
- "!/pro/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
37
- "!/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
38
- "!/pro/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!\n\n" +
39
- "!/projects/#{p_id}/nodes/#{n_id}/attachments/hello.jpg!"
40
- )
41
- end
42
- end
43
-
44
- context 'uploading a template malformed paths as ids' do
45
- let(:file_path) do
46
- File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'malformed_ids.xml')
47
- end
48
-
49
- it 'returns false' do
50
- importer = importer_class::Importer.new(
51
- default_user_id: user.id,
52
- plugin: importer_class,
53
- project_id: project.id
54
- )
55
-
56
- expect(importer.import(file: file_path)).to be false
57
- end
58
- end
59
-
60
- context 'uploading a template with attachment but missing node' do
61
- let(:file_path) do
62
- File.join(File.dirname(__FILE__), '../../../../../../', 'fixtures', 'files', 'missing_node.xml')
63
- end
64
-
65
- it 'does not modify the attachment' do
66
- logger = double('logger')
67
- allow(logger).to receive_messages(debug: nil, error: nil, fatal: nil, info: nil)
68
- expect(logger).to receive(:error).once
69
-
70
- importer = importer_class::Importer.new(
71
- default_user_id: user.id,
72
- logger: logger,
73
- plugin: importer_class,
74
- project_id: project.id
75
- )
76
-
77
- importer.import(file: file_path)
78
-
79
- expect(project.issues.first.text).to include(
80
- "!/pro/projects/222/nodes/12345/attachments/hello.jpg!"
81
- )
82
- end
83
- end
84
- end
@@ -1,65 +0,0 @@
1
- # DEPRECATED - this class is v2 of the Template Importer and shouldn't be updated.
2
- # V4 released on Apr 2022
3
- # V2 can be removed on Apr 2024
4
- #
5
- # We're duplicating this file for v4, and even though the code lives in two
6
- # places now, this file isn't expected to evolve and is now frozen to V2
7
- # behavior.
8
-
9
- require 'rails_helper'
10
-
11
- describe 'Dradis::Plugins::Projects::Upload::V2::Template::Importer' do
12
- let(:project) { create(:project) }
13
- let(:user) { create(:user) }
14
- let(:importer_class) { Dradis::Plugins::Projects::Upload::Template }
15
- let(:file_path) do
16
- File.join(
17
- File.dirname(__FILE__),
18
- '../../../../../../',
19
- 'fixtures',
20
- 'files',
21
- 'with_comments.xml'
22
- )
23
- end
24
-
25
- context 'uploading a template with comments' do
26
- before do
27
- importer = importer_class::Importer.new(
28
- default_user_id: user.id,
29
- plugin: importer_class,
30
- project_id: project.id
31
- )
32
-
33
- importer.import(file: file_path)
34
- end
35
-
36
- let(:node) { project.nodes.find_by(label: 'Node 1') }
37
-
38
- it 'imports comments in issues' do
39
- issue = project.issues.first
40
- expect(issue.comments.first.content).to include('A comment on an issue')
41
- end
42
-
43
- it 'imports comments in notes' do
44
- note = node.notes.first
45
- expect(note.comments.first.content).to include('A comment on a note')
46
- end
47
-
48
- it 'imports comments in evidence' do
49
- evidence = node.evidence.first
50
- expect(evidence.comments.first.content).to include('A comment on an evidence')
51
- end
52
-
53
- it 'imports comments without user' do
54
- issue = project.issues.first
55
- note = node.notes.first
56
- evidence = node.evidence.first
57
-
58
- aggregate_failures do
59
- expect(issue.comments.first.user).to be_nil
60
- expect(note.comments.first.user).to be_nil
61
- expect(evidence.comments.first.user).to be_nil
62
- end
63
- end
64
- end
65
- end