Skip to content

Commit

Permalink
fix(Remediations): RHICOMPL-1124 available only for supported
Browse files Browse the repository at this point in the history
Remediations are only available for rules which have failed against a
supported OS/SSG configuration.

Signed-off-by: Andrew Kofink <akofink@redhat.com>
  • Loading branch information
akofink authored and vkrizan committed Jan 14, 2021
1 parent 3ece2fc commit 9899fad
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/inventory-compliance/src/ComplianceRemediationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class ComplianceRemediationButton extends React.Component {
)

rulesWithRemediations = (rules, system) => {
return rules.filter(rule => rule.remediationAvailable).map(
return rules.filter((rule) => (
rule.remediationAvailable &&
this.ruleProfile(rule, system).supported &&
rule.compliant === false
)).map(
rule => this.formatRule(rule, this.ruleProfile(rule, system).refId, system.id)
);
}
Expand All @@ -53,9 +57,17 @@ class ComplianceRemediationButton extends React.Component {
});
}

noRemediationAvailable = () => {
remediationAvailable = () => {
const { allSystems, selectedRules } = this.props;
return selectedRules.length === 0 && !allSystems.some((system) => system.ruleObjectsFailed.some((rule) => rule.remediationAvailable && system.supported));
let rules = selectedRules.length ? selectedRules : allSystems.flatMap((system) => system.ruleObjectsFailed);
return rules.some((rule) => (
rule.remediationAvailable &&
(
rule.profiles?.some((profile) => profile.supported) ||
allSystems.some((system) => this.ruleProfile(rule, system).supported)
) &&
rule.compliant === false
));
}

render() {
Expand All @@ -64,7 +76,7 @@ class ComplianceRemediationButton extends React.Component {
return (
<React.Fragment>
<RemediationButton
isDisabled={ this.noRemediationAvailable() }
isDisabled={ !this.remediationAvailable() }
onRemediationCreated={ result => addNotification(result.getNotification()) }
dataProvider={ this.dataProvider }
>
Expand Down

0 comments on commit 9899fad

Please sign in to comment.