making the select rules option work for pipelines
This commit is contained in:
committed by
satti-hari-krishna-reddy
parent
a3841e0602
commit
6ec9433564
@@ -5199,7 +5199,11 @@ func initHandlers() {
|
|||||||
r.HandleFunc("/api/v1/files/detection/sigma_rules", shuffle.HandleGetSigmaRules).Methods("GET", "OPTIONS")
|
r.HandleFunc("/api/v1/files/detection/sigma_rules", shuffle.HandleGetSigmaRules).Methods("GET", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/files/detection/{fileId}/{action}", shuffle.HandleToggleRule).Methods("PUT", "OPTIONS")
|
r.HandleFunc("/api/v1/files/detection/{fileId}/{action}", shuffle.HandleToggleRule).Methods("PUT", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/files/detection/{action}", shuffle.HandleFolderToggle).Methods("PUT", "OPTIONS")
|
r.HandleFunc("/api/v1/files/detection/{action}", shuffle.HandleFolderToggle).Methods("PUT", "OPTIONS")
|
||||||
|
|
||||||
r.HandleFunc("/api/v1/detection/siem/node_health", handleTenzirHealthUpdate).Methods("POST","OPTIONS")
|
r.HandleFunc("/api/v1/detection/siem/node_health", handleTenzirHealthUpdate).Methods("POST","OPTIONS")
|
||||||
|
r.HandleFunc("/api/v1/detection/{triggerId}/selected_rules", shuffle.HandleGetSelectedRules).Methods("GET","OPTIONS")
|
||||||
|
r.HandleFunc("/api/v1/detection/{triggerId}/selected_rules/save", shuffle.HandleSaveSelectedRules).Methods("POST","OPTIONS")
|
||||||
|
|
||||||
|
|
||||||
// Introduced in 0.9.21 to handle notifications for e.g. failed Workflow
|
// Introduced in 0.9.21 to handle notifications for e.g. failed Workflow
|
||||||
r.HandleFunc("/api/v1/notifications", shuffle.HandleCreateNotification).Methods("POST", "OPTIONS")
|
r.HandleFunc("/api/v1/notifications", shuffle.HandleCreateNotification).Methods("POST", "OPTIONS")
|
||||||
|
|||||||
@@ -21194,9 +21194,37 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const TenzirConfigModal = () => {
|
const TenzirConfigModal = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [selectedRules, setSelectedRules] = useState([]);
|
const [selectedRules, setSelectedRules] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (tenzirConfigModalOpen) {
|
||||||
|
try {
|
||||||
|
const url = globalUrl + "/api/v1/detection/" + selectedTrigger.id + "/selected_rules"
|
||||||
|
fetch(url, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: "include",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const savedRules = data.selected_rules.map(rule => rule.file_id);
|
||||||
|
setSelectedRules(savedRules);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching selected rules:', error);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [tenzirConfigModalOpen]);
|
||||||
|
|
||||||
const handleRuleChange = (event) => {
|
const handleRuleChange = (event) => {
|
||||||
setSelectedRules(event.target.value);
|
setSelectedRules(event.target.value);
|
||||||
};
|
};
|
||||||
@@ -21211,31 +21239,43 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const selectedRuleFiles = rules
|
const selectedRuleFiles = rules.filter(rule => selectedRules.includes(rule.file_id));
|
||||||
.filter(rule => selectedRules.includes(rule.file_id));
|
|
||||||
|
const payload = {
|
||||||
if (selectedTrigger.trigger_type !== "PIPELINE") {
|
selected_rules: selectedRuleFiles.map(rule => ({
|
||||||
toast("Unable to save the configuration");
|
file_name: rule.file_name,
|
||||||
return;
|
title: rule.title,
|
||||||
}
|
description: rule.description,
|
||||||
|
file_id: rule.file_id,
|
||||||
selectedTrigger.parameters = selectedRuleFiles;
|
is_enabled: rule.is_enabled,
|
||||||
|
}))
|
||||||
|
};
|
||||||
console.log('Selected Rule Files:', selectedRuleFiles);
|
|
||||||
console.log('Selected Rule File Names:', selectedRuleFiles.map(rule => rule.file_id));
|
try {
|
||||||
|
const url = globalUrl + "/api/v1/detection/" + selectedTrigger.id + "/selected_rules/save"
|
||||||
setTenzirConfigModalOpen(false);
|
fetch(url, {
|
||||||
};
|
method: 'POST',
|
||||||
|
credentials: "include",
|
||||||
useEffect(()=>{
|
headers: {
|
||||||
if (selectedTrigger.trigger_type !== "PIPELINE") {
|
'Content-Type': 'application/json',
|
||||||
//toast("Unable to save the configuration");
|
},
|
||||||
return;
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('Rules saved successfully:', data);
|
||||||
|
setTenzirConfigModalOpen(false);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error saving selected rules:', error);
|
||||||
|
toast("Unable to save the configuration");
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
toast("Unable to save the configuration");
|
||||||
}
|
}
|
||||||
setSelectedRules(selectedTrigger.parameters);
|
};
|
||||||
},[])
|
|
||||||
|
|
||||||
const enabledSigmaInfo = rules.filter(rule => rule.is_enabled);
|
const enabledSigmaInfo = rules.filter(rule => rule.is_enabled);
|
||||||
|
|
||||||
if (!tenzirConfigModalOpen) return null;
|
if (!tenzirConfigModalOpen) return null;
|
||||||
@@ -21319,8 +21359,7 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user