-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: action item and threat assessment overhaul
The old impact/likelihood sliders have been removed in favour for new action item reporting. * Action items now come with an assessment input where you set the *severity* of a threat. * Add new action item tab to the left panel of the threat model diagram where you can see all action items of the entire model. * Approve Review modal also displays these as a summary to review before approval.
- Loading branch information
Showing
22 changed files
with
362 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
KeyboardArrowDownRounded, | ||
KeyboardArrowUpRounded, | ||
} from "@mui/icons-material"; | ||
import { Badge, Box, Collapse, IconButton, Paper } from "@mui/material"; | ||
import { useState } from "react"; | ||
|
||
export function CollapsePaper({ | ||
title, | ||
count, | ||
children, | ||
defaultExpanded = false, | ||
sx, | ||
}) { | ||
const [expanded, setExpanded] = useState(defaultExpanded); | ||
|
||
return ( | ||
<Paper elevation={16} sx={sx}> | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
sx={{ paddingLeft: "10px", "&:hover": { cursor: "pointer" } }} | ||
onClick={(e) => { | ||
if (e.target === e.currentTarget) { | ||
setExpanded(!expanded); | ||
} | ||
}} | ||
> | ||
<Badge | ||
badgeContent={count} | ||
onClick={() => setExpanded(!expanded)} | ||
sx={{ | ||
alignItems: "center", | ||
gap: "10px", | ||
"& span": { | ||
position: "relative", | ||
transform: "scale(1)", | ||
backgroundColor: "dimgray", | ||
}, | ||
}} | ||
> | ||
{title} | ||
</Badge> | ||
<IconButton | ||
disableRipple | ||
size="large" | ||
sx={{ | ||
marginLeft: "auto", | ||
}} | ||
onClick={() => setExpanded(!expanded)} | ||
> | ||
{expanded ? <KeyboardArrowUpRounded /> : <KeyboardArrowDownRounded />} | ||
</IconButton> | ||
</Box> | ||
<Collapse in={expanded} timeout="auto" unmountOnExit> | ||
{children} | ||
</Collapse> | ||
</Paper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Chip, IconButton } from "@mui/material"; | ||
import EmailIcon from "@mui/icons-material/Email"; | ||
import ChatIcon from "@mui/icons-material/Chat"; | ||
|
||
export function UserChip({ user }) { | ||
return ( | ||
<Chip | ||
size="small" | ||
sx={{ | ||
color: (theme) => theme.palette.review.text, | ||
}} | ||
variant="outlined" | ||
label={user.name} | ||
icon={ | ||
<> | ||
{user?.slackUrl && ( | ||
<IconButton | ||
href={user?.slackUrl} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<ChatIcon /> | ||
</IconButton> | ||
)} | ||
{user?.mail && ( | ||
<IconButton | ||
href={`mailto:${user?.mail}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<EmailIcon /> | ||
</IconButton> | ||
)} | ||
</> | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useListThreatsQuery } from "../../../api/gram/threats"; | ||
import { useModelID } from "./useModelID"; | ||
|
||
export function useActionItems() { | ||
const modelId = useModelID(); | ||
const { data: threats } = useListThreatsQuery({ modelId }); | ||
|
||
const actionItems = threats?.threats | ||
? Object.keys(threats?.threats) | ||
.map((componentId) => ({ | ||
componentId, | ||
threats: threats?.threats[componentId].filter( | ||
(th) => th.isActionItem | ||
), | ||
})) | ||
.filter(({ threats }) => threats && threats.length > 0) | ||
: []; | ||
|
||
return actionItems; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.