Fix jwt-token

This commit is contained in:
2025-08-18 06:30:42 +02:00
parent 5c1d1ae175
commit c03385dc2b
3 changed files with 55 additions and 12 deletions

View File

@@ -125,6 +125,22 @@ async function seedDatabase() {
cooldown_period: 300, // 5 minutes between alerts
min_detections: 1,
time_window: 60 // 1 minute window
},
{
user_id: adminUser.id,
name: 'Orlan Military Drone Detection Alert',
description: 'Emergency alert for any Orlan military drone detection regardless of location',
is_active: true,
device_ids: [], // All devices
drone_types: [1], // Only Orlan drones (type 1)
min_rssi: -100, // Any RSSI level
priority: 'critical',
min_threat_level: null, // No minimum threat level (will trigger on any Orlan)
alert_channels: ['sms'],
sms_phone_number: '0736419592', // Emergency contact
cooldown_period: 60, // Short cooldown for critical threats
min_detections: 1,
time_window: 30 // Short time window for immediate response
}
]);

View File

@@ -59,19 +59,26 @@ class AlertService {
// Adjust threat level based on drone type (if classified)
const droneTypes = {
0: 'Consumer/Hobby',
1: 'Professional/Military',
2: 'Racing/High-speed',
3: 'Unknown/Custom'
1: 'Orlan/Military', // Orlan drones - highest threat
2: 'Professional/Commercial',
3: 'Racing/High-speed',
4: 'Unknown/Custom'
};
// CRITICAL: Orlan drones (type 1) - ALWAYS CRITICAL regardless of distance
if (droneType === 1) {
// Military/Professional drone - escalate threat
threatLevel = 'critical';
description = 'CRITICAL THREAT: ORLAN MILITARY DRONE DETECTED - IMMEDIATE RESPONSE REQUIRED';
actionRequired = true;
console.log(`🚨 ORLAN DRONE DETECTED - Force escalating to CRITICAL threat level (RSSI: ${rssi})`);
} else if (droneType === 2) {
// Professional/Commercial drone - escalate threat
if (threatLevel === 'low') threatLevel = 'medium';
if (threatLevel === 'medium') threatLevel = 'high';
if (threatLevel === 'high') threatLevel = 'critical';
description += ' - PROFESSIONAL/MILITARY DRONE DETECTED';
description += ' - PROFESSIONAL/COMMERCIAL DRONE DETECTED';
actionRequired = true;
} else if (droneType === 2) {
} else if (droneType === 3) {
// Racing/Fast drone - escalate if close
if (rssi >= -55 && threatLevel !== 'critical') {
threatLevel = 'high';
@@ -177,6 +184,12 @@ class AlertService {
async shouldTriggerAlert(rule, detection, threatAssessment) {
try {
// CRITICAL SECURITY: Orlan drones (type 1) ALWAYS trigger alerts regardless of any other conditions
if (detection.drone_type === 1) {
console.log(`🚨 ORLAN DRONE DETECTED - Force triggering alert for rule ${rule.name} (bypassing all filters)`);
return true;
}
// SECURITY ENHANCEMENT: Check threat level requirements
if (rule.min_threat_level) {
const threatLevels = { 'monitoring': 0, 'low': 1, 'medium': 2, 'high': 3, 'critical': 4 };