Skip to content

Commit

Permalink
Merge pull request #2977 from greenbone/mergify/bp/master/pr-2960
Browse files Browse the repository at this point in the history
Use deprecation tag in NVT details (backport #2960)
  • Loading branch information
swaterkamp authored Jun 8, 2021
2 parents fde55d3 + 25c719f commit e4ab2ce
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [21.04.1] - Unreleased

### Added
- Added isDeprecated() method to NVT model and use it in details [#2960](https://github.com/greenbone/gsa/pull/2960)
- Added @testing-library/user-event as a dev-dependency [#2891](https://github.com/greenbone/gsa/pull/2891)
- Set SameSite=strict for the session cookie to avoid CSRF [#2948](https://github.com/greenbone/gsa/pull/2948)

Expand Down
1 change: 1 addition & 0 deletions gsa/public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@
"There was an error (422) when trying to add one or more hosts to this process. This might occur if the name of the process has invalid characters. Please make sure you are only using a-z, A-Z and 0-9.": "Bei dem Versuch einen oder mehrere Hosts zu diesem Prozess hinzuzufügen ist ein Fehler (422) aufgetreten. Dies kann durch ungültige Zeichen im Prozessnamen verursacht werden. Bitte benutzen Sie möglichst nur a-z, A-Z und 0-9.",
"Third Party": "Drittanbieter",
"This CPE does not appear in the CPE dictionary but is referenced by one or more CVE.": "Diese CPE ist nicht im CPE-Dictionary, wird aber von einem oder mehreren CVE referenziert.",
"This NVT is deprecated.": "Dieser NVT ist veraltet.",
"This dialog will open a new window for {{- to}} if you click on \"follow link\". Following this link is on your own responsibility. Greenbone does not endorse the content you will see there.": "Dieser Dialog öffnet ein neues Fenster für {{-to}}, wenn Sie auf \"Link folgen\" klicken. Diesem Link zu folgen liegt in Ihrer Verantwortung. Greenbone hat keinen Einfluss auf den Inhalt, den Sie dort sehen werden.",
"This form received invalid values. Please check the inputs and submit again.": "Dieses Formular erhielt ungültige Werte. Bitte überprüfen Sie Ihre Eingaben und senden sie erneut ab.",
"This is an Alterable Audit. Reports may not relate to current Policy or Target!": "Dies ist ein änderbares Audit. Berichte könnten sich nicht auf die aktuelle Richtlinie oder das aktuelle Ziel beziehen!",
Expand Down
20 changes: 20 additions & 0 deletions gsa/src/gmp/models/__tests__/nvt.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,24 @@ describe('getFilteredRefIds tests', () => {
expect(refs.length).toEqual(2);
expect(refs).toEqual(['2', '4']);
});

describe('NVT model method tests', () => {
test('isDeprecated() returns correct true/false', () => {
const nvt1 = Nvt.fromElement({
tags: 'summary=foo|deprecated=1',
});
const nvt2 = Nvt.fromElement({
tags: 'summary=bar',
});
const nvt3 = Nvt.fromElement({
tags: 'summary=lorem|deprecated=0',
});
expect(nvt1.tags.summary).toEqual('foo');
expect(nvt1.isDeprecated()).toEqual(true);
expect(nvt2.tags.summary).toEqual('bar');
expect(nvt2.isDeprecated()).toEqual(false);
expect(nvt3.tags.summary).toEqual('lorem');
expect(nvt3.isDeprecated()).toEqual(false);
});
});
});
6 changes: 6 additions & 0 deletions gsa/src/gmp/models/nvt.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
parseSeverity,
parseScoreToSeverity,
parseText,
parseYesNo,
YES_VALUE,
} from 'gmp/parser';

import Info from './info';
Expand Down Expand Up @@ -220,6 +222,10 @@ class Nvt extends Info {

return ret;
}

isDeprecated() {
return parseYesNo(this.tags.deprecated) === YES_VALUE;
}
}

export default Nvt;
Expand Down
1 change: 1 addition & 0 deletions gsa/src/web/pages/nvts/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const NvtDetails = ({entity, links = true}) => {
} = entity;
return (
<Layout flex="column" grow="1">
{entity.isDeprecated() && <div>{_('This NVT is deprecated.')}</div>}
{isDefined(tags.summary) && (
<DetailsBlock title={_('Summary')}>
<Pre>{tags.summary}</Pre>
Expand Down

0 comments on commit e4ab2ce

Please sign in to comment.