Class: AiRootShield::Enterprise::PolicyManager

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_root_shield/enterprise/policy_manager.rb

Overview

Enterprise policy manager for industry-specific security profiles

Constant Summary collapse

SUPPORTED_INDUSTRIES =
%w[fintech healthcare government corporate].freeze
POLICY_VERSION =
'1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(industry_type: nil, custom_policy: nil) ⇒ PolicyManager

Returns a new instance of PolicyManager.



15
16
17
18
19
20
21
22
23
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 15

def initialize(industry_type: nil, custom_policy: nil)
  @industry_type = industry_type
  @custom_policy = custom_policy
  @compliance_frameworks = []
  @policy_cache = {}
  @audit_log = []
  
  load_policy if industry_type || custom_policy
end

Instance Attribute Details

#compliance_frameworks ⇒ Object (readonly)

Returns the value of attribute compliance_frameworks.



13
14
15
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 13

def compliance_frameworks
  @compliance_frameworks
end

#current_policy ⇒ Object (readonly)

Returns the value of attribute current_policy.



13
14
15
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 13

def current_policy
  @current_policy
end

#industry_type ⇒ Object (readonly)

Returns the value of attribute industry_type.



13
14
15
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 13

def industry_type
  @industry_type
end

Instance Method Details

#audit_log ⇒ Object

Get audit log



96
97
98
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 96

def audit_log
  @audit_log.dup
end

#evaluate_compliance(analysis_results) ⇒ Object

Evaluate device compliance against loaded policy



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 40

def evaluate_compliance(analysis_results)
  return { compliant: false, reason: "No policy loaded" } unless @current_policy
  
  compliance_result = {
    compliant: true,
    policy_version: @current_policy[:version],
    industry_type: @industry_type,
    evaluation_timestamp: Time.now.utc.iso8601,
    violations: [],
    warnings: [],
    compliance_score: 100,
    framework_compliance: {},
    recommendations: []
  }
  
  # Evaluate security requirements
  evaluate_security_requirements(analysis_results, compliance_result)
  
  # Evaluate compliance frameworks
  evaluate_compliance_frameworks(analysis_results, compliance_result)
  
  # Calculate final compliance score
  calculate_compliance_score(compliance_result)
  
  # Log compliance evaluation
  log_policy_event("Compliance evaluated", {
    compliant: compliance_result[:compliant],
    score: compliance_result[:compliance_score],
    violations: compliance_result[:violations].length
  })
  
  compliance_result
end

#export_policy ⇒ Object

Export policy for sharing/backup



101
102
103
104
105
106
107
108
109
110
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 101

def export_policy
  return nil unless @current_policy
  
  {
    exported_at: Time.now.utc.iso8601,
    policy: @current_policy,
    industry_type: @industry_type,
    audit_log: @audit_log
  }
end

#get_framework_requirements(framework) ⇒ Object

Get compliance framework requirements



80
81
82
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 80

def get_framework_requirements(framework)
  @current_policy&.dig(:compliance_frameworks, framework.to_sym) || {}
end

#get_requirements(category) ⇒ Object

Get policy requirements for specific category



75
76
77
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 75

def get_requirements(category)
  @current_policy&.dig(:requirements, category.to_sym) || {}
end

#load_policy ⇒ Object

Load industry-specific policy profile



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 26

def load_policy
  if @custom_policy
    @current_policy = load_custom_policy(@custom_policy)
  elsif @industry_type
    @current_policy = load_industry_policy(@industry_type)
  else
    raise ArgumentError, "Either industry_type or custom_policy must be provided"
  end
  
  validate_policy(@current_policy)
  log_policy_event("Policy loaded", { industry: @industry_type, version: @current_policy[:version] })
end

#update_policy_config(config_updates) ⇒ Object

Update policy configuration



85
86
87
88
89
90
91
92
93
# File 'lib/ai_root_shield/enterprise/policy_manager.rb', line 85

def update_policy_config(config_updates)
  return false unless @current_policy
  
  @current_policy[:configuration].merge!(config_updates)
  validate_policy(@current_policy)
  
  log_policy_event("Policy configuration updated", config_updates)
  true
end