Fix jwt-token
This commit is contained in:
@@ -178,13 +178,13 @@ class AlertService {
|
|||||||
async shouldTriggerAlert(rule, detection, threatAssessment) {
|
async shouldTriggerAlert(rule, detection, threatAssessment) {
|
||||||
try {
|
try {
|
||||||
// SECURITY ENHANCEMENT: Check threat level requirements
|
// SECURITY ENHANCEMENT: Check threat level requirements
|
||||||
if (rule.conditions.min_threat_level) {
|
if (rule.min_threat_level) {
|
||||||
const threatLevels = { 'monitoring': 0, 'low': 1, 'medium': 2, 'high': 3, 'critical': 4 };
|
const threatLevels = { 'monitoring': 0, 'low': 1, 'medium': 2, 'high': 3, 'critical': 4 };
|
||||||
const requiredLevel = threatLevels[rule.conditions.min_threat_level] || 0;
|
const requiredLevel = threatLevels[rule.min_threat_level] || 0;
|
||||||
const currentLevel = threatLevels[threatAssessment.level] || 0;
|
const currentLevel = threatLevels[threatAssessment.level] || 0;
|
||||||
|
|
||||||
if (currentLevel < requiredLevel) {
|
if (currentLevel < requiredLevel) {
|
||||||
console.log(`Alert rule ${rule.name}: Threat level ${threatAssessment.level} below minimum ${rule.conditions.min_threat_level}`);
|
console.log(`Alert rule ${rule.name}: Threat level ${threatAssessment.level} below minimum ${rule.min_threat_level}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,25 +196,25 @@ class AlertService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check device filter
|
// Check device filter
|
||||||
if (rule.conditions.device_ids && rule.conditions.device_ids.length > 0 &&
|
if (rule.device_ids && rule.device_ids.length > 0 &&
|
||||||
!rule.conditions.device_ids.includes(detection.device_id)) {
|
!rule.device_ids.includes(detection.device_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check drone type filter
|
// Check drone type filter
|
||||||
if (rule.conditions.drone_types && rule.conditions.drone_types.length > 0 &&
|
if (rule.drone_types && rule.drone_types.length > 0 &&
|
||||||
!rule.conditions.drone_types.includes(detection.drone_type)) {
|
!rule.drone_types.includes(detection.drone_type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check RSSI thresholds (enhanced for security)
|
// Check RSSI thresholds (enhanced for security)
|
||||||
if (rule.conditions.rssi_threshold && detection.rssi < rule.conditions.rssi_threshold) {
|
if (rule.min_rssi && detection.rssi < rule.min_rssi) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SECURITY ENHANCEMENT: Check estimated distance
|
// SECURITY ENHANCEMENT: Check estimated distance
|
||||||
if (rule.conditions.max_distance && threatAssessment.estimatedDistance > rule.conditions.max_distance) {
|
if (rule.max_distance && threatAssessment.estimatedDistance > rule.max_distance) {
|
||||||
console.log(`Alert rule ${rule.name}: Distance ${threatAssessment.estimatedDistance}m exceeds maximum ${rule.conditions.max_distance}m`);
|
console.log(`Alert rule ${rule.name}: Distance ${threatAssessment.estimatedDistance}m exceeds maximum ${rule.max_distance}m`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user