Class: Yara::ScanResult

Inherits:
Object
  • Object
show all
Defined in:
lib/yara/scan_result.rb

Constant Summary collapse

RULE_MATCHING =
1
RULE_NOT_MATCHING =
2
META_FLAGS_LAST_IN_RULE =
1
META_TYPE_INTEGER =
1
META_TYPE_BOOLEAN =

META_TYPE_STRING = 2

3
STRING_FLAGS_LAST_IN_RULE =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callback_type, rule, user_data) ⇒ ScanResult

Returns a new instance of ScanResult.



16
17
18
19
20
21
22
# File 'lib/yara/scan_result.rb', line 16

def initialize(callback_type, rule, user_data)
  @callback_type = callback_type
  @rule = rule
  @rule_meta = extract_rule_meta
  @rule_strings = extract_rule_strings
  @user_data_number = user_data[:number]
end

Instance Attribute Details

#callback_typeObject (readonly)

Returns the value of attribute callback_type.



14
15
16
# File 'lib/yara/scan_result.rb', line 14

def callback_type
  @callback_type
end

#ruleObject (readonly)

Returns the value of attribute rule.



14
15
16
# File 'lib/yara/scan_result.rb', line 14

def rule
  @rule
end

#rule_metaObject (readonly)

Returns the value of attribute rule_meta.



24
25
26
# File 'lib/yara/scan_result.rb', line 24

def rule_meta
  @rule_meta
end

#rule_stringsObject (readonly)

Returns the value of attribute rule_strings.



24
25
26
# File 'lib/yara/scan_result.rb', line 24

def rule_strings
  @rule_strings
end

#user_data_numberObject (readonly)

Returns the value of attribute user_data_number.



24
25
26
# File 'lib/yara/scan_result.rb', line 24

def user_data_number
  @user_data_number
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/yara/scan_result.rb', line 38

def match?
  callback_type == RULE_MATCHING
end

#rule_nameObject



26
27
28
# File 'lib/yara/scan_result.rb', line 26

def rule_name
  @rule[:identifier]
end

#rule_outcome?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/yara/scan_result.rb', line 34

def rule_outcome?
  [RULE_MATCHING, RULE_NOT_MATCHING].include?(callback_type)
end

#scan_complete?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/yara/scan_result.rb', line 30

def scan_complete?
  callback_type == SCAN_FINISHED
end