Class: ModsecurityAuditLogParser::NativeParser
- Inherits:
-
Object
- Object
- ModsecurityAuditLogParser::NativeParser
- Defined in:
- lib/modsecurity_audit_log_parser.rb
Defined Under Namespace
Classes: AuditLogFooterPart, AuditLogHeaderPart, AuditLogTrailerPart, ContentPart, Log, MatchedRulesInformationPart, MultipartFilesInformationPart, OriginalResponseBodyPart, Part, ReducedMultipartRequestBodyPart, RequestBodyPart, RequestHeadersPart, ResponseHeadersPart
Constant Summary collapse
- EMPTY_AUDIT_LOG_HEADER =
AuditLogHeaderPart.new
- EMPTY_AUDIT_LOG_TRAILER =
AuditLogTrailerPart.new
Instance Method Summary collapse
-
#initialize(targets) ⇒ NativeParser
constructor
A new instance of NativeParser.
- #parse(str) ⇒ Object
Constructor Details
#initialize(targets) ⇒ NativeParser
Returns a new instance of NativeParser.
270 271 272 273 |
# File 'lib/modsecurity_audit_log_parser.rb', line 270 def initialize(targets) @log = @part = nil @targets = targets.split('') end |
Instance Method Details
#parse(str) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/modsecurity_audit_log_parser.rb', line 275 def parse(str) str.each_line do |line| if /\A--([0-9a-z]+)-(.)--/ =~ line id, type = $1, $2 if @log.nil? or @log.id != id @log = Log.new(id) end yield @log if type == 'Z' unless @targets.include?(type) @part = nil next end @part = Part.new_subclass(type) @log.add(@part) else @part.add(line) if @part end end end |