Skip to content

Commit

Permalink
Fixes #919 - isNotRhelHost regex too restrictive
Browse files Browse the repository at this point in the history
- Changed regex to be more wide-ranging
- Fixed a bug in InsightsTotalRiskChartWrapper
where the wrong parameter was passed to isNotRhelHost
  • Loading branch information
Thorben-D committed Nov 2, 2024
1 parent 87ba0f9 commit 42cbacb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"remediate",
"remediations",
"repo",
"rhc",
"theforeman",
"tooltip",
"unmount",
Expand Down
7 changes: 5 additions & 2 deletions webpack/ForemanRhCloudHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
export const foremanUrl = path => `${window.URL_PREFIX}${path}`;

export const isNotRhelHost = ({ hostDetails }) =>
// eslint-disable-next-line camelcase
!new RegExp('red\\s?hat', 'i').test(hostDetails?.operatingsystem_name);
// This regex tries matches sane variations of "RedHat", "RHEL" and "RHCOS"
!new RegExp('red[\\s\\-]?hat|rh[\\s\\-]?el|rhc[\\s\\-]?os', 'i').test(
// eslint-disable-next-line camelcase
hostDetails?.operatingsystem_name
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isNotRhelHost } from '../ForemanRhCloudHelpers';
export const InsightsTotalRiskChartWrapper = props => {
if (props.status === 'RESOLVED') {
return (
!isNotRhelHost(props.hostDetails) && <InsightsTotalRiskChart {...props} /> // check for RHEL hosts
!isNotRhelHost(props) && <InsightsTotalRiskChart {...props} /> // check for RHEL hosts
);
}
return null;
Expand Down

0 comments on commit 42cbacb

Please sign in to comment.