-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Host Details Page: Render vulnerable software warnings (#1220)
* Conditionally renders vulnerability div and issue tooltip * Refactors IconToolTip to include an Error icon * Add vulnerabilities to type interface, small cleanup Co-authored-by: Rachel Elysia Perkins <rachel@fleetdm.com>
- Loading branch information
1 parent
f1e42ee
commit d6d5840
Showing
9 changed files
with
214 additions
and
30 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
86 changes: 86 additions & 0 deletions
86
frontend/pages/hosts/HostDetailsPage/SoftwareVulnerabilities/SoftwareVulnerabilities.jsx
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,86 @@ | ||
import React, { Component } from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import FleetIcon from "components/icons/FleetIcon"; | ||
import softwareInterface from "interfaces/software"; | ||
|
||
const baseClass = "software-vulnerabilities"; | ||
|
||
class SoftwareVulnerabilities extends Component { | ||
static propTypes = { | ||
softwareList: PropTypes.arrayOf(softwareInterface), | ||
}; | ||
|
||
render() { | ||
const { softwareList } = this.props; | ||
|
||
const vulsList = []; | ||
|
||
const vulnerabilitiesListMaker = () => { | ||
softwareList.forEach((software) => { | ||
if (software.vulnerabilities) { | ||
software.vulnerabilities.forEach((vulnerability) => { | ||
vulsList.push({ | ||
name: software.name, | ||
cve: vulnerability.cve, | ||
details_link: vulnerability.details_link, | ||
}); | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
vulnerabilitiesListMaker(); | ||
|
||
const renderVulsCount = (list) => { | ||
if (list.length === 1) { | ||
return "1 vulnerability detected"; | ||
} | ||
return `${list.length} vulnerabilities detected`; | ||
}; | ||
|
||
const renderVul = (vul, index) => { | ||
return ( | ||
<li key={index}> | ||
Read more about{" "} | ||
<a href={vul.details_link} target="_blank" rel="noopener noreferrer"> | ||
<em>{vul.name}</em> {vul.cve} vulnerability | ||
<FleetIcon name="external-link" /> | ||
</a> | ||
</li> | ||
); | ||
}; | ||
|
||
// No software vulnerabilities | ||
if (vulsList.length === 0) { | ||
return null; | ||
} | ||
|
||
// Software vulnerabilities | ||
return ( | ||
<div className={`${baseClass}`}> | ||
<div className={`${baseClass}__count`}> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
fill="none" | ||
> | ||
<path | ||
d="M0 8C0 12.4183 3.5817 16 8 16C12.4183 16 16 12.4183 16 8C16 3.5817 12.4183 0 8 0C3.5817 0 0 3.5817 0 8ZM14 8C14 11.3137 11.3137 14 8 14C4.6863 14 2 11.3137 2 8C2 4.6863 4.6863 2 8 2C11.3137 2 14 4.6863 14 8ZM7 12V10H9V12H7ZM7 4V9H9V4H7Z" | ||
fill="#8B8FA2" | ||
/> | ||
</svg> | ||
| ||
{renderVulsCount(vulsList)} | ||
</div> | ||
<div className={`${baseClass}__list`}> | ||
<ul>{vulsList.map((vul, index) => renderVul(vul, index))}</ul> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default SoftwareVulnerabilities; |
26 changes: 26 additions & 0 deletions
26
frontend/pages/hosts/HostDetailsPage/SoftwareVulnerabilities/_styles.scss
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,26 @@ | ||
.software-vulnerabilities { | ||
font-size: $x-small; | ||
background-color: $ui-off-white; | ||
border: solid 1px $ui-fleet-black-50; | ||
box-sizing: border-box; | ||
border-radius: 10px; | ||
overflow: scroll; | ||
margin-bottom: $pad-large; | ||
padding: $pad-large; | ||
padding-bottom: $pad-small; | ||
|
||
a { | ||
color: $core-vibrant-blue; | ||
font-weight: $bold; | ||
text-decoration: none; | ||
} | ||
|
||
&__count { | ||
font-size: $small; | ||
font-weight: $bold; | ||
} | ||
|
||
svg { | ||
padding-right: $pad-xxsmall; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/pages/hosts/HostDetailsPage/SoftwareVulnerabilities/index.js
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 @@ | ||
export { default } from "./SoftwareVulnerabilities"; |
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