Skip to content

Commit

Permalink
Merge pull request #1284 from bjoernricks/delta-results-changed-diff
Browse files Browse the repository at this point in the history
Delta results changed diff
  • Loading branch information
swaterkamp authored Apr 15, 2019
2 parents f276249 + 61aeb52 commit 9089c68
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $ cd gsa && git checkout gsa-8.0 && git log

## gsa 8.0.1 (unreleased)

* Display current result, comparable result and diff between results for delta
reports and their results in delta state "changed" #1284
* Fix New Target dialog contains value from Edit Target #1281
* Fix opening alert report composer #1280 #1276
* Remove fifth from schedule #1279
Expand Down
22 changes: 21 additions & 1 deletion gsa/src/gmp/models/__tests__/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,27 @@ describe('Result model tests', () => {
const result = new Result(elem);

expect(result.delta).toBeInstanceOf(Delta);
expect(result.delta).toEqual({delta_type: 'foo'});
expect(result.delta.delta_type).toEqual('foo');
});

test('should parse changed delta object', () => {
const elem = {
delta: {
__text: Delta.TYPE_CHANGED,
diff: 'some foobar diff',
result: {
_id: 'r1',
description: 'some result description',
},
},
};
const result = new Result(elem);

expect(result.delta).toBeInstanceOf(Delta);
expect(result.delta.delta_type).toEqual(Delta.TYPE_CHANGED);
expect(result.delta.diff).toEqual('some foobar diff');
expect(result.delta.result).toBeInstanceOf(Model);
expect(result.delta.result.description).toEqual('some result description');
});

test('should parse original severity', () => {
Expand Down
2 changes: 2 additions & 0 deletions gsa/src/gmp/models/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class Delta {
this.delta_type = elem;
} else {
this.delta_type = elem.__text;
this.diff = elem.diff;
this.result = new Model(elem.result, 'result');
}
}
}
Expand Down
37 changes: 27 additions & 10 deletions gsa/src/web/pages/results/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,33 @@ const ResultDetails = ({className, links = true, entity}) => {
<P>{tags.summary}</P>
</DetailsBlock>

<DetailsBlock title={_('Detection Result')}>
{!isEmpty(result.description) && result.description.length > 1 ? (
<Pre>{result.description}</Pre>
) : (
_(
'Vulnerability was detected according to the ' +
'Detection Method.',
)
)}
</DetailsBlock>
{result.hasDelta() ? (
<DetailsBlock title={_('Detection Results')}>
<div>
<h3>Result 1</h3>
<Pre>{result.description}</Pre>
</div>
<div>
<h3>Result 2</h3>
<Pre>{result.delta.result.description}</Pre>
</div>
<div>
<h3>Different Lines</h3>
<Pre>{result.delta.diff}</Pre>
</div>
</DetailsBlock>
) : (
<DetailsBlock title={_('Detection Result')}>
{!isEmpty(result.description) && result.description.length > 1 ? (
<Pre>{result.description}</Pre>
) : (
_(
'Vulnerability was detected according to the ' +
'Detection Method.',
)
)}
</DetailsBlock>
)}

{has_detection && (
<DetailsBlock title={_('Product Detection Result')}>
Expand Down

0 comments on commit 9089c68

Please sign in to comment.