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

Session handling #905

Merged
merged 15 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from 14 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
4 changes: 2 additions & 2 deletions gsa/src/gmp/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const parseCvssBaseVector = ({
};

export const parseCvssBaseFromVector = vector => {
if (!isDefined(vector)) {
if (!isDefined(vector) && vector.length > 0) {
return {};
}

Expand All @@ -288,7 +288,7 @@ export const parseCvssBaseFromVector = vector => {
let [metric, value] = currentvalue.split(':');

metric = metric.toLowerCase();
value = value.toLowerCase();
value = isDefined(value) ? value.toLowerCase() : '';

switch (metric) {
case 'av':
Expand Down
47 changes: 36 additions & 11 deletions gsa/src/web/pages/extras/cvsscalculatorpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import React from 'react';

import {connect} from 'react-redux';

import glamorous from 'glamorous';

import _ from 'gmp/locale';
Expand All @@ -35,21 +36,23 @@ import {
parseCvssBaseFromVector,
} from 'gmp/parser';

import SeverityBar from '../../components/bar/severitybar.js';
import SeverityBar from 'web/components/bar/severitybar';

import ManualIcon from '../../components/icon/manualicon.js';
import FormGroup from 'web/components/form/formgroup';
import Select from 'web/components/form/select';
import TextField from 'web/components/form/textfield';

import FormGroup from '../../components/form/formgroup.js';
import Select from '../../components/form/select.js';
import TextField from '../../components/form/textfield.js';
import ManualIcon from 'web/components/icon/manualicon';

import Section from '../../components/section/section.js';
import Layout from 'web/components/layout/layout';

import Layout from '../../components/layout/layout.js';
import Section from 'web/components/section/section';

import withGmp from '../../utils/withGmp.js';
import {renewSessionTimeout} from 'web/store/usersettings/actions';

import PropTypes from '../../utils/proptypes.js';
import compose from 'web/utils/compose';
import PropTypes from 'web/utils/proptypes';
import withGmp from 'web/utils/withGmp';

const StyledTextField = glamorous(TextField)({
width: '180px',
Expand Down Expand Up @@ -137,7 +140,16 @@ class CvssCalculator extends React.Component {
});
}

handleInteraction() {
const {onInteraction} = this.props;
if (isDefined(onInteraction)) {
onInteraction();
}
}

handleMetricsChange(value, name) {
this.handleInteraction();

this.calculateVector({[name]: value});
}

Expand All @@ -147,6 +159,9 @@ class CvssCalculator extends React.Component {

handleVectorChange() {
const {userVector} = this.state;

this.handleInteraction();

const cvssValues = parseCvssBaseFromVector(userVector);
const {
accessVector,
Expand Down Expand Up @@ -293,6 +308,16 @@ class CvssCalculator extends React.Component {

CvssCalculator.propTypes = {
gmp: PropTypes.gmp.isRequired,
onInteraction: PropTypes.func.isRequired,
};

export default withGmp(CvssCalculator);
const mapDispatchToProps = (dispatch, {gmp}) => ({
onInteraction: () => dispatch(renewSessionTimeout(gmp)()),
});

export default compose(
withGmp,
connect(undefined, mapDispatchToProps),
)(CvssCalculator);

// vim: set ts=2 sw=2 tw=80:
101 changes: 65 additions & 36 deletions gsa/src/web/pages/extras/trashcanpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,60 @@
*/
import React from 'react';

import {connect} from 'react-redux';

import {Col} from 'glamorous';

import _ from 'gmp/locale';

import {isDefined} from 'gmp/utils/identity';

import AlertsTable from '../alerts/table.js';
import AgentsTable from '../agents/table.js';
import ScanConfigsTable from '../scanconfigs/table.js';
import CredentialsTable from '../credentials/table.js';
import FiltersTable from '../filters/table.js';
import GroupsTable from '../groups/table.js';
import NotesTable from '../notes/table.js';
import OverridesTable from '../overrides/table.js';
import PermissionsTable from '../permissions/table.js';
import PortListsTable from '../portlists/table.js';
import ReportFormatsTable from '../reportformats/table.js';
import RolesTable from '../roles/table.js';
import ScannersTable from '../scanners/table.js';
import SchedulesTable from '../schedules/table.js';
import TagsTable from '../tags/table.js';
import TargetsTable from '../targets/table.js';
import TasksTable from '../tasks/table.js';
import Button from 'web/components/form/button';

import ManualIcon from 'web/components/icon/manualicon';

import Table from '../../components/table/stripedtable.js';
import TableBody from '../../components/table/body.js';
import TableData from '../../components/table/data.js';
import TableRow from '../../components/table/row.js';
import TableHead from '../../components/table/head.js';
import TableHeader from '../../components/table/header.js';
import Layout from 'web/components/layout/layout';

import Layout from '../../components/layout/layout.js';
import Section from '../../components/section/section.js';
import InnerLink from 'web/components/link/innerlink';
import LinkTarget from 'web/components/link/target';

import InnerLink from '../../components/link/innerlink.js';
import LinkTarget from '../../components/link/target.js';
import Loading from 'web/components/loading/loading';

import Button from '../../components/form/button.js';
import Section from 'web/components/section/section';

import ManualIcon from '../../components/icon/manualicon.js';
import Table from 'web/components/table/stripedtable';
import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import TableRow from 'web/components/table/row';
import TableHead from 'web/components/table/head';
import TableHeader from 'web/components/table/header';

import Loading from '../../components/loading/loading.js';
import {renewSessionTimeout} from 'web/store/usersettings/actions';

import PropTypes from '../../utils/proptypes.js';
import withCapabilities from '../../utils/withCapabilities.js';
import withGmp from '../../utils/withGmp.js';
import compose from 'web/utils/compose';
import PropTypes from 'web/utils/proptypes';
import withCapabilities from 'web/utils/withCapabilities';
import withGmp from 'web/utils/withGmp';

import TrashActions from './trashactions.js';
import AlertsTable from '../alerts/table';
import AgentsTable from '../agents/table';
import ScanConfigsTable from '../scanconfigs/table';
import CredentialsTable from '../credentials/table';
import FiltersTable from '../filters/table';
import GroupsTable from '../groups/table';
import NotesTable from '../notes/table';
import OverridesTable from '../overrides/table';
import PermissionsTable from '../permissions/table';
import PortListsTable from '../portlists/table';
import ReportFormatsTable from '../reportformats/table';
import RolesTable from '../roles/table';
import ScannersTable from '../scanners/table';
import SchedulesTable from '../schedules/table';
import TagsTable from '../tags/table';
import TargetsTable from '../targets/table';
import TasksTable from '../tasks/table';

import TrashActions from './trashactions';

const ToolBarIcons = () => (
<ManualIcon
Expand Down Expand Up @@ -110,7 +115,7 @@ class Trashcan extends React.Component {
}

componentDidMount() {
this.getTrash();
this.getTrash();
}

getTrash() {
Expand All @@ -122,18 +127,34 @@ class Trashcan extends React.Component {
return data;
}

handleInteraction() {
const {onInteraction} = this.props;
if (isDefined(onInteraction)) {
onInteraction();
}
}

handleRestore(entity) {
const {gmp} = this.props;

this.handleInteraction();

gmp.trashcan.restore(entity).then(this.getTrash);
}

handleDelete(entity) {
const {gmp} = this.props;

this.handleInteraction();

gmp.trashcan.delete(entity).then(this.getTrash);
}

handleEmpty() {
const {gmp} = this.props;

this.handleInteraction();

gmp.trashcan.empty().then(this.getTrash);
}

Expand Down Expand Up @@ -434,8 +455,16 @@ class Trashcan extends React.Component {

Trashcan.propTypes = {
gmp: PropTypes.gmp.isRequired,
onInteraction: PropTypes.func.isRequired,
};

export default withGmp(Trashcan);
const mapDispatchToProps = (dispatch, {gmp}) => ({
onInteraction: () => dispatch(renewSessionTimeout(gmp)()),
});

export default compose(
withGmp,
connect(undefined, mapDispatchToProps),
)(Trashcan);

// vim: set ts=2 sw=2 tw=80:
64 changes: 43 additions & 21 deletions gsa/src/web/pages/ldap/ldappage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,45 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import React from 'react';

import {connect} from 'react-redux';

import _ from 'gmp/locale';

import {YES_VALUE, NO_VALUE} from 'gmp/parser';

import {isDefined} from 'gmp/utils/identity';

import Button from '../../components/form/button.js';
import CheckBox from '../../components/form/checkbox.js';
import FileField from '../../components/form/filefield.js';
import FormGroup from '../../components/form/formgroup.js';
import TextField from '../../components/form/textfield.js';

import ManualIcon from '../../components/icon/manualicon.js';
import Button from 'web/components/form/button';
import CheckBox from 'web/components/form/checkbox';
import FileField from 'web/components/form/filefield';
import FormGroup from 'web/components/form/formgroup';
import TextField from 'web/components/form/textfield';

import Layout from '../../components/layout/layout.js';
import Section from '../../components/section/section.js';
import ManualIcon from 'web/components/icon/manualicon';

import Table from '../../components/table/simpletable.js';
import TableBody from '../../components/table/body.js';
import TableData from '../../components/table/data.js';
import TableRow from '../../components/table/row.js';
import Layout from 'web/components/layout/layout';
import Section from 'web/components/section/section';

import Loading from '../../components/loading/loading.js';
import Table from 'web/components/table/simpletable';
import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import TableRow from 'web/components/table/row';

import PropTypes from '../../utils/proptypes.js';
import Loading from 'web/components/loading/loading';

import withGmp from '../../utils/withGmp.js';
import {renewSessionTimeout} from 'web/store/usersettings/actions';

import compose from 'web/utils/compose';
import PropTypes from 'web/utils/proptypes';
import withGmp from 'web/utils/withGmp';

class LdapAuthentication extends React.Component {
constructor() {
super();

constructor(...args) {
super(...args);

this.state = {
authdn: '',
ldaphost: '',
Expand All @@ -74,7 +78,7 @@ class LdapAuthentication extends React.Component {

load() {
this.getLdapAuth()
.then(this.setState({loading: false}));
.then(this.setState({loading: false}));
}

getLdapAuth() {
Expand All @@ -94,6 +98,13 @@ class LdapAuthentication extends React.Component {
return auth_data;
}

handleInteraction() {
const {onInteraction} = this.props;
if (isDefined(onInteraction)) {
onInteraction();
}
}

handleSaveSettings() {
const {
authdn,
Expand All @@ -108,6 +119,9 @@ class LdapAuthentication extends React.Component {
ldaphost,
};
const {gmp} = this.props;

this.handleInteraction();

return gmp.auth.saveLdap(data);
}

Expand Down Expand Up @@ -235,8 +249,16 @@ class LdapAuthentication extends React.Component {

LdapAuthentication.propTypes = {
gmp: PropTypes.gmp.isRequired,
onInteraction: PropTypes.func.isRequired,
};

export default withGmp(LdapAuthentication);
const mapDispatchToProps = (dispatch, {gmp}) => ({
onInteraction: () => dispatch(renewSessionTimeout(gmp)()),
});

export default compose(
withGmp,
connect(undefined, mapDispatchToProps),
)(LdapAuthentication);

// vim: set ts=2 sw=2 tw=80:
Loading