Skip to content

Commit 86a85fc

Browse files
Integrate cloud, operational, and information security tools into the Global Security Platform.
- Added `social_media_analyzer/operational_security.py` with AI-driven auditing for cloud, IoT, and logs. - Integrated new security endpoints in Flask backend (`text_message_analyzer/app.py`). - Enhanced `OfficialAssistance` React component with an "Operational Security" role and interactive tools. - Updated `Marketplace` with the new capability description. Co-authored-by: GYFX35 <134739293+GYFX35@users.noreply.github.com>
1 parent 41f6058 commit 86a85fc

File tree

4 files changed

+193
-3
lines changed

4 files changed

+193
-3
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import re
2+
3+
class CloudSecurityAI:
4+
"""AI for auditing cloud configurations and identifying security misconfigurations."""
5+
6+
def audit_config(self, config_text):
7+
findings = []
8+
if "0.0.0.0/0" in config_text and "SSH" in config_text:
9+
findings.append("Open SSH port (22) to the world (0.0.0.0/0).")
10+
if "Allow" in config_text and "All" in config_text and "Inbound" in config_text:
11+
findings.append("Overly permissive inbound security group rule.")
12+
if "s3" in config_text.lower() and "public-read" in config_text.lower():
13+
findings.append("S3 bucket with public read access detected.")
14+
15+
if not findings:
16+
return {"status": "SECURE", "findings": ["No immediate cloud misconfigurations detected."]}
17+
return {"status": "RISK_DETECTED", "findings": findings}
18+
19+
class IoTSecurityAI:
20+
"""AI for analyzing IoT telemetry and detecting tampering or anomalies."""
21+
22+
def analyze_telemetry(self, telemetry_data):
23+
# Expecting telemetry_data to be a dict
24+
findings = []
25+
voltage = telemetry_data.get('voltage')
26+
temp = telemetry_data.get('temperature')
27+
28+
if voltage is not None and voltage < 3.0:
29+
findings.append(f"Low voltage ({voltage}V) - potential battery tampering or exhaustion.")
30+
if temp is not None and temp > 85:
31+
findings.append(f"High temperature ({temp}°C) - possible hardware stress or cooling failure.")
32+
33+
if not findings:
34+
return {"status": "STABLE", "findings": ["IoT telemetry within normal parameters."]}
35+
return {"status": "ANOMALY", "findings": findings}
36+
37+
class OpSecAI:
38+
"""AI for scanning operational logs and detecting security-sensitive patterns."""
39+
40+
def scan_logs(self, log_text):
41+
findings = []
42+
# Basic secret detection (similar to sensitive_data_scanner)
43+
if re.search(r"AKIA[0-9A-Z]{16}", log_text):
44+
findings.append("Potential AWS Access Key ID found in logs.")
45+
if re.search(r"AIza[0-9A-Za-z\-_]{35}", log_text):
46+
findings.append("Potential Google API Key found in logs.")
47+
if "password" in log_text.lower() and ":" in log_text:
48+
findings.append("Possible plaintext password found in log entry.")
49+
50+
if not findings:
51+
return {"status": "CLEAR", "findings": ["No operational security threats found in logs."]}
52+
return {"status": "THREAT_DETECTED", "findings": findings}

src/Marketplace.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const tools = [
4040
{
4141
id: 'assistance',
4242
name: 'Official Assistance',
43-
description: 'Integrated support tools for Police, Military, Gendarmerie, and Mobile Operators.',
43+
description: 'Integrated support tools for Police, Military, Gendarmerie, Mobile Operators, and Operational Security.',
4444
icon: '🛡️'
4545
}
4646
];

src/OfficialAssistance.jsx

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,66 @@ const assistanceRoles = {
4040
{ id: 'anti_stealing', name: 'Anti-Stealing Guard', icon: '🔒', desc: 'Detect and prevent bandwidth or data theft from mobile networks.' },
4141
{ id: 'signal_integrity', name: 'Signal Integrity', icon: '📶', desc: 'Monitor network signal strength and detect interference or spoofing.' }
4242
]
43+
},
44+
operational_security: {
45+
title: 'Operational Security',
46+
icon: '🕵️',
47+
description: 'AI-driven security auditing for cloud, IoT, and operational logs.',
48+
tools: [
49+
{ id: 'cloud_audit', name: 'Cloud Security Audit', icon: '☁️', desc: 'Scan cloud configurations for misconfigurations and exposure.' },
50+
{ id: 'iot_telemetry', name: 'IoT Telemetry Analysis', icon: '📡', desc: 'Real-time analysis of IoT device telemetry for anomalies.' },
51+
{ id: 'opsec_scanner', name: 'OpSec Log Scanner', icon: '📜', desc: 'Audit operational logs for sensitive data leaks and security threats.' }
52+
]
4353
}
4454
};
4555

