Class: Dradis::Plugins::MappingService
- Inherits:
-
Object
- Object
- Dradis::Plugins::MappingService
- Defined in:
- lib/dradis/plugins/mapping_service.rb
Instance Attribute Summary collapse
-
#component ⇒ Object
Returns the value of attribute component.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#integration ⇒ Object
Returns the value of attribute integration.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #apply_mapping(data:, source:, mapping_fields: nil) ⇒ Object
-
#initialize(destination: nil, integration:) ⇒ MappingService
constructor
A new instance of MappingService.
-
#sample ⇒ Object
This returns a sample of valid entry for the Mappings Manager.
Constructor Details
#initialize(destination: nil, integration:) ⇒ MappingService
Returns a new instance of MappingService.
6 7 8 9 10 11 |
# File 'lib/dradis/plugins/mapping_service.rb', line 6 def initialize(destination: nil, integration:) @destination = destination @integration = integration @component = @integration.[:name].to_s @sample_dir = default_sample_dir end |
Instance Attribute Details
#component ⇒ Object
Returns the value of attribute component.
4 5 6 |
# File 'lib/dradis/plugins/mapping_service.rb', line 4 def component @component end |
#destination ⇒ Object
Returns the value of attribute destination.
4 5 6 |
# File 'lib/dradis/plugins/mapping_service.rb', line 4 def destination @destination end |
#integration ⇒ Object
Returns the value of attribute integration.
4 5 6 |
# File 'lib/dradis/plugins/mapping_service.rb', line 4 def integration @integration end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/dradis/plugins/mapping_service.rb', line 4 def source @source end |
Instance Method Details
#apply_mapping(data:, source:, mapping_fields: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dradis/plugins/mapping_service.rb', line 13 def apply_mapping(data:, source:, mapping_fields: nil) @source = source return unless valid_source? field_processor = integration::FieldProcessor.new(data: data) mapping_fields = mapping_fields || get_mapping_fields mapping_fields.map do |field| field_name = field.destination_field field_content = process_content( field.content, field_processor ) "#[#{field_name}]#\n#{field_content}" end&.join("\n\n") end |
#sample ⇒ Object
This returns a sample of valid entry for the Mappings Manager
32 33 34 35 36 37 38 39 40 |
# File 'lib/dradis/plugins/mapping_service.rb', line 32 def sample @sample ||= {} if valid_source? @sample[source] ||= begin sample_file = File.join(@sample_dir, "#{source}.sample") File.read(sample_file) end end end |