From 0d216b24517df1d7bce3d4d50615fa1544c0cd9a Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 17 Dec 2019 18:46:51 +0100 Subject: [PATCH] SONAR-12719 Update list when hotspot status is changed --- .../securityHotspots/SecurityHotspotsApp.tsx | 20 +++++++++++++- .../SecurityHotspotsAppRenderer.tsx | 4 ++- .../__tests__/SecurityHotspotsApp-test.tsx | 26 +++++++++++++++++++ .../SecurityHotspotsAppRenderer-test.tsx | 1 + .../SecurityHotspotsApp-test.tsx.snap | 1 + .../SecurityHotspotsAppRenderer-test.tsx.snap | 17 ++++++------ .../components/HotspotActions.tsx | 10 ++++++- .../components/HotspotActionsForm.tsx | 9 ++++--- .../components/HotspotViewer.tsx | 12 ++++++++- .../components/HotspotViewerRenderer.tsx | 7 +++-- .../__tests__/HotspotActions-test.tsx | 2 +- .../__tests__/HotspotActionsForm-test.tsx | 1 - .../__tests__/HotspotViewer-test.tsx | 1 + .../__tests__/HotspotViewerRenderer-test.tsx | 1 + .../HotspotCategory-test.tsx.snap | 12 ++++----- .../__snapshots__/HotspotList-test.tsx.snap | 20 +++++++------- .../HotspotListItem-test.tsx.snap | 4 +-- .../__snapshots__/HotspotViewer-test.tsx.snap | 2 ++ .../HotspotViewerRenderer-test.tsx.snap | 1 + .../js/helpers/mocks/security-hotspots.ts | 5 ++-- .../src/main/js/types/security-hotspots.ts | 13 ++++++++-- 21 files changed, 127 insertions(+), 42 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx index e1d9e8a17fd..78d3ddf7d53 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx @@ -22,7 +22,7 @@ import { addNoFooterPageClass, removeNoFooterPageClass } from 'sonar-ui-common/h import { getSecurityHotspots } from '../../api/security-hotspots'; import { getStandards } from '../../helpers/security-standard'; import { BranchLike } from '../../types/branch-like'; -import { RawHotspot } from '../../types/security-hotspots'; +import { HotspotUpdate, RawHotspot } from '../../types/security-hotspots'; import SecurityHotspotsAppRenderer from './SecurityHotspotsAppRenderer'; import './styles.css'; import { sortHotspots } from './utils'; @@ -95,6 +95,23 @@ export default class SecurityHotspotsApp extends React.PureComponent this.setState({ selectedHotspotKey: key }); + handleHotspotUpdate = ({ key, status, resolution }: HotspotUpdate) => { + this.setState(({ hotspots }) => { + const index = hotspots.findIndex(h => h.key === key); + + if (index > -1) { + const hotspot = { + ...hotspots[index], + status, + resolution + }; + + return { hotspots: [...hotspots.slice(0, index), hotspot, ...hotspots.slice(index + 1)] }; + } + return null; + }); + }; + render() { const { branchLike } = this.props; const { hotspots, loading, securityCategories, selectedHotspotKey } = this.state; @@ -105,6 +122,7 @@ export default class SecurityHotspotsApp extends React.PureComponent diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsAppRenderer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsAppRenderer.tsx index 59caa829c27..9ba9dc43870 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsAppRenderer.tsx @@ -27,7 +27,7 @@ import A11ySkipTarget from '../../app/components/a11y/A11ySkipTarget'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import ScreenPositionHelper from '../../components/common/ScreenPositionHelper'; import { BranchLike } from '../../types/branch-like'; -import { RawHotspot } from '../../types/security-hotspots'; +import { HotspotUpdate, RawHotspot } from '../../types/security-hotspots'; import FilterBar from './components/FilterBar'; import HotspotList from './components/HotspotList'; import HotspotViewer from './components/HotspotViewer'; @@ -38,6 +38,7 @@ export interface SecurityHotspotsAppRendererProps { hotspots: RawHotspot[]; loading: boolean; onHotspotClick: (key: string) => void; + onUpdateHotspot: (hotspot: HotspotUpdate) => void; selectedHotspotKey?: string; securityCategories: T.StandardSecurityCategories; } @@ -91,6 +92,7 @@ export default function SecurityHotspotsAppRenderer(props: SecurityHotspotsAppRe )} diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx index b813bc82417..1b43fe4cfcc 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx @@ -26,7 +26,9 @@ import { mockMainBranch } from '../../../helpers/mocks/branch-like'; import { mockRawHotspot } from '../../../helpers/mocks/security-hotspots'; import { getStandards } from '../../../helpers/security-standard'; import { mockComponent } from '../../../helpers/testMocks'; +import { HotspotResolution, HotspotStatus } from '../../../types/security-hotspots'; import SecurityHotspotsApp from '../SecurityHotspotsApp'; +import SecurityHotspotsAppRenderer from '../SecurityHotspotsAppRenderer'; jest.mock('sonar-ui-common/helpers/pages', () => ({ addNoFooterPageClass: jest.fn(), @@ -72,6 +74,30 @@ it('should load data correctly', async () => { expect(wrapper.state()); }); +it('should handle hotspot update', async () => { + const key = 'hotspotKey'; + const hotspots = [mockRawHotspot(), mockRawHotspot({ key })]; + (getSecurityHotspots as jest.Mock).mockResolvedValue({ + hotspots + }); + + const wrapper = shallowRender(); + + await waitAndUpdate(wrapper); + + wrapper + .find(SecurityHotspotsAppRenderer) + .props() + .onUpdateHotspot({ key, status: HotspotStatus.REVIEWED, resolution: HotspotResolution.SAFE }); + + expect(wrapper.state().hotspots[0]).toEqual(hotspots[0]); + expect(wrapper.state().hotspots[1]).toEqual({ + ...hotspots[1], + status: HotspotStatus.REVIEWED, + resolution: HotspotResolution.SAFE + }); +}); + function shallowRender(props: Partial = {}) { return shallow( diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx index 8d7db84876b..c46274751bf 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx @@ -54,6 +54,7 @@ function shallowRender(props: Partial = {}) { hotspots={[]} loading={false} onHotspotClick={jest.fn()} + onUpdateHotspot={jest.fn()} securityCategories={{}} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsApp-test.tsx.snap index 6ad55141e38..56682f1ba2e 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsApp-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsApp-test.tsx.snap @@ -13,6 +13,7 @@ exports[`should render correctly 1`] = ` hotspots={Array []} loading={true} onHotspotClick={[Function]} + onUpdateHotspot={[Function]} securityCategories={Object {}} /> `; diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap index f73832adf08..4df9e59c2e9 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap @@ -118,10 +118,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -133,10 +133,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -198,10 +198,10 @@ exports[`should render correctly with hotspots 2`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -213,10 +213,10 @@ exports[`should render correctly with hotspots 2`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -232,6 +232,7 @@ exports[`should render correctly with hotspots 2`] = ` > diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx index 9f40f72c4d1..2a59969b48f 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx @@ -24,10 +24,12 @@ import OutsideClickHandler from 'sonar-ui-common/components/controls/OutsideClic import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon'; import { PopupPlacement } from 'sonar-ui-common/components/ui/popups'; import { translate } from 'sonar-ui-common/helpers/l10n'; +import { HotspotUpdateFields } from '../../../types/security-hotspots'; import HotspotActionsForm from './HotspotActionsForm'; export interface HotspotActionsProps { hotspotKey: string; + onSubmit: (hotspot: HotspotUpdateFields) => void; } const ESCAPE_KEY = 'Escape'; @@ -59,7 +61,13 @@ export default function HotspotActions(props: HotspotActionsProps) { {open && ( setOpen(false)}> - setOpen(false)} /> + { + setOpen(false); + props.onSubmit(data); + }} + /> )} diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx index e34a2ad1acc..97713831d4c 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx @@ -23,13 +23,14 @@ import { HotspotResolution, HotspotSetStatusRequest, HotspotStatus, - HotspotStatusOptions + HotspotStatusOptions, + HotspotUpdateFields } from '../../../types/security-hotspots'; import HotspotActionsFormRenderer from './HotspotActionsFormRenderer'; interface Props { hotspotKey: string; - onSubmit: () => void; + onSubmit: (data: HotspotUpdateFields) => void; } interface State { @@ -65,9 +66,9 @@ export default class HotspotActionsForm extends React.Component { this.setState({ submitting: true }); return setSecurityHotspotStatus(data) .then(() => { - this.props.onSubmit(); + this.props.onSubmit({ status, resolution: data.resolution }); }) - .finally(() => { + .catch(() => { this.setState({ submitting: false }); }); }; diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx index 9ca28887e07..b61510d9ad8 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx @@ -21,12 +21,17 @@ import * as React from 'react'; import { getSecurityHotspotDetails } from '../../../api/security-hotspots'; import { BranchLike } from '../../../types/branch-like'; -import { DetailedHotspot } from '../../../types/security-hotspots'; +import { + DetailedHotspot, + HotspotUpdate, + HotspotUpdateFields +} from '../../../types/security-hotspots'; import HotspotViewerRenderer from './HotspotViewerRenderer'; interface Props { branchLike?: BranchLike; hotspotKey: string; + onUpdateHotspot: (hotspot: HotspotUpdate) => void; securityCategories: T.StandardSecurityCategories; } @@ -60,6 +65,10 @@ export default class HotspotViewer extends React.PureComponent { .finally(() => this.mounted && this.setState({ loading: false })); } + handleHotspotUpdate = (data: HotspotUpdateFields) => { + this.props.onUpdateHotspot({ key: this.props.hotspotKey, ...data }); + }; + render() { const { branchLike, securityCategories } = this.props; const { hotspot, loading } = this.state; @@ -69,6 +78,7 @@ export default class HotspotViewer extends React.PureComponent { branchLike={branchLike} hotspot={hotspot} loading={loading} + onUpdateHotspot={this.handleHotspotUpdate} securityCategories={securityCategories} /> ); diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx index 18cdf29c91b..163693de895 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx @@ -23,7 +23,7 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; import { isLoggedIn } from '../../../helpers/users'; import { BranchLike } from '../../../types/branch-like'; -import { DetailedHotspot } from '../../../types/security-hotspots'; +import { DetailedHotspot, HotspotUpdateFields } from '../../../types/security-hotspots'; import HotspotActions from './HotspotActions'; import HotspotSnippetContainer from './HotspotSnippetContainer'; import HotspotViewerTabs from './HotspotViewerTabs'; @@ -33,6 +33,7 @@ export interface HotspotViewerRendererProps { currentUser: T.CurrentUser; hotspot?: DetailedHotspot; loading: boolean; + onUpdateHotspot: (hotspot: HotspotUpdateFields) => void; securityCategories: T.StandardSecurityCategories; } @@ -46,7 +47,9 @@ export function HotspotViewerRenderer(props: HotspotViewerRendererProps) {

