1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
| import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import requests
import json
class DueDiligenceManagement:
def __init__(self):
self.third_parties = {}
self.evaluations = {}
self.risk_categories = {
'critical': {'score': 4, 'description': 'Acceso a sistemas críticos'},
'high': {'score': 3, 'description': 'Acceso a datos sensibles'},
'medium': {'score': 2, 'description': 'Acceso limitado a sistemas'},
'low': {'score': 1, 'description': 'Acceso mínimo o sin acceso'}
}
self.evaluation_criteria = {
'security_policies': {'weight': 0.2, 'max_score': 100},
'technical_controls': {'weight': 0.3, 'max_score': 100},
'incident_response': {'weight': 0.15, 'max_score': 100},
'compliance': {'weight': 0.2, 'max_score': 100},
'business_continuity': {'weight': 0.15, 'max_score': 100}
}
def register_third_party(self, party_id, party_data):
"""Registrar tercero"""
self.third_parties[party_id] = {
'party_id': party_id,
'name': party_data['name'],
'type': party_data['type'],
'industry': party_data.get('industry', 'unknown'),
'risk_level': party_data.get('risk_level', 'medium'),
'services': party_data.get('services', []),
'data_access': party_data.get('data_access', 'none'),
'system_access': party_data.get('system_access', 'none'),
'contact_info': party_data.get('contact_info', {}),
'registration_date': datetime.now(),
'status': 'pending_evaluation'
}
def create_evaluation(self, evaluation_id, party_id, evaluation_config):
"""Crear evaluación de due diligence"""
if party_id not in self.third_parties:
return False
evaluation = {
'evaluation_id': evaluation_id,
'party_id': party_id,
'evaluation_type': evaluation_config['type'],
'scope': evaluation_config['scope'],
'evaluator': evaluation_config['evaluator'],
'start_date': evaluation_config.get('start_date', datetime.now()),
'due_date': evaluation_config.get('due_date'),
'status': 'in_progress',
'scores': {},
'findings': [],
'recommendations': [],
'overall_score': 0,
'risk_assessment': {}
}
self.evaluations[evaluation_id] = evaluation
return True
def conduct_security_assessment(self, evaluation_id, assessment_data):
"""Realizar evaluación de seguridad"""
if evaluation_id not in self.evaluations:
return False
evaluation = self.evaluations[evaluation_id]
party = self.third_parties[evaluation['party_id']]
# Evaluar cada criterio
scores = {}
findings = []
for criterion, config in self.evaluation_criteria.items():
score = self.evaluate_criterion(criterion, assessment_data, party)
scores[criterion] = score
# Generar hallazgos
if score < 70:
findings.append({
'criterion': criterion,
'score': score,
'severity': 'high' if score < 50 else 'medium',
'description': f"Puntuación baja en {criterion}: {score}/100"
})
# Calcular puntuación general
overall_score = sum(scores[criterion] * config['weight']
for criterion, config in self.evaluation_criteria.items())
# Evaluar riesgo
risk_assessment = self.assess_risk(party, scores, findings)
# Actualizar evaluación
evaluation['scores'] = scores
evaluation['findings'] = findings
evaluation['overall_score'] = overall_score
evaluation['risk_assessment'] = risk_assessment
evaluation['status'] = 'completed'
evaluation['completion_date'] = datetime.now()
return True
def evaluate_criterion(self, criterion, assessment_data, party):
"""Evaluar criterio específico"""
if criterion == 'security_policies':
return self.evaluate_security_policies(assessment_data)
elif criterion == 'technical_controls':
return self.evaluate_technical_controls(assessment_data)
elif criterion == 'incident_response':
return self.evaluate_incident_response(assessment_data)
elif criterion == 'compliance':
return self.evaluate_compliance(assessment_data)
elif criterion == 'business_continuity':
return self.evaluate_business_continuity(assessment_data)
else:
return 0
def evaluate_security_policies(self, assessment_data):
"""Evaluar políticas de seguridad"""
score = 0
# Verificar existencia de políticas
if assessment_data.get('has_security_policy'):
score += 20
if assessment_data.get('has_incident_response_policy'):
score += 20
if assessment_data.get('has_data_protection_policy'):
score += 20
if assessment_data.get('has_access_control_policy'):
score += 20
if assessment_data.get('has_business_continuity_plan'):
score += 20
return min(score, 100)
def evaluate_technical_controls(self, assessment_data):
"""Evaluar controles técnicos"""
score = 0
# Verificar controles de red
if assessment_data.get('has_firewall'):
score += 15
if assessment_data.get('has_intrusion_detection'):
score += 15
if assessment_data.get('has_antivirus'):
score += 10
# Verificar controles de acceso
if assessment_data.get('has_mfa'):
score += 15
if assessment_data.get('has_privileged_access_management'):
score += 15
# Verificar monitoreo
if assessment_data.get('has_siem'):
score += 15
if assessment_data.get('has_logging'):
score += 15
return min(score, 100)
def evaluate_incident_response(self, assessment_data):
"""Evaluar respuesta a incidentes"""
score = 0
if assessment_data.get('has_incident_response_team'):
score += 25
if assessment_data.get('has_incident_response_procedures'):
score += 25
if assessment_data.get('has_communication_plan'):
score += 25
if assessment_data.get('has_forensic_capabilities'):
score += 25
return min(score, 100)
def evaluate_compliance(self, assessment_data):
"""Evaluar cumplimiento"""
score = 0
# Verificar certificaciones
certifications = assessment_data.get('certifications', [])
if 'ISO_27001' in certifications:
score += 30
if 'SOC_2' in certifications:
score += 25
if 'PCI_DSS' in certifications:
score += 20
if 'GDPR' in certifications:
score += 25
return min(score, 100)
def evaluate_business_continuity(self, assessment_data):
"""Evaluar continuidad del negocio"""
score = 0
if assessment_data.get('has_business_continuity_plan'):
score += 25
if assessment_data.get('has_disaster_recovery_plan'):
score += 25
if assessment_data.get('has_backup_systems'):
score += 25
if assessment_data.get('has_alternate_sites'):
score += 25
return min(score, 100)
def assess_risk(self, party, scores, findings):
"""Evaluar riesgo del tercero"""
# Calcular riesgo basado en puntuaciones
overall_score = sum(scores.values()) / len(scores)
# Ajustar por nivel de acceso
access_risk = self.risk_categories.get(party['risk_level'], {}).get('score', 2)
# Ajustar por hallazgos críticos
critical_findings = len([f for f in findings if f['severity'] == 'high'])
# Calcular riesgo final
risk_score = (100 - overall_score) * access_risk + (critical_findings * 10)
if risk_score >= 80:
risk_level = 'critical'
elif risk_score >= 60:
risk_level = 'high'
elif risk_score >= 40:
risk_level = 'medium'
else:
risk_level = 'low'
return {
'risk_score': risk_score,
'risk_level': risk_level,
'access_risk': access_risk,
'critical_findings': critical_findings,
'mitigation_required': risk_level in ['critical', 'high']
}
def generate_evaluation_report(self, evaluation_id):
"""Generar reporte de evaluación"""
if evaluation_id not in self.evaluations:
return None
evaluation = self.evaluations[evaluation_id]
party = self.third_parties[evaluation['party_id']]
report = {
'evaluation_id': evaluation_id,
'party_name': party['name'],
'evaluation_date': evaluation['completion_date'],
'overall_score': evaluation['overall_score'],
'risk_assessment': evaluation['risk_assessment'],
'scores_by_criterion': evaluation['scores'],
'findings': evaluation['findings'],
'recommendations': self.generate_recommendations(evaluation),
'approval_status': self.determine_approval_status(evaluation)
}
return report
def generate_recommendations(self, evaluation):
"""Generar recomendaciones basadas en evaluación"""
recommendations = []
# Recomendaciones basadas en puntuaciones bajas
for criterion, score in evaluation['scores'].items():
if score < 70:
recommendations.append({
'type': 'improvement',
'criterion': criterion,
'description': f"Mejorar {criterion} - puntuación actual: {score}/100",
'priority': 'high' if score < 50 else 'medium'
})
# Recomendaciones basadas en riesgo
risk_level = evaluation['risk_assessment']['risk_level']
if risk_level in ['critical', 'high']:
recommendations.append({
'type': 'risk_mitigation',
'description': f"Implementar controles adicionales - riesgo {risk_level}",
'priority': 'critical'
})
# Recomendaciones basadas en hallazgos
critical_findings = [f for f in evaluation['findings'] if f['severity'] == 'high']
if critical_findings:
recommendations.append({
'type': 'immediate_action',
'description': f"Abordar {len(critical_findings)} hallazgos críticos inmediatamente",
'priority': 'critical'
})
return recommendations
def determine_approval_status(self, evaluation):
"""Determinar estado de aprobación"""
overall_score = evaluation['overall_score']
risk_level = evaluation['risk_assessment']['risk_level']
critical_findings = len([f for f in evaluation['findings'] if f['severity'] == 'high'])
if overall_score >= 80 and risk_level in ['low', 'medium'] and critical_findings == 0:
return 'approved'
elif overall_score >= 70 and risk_level in ['low', 'medium', 'high'] and critical_findings <= 2:
return 'approved_with_conditions'
elif overall_score >= 60 and risk_level in ['low', 'medium'] and critical_findings <= 5:
return 'pending_review'
else:
return 'rejected'
# Ejemplo de uso
dd_mgmt = DueDiligenceManagement()
# Registrar tercero
dd_mgmt.register_third_party('TP-001', {
'name': 'Cloud Services Provider',
'type': 'cloud_provider',
'industry': 'technology',
'risk_level': 'high',
'services': ['cloud_infrastructure', 'data_storage'],
'data_access': 'sensitive',
'system_access': 'limited'
})
# Crear evaluación
dd_mgmt.create_evaluation('EVAL-001', 'TP-001', {
'type': 'comprehensive',
'scope': 'full_security_assessment',
'evaluator': 'Security Team',
'due_date': datetime.now() + timedelta(days=30)
})
# Realizar evaluación
assessment_data = {
'has_security_policy': True,
'has_incident_response_policy': True,
'has_data_protection_policy': True,
'has_access_control_policy': True,
'has_business_continuity_plan': False,
'has_firewall': True,
'has_intrusion_detection': True,
'has_antivirus': True,
'has_mfa': True,
'has_privileged_access_management': False,
'has_siem': True,
'has_logging': True,
'has_incident_response_team': True,
'has_incident_response_procedures': True,
'has_communication_plan': True,
'has_forensic_capabilities': False,
'certifications': ['ISO_27001', 'SOC_2'],
'has_business_continuity_plan': False,
'has_disaster_recovery_plan': True,
'has_backup_systems': True,
'has_alternate_sites': False
}
dd_mgmt.conduct_security_assessment('EVAL-001', assessment_data)
# Generar reporte
report = dd_mgmt.generate_evaluation_report('EVAL-001')
print(f"Reporte de evaluación: {report['overall_score']}/100")
print(f"Estado de aprobación: {report['approval_status']}")
|