dradis-plugins 4.9.0 → 4.10.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 +4 -0
- data/app/controllers/dradis/plugins/export/base_controller.rb +35 -1
- data/dradis-plugins.gemspec +2 -3
- data/lib/dradis/plugins/gem_version.rb +1 -1
- data/lib/dradis/plugins/template_service.rb +5 -7
- data/spec/lib/dradis/plugins/template_service_spec.rb +28 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a58f55546e5cdc567817057c51b984d0b7696168b23d558e14672cc96ee47c47
|
4
|
+
data.tar.gz: 5ec9b6f9447ba38c3683f6b1b043b4b335050e85c65cabf0f7a90d3e9795dbfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10bf1639f13a54120880e99510e148c9c02b98371768209a00ee2e50547d7e2a5a256b76b11f5e8d74671cccdf12770daa12eb740532c9d6149f38f7fa6cdab
|
7
|
+
data.tar.gz: 78ba3a3f1e9ab31bde738e63832de8b3cc34bd1390976d5be45d71d11dd4659f23c5d878c7790231b4819b26e28f16e47142b3ea0a1da23a6c264241a9896547
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,12 @@ module Dradis
|
|
2
2
|
module Plugins
|
3
3
|
module Export
|
4
4
|
class BaseController < Rails.application.config.dradis.base_export_controller_class_name.to_s.constantize
|
5
|
+
include ProjectScoped
|
6
|
+
include UsageTracking if defined?(Dradis::Pro)
|
7
|
+
|
5
8
|
before_action :validate_scope
|
9
|
+
before_action :validate_template
|
10
|
+
after_action :track_export, if: -> { defined?(Dradis::Pro) }
|
6
11
|
|
7
12
|
protected
|
8
13
|
|
@@ -10,11 +15,40 @@ module Dradis
|
|
10
15
|
params.permit(:project_id, :scope, :template)
|
11
16
|
end
|
12
17
|
|
18
|
+
def validate_template
|
19
|
+
@template_file =
|
20
|
+
File.expand_path(File.join(templates_dir, export_params[:template]))
|
21
|
+
|
22
|
+
unless @template_file.starts_with?(templates_dir) && File.exists?(@template_file)
|
23
|
+
raise 'Something fishy is going on...'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
13
27
|
def validate_scope
|
14
|
-
unless Dradis::Plugins::ContentService::Base::VALID_SCOPES.include?(
|
28
|
+
unless Dradis::Plugins::ContentService::Base::VALID_SCOPES.include?(export_params[:scope])
|
15
29
|
raise 'Something fishy is going on...'
|
16
30
|
end
|
17
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def engine_name
|
36
|
+
"#{self.class.to_s.deconstantize}::Engine".constantize.plugin_name.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def templates_dir
|
40
|
+
@templates_dir ||= File.join(::Configuration::paths_templates_reports, engine_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def track_export
|
44
|
+
project = Project.includes(:evidence, :nodes).find(current_project.id)
|
45
|
+
track_usage('report.exported', {
|
46
|
+
exporter: engine_name,
|
47
|
+
issue_count: project.issues.size,
|
48
|
+
evidence_count: project.evidence.size,
|
49
|
+
node_count: project.nodes.in_tree.size
|
50
|
+
})
|
51
|
+
end
|
18
52
|
end
|
19
53
|
end
|
20
54
|
end
|
data/dradis-plugins.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'dradis/plugins/version'
|
|
4
4
|
|
5
5
|
# Describe your gem and declare its dependencies:
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.platform
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
8
8
|
spec.name = 'dradis-plugins'
|
9
9
|
spec.version = Dradis::Plugins::VERSION::STRING
|
10
10
|
spec.summary = 'Plugin manager for the Dradis Framework project.'
|
@@ -13,8 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.license = 'GPL-2'
|
14
14
|
|
15
15
|
spec.authors = ['Daniel Martin']
|
16
|
-
spec.
|
17
|
-
spec.homepage = 'http://dradisframework.org'
|
16
|
+
spec.homepage = 'http://dradis.com'
|
18
17
|
|
19
18
|
spec.files = `git ls-files`.split($\)
|
20
19
|
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -3,21 +3,20 @@ module Dradis
|
|
3
3
|
class TemplateService
|
4
4
|
attr_accessor :logger, :template, :templates_dir
|
5
5
|
|
6
|
-
def initialize(args={})
|
6
|
+
def initialize(args = {})
|
7
7
|
@plugin = args.fetch(:plugin)
|
8
8
|
@templates_dir = args[:templates_dir] || default_templates_dir
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
# For a given entry, return a text blob resulting from applying the
|
13
12
|
# chosen template to the supplied entry.
|
14
|
-
def process_template(args={})
|
13
|
+
def process_template(args = {})
|
15
14
|
self.template = args[:template]
|
16
15
|
data = args[:data]
|
17
16
|
|
18
17
|
processor = @plugin::FieldProcessor.new(data: data)
|
19
18
|
|
20
|
-
template_source.gsub(
|
19
|
+
template_source.gsub(/%(\S*?)%/) do |field|
|
21
20
|
name = field[1..-2]
|
22
21
|
if fields.include?(name)
|
23
22
|
processor.value(field: name)
|
@@ -27,7 +26,6 @@ module Dradis
|
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
29
|
# ---------------------------------------------- Plugin Manager interface
|
32
30
|
|
33
31
|
# This lists the fields defined by this plugin that can be used in the
|
@@ -51,7 +49,7 @@ module Dradis
|
|
51
49
|
|
52
50
|
# Set the plugin's item template. This is used by the Plugins Manager
|
53
51
|
# to force the plugin to use the new_template (provided by the user)
|
54
|
-
def set_template(args={})
|
52
|
+
def set_template(args = {})
|
55
53
|
template = args[:template]
|
56
54
|
content = args[:content]
|
57
55
|
|
@@ -77,7 +75,7 @@ module Dradis
|
|
77
75
|
# refresh cached version if modified since last read
|
78
76
|
if template_mtime > @sources[template][:mtime]
|
79
77
|
@template[template][:mtime] = template_mtime
|
80
|
-
@template[template][:content] = File.read(
|
78
|
+
@template[template][:content] = File.read(template_file)
|
81
79
|
end
|
82
80
|
else
|
83
81
|
@sources[template] = {
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# To run, execute from Dradis main app folder:
|
4
|
+
# bin/rspec [dradis-plugins path]/spec/lib/dradis/plugins/template_service_spec.rb
|
5
|
+
describe Dradis::Plugins::TemplateService do
|
6
|
+
describe '#process_template' do
|
7
|
+
let(:data) { double }
|
8
|
+
let(:plugin) { Dradis::Plugins::Nessus }
|
9
|
+
let(:template_service) do
|
10
|
+
Dradis::Plugins::TemplateService.new(plugin: plugin)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'liquid' do
|
14
|
+
before do
|
15
|
+
allow(data).to receive(:name).and_return('ReportHost')
|
16
|
+
allow(template_service).to receive(:template_source).and_return(
|
17
|
+
"{% if issue.evidence %}\n{% end if %}"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not parse the liquid data as fields' do
|
22
|
+
expect(template_service).to_not receive(:fields)
|
23
|
+
|
24
|
+
template_service.process_template(data: data)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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.10.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: 2023-
|
11
|
+
date: 2023-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,8 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Required dependency for Dradis Framework.
|
56
|
-
email:
|
57
|
-
- etd@nomejortu.com
|
56
|
+
email:
|
58
57
|
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|
@@ -111,9 +110,10 @@ files:
|
|
111
110
|
- spec/lib/dradis/plugins/content_service/content_blocks_spec.rb
|
112
111
|
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|
113
112
|
- spec/lib/dradis/plugins/settings/adapters/encrypted_configuration_spec.rb
|
113
|
+
- spec/lib/dradis/plugins/template_service_spec.rb
|
114
114
|
- spec/settings_spec.rb
|
115
115
|
- spec/spec_helper.rb
|
116
|
-
homepage: http://
|
116
|
+
homepage: http://dradis.com
|
117
117
|
licenses:
|
118
118
|
- GPL-2
|
119
119
|
metadata: {}
|
@@ -143,5 +143,6 @@ test_files:
|
|
143
143
|
- spec/lib/dradis/plugins/content_service/content_blocks_spec.rb
|
144
144
|
- spec/lib/dradis/plugins/content_service/issues_spec.rb
|
145
145
|
- spec/lib/dradis/plugins/settings/adapters/encrypted_configuration_spec.rb
|
146
|
+
- spec/lib/dradis/plugins/template_service_spec.rb
|
146
147
|
- spec/settings_spec.rb
|
147
148
|
- spec/spec_helper.rb
|