4656
export default function OfficialAssistance() {
4757
const [activeRole, setActiveRole] = useState('police');
58+
const [result, setResult] = useState(null);
59+
const [loading, setLoading] = useState(false);
60+
61+
const handleLaunch = async (tool) => {
62+
let endpoint = '';
63+
let payload = {};
64+
65+
if (tool.id === 'cloud_audit') {
66+
endpoint = '/analyze/cloud';
67+
const config = prompt("Enter cloud configuration to audit:");
68+
if (!config) return;
69+
payload = { config };
70+
} else if (tool.id === 'iot_telemetry') {
71+
endpoint = '/analyze/iot';
72+
const voltage = prompt("Enter IoT voltage (V):", "3.3");
73+
const temperature = prompt("Enter IoT temperature (°C):", "25");
74+
if (voltage === null || temperature === null) return;
75+
payload = { voltage: parseFloat(voltage), temperature: parseFloat(temperature) };
76+
} else if (tool.id === 'opsec_scanner') {
77+
endpoint = '/analyze/opsec';
78+
const logs = prompt("Enter operational logs to scan:");
79+
if (!logs) return;
80+
payload = { logs };
81+
} else {
82+
alert(`Launching ${tool.name}... (Simulated)`);
83+
return;
84+
}
85+
86+
setLoading(true);
87+
setResult(null);
88+
try {
89+
const response = await fetch(endpoint, {
90+
method: 'POST',
91+
headers: { 'Content-Type': 'application/json' },
92+
body: JSON.stringify(payload)
93+
});
94+
const data = await response.json();
95+
setResult({ tool: tool.name, data });
96+
} catch (error) {
97+
console.error("Error launching tool:", error);
98+
alert("Failed to connect to the analysis backend.");
99+
} finally {
100+
setLoading(false);
101+
}
102+
};
48103

49104
return (
50105
<div className="assistance-container">
@@ -65,6 +120,23 @@ export default function OfficialAssistance() {
65120
<h2>{assistanceRoles[activeRole].title}</h2>
66121
<p className="role-description">{assistanceRoles[activeRole].description}</p>
67122

123+
{loading && <div className="loading-overlay">Analyzing...</div>}
124+
125+
{result && (
126+
<div className="analysis-result-box">
127+
<h3>{result.tool} Results</h3>
128+
<div className={`status-badge ${result.data.status}`}>
129+
Status: {result.data.status}
130+
</div>
131+
<ul>
132+
{result.data.findings.map((finding, idx) => (
133+
<li key={idx}>{finding}</li>
134+
))}
135+
</ul>
136+
<button className="close-btn" onClick={() => setResult(null)}>Close</button>
137+
</div>
138+
)}
139+
68140
<div className="tool-list">
69141
{assistanceRoles[activeRole].tools.map((tool) => (
70142
<div key={tool.id} className="assistance-tool-card">
@@ -73,7 +145,7 @@ export default function OfficialAssistance() {
73145
<h3>{tool.name}</h3>
74146
<p>{tool.desc}</p>
75147
</div>
76-
<button className="action-btn" onClick={() => alert(`Launching ${tool.name}...`)}>Launch</button>
148+
<button className="action-btn" onClick={() => handleLaunch(tool)}>Launch</button>
77149
</div>
78150
))}
79151
</div>
@@ -160,6 +232,37 @@ export default function OfficialAssistance() {
160232
font-weight: bold;
161233
cursor: pointer;
162234
}
235+
.analysis-result-box {
236+
background: #1e2127;
237+
border: 1px solid #61dafb;
238+
padding: 20px;
239+
border-radius: 10px;
240+
margin-bottom: 30px;
241+
}
242+
.status-badge {
243+
display: inline-block;
244+
padding: 5px 10px;
245+
border-radius: 4px;
246+
font-weight: bold;
247+
margin-bottom: 10px;
248+
}
249+
.status-badge.SECURE, .status-badge.STABLE, .status-badge.CLEAR { background: #4caf50; }
250+
.status-badge.RISK_DETECTED, .status-badge.ANOMALY, .status-badge.THREAT_DETECTED { background: #f44336; }
251+
.loading-overlay {
252+
padding: 20px;
253+
text-align: center;
254+
color: #61dafb;
255+
font-weight: bold;
256+
}
257+
.close-btn {
258+
background: #555;
259+
color: white;
260+
border: none;
261+
padding: 5px 15px;
262+
border-radius: 4px;
263+
cursor: pointer;
264+
margin-top: 10px;
265+
}
163266
`}</style>
164267
</div>
165268
);

text_message_analyzer/app.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from flask import Flask, request, jsonify
2-
from social_media_analyzer import scam_detector, fake_news_detector, ai_content_detector, fake_content_verifier
2+
from social_media_analyzer import (
3+
scam_detector,
4+
fake_news_detector,
5+
ai_content_detector,
6+
fake_content_verifier,
7+
operational_security
8+
)
39
import os
410

511
app = Flask(__name__)
@@ -51,6 +57,35 @@ def analyze_fake_content():
5157
result = fake_content_verifier.analyze_text_for_fake_content(text_to_analyze)
5258
return jsonify(result)
5359

60+
@app.route('/analyze/cloud', methods=['POST'])
61+
def analyze_cloud():
62+
data = request.get_json()
63+
if not data or 'config' not in data:
64+
return jsonify({"error": "Missing 'config' in request body"}), 400
65+
66+
audit_ai = operational_security.CloudSecurityAI()
67+
result = audit_ai.audit_config(data['config'])
68+
return jsonify(result)
69+
70+
@app.route('/analyze/iot', methods=['POST'])
71+
def analyze_iot():
72+
data = request.get_json()
73+
if not data:
74+
return jsonify({"error": "Missing data in request body"}), 400
75+
76+
iot_ai = operational_security.IoTSecurityAI()
77+
result = iot_ai.analyze_telemetry(data)
78+
return jsonify(result)
79+
80+
@app.route('/analyze/opsec', methods=['POST'])
81+
def analyze_opsec():
82+
data = request.get_json()
83+
if not data or 'logs' not in data:
84+
return jsonify({"error": "Missing 'logs' in request body"}), 400
85+
86+
opsec_ai = operational_security.OpSecAI()
87+
result = opsec_ai.scan_logs(data['logs'])
88+
return jsonify(result)
5489

5590
if __name__ == '__main__':
5691
app.run(debug=True)

0 commit comments

Comments
 (0)