{hotspot.message}

- {isLoggedIn(currentUser) && } + {isLoggedIn(currentUser) && ( + + )}
{translate('hotspot.category')} diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx index 7f6f2387fc9..aa92a004488 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx @@ -66,5 +66,5 @@ it('should register an eventlistener', () => { }); function shallowRender(props: Partial = {}) { - return shallow(); + return shallow(); } diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActionsForm-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActionsForm-test.tsx index a19f3f27bfd..b4add87f98c 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActionsForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActionsForm-test.tsx @@ -55,7 +55,6 @@ it('should handle submit', async () => { expect(wrapper.state().submitting).toBe(true); await promise; - expect(wrapper.state().submitting).toBe(false); expect(setSecurityHotspotStatus).toBeCalledWith({ hotspot: 'key', status: HotspotStatus.TO_REVIEW diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewer-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewer-test.tsx index 380d91bd3cc..01e8029eee0 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewer-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewer-test.tsx @@ -49,6 +49,7 @@ function shallowRender(props?: Partial) { return shallow( diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewerRenderer-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewerRenderer-test.tsx index 70eaf778cd8..84025073a89 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewerRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotViewerRenderer-test.tsx @@ -40,6 +40,7 @@ function shallowRender(props?: Partial) { currentUser={mockCurrentUser()} hotspot={mockDetailledHotspot()} loading={false} + onUpdateHotspot={jest.fn()} securityCategories={{ 'sql-injection': { title: 'SQL injection' } }} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap index 3f07388c5ad..dfde95a28d3 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap @@ -67,10 +67,10 @@ exports[`should handle collapse and expand 2`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", } @@ -124,10 +124,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", } @@ -149,10 +149,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "command-injection", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", } diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap index 68c4b07fa9b..f222cf6e39e 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap @@ -67,10 +67,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "cat1", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -101,10 +101,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "cat2", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "HIGH", }, @@ -154,10 +154,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "cat1", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "MEDIUM", }, @@ -169,10 +169,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "cat1", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "MEDIUM", }, @@ -203,10 +203,10 @@ exports[`should render correctly with hotspots 1`] = ` "line": 81, "message": "'3' is a magic number.", "project": "com.github.kevinsawicki:http-request", - "resolution": "FALSE-POSITIVE", + "resolution": undefined, "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "securityCategory": "cat2", - "status": "RESOLVED", + "status": "TO_REVIEW", "updateDate": "2013-05-13T17:55:39+0200", "vulnerabilityProbability": "MEDIUM", }, diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotListItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotListItem-test.tsx.snap index 457deefac03..7df6dbe4ac5 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotListItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotListItem-test.tsx.snap @@ -14,7 +14,7 @@ exports[`should render correctly 1`] = `
- issue.status.RESOLVED + issue.status.TO_REVIEW
`; @@ -33,7 +33,7 @@ exports[`should render correctly 2`] = `
- issue.status.RESOLVED + issue.status.TO_REVIEW
`; diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewer-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewer-test.tsx.snap index 39de7c9e177..c9bd0adb0ab 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewer-test.tsx.snap @@ -3,6 +3,7 @@ exports[`should render correctly 1`] = `
= {}): RawHotspot component: 'com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest', project: 'com.github.kevinsawicki:http-request', rule: 'checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck', - status: 'RESOLVED', - resolution: 'FALSE-POSITIVE', + status: HotspotStatus.TO_REVIEW, + resolution: undefined, securityCategory: 'command-injection', vulnerabilityProbability: RiskExposure.HIGH, message: "'3' is a magic number.", diff --git a/server/sonar-web/src/main/js/types/security-hotspots.ts b/server/sonar-web/src/main/js/types/security-hotspots.ts index cabf1267559..13b8a12bb01 100644 --- a/server/sonar-web/src/main/js/types/security-hotspots.ts +++ b/server/sonar-web/src/main/js/types/security-hotspots.ts @@ -48,7 +48,7 @@ export interface RawHotspot { line?: number; message: string; project: string; - resolution: string; + resolution?: string; rule: string; securityCategory: string; status: string; @@ -66,13 +66,22 @@ export interface DetailedHotspot { line?: number; message: string; project: T.Component; - resolution: string; + resolution?: string; rule: DetailedHotspotRule; status: string; textRange: T.TextRange; updateDate: string; } +export interface HotspotUpdateFields { + status: HotspotStatus; + resolution?: HotspotResolution; +} + +export interface HotspotUpdate extends HotspotUpdateFields { + key: string; +} + export interface DetailedHotspotRule { fixRecommendations?: string; key: string; -- 2.39.5