forked from p15670423/monkey
Altered SS rule dropdowns to display resource name whenever possible, and to display more proper value
This commit is contained in:
parent
672c19ef0d
commit
22a97096ca
|
@ -12,6 +12,8 @@ import {faArrowRight} from '@fortawesome/free-solid-svg-icons';
|
|||
export default function ResourceDropdown(props) {
|
||||
|
||||
const [isCollapseOpen, setIsCollapseOpen] = useState(false);
|
||||
let parser = new ScoutSuiteDataParser(props.scoutsuite_data.data.services);
|
||||
let resource_value = parser.getResourceValue(props.resource_path, props.template_path);
|
||||
|
||||
function getResourceDropdown() {
|
||||
return (
|
||||
|
@ -20,7 +22,7 @@ export default function ResourceDropdown(props) {
|
|||
<button className={'btn-collapse'}
|
||||
onClick={() => setIsCollapseOpen(!isCollapseOpen)}>
|
||||
<span>
|
||||
{props.resource_path}
|
||||
{resource_value.hasOwnProperty('name') ? resource_value.name : props.resource_path}
|
||||
</span>
|
||||
<span>
|
||||
<FontAwesomeIcon icon={isCollapseOpen ? faChevronDown : faChevronUp}/>
|
||||
|
@ -51,8 +53,6 @@ export default function ResourceDropdown(props) {
|
|||
}
|
||||
|
||||
function getResourceValueDisplay() {
|
||||
let parser = new ScoutSuiteDataParser(props.scoutsuite_data.data.services);
|
||||
let resource_value = parser.getValueAt(props.resource_path);
|
||||
if (resource_value) {
|
||||
return(
|
||||
<div>
|
||||
|
@ -81,6 +81,7 @@ export default function ResourceDropdown(props) {
|
|||
}
|
||||
|
||||
ResourceDropdown.propTypes = {
|
||||
resource_path: PropTypes.object,
|
||||
template_path: PropTypes.string,
|
||||
resource_path: PropTypes.string,
|
||||
scoutsuite_data: PropTypes.object
|
||||
};
|
||||
|
|
|
@ -40,7 +40,10 @@ export default function RuleDisplay(props) {
|
|||
function getResources() {
|
||||
let resources = []
|
||||
props.rule.items.forEach(item => {
|
||||
resources.push(<ResourceDropdown resource_path={item} scoutsuite_data={props.scoutsuite_data}/>)
|
||||
let template_path = props.rule.hasOwnProperty('display_path') ? props.rule.display_path : props.rule.path;
|
||||
resources.push(<ResourceDropdown resource_path={item}
|
||||
template_path={template_path}
|
||||
scoutsuite_data={props.scoutsuite_data}/>)
|
||||
})
|
||||
return (
|
||||
<div className={'reference-list'}>
|
||||
|
|
|
@ -3,6 +3,22 @@ export default class ScoutSuiteDataParser {
|
|||
this.runResults = runResults
|
||||
}
|
||||
|
||||
/*
|
||||
itemPath contains path to a specific value e.g. s3.buckets.da1e7081077ce92.secure_transport_enabled"
|
||||
templatePath contains a template path for resource we would want to display e.g. s3.buckets.id
|
||||
*/
|
||||
getResourceValue(itemPath, templatePath) {
|
||||
let resourcePath = this.fillTemplatePath(itemPath, templatePath);
|
||||
return this.getValueAt(resourcePath);
|
||||
}
|
||||
|
||||
fillTemplatePath(itemPath, templatePath) {
|
||||
let itemPathArray = itemPath.split('.');
|
||||
let templatePathArray = templatePath.split('.');
|
||||
let resourcePathArray = templatePathArray.map((val, i) => {return val === 'id' ? itemPathArray[i] : val})
|
||||
return resourcePathArray.join('.');
|
||||
}
|
||||
|
||||
getValueAt(path) {
|
||||
return this.getValueAtRecursive(path, this.runResults)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue