7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/phisher_phinder/mail_parser/received_headers/starttls_parser.rb', line 7
def parse(component)
return {starttls: nil} unless component
patterns = [
/\(version=(?<version>\S+)\scipher=(?<cipher>\S+)\sbits=(?<bits>\S+)\)/,
/\(version=(?<version>\S+),\scipher=(?<cipher>\S+)\)/,
/using\s(?<version>\S+)\swith cipher\s(?<cipher>\S+)\s\((?<bits>.+?) bits\)/
]
matches = patterns.inject(nil) do |memo, pattern|
memo || component.match(pattern)
end
{
starttls: {
version: matches[:version],
cipher: matches[:cipher],
bits: matches.names.include?('bits') ? matches[:bits] : nil,
}
}
end
|