dradis-plugins 3.18.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +10 -0
- data/LICENSE +339 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/app/controllers/concerns/dradis/plugins/persistent_permissions.rb +43 -0
- data/app/controllers/dradis/plugins/export/base_controller.rb +18 -0
- data/dradis-plugins.gemspec +31 -0
- data/lib/dradis-plugins.rb +1 -0
- data/lib/dradis/plugins.rb +80 -0
- data/lib/dradis/plugins/base.rb +45 -0
- data/lib/dradis/plugins/configurable.rb +26 -0
- data/lib/dradis/plugins/content_service/base.rb +26 -0
- data/lib/dradis/plugins/content_service/boards.rb +32 -0
- data/lib/dradis/plugins/content_service/categories.rb +9 -0
- data/lib/dradis/plugins/content_service/content_blocks.rb +44 -0
- data/lib/dradis/plugins/content_service/core.rb +53 -0
- data/lib/dradis/plugins/content_service/evidence.rb +36 -0
- data/lib/dradis/plugins/content_service/issues.rb +94 -0
- data/lib/dradis/plugins/content_service/nodes.rb +88 -0
- data/lib/dradis/plugins/content_service/notes.rb +43 -0
- data/lib/dradis/plugins/content_service/properties.rb +9 -0
- data/lib/dradis/plugins/engine.rb +15 -0
- data/lib/dradis/plugins/export.rb +1 -0
- data/lib/dradis/plugins/export/base.rb +57 -0
- data/lib/dradis/plugins/gem_version.rb +17 -0
- data/lib/dradis/plugins/import.rb +3 -0
- data/lib/dradis/plugins/import/filters.rb +51 -0
- data/lib/dradis/plugins/import/filters/base.rb +16 -0
- data/lib/dradis/plugins/import/result.rb +12 -0
- data/lib/dradis/plugins/settings.rb +91 -0
- data/lib/dradis/plugins/template_service.rb +104 -0
- data/lib/dradis/plugins/templates.rb +57 -0
- data/lib/dradis/plugins/thor.rb +30 -0
- data/lib/dradis/plugins/thor_helper.rb +29 -0
- data/lib/dradis/plugins/upload.rb +10 -0
- data/lib/dradis/plugins/upload/base.rb +57 -0
- data/lib/dradis/plugins/upload/field_processor.rb +35 -0
- data/lib/dradis/plugins/upload/importer.rb +78 -0
- data/lib/dradis/plugins/version.rb +11 -0
- data/spec/internal/log/test.log +0 -0
- data/spec/lib/dradis/plugins/content_service/boards_spec.rb +45 -0
- data/spec/lib/dradis/plugins/content_service/issues_spec.rb +64 -0
- data/spec/settings_spec.rb +88 -0
- data/spec/spec_helper.rb +2 -0
- metadata +138 -0
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# To run, execute from Dradis main app folder:
|
4
|
+
# bin/rspec [dradis-plugins path]/spec/lib/dradis/plugins/content_service/boards_spec.rb
|
5
|
+
describe Dradis::Plugins::ContentService::Boards do
|
6
|
+
let(:plugin) { Dradis::Plugins::Nessus }
|
7
|
+
let(:project) { create(:project) }
|
8
|
+
let(:service) do
|
9
|
+
Dradis::Plugins::ContentService::Base.new(
|
10
|
+
plugin: plugin,
|
11
|
+
logger: Rails.logger,
|
12
|
+
project: project
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'Boards' do
|
17
|
+
describe '#all_boards' do
|
18
|
+
it 'returns all the project-level boards' do
|
19
|
+
board = create(:board, project: project)
|
20
|
+
node = create(:node, project: project)
|
21
|
+
node_board = create(:board, node: node, project: project)
|
22
|
+
|
23
|
+
boards = service.all_boards
|
24
|
+
|
25
|
+
expect(boards).to include(board)
|
26
|
+
expect(boards).to_not include(node_board)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#create_board' do
|
31
|
+
it 'creates a board without a node' do
|
32
|
+
service.create_board(name: 'NodelessBoard')
|
33
|
+
|
34
|
+
expect(project.reload.boards.where(name: 'NodelessBoard')).to_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'creates a board with a node' do
|
38
|
+
node = create(:node, project: project)
|
39
|
+
service.create_board(name: 'NodeBoard', node_id: node.id)
|
40
|
+
|
41
|
+
expect(project.reload.boards.where(name: 'NodeBoard')).to_not be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# These specs are coming from engines/dradispro-rules/spec/content_service_spec.rb
|
4
|
+
# To run, execute from Dradis main app folder:
|
5
|
+
# bin/rspec [dradis-plugins path]/spec/lib/dradis/plugins/content_service/issues_spec.rb
|
6
|
+
|
7
|
+
describe Dradis::Plugins::ContentService::Base do
|
8
|
+
let(:plugin) { Dradis::Plugins::Nessus }
|
9
|
+
let(:project) { create(:project) }
|
10
|
+
let(:service) do
|
11
|
+
Dradis::Plugins::ContentService::Base.new(
|
12
|
+
plugin: plugin,
|
13
|
+
logger: Rails.logger,
|
14
|
+
project: project
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Issues' do
|
19
|
+
let(:create_issue) do
|
20
|
+
service.create_issue_without_callback(id: plugin_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Remember: even though we're calling create_issue_without_callback,
|
24
|
+
# that method will still call issue_cache_with_callback internally.
|
25
|
+
# So when we store an issue in the issue_cache/finding_cache below,
|
26
|
+
# it's being stored within an instance of FindingCache, which
|
27
|
+
# automatically wraps Issues in Findings.
|
28
|
+
|
29
|
+
describe 'when the issue already exists in the cache' do
|
30
|
+
let(:existing_issue) { create(:issue, text: cached_issue_text) }
|
31
|
+
before { cache.store(existing_issue) }
|
32
|
+
|
33
|
+
it "doesn't create a new issue" do
|
34
|
+
expect{create_issue}.not_to change{Issue.count}
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the cached issue encapsulated in a finding' do
|
38
|
+
finding = create_issue
|
39
|
+
expect(finding).to be_a(Finding)
|
40
|
+
expect(finding).to eq Finding.from_issue(existing_issue)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "when the issue doesn't already exist in the cache" do
|
45
|
+
it "creates a new Issue containing 'plugin' and 'plugin_id'" do
|
46
|
+
new_issue = nil
|
47
|
+
expect{new_issue = create_issue}.to change{Issue.count}.by(1)
|
48
|
+
expect(new_issue.body).to match(/#\[plugin\]#\n*#{plugin_name}/)
|
49
|
+
expect(new_issue.body).to match(/#\[plugin_id\]#\n*#{plugin_id}/)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns the new Issue encapsulated in a Finding' do
|
53
|
+
finding = create_issue
|
54
|
+
expect(finding).to be_a(Finding)
|
55
|
+
expect(finding).to eq Finding.from_issue(Issue.last)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'adds the new Finding to the cache' do
|
59
|
+
finding = create_issue
|
60
|
+
expect(cache[cache_key]).to eq finding
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# This spec must be ran from Dradis root dir
|
3
|
+
#
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
class TestEngine < ::Rails::Engine
|
7
|
+
include ::Dradis::Plugins::Base
|
8
|
+
addon_settings :test_engine do
|
9
|
+
settings.default_host = 'localhost'
|
10
|
+
settings.default_port = 80
|
11
|
+
settings.default_protocol = 'http'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Dradis::Plugins::Settings do
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
TestEngine::settings.reset_defaults!
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets and return default values" do
|
22
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
23
|
+
expect(TestEngine::settings.port).to eq(80)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets and returns user defined values" do
|
27
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
28
|
+
TestEngine::settings.host = '127.0.0.1'
|
29
|
+
expect(TestEngine::settings.host).to eq('127.0.0.1')
|
30
|
+
expect(TestEngine::settings.port).to eq(80)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets and returns new value even if it equals default value" do
|
34
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
35
|
+
TestEngine::settings.host = '127.0.0.1'
|
36
|
+
expect(TestEngine::settings.host).to eq('127.0.0.1')
|
37
|
+
TestEngine::settings.host = 'localhost'
|
38
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "saves to db and returns persisted values" do
|
42
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
43
|
+
TestEngine::settings.host = '127.0.0.1'
|
44
|
+
expect_any_instance_of(TestEngine::settings::send(:configuration_class)).to receive(:update_attribute)
|
45
|
+
expect(TestEngine::settings.save).to eq( { host: '127.0.0.1'} )
|
46
|
+
expect(TestEngine::settings.host).to eq('127.0.0.1')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "reads from db after saving" do
|
50
|
+
expect(TestEngine::settings.host).to eq('localhost')
|
51
|
+
TestEngine::settings.host = '127.0.0.1'
|
52
|
+
expect(TestEngine::settings.save).to eq( { host: '127.0.0.1'} )
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe Dradis::Plugins::Settings, '#is_default?' do
|
58
|
+
it 'knows if a string value equals its default integer value' do
|
59
|
+
TestEngine::settings.is_default?(:port, '80')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe Dradis::Plugins::Settings, '#all' do
|
64
|
+
it 'returns values from db, dirty state or default as needed and tells which one is default' do
|
65
|
+
TestEngine::settings.host = '127.0.0.1'
|
66
|
+
TestEngine::settings.save
|
67
|
+
TestEngine::settings.protocol = 'https'
|
68
|
+
expect(TestEngine::settings.all).to eq([
|
69
|
+
{
|
70
|
+
name: :host,
|
71
|
+
value: '127.0.0.1',
|
72
|
+
default: false
|
73
|
+
},
|
74
|
+
{
|
75
|
+
name: :port,
|
76
|
+
value: 80,
|
77
|
+
default: true
|
78
|
+
},
|
79
|
+
{
|
80
|
+
name: :protocol,
|
81
|
+
value: 'https',
|
82
|
+
default: false
|
83
|
+
},
|
84
|
+
])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dradis-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.18.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Martin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Required dependency for Dradis Framework.
|
56
|
+
email:
|
57
|
+
- etd@nomejortu.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- CHANGELOG.md
|
65
|
+
- CONTRIBUTING.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- app/controllers/concerns/dradis/plugins/persistent_permissions.rb
|
71
|
+
- app/controllers/dradis/plugins/export/base_controller.rb
|
72
|
+
- dradis-plugins.gemspec
|
73
|
+
- lib/dradis-plugins.rb
|
74
|
+
- lib/dradis/plugins.rb
|
75
|
+
- lib/dradis/plugins/base.rb
|
76
|
+
- lib/dradis/plugins/configurable.rb
|
77
|
+
- lib/dradis/plugins/content_service/base.rb
|
78
|
+
- lib/dradis/plugins/content_service/boards.rb
|
79
|
+
- lib/dradis/plugins/content_service/categories.rb
|
80
|
+
- lib/dradis/plugins/content_service/content_blocks.rb
|
81
|
+
- lib/dradis/plugins/content_service/core.rb
|
82
|
+
- lib/dradis/plugins/content_service/evidence.rb
|
83
|
+
- lib/dradis/plugins/content_service/issues.rb
|
84
|
+
- lib/dradis/plugins/content_service/nodes.rb
|
85
|
+
- lib/dradis/plugins/content_service/notes.rb
|
86
|
+
- lib/dradis/plugins/content_service/properties.rb
|
87
|
+
- lib/dradis/plugins/engine.rb
|
88
|
+
- lib/dradis/plugins/export.rb
|
89
|
+
- lib/dradis/plugins/export/base.rb
|
90
|
+
- lib/dradis/plugins/gem_version.rb
|
91
|
+
- lib/dradis/plugins/import.rb
|
92
|
+
- lib/dradis/plugins/import/filters.rb
|
93
|
+
- lib/dradis/plugins/import/filters/base.rb
|
94
|
+
- lib/dradis/plugins/import/result.rb
|
95
|
+
- lib/dradis/plugins/settings.rb
|
96
|
+
- lib/dradis/plugins/template_service.rb
|
97
|
+
- lib/dradis/plugins/templates.rb
|
98
|
+
- lib/dradis/plugins/thor.rb
|
99
|
+
- lib/dradis/plugins/thor_helper.rb
|
100
|
+
- lib/dradis/plugins/upload.rb
|
101
|
+
- lib/dradis/plugins/upload/base.rb
|
102
|
+
- lib/dradis/plugins/upload/field_processor.rb
|
103
|
+
- lib/dradis/plugins/upload/importer.rb
|
104
|
+
- lib/dradis/plugins/version.rb
|
105
|
+
- spec/internal/log/test.log
|
106
|
+
- spec/lib/dradis/plugins/content_service/boards_spec.rb
|
107
|
+
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|
108
|
+
- spec/settings_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
homepage: http://dradisframework.org
|
111
|
+
licenses:
|
112
|
+
- GPL-2
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubygems_version: 3.1.2
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Plugin manager for the Dradis Framework project.
|
133
|
+
test_files:
|
134
|
+
- spec/internal/log/test.log
|
135
|
+
- spec/lib/dradis/plugins/content_service/boards_spec.rb
|
136
|
+
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|
137
|
+
- spec/settings_spec.rb
|
138
|
+
- spec/spec_helper.rb
|