dradis-plugins 4.5.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/dradis/plugins/base.rb +14 -0
- data/lib/dradis/plugins/gem_version.rb +1 -1
- data/lib/dradis/plugins/settings.rb +2 -2
- data/lib/dradis/plugins.rb +11 -2
- data/spec/engine_spec.rb +34 -0
- data/spec/settings_spec.rb +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a55255c245e1ce6009d032fab79a582b05e760af0942ae7893ee7bb42af99dc
|
4
|
+
data.tar.gz: 350e48e4f5c7021339e0d542d7d9776bafaf44f78e23b3feae5e7f8e8d8e6d4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ee0fb58cc17d416a403dd60b9eeae6c106f16fdc4badeda6816f171f5154da7443b0c0b9d96964bf06d32a1f7b41f94db5e7d5c15f7bf3cb4c6ee0a773b643
|
7
|
+
data.tar.gz: 04af89b9742efb8803f8e8d9c934aea5fa9b38c0fa7dcf16fe0f1d23a270167ef1f2c2e46af93d9e00c47c20618467e07b862b03fb4765e799d45dbcbec8ed8b
|
data/CHANGELOG.md
CHANGED
data/lib/dradis/plugins/base.rb
CHANGED
@@ -39,6 +39,20 @@ module Dradis
|
|
39
39
|
def provides?(feature)
|
40
40
|
@features.include?(feature)
|
41
41
|
end
|
42
|
+
|
43
|
+
def enabled?
|
44
|
+
ActiveRecord::Type::Boolean.new.cast(self.settings.enabled)
|
45
|
+
end
|
46
|
+
|
47
|
+
def enable!
|
48
|
+
self.settings.update_settings(enabled: true)
|
49
|
+
Dradis::Plugins::clear_enabled_list
|
50
|
+
end
|
51
|
+
|
52
|
+
def disable!
|
53
|
+
self.settings.update_settings(enabled: false)
|
54
|
+
Dradis::Plugins::clear_enabled_list
|
55
|
+
end
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
@@ -5,7 +5,7 @@ module Dradis::Plugins
|
|
5
5
|
def initialize(namespace)
|
6
6
|
@namespace = namespace
|
7
7
|
@dirty_options ||= {}
|
8
|
-
@default_options ||=
|
8
|
+
@default_options ||= { enabled: true }.with_indifferent_access
|
9
9
|
end
|
10
10
|
|
11
11
|
def respond_to?(name)
|
@@ -13,7 +13,7 @@ module Dradis::Plugins
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def all
|
16
|
-
@default_options.map do |key, value|
|
16
|
+
@default_options.except(:enabled).map do |key, value|
|
17
17
|
{
|
18
18
|
name: key.to_sym,
|
19
19
|
value: value = dirty_or_db_setting_or_default(key.to_sym),
|
data/lib/dradis/plugins.rb
CHANGED
@@ -11,10 +11,19 @@ module Dradis
|
|
11
11
|
@@extensions
|
12
12
|
end
|
13
13
|
|
14
|
+
# Returns an array of modules representing currently enabled engines
|
15
|
+
def enabled_list
|
16
|
+
@@enabled_list ||= @@extensions.select(&:enabled?)
|
17
|
+
end
|
18
|
+
|
19
|
+
def clear_enabled_list
|
20
|
+
@@enabled_list = nil
|
21
|
+
end
|
22
|
+
|
14
23
|
# Filters the list of plugins and only returns those that provide the
|
15
|
-
# requested feature
|
24
|
+
# requested feature and enabled
|
16
25
|
def with_feature(feature)
|
17
|
-
|
26
|
+
enabled_list.select do |plugin|
|
18
27
|
# engine = "#{plugin}::Engine".constantize
|
19
28
|
plugin.provides?(feature)
|
20
29
|
end
|
data/spec/engine_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
class TestEngine < ::Rails::Engine
|
4
|
+
include ::Dradis::Plugins::Base
|
5
|
+
addon_settings :test_engine do
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Dradis::Plugins::Base do
|
10
|
+
before(:each) do
|
11
|
+
TestEngine::settings.reset_defaults!
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#enabled?' do
|
15
|
+
it 'returns default value' do
|
16
|
+
expect(TestEngine.enabled?).to eq(false)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#enable!' do
|
20
|
+
it 'sets enabled to true' do
|
21
|
+
expect { TestEngine.enable! }.to change {
|
22
|
+
TestEngine.enabled?
|
23
|
+
}.from(false).to(true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '#disable!' do
|
27
|
+
it 'sets enabled to false' do
|
28
|
+
TestEngine.enable!
|
29
|
+
expect { TestEngine.disable! }.to change {
|
30
|
+
TestEngine.enabled?
|
31
|
+
}.from(true).to(false)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/settings_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# This spec must be ran from Dradis root dir
|
3
3
|
#
|
4
|
-
require '
|
4
|
+
require 'rails_helper'
|
5
5
|
|
6
6
|
class TestEngine < ::Rails::Engine
|
7
7
|
include ::Dradis::Plugins::Base
|
@@ -19,6 +19,7 @@ describe Dradis::Plugins::Settings do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "sets and return default values" do
|
22
|
+
expect(TestEngine::settings.enabled).to eq(false)
|
22
23
|
expect(TestEngine::settings.host).to eq('localhost')
|
23
24
|
expect(TestEngine::settings.port).to eq(80)
|
24
25
|
end
|
@@ -41,7 +42,6 @@ describe Dradis::Plugins::Settings do
|
|
41
42
|
it "saves to db and returns persisted values" do
|
42
43
|
expect(TestEngine::settings.host).to eq('localhost')
|
43
44
|
TestEngine::settings.host = '127.0.0.1'
|
44
|
-
expect_any_instance_of(TestEngine::settings::send(:configuration_class)).to receive(:update_attribute)
|
45
45
|
expect(TestEngine::settings.save).to eq( { host: '127.0.0.1'} )
|
46
46
|
expect(TestEngine::settings.host).to eq('127.0.0.1')
|
47
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dradis-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.7.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:
|
11
|
+
date: 2023-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/dradis/plugins/upload/field_processor.rb
|
104
104
|
- lib/dradis/plugins/upload/importer.rb
|
105
105
|
- lib/dradis/plugins/version.rb
|
106
|
+
- spec/engine_spec.rb
|
106
107
|
- spec/internal/log/test.log
|
107
108
|
- spec/lib/dradis/plugins/content_service/boards_spec.rb
|
108
109
|
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|
@@ -127,11 +128,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
- !ruby/object:Gem::Version
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.1.4
|
131
132
|
signing_key:
|
132
133
|
specification_version: 4
|
133
134
|
summary: Plugin manager for the Dradis Framework project.
|
134
135
|
test_files:
|
136
|
+
- spec/engine_spec.rb
|
135
137
|
- spec/internal/log/test.log
|
136
138
|
- spec/lib/dradis/plugins/content_service/boards_spec.rb
|
137
139
|
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|