michaelmc1618 commited on
Commit
347f661
·
verified ·
1 Parent(s): 0713ea2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -19
app.py CHANGED
@@ -15,8 +15,19 @@ def prompt_based_analysis(question, context):
15
  except Exception as e:
16
  return f"Error analyzing data: {str(e)}"
17
 
18
- # Function to analyze audit data for GDPR compliance using prompts
19
  def analyze_gdpr_compliance(audit_data):
 
 
 
 
 
 
 
 
 
 
 
20
  system_info_context = f"OS Version: {audit_data.get('os_version', 'Unknown')}, Architecture: {audit_data.get('architecture', 'Unknown')}, Memory: {audit_data.get('memory', 'Unknown')}"
21
  disk_usage_context = f"Disk Usage: {audit_data.get('disk_usage', {}).get('usage_percent', 'Unknown')}%"
22
  network_info_context = f"Interfaces: {', '.join(audit_data.get('network_info', {}).get('interfaces', []))}"
@@ -24,14 +35,26 @@ def analyze_gdpr_compliance(audit_data):
24
  processes_context = f"Running Processes: {', '.join(audit_data.get('running_processes', []))}"
25
  software_inventory_context = f"Software Installed: {', '.join(audit_data.get('software_inventory', []))}"
26
 
27
- # Prompts for each section
28
- system_info_analysis = prompt_based_analysis("Evaluate the system information for GDPR compliance. Highlight any potential risks related to OS version, architecture, and memory.", system_info_context)
29
- disk_usage_analysis = prompt_based_analysis("Evaluate the disk usage in terms of GDPR compliance. Discuss data storage practices, retention policies, and any storage-related risks.", disk_usage_context)
30
- network_info_analysis = prompt_based_analysis("Evaluate the network interfaces in terms of GDPR compliance. Focus on potential risks related to network security and data transmission.", network_info_context)
31
- security_measures_analysis = prompt_based_analysis("Assess the security measures for GDPR compliance, particularly encryption and data anonymization. Identify any weaknesses or gaps in data protection.", security_measures_context)
32
- processes_analysis = prompt_based_analysis("Analyze the running processes for GDPR compliance. Identify potential vulnerabilities and risks related to the execution of unauthorized processes.", processes_context)
33
- software_inventory_analysis = prompt_based_analysis("Evaluate the installed software for GDPR compliance. Highlight any outdated or vulnerable software that could pose risks.", software_inventory_context)
34
-
 
 
 
 
 
 
 
 
 
 
 
 
35
  # Findings organized by section
36
  findings = {
37
  "system_info": system_info_analysis,
@@ -42,26 +65,26 @@ def analyze_gdpr_compliance(audit_data):
42
  "software_inventory": software_inventory_analysis,
43
  }
44
 
45
- # Recommendations based on the findings
46
  recommendations = []
47
  if "Unknown" in system_info_context:
48
- recommendations.append("Review System Information: Ensure that the OS, architecture, and memory configurations are well documented and up to date.")
49
 
50
  if 'not encrypted' in security_measures_analysis.lower() or 'no encryption' in security_measures_analysis.lower():
51
- recommendations.append("Implement Encryption: Ensure that both stored and transmitted data are encrypted.")
52
 
53
  if 'not anonymized' in security_measures_analysis.lower():
54
- recommendations.append("Implement Data Anonymization: Ensure that sensitive data is anonymized during storage.")
55
 
56
  if 'outdated' in software_inventory_analysis.lower() or 'vulnerable' in software_inventory_analysis.lower():
57
- recommendations.append("Update Software: Ensure that all installed software is up to date and free from known vulnerabilities.")
58
-
59
  if 'vulnerable processes' in processes_analysis.lower() or 'unauthorized processes' in processes_analysis.lower():
60
- recommendations.append("Review Running Processes: Regularly audit running processes and ensure that no unauthorized or vulnerable processes are running.")
61
 
62
  return findings, recommendations
63
 
64
- # Generate GDPR Compliance Report with advanced prompts for each section
65
  def generate_gdpr_report(audit_data, company_name="Company Name", system_name="System Name"):
66
  findings, recommendations = analyze_gdpr_compliance(audit_data)
67
 
