-
Notifications
You must be signed in to change notification settings - Fork 65
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
- Loading branch information
Showing
23 changed files
with
1,011 additions
and
14 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
19 changes: 19 additions & 0 deletions
19
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,19 @@ | ||
<%# | ||
name: Run OpenSCAP remediation - Ansible Default | ||
job_category: OpenSCAP Ansible Commands | ||
description_format: Run OpenSCAP remediation on given host | ||
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 | ||
%> | ||
--- | ||
- hosts: all | ||
tasks: | ||
<%= input('tasks') %> |
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
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
import { | ||
selectAPIError, | ||
selectAPIResponse, | ||
selectAPIStatus, | ||
} from 'foremanReact/redux/API/APISelectors'; | ||
import { STATUS } from 'foremanReact/constants'; | ||
import { | ||
JOB_INVOCATION_API_REQUEST_KEY, | ||
REPORT_LOG_REQUEST_KEY, | ||
} from './constants'; | ||
|
||
export const selectRemediationResponse = state => | ||
selectAPIResponse(state, JOB_INVOCATION_API_REQUEST_KEY) || {}; | ||
|
||
export const selectRemediationStatus = state => | ||
selectAPIStatus(state, JOB_INVOCATION_API_REQUEST_KEY) || STATUS.PENDING; | ||
|
||
export const selectRemediationError = state => | ||
selectAPIError(state, JOB_INVOCATION_API_REQUEST_KEY); | ||
|
||
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; |
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,15 @@ | ||
export const OPENSCAP_REMEDIATION_MODAL_ID = 'openscapRemediationModal'; | ||
export const NEW_HOSTS_PATH = '/new/hosts'; | ||
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'; |
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 @@ | ||
import { join } from 'lodash'; | ||
|
||
const getResponseErrorMsgs = ({ data } = {}) => { | ||
if (data) { | ||
const messages = | ||
data.displayMessage || data.message || data.errors || data.error?.message; | ||
return Array.isArray(messages) ? messages : [messages]; | ||
} | ||
return []; | ||
}; | ||
|
||
export const errorMsg = error => { | ||
join(getResponseErrorMsgs(error?.response || {}), '\n'); | ||
}; |
Oops, something went wrong.