Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for default hosts and os filters #1243

Merged
merged 7 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $ cd gsa && git log

## gsa 8.0 unreleased

* Allow to set default host and operating system filters #1243
* Don't crash if start or end date for performance page are invalid #1237
* Change order of options in target dialog #1233
* Don't limit the input field lengths anymore #1232
Expand Down
3 changes: 3 additions & 0 deletions gsa/src/gmp/commands/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ class UserCommand extends EntityCommand {
data.credentialsFilter,
'settings_filter:f9691163-976c-47e7-ad9a-38f2d5c81649':
data.filtersFilter,
'settings_filter:37562dfe-1f7e-4cae-a7c0-fa95e6f194c5': data.hostsFilter,
'settings_filter:96abcd5a-9b6d-456c-80b8-c3221bfa499d': data.notesFilter,
'settings_filter:f608c3ec-ce73-4ff6-8e04-7532749783af':
data.operatingSystemsFilter,
'settings_filter:eaaaebf1-01ef-4c49-b7bb-955461c78e0a':
data.overidesFilter,
'settings_filter:ffb16b28-538c-11e3-b8f9-406186ea4fc5':
Expand Down
1 change: 0 additions & 1 deletion gsa/src/gmp/models/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@ class Filter extends Model {
export const ALL_FILTER = new Filter().all();
export const AGENTS_FILTER_FILTER = Filter.fromString('type=agent');
export const ALERTS_FILTER_FILTER = Filter.fromString('type=alert');
export const ASSETS_FILTER_FILTER = Filter.fromString('type=asset');
export const CERTBUND_FILTER_FILTER = Filter.fromString('type=info');
export const CPES_FILTER_FILTER = Filter.fromString('type=info');
export const CREDENTIALS_FILTER_FILTER = Filter.fromString('type=credential');
Expand Down
3 changes: 2 additions & 1 deletion gsa/src/web/pages/filters/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ import FilterDialog from 'web/pages/filters/dialog';
const FILTER_OPTIONS = [
['agent', _l('Agent')],
['alert', _l('Alert')],
['asset', _l('Asset')],
['credential', _l('Credential')],
['filter', _l('Filter')],
['group', _l('Group')],
['host', _l('Host')],
['note', _l('Note')],
['os', _l('Operating System')],
['override', _l('Override')],
['permission', _l('Permission')],
['port_list', _l('Port List')],
Expand Down
12 changes: 8 additions & 4 deletions gsa/src/web/pages/usersettings/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ let UserSettingsDialog = ({
defaultTarget,
agentsFilter,
alertsFilter,
assetsFilter,
configsFilter,
credentialsFilter,
filtersFilter,
hostsFilter,
notesFilter,
operatingSystemsFilter,
overridesFilter,
permissionsFilter,
portListsFilter,
Expand Down Expand Up @@ -141,11 +142,12 @@ let UserSettingsDialog = ({
defaultTarget,
agentsFilter,
alertsFilter,
assetsFilter,
configsFilter,
credentialsFilter,
filtersFilter,
hostsFilter,
notesFilter,
operatingSystemsFilter,
overridesFilter,
permissionsFilter,
portListsFilter,
Expand Down Expand Up @@ -240,11 +242,12 @@ let UserSettingsDialog = ({
<FilterPart
agentsFilter={values.agentsFilter}
alertsFilter={values.alertsFilter}
assetsFilter={values.assetsFilter}
configsFilter={values.configsFilter}
credentialsFilter={values.credentialsFilter}
filtersFilter={values.filtersFilter}
hostsFilter={values.hostsFilter}
notesFilter={values.notesFilter}
operatingSystemsFilter={values.operatingSystemsFilter}
overridesFilter={values.overridesFilter}
permissionsFilter={values.permissionsFilter}
portListsFilter={values.portListsFilter}
Expand Down Expand Up @@ -280,7 +283,6 @@ UserSettingsDialog.propTypes = {
agentsFilter: PropTypes.string,
alerts: PropTypes.array,
alertsFilter: PropTypes.string,
assetsFilter: PropTypes.string,
autoCacheRebuild: PropTypes.string,
capabilities: PropTypes.capabilities.isRequired,
certBundFilter: PropTypes.string,
Expand Down Expand Up @@ -308,12 +310,14 @@ UserSettingsDialog.propTypes = {
dynamicSeverity: PropTypes.string,
filters: PropTypes.array,
filtersFilter: PropTypes.string,
hostsFilter: PropTypes.string,
listExportFileName: PropTypes.string,
maxRowsPerPage: PropTypes.string,
notesFilter: PropTypes.string,
nvtFilter: PropTypes.string,
openVasScanConfigs: PropTypes.array,
openVasScanners: PropTypes.array,
operatingSystemsFilter: PropTypes.string,
ospScanConfigs: PropTypes.array,
ospScanners: PropTypes.array,
ovalFilter: PropTypes.string,
Expand Down
33 changes: 20 additions & 13 deletions gsa/src/web/pages/usersettings/filterpart.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ const filterFilters = (filters, type) =>
const FilterPart = ({
agentsFilter,
alertsFilter,
assetsFilter,
configsFilter,
credentialsFilter,
filtersFilter,
hostsFilter,
notesFilter,
operatingSystemsFilter,
overridesFilter,
permissionsFilter,
portListsFilter,
Expand Down Expand Up @@ -84,17 +85,6 @@ const FilterPart = ({
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Assets Filter')} titleSize="3">
<Select
name="assetsFilter"
value={assetsFilter}
items={renderSelectItems(
filterFilters(filters, 'asset'),
UNSET_VALUE,
)}
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Scan Configs Filter')} titleSize="3">
<Select
name="configsFilter"
Expand Down Expand Up @@ -128,6 +118,14 @@ const FilterPart = ({
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Hosts Filter')} titleSize="3">
<Select
name="hostsFilter"
value={hostsFilter}
items={renderSelectItems(filterFilters(filters, 'host'), UNSET_VALUE)}
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Notes Filter')} titleSize="3">
<Select
name="notesFilter"
Expand All @@ -136,6 +134,14 @@ const FilterPart = ({
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Operating Systems Filter')} titleSize="3">
<Select
name="operatingSystemsFilter"
value={operatingSystemsFilter}
items={renderSelectItems(filterFilters(filters, 'os'), UNSET_VALUE)}
onChange={onChange}
/>
</FormGroup>
<FormGroup title={_('Overrides Filter')} titleSize="3">
<Select
name="overridesFilter"
Expand Down Expand Up @@ -311,7 +317,6 @@ const FilterPart = ({
FilterPart.propTypes = {
agentsFilter: PropTypes.string,
alertsFilter: PropTypes.string,
assetsFilter: PropTypes.string,
certBundFilter: PropTypes.string,
configsFilter: PropTypes.string,
cpeFilter: PropTypes.string,
Expand All @@ -320,8 +325,10 @@ FilterPart.propTypes = {
dfnCertFilter: PropTypes.string,
filters: PropTypes.array,
filtersFilter: PropTypes.string,
hostsFilter: PropTypes.string,
notesFilter: PropTypes.string,
nvtFilter: PropTypes.string,
operatingSystemsFilter: PropTypes.string,
ovalFilter: PropTypes.string,
overridesFilter: PropTypes.string,
permissionsFilter: PropTypes.string,
Expand Down
35 changes: 24 additions & 11 deletions gsa/src/web/pages/usersettings/usersettingspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ class UserSettings extends React.Component {
defaultTarget = {},
agentsFilter = {},
alertsFilter = {},
assetsFilter = {},
configsFilter = {},
credentialsFilter = {},
filtersFilter = {},
hostsFilter = {},
notesFilter = {},
operatingSystemsFilter = {},
overridesFilter = {},
permissionsFilter = {},
portListsFilter = {},
Expand Down Expand Up @@ -566,11 +567,6 @@ class UserSettings extends React.Component {
title={_('Alerts Filter')}
type="filter"
/>
<SettingTableRow
setting={assetsFilter}
title={_('Assets Filter')}
type="filter"
/>
<SettingTableRow
setting={configsFilter}
title={_('Configs Filter')}
Expand All @@ -586,11 +582,21 @@ class UserSettings extends React.Component {
title={_('Filters Filter')}
type="filter"
/>
<SettingTableRow
setting={hostsFilter}
title={_('Hosts Filter')}
type="filter"
/>
<SettingTableRow
setting={notesFilter}
title={_('Notes Filter')}
type="filter"
/>
<SettingTableRow
setting={operatingSystemsFilter}
title={_('Operating Systems Filter')}
type="filter"
/>
<SettingTableRow
setting={overridesFilter}
title={_('Overrides Filter')}
Expand Down Expand Up @@ -730,11 +736,12 @@ class UserSettings extends React.Component {
defaultTarget={defaultTarget.id}
agentsFilter={agentsFilter.id}
alertsFilter={alertsFilter.id}
assetsFilter={assetsFilter.id}
configsFilter={configsFilter.id}
credentialsFilter={credentialsFilter.id}
filtersFilter={filtersFilter.id}
hostsFilter={hostsFilter.id}
notesFilter={notesFilter.id}
operatingSystemsFilter={operatingSystemsFilter.id}
overridesFilter={overridesFilter.id}
permissionsFilter={permissionsFilter.id}
portListsFilter={portListsFilter.id}
Expand Down Expand Up @@ -768,7 +775,6 @@ UserSettings.propTypes = {
agentsFilter: PropTypes.object,
alerts: PropTypes.array,
alertsFilter: PropTypes.object,
assetsFilter: PropTypes.object,
autoCacheRebuild: PropTypes.object,
capabilities: PropTypes.capabilities.isRequired,
certBundFilter: PropTypes.object,
Expand Down Expand Up @@ -797,6 +803,7 @@ UserSettings.propTypes = {
filters: PropTypes.array,
filtersFilter: PropTypes.object,
gmp: PropTypes.gmp.isRequired,
hostsFilter: PropTypes.object,
isLoading: PropTypes.bool,
listExportFileName: PropTypes.object,
loadAlerts: PropTypes.func.isRequired,
Expand All @@ -812,6 +819,7 @@ UserSettings.propTypes = {
maxRowsPerPage: PropTypes.object,
notesFilter: PropTypes.object,
nvtFilter: PropTypes.object,
operatingSystemsFilter: PropTypes.object,
ovalFilter: PropTypes.object,
overridesFilter: PropTypes.object,
permissionsFilter: PropTypes.object,
Expand Down Expand Up @@ -903,13 +911,16 @@ const mapStateToProps = rootState => {

const agentsFilterId = userDefaultsSelector.getValueByName('agentsfilter');
const alertsFilterId = userDefaultsSelector.getValueByName('alertsfilter');
const assetsFilterId = userDefaultsSelector.getValueByName('assetsfilter');
const hostsFilterId = userDefaultsSelector.getValueByName('hostsfilter');
const configsFilterId = userDefaultsSelector.getValueByName('configsfilter');
const credentialsFilterId = userDefaultsSelector.getValueByName(
'credentialsfilter',
);
const filtersFilterId = userDefaultsSelector.getValueByName('filtersfilter');
const notesFilterId = userDefaultsSelector.getValueByName('notesfilter');
const operatingSystemsFilterId = userDefaultsSelector.getValueByName(
'operatingsystemsfilter',
);
const overridesFilterId = userDefaultsSelector.getValueByName(
'overridesfilter',
);
Expand Down Expand Up @@ -977,11 +988,12 @@ const mapStateToProps = rootState => {
const defaultTarget = targetsSel.getEntity(defaultTargetId);
const agentsFilter = filtersSel.getEntity(agentsFilterId);
const alertsFilter = filtersSel.getEntity(alertsFilterId);
const assetsFilter = filtersSel.getEntity(assetsFilterId);
const configsFilter = filtersSel.getEntity(configsFilterId);
const credentialsFilter = filtersSel.getEntity(credentialsFilterId);
const filtersFilter = filtersSel.getEntity(filtersFilterId);
const hostsFilter = filtersSel.getEntity(hostsFilterId);
const notesFilter = filtersSel.getEntity(notesFilterId);
const operatingSystemsFilter = filtersSel.getEntity(operatingSystemsFilterId);
const overridesFilter = filtersSel.getEntity(overridesFilterId);
const permissionsFilter = filtersSel.getEntity(permissionsFilterId);
const portListsFilter = filtersSel.getEntity(portListsFilterId);
Expand Down Expand Up @@ -1042,11 +1054,12 @@ const mapStateToProps = rootState => {
defaultTarget,
agentsFilter,
alertsFilter,
assetsFilter,
configsFilter,
credentialsFilter,
filtersFilter,
hostsFilter,
notesFilter,
operatingSystemsFilter,
overridesFilter,
permissionsFilter,
portListsFilter,
Expand Down