@@ -76,7 +99,7 @@ def generate_gdpr_report(audit_data, company_name="Company Name", system_name="S
76
  Executive Summary:
77
  This report evaluates the compliance of {company_name} with the General Data Protection Regulation (GDPR).
78
  Based on the system audit and analysis of data handling processes, this report provides findings, identifies compliance gaps,
79
- and suggests recommendations to enhance GDPR adherence.
80
 
81
  Key Findings:
82
 
@@ -142,7 +165,7 @@ def analyze_csv_file(file_obj):
142
  # Gradio Interface
143
  with gr.Blocks() as demo:
144
  with gr.Column():
145
- gr.Markdown("# GDPR and PCI Compliance Evaluation\n### Upload Audit Data in CSV Format")
146
  csv_file = gr.File(label="Upload CSV file")
147
 
148
  gdpr_compliance = gr.Textbox(lines=10, placeholder="GDPR Compliance Analysis...", label="GDPR Compliance Analysis")
 
15
  except Exception as e:
16
  return f"Error analyzing data: {str(e)}"
17
 
18
+ # Function to analyze audit data for GDPR compliance using the GDPR framework
19
  def analyze_gdpr_compliance(audit_data):
20
+ # GDPR Principles
21
+ principles = {
22
+ "Lawfulness, Fairness, and Transparency": "Ensure that data processing is done lawfully, fairly, and in a transparent manner.",
23
+ "Purpose Limitation": "Ensure that data collected is for specified, explicit, and legitimate purposes.",
24
+ "Data Minimization": "Ensure that data collected is adequate, relevant, and limited to what is necessary.",
25
+ "Accuracy": "Ensure that personal data is accurate and up to date.",
26
+ "Storage Limitation": "Ensure that personal data is kept no longer than necessary.",
27
+ "Integrity and Confidentiality": "Ensure that personal data is processed securely to prevent unauthorized access, loss, or destruction."
28
+ }
29
+
30
+ # Prompt context from audit data
31
  system_info_context = f"OS Version: {audit_data.get('os_version', 'Unknown')}, Architecture: {audit_data.get('architecture', 'Unknown')}, Memory: {audit_data.get('memory', 'Unknown')}"
32
  disk_usage_context = f"Disk Usage: {audit_data.get('disk_usage', {}).get('usage_percent', 'Unknown')}%"
33
  network_info_context = f"Interfaces: {', '.join(audit_data.get('network_info', {}).get('interfaces', []))}"
 
35
  processes_context = f"Running Processes: {', '.join(audit_data.get('running_processes', []))}"
36
  software_inventory_context = f"Software Installed: {', '.join(audit_data.get('software_inventory', []))}"
37
 
38
+ # Prompts for GDPR principles applied to sections
39
+ system_info_analysis = prompt_based_analysis(
40
+ f"Evaluate the system information in terms of GDPR compliance focusing on {principles['Lawfulness, Fairness, and Transparency']} and {principles['Purpose Limitation']}.", system_info_context
41
+ )
42
+ disk_usage_analysis = prompt_based_analysis(
43
+ f"Evaluate the disk usage under the {principles['Storage Limitation']} principle and ensure compliance.", disk_usage_context
44
+ )
45
+ network_info_analysis = prompt_based_analysis(
46
+ f"Evaluate the network interfaces with respect to {principles['Integrity and Confidentiality']}, identifying any potential security risks.", network_info_context
47
+ )
48
+ security_measures_analysis = prompt_based_analysis(
49
+ f"Analyze the encryption and anonymization methods under the {principles['Integrity and Confidentiality']} principle, identifying any weaknesses.", security_measures_context
50
+ )
51
+ processes_analysis = prompt_based_analysis(
52
+ f"Evaluate the running processes for GDPR compliance under {principles['Lawfulness, Fairness, and Transparency']}, focusing on unauthorized or risky processes.", processes_context
53
+ )
54
+ software_inventory_analysis = prompt_based_analysis(
55
+ f"Assess the installed software for GDPR compliance focusing on {principles['Accuracy']} and {principles['Integrity and Confidentiality']}.", software_inventory_context
56
+ )
57
+
58
  # Findings organized by section
59
  findings = {
60
  "system_info": system_info_analysis,
 
65
  "software_inventory": software_inventory_analysis,
66
  }
67
 
68
+ # Detailed Recommendations based on the findings
69
  recommendations = []
70
  if "Unknown" in system_info_context:
71
+ recommendations.append("Review System Information: Ensure that the OS, architecture, and memory configurations are well documented and up to date in accordance with GDPR transparency requirements.")
72
 
73
  if 'not encrypted' in security_measures_analysis.lower() or 'no encryption' in security_measures_analysis.lower():
74
+ recommendations.append("Implement Encryption: Ensure that both stored and transmitted data are encrypted to meet GDPR security requirements.")
75
 
76
  if 'not anonymized' in security_measures_analysis.lower():
77
+ recommendations.append("Implement Data Anonymization: Ensure that sensitive data is anonymized during storage to comply with GDPR's confidentiality principle.")
78
 
79
  if 'outdated' in software_inventory_analysis.lower() or 'vulnerable' in software_inventory_analysis.lower():
80
+ recommendations.append("Update Software: Ensure that all installed software is up to date and free from known vulnerabilities to maintain the integrity and confidentiality of personal data.")
81
+
82
  if 'vulnerable processes' in processes_analysis.lower() or 'unauthorized processes' in processes_analysis.lower():
83
+ recommendations.append("Review Running Processes: Regularly audit running processes and ensure that no unauthorized or risky processes are running to maintain GDPR compliance.")
84
 
85
  return findings, recommendations
86
 
87
+ # Generate GDPR Compliance Report with advanced prompts for each section using the GDPR framework
88
  def generate_gdpr_report(audit_data, company_name="Company Name", system_name="System Name"):
89
  findings, recommendations = analyze_gdpr_compliance(audit_data)
90
 
 
99
  Executive Summary:
100
  This report evaluates the compliance of {company_name} with the General Data Protection Regulation (GDPR).
101
  Based on the system audit and analysis of data handling processes, this report provides findings, identifies compliance gaps,
102
+ and suggests recommendations to enhance GDPR adherence based on the key principles of GDPR, such as Lawfulness, Fairness, Transparency, Purpose Limitation, Data Minimization, Accuracy, Storage Limitation, and Integrity & Confidentiality.
103
 
104
  Key Findings:
105
 
 
165
  # Gradio Interface
166
  with gr.Blocks() as demo:
167
  with gr.Column():
168
+ gr.Markdown("# GDPR Compliance Evaluation\n### Upload Audit Data in CSV Format")
169
  csv_file = gr.File(label="Upload CSV file")
170
 
171
  gdpr_compliance = gr.Textbox(lines=10, placeholder="GDPR Compliance Analysis...", label="GDPR Compliance Analysis")