reverting select rules and adding the kafka ui back
This commit is contained in:
@@ -535,6 +535,7 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
const [selectedOption, setSelectedOption] = React.useState("");
|
const [selectedOption, setSelectedOption] = React.useState("");
|
||||||
const [tenzirConfigModalOpen, setTenzirConfigModalOpen] = React.useState(false);
|
const [tenzirConfigModalOpen, setTenzirConfigModalOpen] = React.useState(false);
|
||||||
const [rules, setRules] = React.useState([]);
|
const [rules, setRules] = React.useState([]);
|
||||||
|
const [sigmaFilesNames, setSigmaFileNames] = React.useState("")
|
||||||
|
|
||||||
const [distributedFromParent, setDistributedFromParent] = React.useState("")
|
const [distributedFromParent, setDistributedFromParent] = React.useState("")
|
||||||
const [suborgWorkflows, setSuborgWorkflows] = React.useState([])
|
const [suborgWorkflows, setSuborgWorkflows] = React.useState([])
|
||||||
@@ -993,12 +994,6 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
}
|
}
|
||||||
}, [authenticationModalOpen])
|
}, [authenticationModalOpen])
|
||||||
|
|
||||||
useEffect(() =>{
|
|
||||||
if (tenzirConfigModalOpen === false) return;
|
|
||||||
|
|
||||||
getSigmaInfo();
|
|
||||||
},[tenzirConfigModalOpen])
|
|
||||||
|
|
||||||
const listOrgCache = (orgId) => {
|
const listOrgCache = (orgId) => {
|
||||||
fetch(`${globalUrl}/api/v1/orgs/${orgId}/list_cache`, {
|
fetch(`${globalUrl}/api/v1/orgs/${orgId}/list_cache`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -1474,6 +1469,59 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
setTenzirConfigModalOpen(false);
|
setTenzirConfigModalOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSubmit = (trigger) => {
|
||||||
|
if (trigger.trigger_type !== "PIPELINE") {
|
||||||
|
toast("Unable to save the configuration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedOption == "kafka Queue") {
|
||||||
|
trigger.parameters = []
|
||||||
|
|
||||||
|
const topic = document.getElementById('topic')?.value
|
||||||
|
const bootstrapServers = document.getElementById('bootstrap_servers')?.value
|
||||||
|
const groupId = document.getElementById('group_id')?.value
|
||||||
|
const autoOffsetReset = document.getElementById('auto_offset_reset')?.value;
|
||||||
|
|
||||||
|
if(topic) {
|
||||||
|
trigger.parameters.push({
|
||||||
|
name: "topic",
|
||||||
|
value: topic
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
toast("Please enter the topic name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bootstrapServers) {
|
||||||
|
trigger.parameters.push({
|
||||||
|
name: "bootstrap_servers",
|
||||||
|
value: bootstrapServers
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toast("please enter bootstrap server details");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupId) {
|
||||||
|
trigger.parameters.push({
|
||||||
|
name: "group_id",
|
||||||
|
value: groupId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoOffsetReset) {
|
||||||
|
trigger.parameters.push({
|
||||||
|
name: "auto_offset_reset",
|
||||||
|
value: autoOffsetReset
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setTenzirConfigModalOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleColoring = (actionId, status, label) => {
|
const handleColoring = (actionId, status, label) => {
|
||||||
if (cy === undefined) {
|
if (cy === undefined) {
|
||||||
return
|
return
|
||||||
@@ -15417,7 +15465,18 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
setSelectedOption("SigmaRule");
|
setSelectedOption("SigmaRule");
|
||||||
setTenzirConfigModalOpen(true);
|
const command = `export | sigma /var/lib/tenzir/sigma_rules | to ${globalUrl}/api/v1/pipelines/pipeline_${selectedTrigger.id}`
|
||||||
|
const pipelineConfig = {
|
||||||
|
command: command,
|
||||||
|
name: selectedTrigger.label,
|
||||||
|
type: "create",
|
||||||
|
environment: selectedTrigger.environment,
|
||||||
|
workflow_id: workflow.id,
|
||||||
|
trigger_id: selectedTrigger.id,
|
||||||
|
start_node: "",
|
||||||
|
};
|
||||||
|
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig);
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
style={{
|
style={{
|
||||||
border: "1px solid rgba(255,255,255,0.3)",
|
border: "1px solid rgba(255,255,255,0.3)",
|
||||||
@@ -21194,90 +21253,6 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const TenzirConfigModal = () => {
|
const TenzirConfigModal = () => {
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
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) => {
|
|
||||||
setSelectedRules(event.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectAll = () => {
|
|
||||||
const allEnabledRules = rules.filter(rule => rule.is_enabled).map(rule => rule.file_id);
|
|
||||||
setSelectedRules(allEnabledRules);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleClose = () => {
|
|
||||||
setTenzirConfigModalOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
const selectedRuleFiles = rules.filter(rule => selectedRules.includes(rule.file_id));
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
selected_rules: selectedRuleFiles.map(rule => ({
|
|
||||||
file_name: rule.file_name,
|
|
||||||
title: rule.title,
|
|
||||||
description: rule.description,
|
|
||||||
file_id: rule.file_id,
|
|
||||||
is_enabled: rule.is_enabled,
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const url = globalUrl + "/api/v1/detection/" + selectedTrigger.id + "/selected_rules/save"
|
|
||||||
fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: "include",
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const enabledSigmaInfo = rules.filter(rule => rule.is_enabled);
|
|
||||||
|
|
||||||
if (!tenzirConfigModalOpen) return null;
|
if (!tenzirConfigModalOpen) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -21302,61 +21277,112 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{loading ? (
|
<DialogTitle id="tenzir-config-modal" style={{ cursor: "move" }}>
|
||||||
<CircularProgress />
|
<div style={{ color: "white" }}>Configuration options for Kafka</div>
|
||||||
) : (
|
</DialogTitle>
|
||||||
<div
|
<DialogContent>
|
||||||
style={{
|
{selectedOption === "Kafka Queue" ? (
|
||||||
flex: 2,
|
<div>
|
||||||
padding: 0,
|
<b>Topic</b>
|
||||||
minHeight: isMobile ? "90%" : 700,
|
<TextField
|
||||||
maxHeight: isMobile ? "90%" : 700,
|
id="topic"
|
||||||
overflowY: "auto",
|
style={{
|
||||||
overflowX: isMobile ? "auto" : "hidden",
|
backgroundColor: theme.palette.inputColor,
|
||||||
}}
|
borderRadius: theme.palette.borderRadius,
|
||||||
>
|
}}
|
||||||
<DialogContent>
|
InputProps={{
|
||||||
{selectedOption === 'SigmaRule' && (
|
style: {},
|
||||||
<>
|
}}
|
||||||
<FormControl fullWidth>
|
fullWidth
|
||||||
<InputLabel>Select Sigma Rules</InputLabel>
|
color="primary"
|
||||||
<Select
|
placeholder={"topic name"}
|
||||||
multiple
|
defaultValue={
|
||||||
value={selectedRules}
|
selectedTrigger?.parameters?.find(
|
||||||
onChange={handleRuleChange}
|
(param) => param.name === "topic",
|
||||||
renderValue={(selected) => selected.join(', ')}
|
)?.value || ""
|
||||||
>
|
}
|
||||||
{enabledSigmaInfo.map(rule => (
|
/>
|
||||||
<MenuItem key={rule.file_id} value={rule.file_id}>
|
<b>bootstrap.servers</b>
|
||||||
<Checkbox checked={selectedRules.indexOf(rule.file_id) > -1} />
|
<TextField
|
||||||
<ListItemText primary={rule.title} />
|
id="bootstrap_servers"
|
||||||
</MenuItem>
|
style={{
|
||||||
))}
|
backgroundColor: theme.palette.inputColor,
|
||||||
</Select>
|
borderRadius: theme.palette.borderRadius,
|
||||||
</FormControl>
|
}}
|
||||||
<Button onClick={handleSelectAll}>Select All</Button>
|
InputProps={{
|
||||||
</>
|
style: {},
|
||||||
)}
|
}}
|
||||||
</DialogContent>
|
fullWidth
|
||||||
<DialogActions>
|
color="primary"
|
||||||
<Button style={{ borderRadius: "0px" }} onClick={handleClose} color="primary">Cancel</Button>
|
placeholder={"broker1.example.com:9092,192.168.1.100:9092"}
|
||||||
<Button style={{ borderRadius: "0px" }} onClick={handleSubmit} color="primary">Submit</Button>
|
defaultValue={
|
||||||
</DialogActions>
|
selectedTrigger?.parameters?.find(
|
||||||
</div>
|
(param) => param.name === "bootstrap_servers",
|
||||||
)}
|
)?.value || ""
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<b>group.id</b>
|
||||||
|
<TextField
|
||||||
|
id="group_id"
|
||||||
|
style={{
|
||||||
|
backgroundColor: theme.palette.inputColor,
|
||||||
|
borderRadius: theme.palette.borderRadius,
|
||||||
|
}}
|
||||||
|
InputProps={{
|
||||||
|
style: {},
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
color="primary"
|
||||||
|
placeholder={"tenzir"}
|
||||||
|
defaultValue={
|
||||||
|
selectedTrigger?.parameters?.find(
|
||||||
|
(param) => param.name === "group_id",
|
||||||
|
)?.value || ""
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<b>auto.offest.reset</b>
|
||||||
|
<TextField
|
||||||
|
id="auto_offset_reset"
|
||||||
|
style={{
|
||||||
|
backgroundColor: theme.palette.inputColor,
|
||||||
|
borderRadius: theme.palette.borderRadius,
|
||||||
|
}}
|
||||||
|
InputProps={{
|
||||||
|
style: {},
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
color="primary"
|
||||||
|
placeholder={"earliest"}
|
||||||
|
defaultValue={
|
||||||
|
selectedTrigger?.parameters?.find(
|
||||||
|
(param) => param.name === "auto_offset_reset",
|
||||||
|
)?.value || ""
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null}{" "}
|
||||||
|
</DialogContent>
|
||||||
|
|
||||||
<IconButton
|
<DialogActions>
|
||||||
style={{
|
<Button
|
||||||
zIndex: 5000,
|
style={{ borderRadius: "0px" }}
|
||||||
position: "absolute",
|
onClick={() => {
|
||||||
top: 14,
|
setTenzirConfigModalOpen(false);
|
||||||
right: 18,
|
}}
|
||||||
color: "grey",
|
color="primary"
|
||||||
}}
|
>
|
||||||
onClick={handleClose}
|
Cancel
|
||||||
>
|
</Button>
|
||||||
<CloseIcon />
|
<Button
|
||||||
</IconButton>
|
style={{ borderRadius: "0px" }}
|
||||||
|
onClick={() => {
|
||||||
|
handleSubmit(selectedTrigger);
|
||||||
|
}}
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user