Skip to content

Commit

Permalink
Merge pull request #1454 from saberlynx/nvt
Browse files Browse the repository at this point in the history
updated nvt vars to camelCase
  • Loading branch information
bjoernricks authored Jun 25, 2019
2 parents 471a8a1 + 4794d8f commit 9b5b9cb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
9 changes: 5 additions & 4 deletions gsa/src/gmp/models/__tests__/nvt.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('NVT model tests', () => {
test('should parse nvt_type', () => {
const nvt = new Nvt({_type: 'foo'});

expect(nvt.nvt_type).toEqual('foo');
expect(nvt.nvtType).toEqual('foo');
});

test('should parse tags', () => {
Expand Down Expand Up @@ -179,9 +179,10 @@ describe('NVT model tests', () => {
const nvt2 = new Nvt({default_timeout: ''});
const nvt3 = new Nvt({default_timeout: '123'});

expect(nvt1.default_timeout).toBeUndefined();
expect(nvt2.default_timeout).toBeUndefined();
expect(nvt3.default_timeout).toEqual(123);
expect(nvt1.defaultTimeout).toBeUndefined();
expect(nvt2.defaultTimeout).toBeUndefined();
expect(nvt3.defaultTimeout).toEqual(123);
expect(nvt3.default_timeout).toBeUndefined();
});

test('should parse timeout', () => {
Expand Down
15 changes: 8 additions & 7 deletions gsa/src/gmp/models/nvt.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ class Nvt extends Info {
parseProperties(elem) {
const ret = super.parseProperties(elem, 'nvt');

ret.nvt_type = elem._type;
ret.nvtType = elem._type;

ret.oid = ret._oid;
ret.id = ret.oid;
ret.tags = parse_tags(ret.tags);
ret.tags = parse_tags(elem.tags);

let refs = [];
if (isDefined(ret.refs) && isArray(ret.refs.ref)) {
if (isDefined(elem.refs) && isArray(elem.refs.ref)) {
refs = ret.refs.ref;
} else if (isDefined(ret.refs) && isDefined(ret.refs.ref)) {
} else if (isDefined(elem.refs) && isDefined(elem.refs.ref)) {
refs = [ret.refs.ref];
}

Expand All @@ -132,10 +132,10 @@ class Nvt extends Info {

delete ret.refs;

ret.severity = parseSeverity(ret.cvss_base);
ret.severity = parseSeverity(elem.cvss_base);
delete ret.cvss_base;

if (isDefined(ret.preferences)) {
if (isDefined(elem.preferences)) {
ret.preferences = map(ret.preferences.preference, preference => {
const pref = {...preference};
delete pref.nvt;
Expand All @@ -160,7 +160,8 @@ class Nvt extends Info {
if (isEmpty(elem.default_timeout)) {
delete ret.default_timeout;
} else {
ret.default_timeout = parseFloat(elem.default_timeout);
ret.defaultTimeout = parseFloat(elem.default_timeout);
delete ret.default_timeout;
}

if (isEmpty(elem.timeout)) {
Expand Down
4 changes: 2 additions & 2 deletions gsa/src/web/pages/nvts/detailspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const Page = ({
onInteraction,
...props
}) => {
const {default_timeout, preferences = [], userTags} = entity;
const {defaultTimeout, preferences = [], userTags} = entity;
const numPreferences = preferences.length;

return (
Expand Down Expand Up @@ -247,7 +247,7 @@ const Page = ({
<TabPanel>
<Preferences
preferences={preferences}
default_timeout={default_timeout}
defaultTimeout={defaultTimeout}
/>
</TabPanel>
<TabPanel>
Expand Down
6 changes: 3 additions & 3 deletions gsa/src/web/pages/nvts/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import TableHeader from 'web/components/table/header';
import TableHead from 'web/components/table/head';
import TableRow from 'web/components/table/row';

const Preferences = ({preferences = [], default_timeout}) => {
const Preferences = ({preferences = [], defaultTimeout}) => {
return (
<Table>
<TableHeader>
Expand All @@ -44,7 +44,7 @@ const Preferences = ({preferences = [], default_timeout}) => {
<TableRow>
<TableData>{_('Timeout')}</TableData>
<TableData>
{isDefined(default_timeout) ? default_timeout : _('default')}
{isDefined(defaultTimeout) ? defaultTimeout : _('default')}
</TableData>
</TableRow>
{preferences.map(pref => (
Expand All @@ -59,7 +59,7 @@ const Preferences = ({preferences = [], default_timeout}) => {
};

Preferences.propTypes = {
default_timeout: PropTypes.number,
defaultTimeout: PropTypes.number,
preferences: PropTypes.array,
};

Expand Down
4 changes: 2 additions & 2 deletions gsa/src/web/pages/scanconfigs/editconfigfamilydialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Nvt extends React.Component {
pref_count = '';
}

const {name, oid, severity, timeout, default_timeout} = nvt;
const {name, oid, severity, timeout, defaultTimeout} = nvt;
return (
<TableRow>
<TableData>{name}</TableData>
Expand All @@ -84,7 +84,7 @@ class Nvt extends React.Component {
</TableData>
<TableData>
{isEmpty(timeout) ? _('default') : timeout}
{isEmpty(default_timeout) ? '' : ' (' + default_timeout + ')'}
{isEmpty(defaultTimeout) ? '' : ' (' + defaultTimeout + ')'}
</TableData>
<TableData>{pref_count}</TableData>
<TableData align="center">
Expand Down
8 changes: 3 additions & 5 deletions gsa/src/web/pages/scanconfigs/editnvtdetailsdialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ class EditDialog extends React.Component {
/>
<span>
{_('Apply default timeout')}
{isDefined(nvt.default_timeout)
? ' (' + nvt.default_timeout + ')'
{isDefined(nvt.defaultTimeout)
? ' (' + nvt.defaultTimeout + ')'
: ''}
</span>
</Divider>
Expand All @@ -224,9 +224,7 @@ class EditDialog extends React.Component {
</Divider>
</TableData>
<TableData>
{isDefined(nvt.default_timeout)
? nvt.default_timeout
: ''}
{isDefined(nvt.defaultTimeout) ? nvt.defaultTimeout : ''}
</TableData>
</TableRow>
{nvt.preferences.map(pref => {
Expand Down

0 comments on commit 9b5b9cb

Please sign in to comment.