-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36738 - Add remediation wizard (#546)
* Fixes #36738 - Add remediation wizard * Refs #36738 - Re-use host selection box from core * Refs #36738 - Remove searchbar * Refs #36738 - Return SelectNone option * Refs #36738 - Use relative import for ExternalLink icon * Refs #36738 - Return SelectAll option * Refs #36738 - Change Select none to Select default * Refs #36738 - Improve help strings
- Loading branch information
Showing
25 changed files
with
1,150 additions
and
16 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
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
27 changes: 27 additions & 0 deletions
27
app/views/job_templates/run_openscap_remediation_-_ansible_default.erb
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,27 @@ | ||
<%# | ||
name: Run OpenSCAP remediation - Ansible Default | ||
job_category: OpenSCAP Ansible Commands | ||
description_format: Run OpenSCAP remediation on given host. Please note, it is not meant to be used directly. | ||
snippet: false | ||
provider_type: Ansible | ||
kind: job_template | ||
model: JobTemplate | ||
feature: ansible_run_openscap_remediation | ||
template_inputs: | ||
- name: tasks | ||
description: Tasks to run on the host | ||
input_type: user | ||
required: true | ||
- name: reboot | ||
description: Indicate wether the host should be rebooted after all the remediation | ||
input_type: user | ||
required: false | ||
%> | ||
--- | ||
- hosts: all | ||
tasks: | ||
<%= indent(4) { input('tasks') } -%> | ||
<% if truthy?(input('reboot')) %> | ||
- name: Reboot the machine | ||
reboot: | ||
<% end %> |
24 changes: 24 additions & 0 deletions
24
app/views/job_templates/run_openscap_remediation_-_script_default.erb
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,24 @@ | ||
<%# | ||
name: Run OpenSCAP remediation - Script Default | ||
job_category: OpenSCAP | ||
description_format: Run OpenSCAP remediation on given host. Please note, it is not meant to be used directly. | ||
snippet: false | ||
provider_type: script | ||
kind: job_template | ||
model: JobTemplate | ||
feature: script_run_openscap_remediation | ||
template_inputs: | ||
- name: command | ||
description: Command to run on the host | ||
input_type: user | ||
required: true | ||
- name: reboot | ||
description: Indicate wether the host should be rebooted after the remediation | ||
input_type: user | ||
required: false | ||
%> | ||
<%= input('command') %> | ||
<% if truthy?(input('reboot')) -%> | ||
echo "A reboot is required to finish the remediation. The system is going to reboot now." | ||
<%= render_template('Power Action - Script Default', action: 'restart') %> | ||
<% end -%> |
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,5 @@ | ||
class AddFixesToMessage < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :messages, :fixes, :text | ||
end | ||
end |
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
16 changes: 16 additions & 0 deletions
16
webpack/components/OpenscapRemediationWizard/OpenscapRemediationSelectors.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,16 @@ | ||
import { | ||
selectAPIError, | ||
selectAPIResponse, | ||
selectAPIStatus, | ||
} from 'foremanReact/redux/API/APISelectors'; | ||
import { STATUS } from 'foremanReact/constants'; | ||
import { REPORT_LOG_REQUEST_KEY } from './constants'; | ||
|
||
export const selectLogResponse = state => | ||
selectAPIResponse(state, REPORT_LOG_REQUEST_KEY); | ||
|
||
export const selectLogStatus = state => | ||
selectAPIStatus(state, REPORT_LOG_REQUEST_KEY) || STATUS.PENDING; | ||
|
||
export const selectLogError = state => | ||
selectAPIError(state, REPORT_LOG_REQUEST_KEY); |
4 changes: 4 additions & 0 deletions
4
webpack/components/OpenscapRemediationWizard/OpenscapRemediationWizardContext.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,4 @@ | ||
import { createContext } from 'react'; | ||
|
||
const OpenscapRemediationWizardContext = createContext({}); | ||
export default OpenscapRemediationWizardContext; |
38 changes: 38 additions & 0 deletions
38
webpack/components/OpenscapRemediationWizard/ViewSelectedHostsLink.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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons'; | ||
import { Button } from '@patternfly/react-core'; | ||
|
||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import { foremanUrl } from 'foremanReact/common/helpers'; | ||
import { getHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext'; | ||
|
||
const ViewSelectedHostsLink = ({ | ||
hostIdsParam, | ||
isAllHostsSelected, | ||
defaultFailedHostsSearch, | ||
}) => { | ||
const search = isAllHostsSelected ? defaultFailedHostsSearch : hostIdsParam; | ||
const url = foremanUrl(`${getHostsPageUrl(false)}?search=${search}`); | ||
return ( | ||
<Button | ||
component="a" | ||
variant="link" | ||
icon={<ExternalLinkSquareAltIcon />} | ||
iconPosition="right" | ||
target="_blank" | ||
href={url} | ||
> | ||
{__('View selected hosts')} | ||
</Button> | ||
); | ||
}; | ||
|
||
ViewSelectedHostsLink.propTypes = { | ||
isAllHostsSelected: PropTypes.bool.isRequired, | ||
defaultFailedHostsSearch: PropTypes.string.isRequired, | ||
hostIdsParam: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ViewSelectedHostsLink; |
43 changes: 43 additions & 0 deletions
43
webpack/components/OpenscapRemediationWizard/WizardHeader.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,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Grid, | ||
TextContent, | ||
Text, | ||
TextVariants, | ||
Flex, | ||
FlexItem, | ||
} from '@patternfly/react-core'; | ||
|
||
const WizardHeader = ({ title, description }) => ( | ||
<Grid style={{ gridGap: '24px' }}> | ||
{title && ( | ||
<TextContent> | ||
<Text ouiaId="wizard-header-text" component={TextVariants.h2}> | ||
{title} | ||
</Text> | ||
</TextContent> | ||
)} | ||
{description && ( | ||
<TextContent> | ||
<Flex flex={{ default: 'inlineFlex' }}> | ||
<FlexItem> | ||
<TextContent>{description}</TextContent> | ||
</FlexItem> | ||
</Flex> | ||
</TextContent> | ||
)} | ||
</Grid> | ||
); | ||
|
||
WizardHeader.propTypes = { | ||
title: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), | ||
description: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), | ||
}; | ||
|
||
WizardHeader.defaultProps = { | ||
title: undefined, | ||
description: undefined, | ||
}; | ||
|
||
export default WizardHeader; |
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,14 @@ | ||
export const OPENSCAP_REMEDIATION_MODAL_ID = 'openscapRemediationModal'; | ||
export const HOSTS_PATH = '/hosts'; | ||
export const FAIL_RULE_SEARCH = 'fails_xccdf_rule'; | ||
|
||
export const HOSTS_API_PATH = '/api/hosts'; | ||
export const HOSTS_API_REQUEST_KEY = 'HOSTS'; | ||
export const REPORT_LOG_REQUEST_KEY = 'ARF_REPORT_LOG'; | ||
|
||
export const JOB_INVOCATION_PATH = '/job_invocations'; | ||
export const JOB_INVOCATION_API_PATH = '/api/job_invocations'; | ||
export const JOB_INVOCATION_API_REQUEST_KEY = 'OPENSCAP_REX_JOB_INVOCATIONS'; | ||
|
||
export const SNIPPET_SH = 'urn:xccdf:fix:script:sh'; | ||
export const SNIPPET_ANSIBLE = 'urn:xccdf:fix:script:ansible'; |
Oops, something went wrong.