Class: TCellAgent::Policies::PatchesPolicy

Inherits:
Policy
  • Object
show all
Defined in:
lib/tcell_agent/policies/patches_policy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(native_agent, enablements) ⇒ PatchesPolicy

Returns a new instance of PatchesPolicy.



12
13
14
15
# File 'lib/tcell_agent/policies/patches_policy.rb', line 12

def initialize(native_agent, enablements)
  @native_agent = native_agent
  @enabled = enablements['patches'] || false
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



10
11
12
# File 'lib/tcell_agent/policies/patches_policy.rb', line 10

def enabled
  @enabled
end

Class Method Details

.api_identifierObject



6
7
8
# File 'lib/tcell_agent/policies/patches_policy.rb', line 6

def self.api_identifier
  'patches'
end

Instance Method Details

#block_request?(appsensor_meta) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tcell_agent/policies/patches_policy.rb', line 17

def block_request?(appsensor_meta)
  return false unless @enabled

  quick_check_response = @native_agent.apply_suspicious_quick_check(appsensor_meta)

  if quick_check_response == 1
    response = @native_agent.apply_patches(appsensor_meta)
    return !response['apply_response'].nil? && response['apply_response']['status'] == 'Blocked'
  end

  quick_check_response == 2
end