Class: Memorandom::Plugins::PEM

Inherits:
Memorandom::PluginTemplate show all
Defined in:
lib/memorandom/plugins/pem.rb

Constant Summary collapse

@@description =
"This plugin looks for PEM-encoded data (keys, certificates, crls, etc)"
@@confidence =
0.90

Instance Attribute Summary

Attributes inherited from Memorandom::PluginTemplate

#hits, #scanner

Instance Method Summary collapse

Methods inherited from Memorandom::PluginTemplate

#confidence, confidence, #description, description, #initialize, #report_hit, #reset

Constructor Details

This class inherits a constructor from Memorandom::PluginTemplate

Instance Method Details

#scan(buffer, source_offset) ⇒ Object

Scan takes a buffer and an offset of where this buffer starts in the source



9
10
11
12
13
14
15
16
17
18
# File 'lib/memorandom/plugins/pem.rb', line 9

def scan(buffer, source_offset)
  buffer.scan(
    /-----BEGIN\s*[^\-]+-----+\r?\n[^\-]*-----END\s*[^\-]+-----\r?\n?/m
  ).each do |m|
    # This may hit an earlier identical match, but thats ok
    last_offset = buffer.index(m)
    report_hit(:plugin => self, :type => 'PEM', :data => m, :offset => source_offset + last_offset)
    last_offset += m.length
  end
end