adding a select option for the sigma rules
This commit is contained in:
@@ -534,6 +534,7 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
const [listCache, setListCache] = React.useState([]);
|
const [listCache, setListCache] = React.useState([]);
|
||||||
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 [distributedFromParent, setDistributedFromParent] = React.useState("")
|
const [distributedFromParent, setDistributedFromParent] = React.useState("")
|
||||||
const [suborgWorkflows, setSuborgWorkflows] = React.useState([])
|
const [suborgWorkflows, setSuborgWorkflows] = React.useState([])
|
||||||
@@ -992,6 +993,12 @@ 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",
|
||||||
@@ -8308,6 +8315,32 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSigmaInfo = () => {
|
||||||
|
const url = globalUrl + "/api/v1/files/detection/sigma_rules";
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: "include",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) =>
|
||||||
|
response.json().then((responseJson) => {
|
||||||
|
if (responseJson["success"] === false) {
|
||||||
|
toast("Failed to get sigma rules");
|
||||||
|
} else {
|
||||||
|
setRules(responseJson.sigma_info);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.catch((error) => {
|
||||||
|
console.log("Error in getting sigma files: ", error);
|
||||||
|
toast("An error occurred while fetching sigma rules");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const parsedHeight = isMobile ? bodyHeight - appBarSize * 4 : bodyHeight - appBarSize - 50
|
const parsedHeight = isMobile ? bodyHeight - appBarSize * 4 : bodyHeight - appBarSize - 50
|
||||||
const appViewStyle = {
|
const appViewStyle = {
|
||||||
marginLeft: 5,
|
marginLeft: 5,
|
||||||
@@ -21160,95 +21193,116 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const tenzirConfigModal = tenzirConfigModalOpen ? (
|
const tenzirConfigModal = () => {
|
||||||
<Dialog
|
if (!tenzirConfigModalOpen) return null;
|
||||||
PaperComponent={PaperComponent}
|
|
||||||
hideBackdrop={true}
|
const [loading, setLoading] = useState(true);
|
||||||
disableEnforceFocus={true}
|
const [selectedRules, setSelectedRules] = useState([]);
|
||||||
disableBackdropClick={true}
|
|
||||||
style={{ pointerEvents: "none" }}
|
const handleRuleChange = (event) => {
|
||||||
open={tenzirConfigModalOpen}
|
setSelectedRules(event.target.value);
|
||||||
PaperProps={{
|
};
|
||||||
style: {
|
|
||||||
pointerEvents: "auto",
|
const handleSelectAll = () => {
|
||||||
color: "white",
|
const allEnabledRules = rules.filter(rule => rule.is_enabled).map(rule => rule.file_id);
|
||||||
minWidth: 600,
|
setSelectedRules(allEnabledRules);
|
||||||
minHeight: 200,
|
};
|
||||||
maxHeight: 200,
|
|
||||||
padding: 15,
|
const handleClose = () => {
|
||||||
overflow: "hidden",
|
setTenzirConfigModalOpen(false);
|
||||||
zIndex: 10012,
|
};
|
||||||
border: theme.palette.defaultBorder,
|
|
||||||
},
|
const handleSubmit = () => {
|
||||||
|
const selectedRuleFiles = rules
|
||||||
|
.filter(rule => selectedRules.includes(rule.file_id));
|
||||||
|
|
||||||
|
console.log('Selected Rule Files:', selectedRuleFiles);
|
||||||
|
console.log('Selected Rule File Names:', selectedRuleFiles.map(rule => rule.file_id));
|
||||||
|
|
||||||
|
setTenzirConfigModalOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const enabledSigmaInfo = rules.filter(rule => rule.is_enabled);
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
PaperComponent={PaperComponent}
|
||||||
|
hideBackdrop={true}
|
||||||
|
disableEnforceFocus={true}
|
||||||
|
disableBackdropClick={true}
|
||||||
|
style={{ pointerEvents: "none" }}
|
||||||
|
open={tenzirConfigModalOpen}
|
||||||
|
PaperProps={{
|
||||||
|
style: {
|
||||||
|
pointerEvents: "auto",
|
||||||
|
color: "white",
|
||||||
|
minWidth: 600,
|
||||||
|
minHeight: 200,
|
||||||
|
maxHeight: 200,
|
||||||
|
padding: 15,
|
||||||
|
overflow: "hidden",
|
||||||
|
zIndex: 10012,
|
||||||
|
border: theme.palette.defaultBorder,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<CircularProgress />
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 2,
|
||||||
|
padding: 0,
|
||||||
|
minHeight: isMobile ? "90%" : 700,
|
||||||
|
maxHeight: isMobile ? "90%" : 700,
|
||||||
|
overflowY: "auto",
|
||||||
|
overflowX: isMobile ? "auto" : "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<DialogContent>
|
||||||
style={{
|
{selectedOption === 'sigmaRule' && (
|
||||||
flex: 2,
|
<>
|
||||||
padding: 0,
|
<FormControl fullWidth>
|
||||||
minHeight: isMobile ? "90%" : 700,
|
<InputLabel>Select Sigma Rules</InputLabel>
|
||||||
maxHeight: isMobile ? "90%" : 700,
|
<Select
|
||||||
overflowY: "auto",
|
multiple
|
||||||
overflowX: isMobile ? "auto" : "hidden",
|
value={selectedRules}
|
||||||
}}
|
onChange={handleRuleChange}
|
||||||
>
|
renderValue={(selected) => selected.join(', ')}
|
||||||
<DialogContent>
|
>
|
||||||
|
{enabledSigmaInfo.map(rule => (
|
||||||
<b>command</b>
|
<MenuItem key={rule.file_id} value={rule.file_id}>
|
||||||
<TextField
|
<Checkbox checked={selectedRules.indexOf(rule.file_id) > -1} />
|
||||||
id="sigma"
|
<ListItemText primary={rule.title} />
|
||||||
style={{
|
</MenuItem>
|
||||||
backgroundColor: theme.palette.inputColor,
|
))}
|
||||||
borderRadius: theme.palette.borderRadius,
|
</Select>
|
||||||
}}
|
</FormControl>
|
||||||
InputProps={{
|
<Button onClick={handleSelectAll}>Select All</Button>
|
||||||
style: {},
|
</>
|
||||||
}}
|
)}
|
||||||
fullWidth
|
</DialogContent>
|
||||||
color="primary"
|
<DialogActions>
|
||||||
placeholder={"command"}
|
<Button style={{ borderRadius: "0px" }} onClick={handleClose} color="primary">Cancel</Button>
|
||||||
defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "command")?.value) || ''}
|
<Button style={{ borderRadius: "0px" }} onClick={handleSubmit} color="primary">Submit</Button>
|
||||||
/>
|
</DialogActions>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
</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" }}
|
</Dialog>
|
||||||
onClick={() => {
|
}
|
||||||
handleCommandSubmit(selectedTrigger);
|
|
||||||
}}
|
|
||||||
color="primary"
|
|
||||||
>
|
|
||||||
Submit
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<IconButton
|
|
||||||
style={{
|
|
||||||
zIndex: 5000,
|
|
||||||
position: "absolute",
|
|
||||||
top: 14,
|
|
||||||
right: 18,
|
|
||||||
color: "grey",
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
setTenzirConfigModalOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CloseIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Dialog>
|
|
||||||
) : null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user