]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16101 Adding new status for security hotspot
authorRevanshu Paliwal <revanshu.paliwal@sonarsource.com>
Mon, 7 Mar 2022 17:00:17 +0000 (18:00 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 10 Mar 2022 20:03:37 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/security-hotspots/components/FilterBar.tsx
server/sonar-web/src/main/js/apps/security-hotspots/components/StatusUpdateSuccessModal.tsx
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/FilterBar-test.tsx.snap
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/StatusUpdateSuccessModal-test.tsx.snap
server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx
server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/security-hotspots/utils.ts
server/sonar-web/src/main/js/types/security-hotspots.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 1c5ecea91421a2f4c969e9bc37a0796664312a54..720b7fd545497789c957c2a6f8fcee5848959335 100644 (file)
@@ -45,6 +45,10 @@ export interface FilterBarProps {
 
 const statusOptions: Array<{ label: string; value: string }> = [
   { value: HotspotStatusFilter.TO_REVIEW, label: translate('hotspot.filters.status.to_review') },
+  {
+    value: HotspotStatusFilter.ACKNOWLEDGED,
+    label: translate('hotspot.filters.status.acknowledged')
+  },
   { value: HotspotStatusFilter.FIXED, label: translate('hotspot.filters.status.fixed') },
   { value: HotspotStatusFilter.SAFE, label: translate('hotspot.filters.status.safe') }
 ];
index 5c1499578296725e0deacf639f3b4444b5af0c83..39b038eb624216865eb0adfef7a301e80a0e86d7 100644 (file)
@@ -17,7 +17,6 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import classNames from 'classnames';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { Button, ButtonLink } from '../../../components/controls/buttons';
@@ -48,26 +47,16 @@ export default function StatusUpdateSuccessModal(props: StatusUpdateSuccessModal
 
   return (
     <Modal contentLabel={modalTitle}>
-      <div className="modal-head">
-        <h2
-          className={classNames('huge text-normal', {
-            'text-success': closingHotspots
-          })}>
-          {modalTitle}
-        </h2>
+      <div className="modal-head huge text-center text-bold">
+        <p>{translateWithParameters('hotspots.successful_status_change_to_x', statusLabel)}</p>
       </div>
 
-      <div className="modal-body">
+      <div className="modal-body text-center big">
         <FormattedMessage
           id="hotspots.successfully_changed_to_x"
-          defaultMessage={translate('hotspots.successfully_changed_to_x')}
+          defaultMessage={translate('hotspots.find_in_status_filter_x')}
           values={{
-            status_label: statusLabel,
-            status_change: (
-              <strong>
-                {translateWithParameters('hotspots.successful_status_change_to_x', statusLabel)}
-              </strong>
-            )
+            status_label: <strong>{statusLabel}</strong>
           }}
         />
         {closingHotspots && (
@@ -93,7 +82,7 @@ export default function StatusUpdateSuccessModal(props: StatusUpdateSuccessModal
         <ButtonLink onClick={props.onSwitchFilterToStatusOfUpdatedHotspot}>
           {translateWithParameters('hotspots.see_x_hotspots', statusLabel)}
         </ButtonLink>
-        <Button className="button-primary padded" onClick={props.onClose}>
+        <Button className="button padded" onClick={props.onClose}>
           {translate('hotspots.continue_to_next_hotspot')}
         </Button>
       </div>
index 2332ce7de08ba1bb396a7922ab85702e018c5805..89dd27708424cfdacb5db2af649ddc3515ef1ef3 100644 (file)
@@ -59,6 +59,10 @@ exports[`should render correctly: anonymous 1`] = `
                   "label": "hotspot.filters.status.to_review",
                   "value": "TO_REVIEW",
                 },
+                Object {
+                  "label": "hotspot.filters.status.acknowledged",
+                  "value": "ACKNOWLEDGED",
+                },
                 Object {
                   "label": "hotspot.filters.status.fixed",
                   "value": "FIXED",
@@ -175,6 +179,10 @@ exports[`should render correctly: logged-in 1`] = `
                   "label": "hotspot.filters.status.to_review",
                   "value": "TO_REVIEW",
                 },
+                Object {
+                  "label": "hotspot.filters.status.acknowledged",
+                  "value": "ACKNOWLEDGED",
+                },
                 Object {
                   "label": "hotspot.filters.status.fixed",
                   "value": "FIXED",
@@ -291,6 +299,10 @@ exports[`should render correctly: non-project 1`] = `
                   "label": "hotspot.filters.status.to_review",
                   "value": "TO_REVIEW",
                 },
+                Object {
+                  "label": "hotspot.filters.status.acknowledged",
+                  "value": "ACKNOWLEDGED",
+                },
                 Object {
                   "label": "hotspot.filters.status.fixed",
                   "value": "FIXED",
@@ -366,6 +378,10 @@ exports[`should render correctly: on Pull request 1`] = `
                   "label": "hotspot.filters.status.to_review",
                   "value": "TO_REVIEW",
                 },
+                Object {
+                  "label": "hotspot.filters.status.acknowledged",
+                  "value": "ACKNOWLEDGED",
+                },
                 Object {
                   "label": "hotspot.filters.status.fixed",
                   "value": "FIXED",
@@ -444,6 +460,10 @@ exports[`should render correctly: with hotspots reviewed measure 1`] = `
                   "label": "hotspot.filters.status.to_review",
                   "value": "TO_REVIEW",
                 },
+                Object {
+                  "label": "hotspot.filters.status.acknowledged",
+                  "value": "ACKNOWLEDGED",
+                },
                 Object {
                   "label": "hotspot.filters.status.fixed",
                   "value": "FIXED",
index f6f4cc4189a8ab7d3cdbe737f9b532fe00ef113f..3fedbef7b09e3d06c7eb3855296a9fc5407cd1c0 100644 (file)
@@ -5,26 +5,23 @@ exports[`should render correctly: default 1`] = `
   contentLabel="hotspots.congratulations"
 >
   <div
-    className="modal-head"
+    className="modal-head huge text-center text-bold"
   >
-    <h2
-      className="huge text-normal text-success"
-    >
-      hotspots.congratulations
-    </h2>
+    <p>
+      hotspots.successful_status_change_to_x.hotspots.status_option.FIXED
+    </p>
   </div>
   <div
-    className="modal-body"
+    className="modal-body text-center big"
   >
     <FormattedMessage
-      defaultMessage="hotspots.successfully_changed_to_x"
+      defaultMessage="hotspots.find_in_status_filter_x"
       id="hotspots.successfully_changed_to_x"
       values={
         Object {
-          "status_change": <strong>
-            hotspots.successful_status_change_to_x.hotspots.status_option.FIXED
+          "status_label": <strong>
+            hotspots.status_option.FIXED
           </strong>,
-          "status_label": "hotspots.status_option.FIXED",
         }
       }
     />
@@ -53,7 +50,7 @@ exports[`should render correctly: default 1`] = `
       hotspots.see_x_hotspots.hotspots.status_option.FIXED
     </ButtonLink>
     <Button
-      className="button-primary padded"
+      className="button padded"
       onClick={[MockFunction]}
     >
       hotspots.continue_to_next_hotspot
@@ -67,26 +64,23 @@ exports[`should render correctly: opening hotspots again 1`] = `
   contentLabel="hotspots.update.success"
 >
   <div
-    className="modal-head"
+    className="modal-head huge text-center text-bold"
   >
-    <h2
-      className="huge text-normal"
-    >
-      hotspots.update.success
-    </h2>
+    <p>
+      hotspots.successful_status_change_to_x.hotspots.status_option.TO_REVIEW
+    </p>
   </div>
   <div
-    className="modal-body"
+    className="modal-body text-center big"
   >
     <FormattedMessage
-      defaultMessage="hotspots.successfully_changed_to_x"
+      defaultMessage="hotspots.find_in_status_filter_x"
       id="hotspots.successfully_changed_to_x"
       values={
         Object {
-          "status_change": <strong>
-            hotspots.successful_status_change_to_x.hotspots.status_option.TO_REVIEW
+          "status_label": <strong>
+            hotspots.status_option.TO_REVIEW
           </strong>,
-          "status_label": "hotspots.status_option.TO_REVIEW",
         }
       }
     />
@@ -100,7 +94,7 @@ exports[`should render correctly: opening hotspots again 1`] = `
       hotspots.see_x_hotspots.hotspots.status_option.TO_REVIEW
     </ButtonLink>
     <Button
-      className="button-primary padded"
+      className="button padded"
       onClick={[MockFunction]}
     >
       hotspots.continue_to_next_hotspot
index 66e9c7f26300f297ad016f425dde47d37e931dd4..e9af5ed7f5ebc852aa592c29cb218560007f8797 100644 (file)
@@ -57,6 +57,7 @@ export default function StatusSelectionRenderer(props: StatusSelectionRendererPr
     <div className="abs-width-400">
       <div className="big-padded">
         {renderOption(HotspotStatusOption.TO_REVIEW)}
+        {renderOption(HotspotStatusOption.ACKNOWLEDGED)}
         {renderOption(HotspotStatusOption.FIXED)}
         {renderOption(HotspotStatusOption.SAFE)}
       </div>
index 7d0722dd8351a68d201ec1f8cf9cb67dafa651c2..0f1f287ca7709014a85e0d304e8c0b7765a8addd 100644 (file)
@@ -17,6 +17,16 @@ exports[`should render correctly 1`] = `
         statusOption="TO_REVIEW"
       />
     </Radio>
+    <Radio
+      checked={false}
+      className="big-spacer-bottom"
+      onCheck={[MockFunction]}
+      value="ACKNOWLEDGED"
+    >
+      <StatusDescription
+        statusOption="ACKNOWLEDGED"
+      />
+    </Radio>
     <Radio
       checked={false}
       className="big-spacer-bottom"
@@ -87,6 +97,16 @@ exports[`should render correctly: loading 1`] = `
         statusOption="TO_REVIEW"
       />
     </Radio>
+    <Radio
+      checked={false}
+      className="big-spacer-bottom"
+      onCheck={[MockFunction]}
+      value="ACKNOWLEDGED"
+    >
+      <StatusDescription
+        statusOption="ACKNOWLEDGED"
+      />
+    </Radio>
     <Radio
       checked={false}
       className="big-spacer-bottom"
index cdcdd8cae4558a2ed9fd4c9cec8d49a5f96f51f6..ca95c09599074f6e82c32c9378c943ce0759017d 100644 (file)
@@ -157,6 +157,7 @@ export function getHotspotReviewHistory(hotspot: Hotspot): ReviewHistoryElement[
 const STATUS_AND_RESOLUTION_TO_STATUS_OPTION = {
   [HotspotStatus.TO_REVIEW]: HotspotStatusOption.TO_REVIEW,
   [HotspotStatus.REVIEWED]: HotspotStatusOption.FIXED,
+  [HotspotResolution.ACKNOWLEDGED]: HotspotStatusOption.ACKNOWLEDGED,
   [HotspotResolution.FIXED]: HotspotStatusOption.FIXED,
   [HotspotResolution.SAFE]: HotspotStatusOption.SAFE
 };
@@ -172,6 +173,10 @@ export function getStatusOptionFromStatusAndResolution(
 
 const STATUS_OPTION_TO_STATUS_AND_RESOLUTION_MAP = {
   [HotspotStatusOption.TO_REVIEW]: { status: HotspotStatus.TO_REVIEW, resolution: undefined },
+  [HotspotStatusOption.ACKNOWLEDGED]: {
+    status: HotspotStatus.REVIEWED,
+    resolution: HotspotResolution.ACKNOWLEDGED
+  },
   [HotspotStatusOption.FIXED]: {
     status: HotspotStatus.REVIEWED,
     resolution: HotspotResolution.FIXED
@@ -188,6 +193,7 @@ export function getStatusAndResolutionFromStatusOption(statusOption: HotspotStat
 
 const STATUS_OPTION_TO_STATUS_FILTER = {
   [HotspotStatusOption.TO_REVIEW]: HotspotStatusFilter.TO_REVIEW,
+  [HotspotStatusOption.ACKNOWLEDGED]: HotspotStatusFilter.ACKNOWLEDGED,
   [HotspotStatusOption.FIXED]: HotspotStatusFilter.FIXED,
   [HotspotStatusOption.SAFE]: HotspotStatusFilter.SAFE
 };
index 8d0a15fcde0b0964834f017bf110c3ccb94365c2..6dfa65c923bb8576682c20b698d4e1d113008a4e 100644 (file)
@@ -40,19 +40,22 @@ export enum HotspotStatus {
 
 export enum HotspotResolution {
   FIXED = 'FIXED',
-  SAFE = 'SAFE'
+  SAFE = 'SAFE',
+  ACKNOWLEDGED = 'ACKNOWLEDGED'
 }
 
 export enum HotspotStatusFilter {
   FIXED = 'FIXED',
   SAFE = 'SAFE',
-  TO_REVIEW = 'TO_REVIEW'
+  TO_REVIEW = 'TO_REVIEW',
+  ACKNOWLEDGED = 'ACKNOWLEDGED'
 }
 
 export enum HotspotStatusOption {
   FIXED = 'FIXED',
   SAFE = 'SAFE',
-  TO_REVIEW = 'TO_REVIEW'
+  TO_REVIEW = 'TO_REVIEW',
+  ACKNOWLEDGED = 'ACKNOWLEDGED'
 }
 
 export interface HotspotFilters {
index 4653f0ec0f764ec87b4ef665167b4f69c99d1666..a2ce05c61bce1621210afdcae2b87bf2ee92c8db 100644 (file)
@@ -731,6 +731,7 @@ hotspots.no_hotspots_for_keys.description=They have been closed because the code
 hotspots.learn_more=Learn more about Security Hotspots
 hotspots.list_title={0} Security Hotspots
 hotspots.list_title.TO_REVIEW={0} Security Hotspots to review
+hotspots.list_title.ACKNOWLEDGED={0} Security Hotspots reviewed as acknowledged
 hotspots.list_title.FIXED={0} Security Hotspots reviewed as fixed
 hotspots.list_title.SAFE={0} Security Hotspots reviewed as safe
 hotspots.risk_exposure=Review priority
@@ -754,32 +755,35 @@ hotspots.status.select_status=Change status
 hotspots.status.add_comment=Add a comment (Optional)
 hotspots.status.change_status=Change status
 hotspots.status_option.TO_REVIEW=To review
-hotspots.status_option.TO_REVIEW.description=This Security Hotspot needs to be reviewed to assess whether the code poses a risk.
+hotspots.status_option.TO_REVIEW.description=This security hotspot needs to be reviewed to assess whether the code poses a risk.
+hotspots.status_option.ACKNOWLEDGED=Acknowledged
+hotspots.status_option.ACKNOWLEDGED.description=The code has been reviewed and does pose a risk. A fix is required.
 hotspots.status_option.FIXED=Fixed
-hotspots.status_option.FIXED.description=The code has been modified to follow recommended secure coding practices.
+hotspots.status_option.FIXED.description=The code has been reviewed and modified to follow the recommended secure coding practices.
 hotspots.status_option.SAFE=Safe
-hotspots.status_option.SAFE.description=The code is not at risk and doesn't need to be modified.
+hotspots.status_option.SAFE.description=The code has been reviewed and does not pose a risk. It does not need to be modified.
 hotspots.get_permalink=Get Permalink
 hotspots.no_associated_lines=Security Hotspot raised on the following file:
 hotspots.congratulations=Congratulations!
-hotspots.successfully_changed_to_x=The Security Hotspot was {status_change}. You can find it by changing the top filter to display "{status_label}" Security Hotspots.
-hotspots.successful_status_change_to_x=successfully changed to "{0}"
+hotspots.find_in_status_filter_x= You can find it again by setting status filter to {status_label}.
+hotspots.successful_status_change_to_x=The Security Hotspot was successfully changed to {0}.
 hotspots.x_done_keep_going={percentage} of the Security Hotspots have been reviewed, keep going!
 hotspots.see_x_hotspots=See "{0}" Security Hotspots
-hotspots.continue_to_next_hotspot=Continue reviewing next Security Hotspot
+hotspots.continue_to_next_hotspot=Continue Reviewing
 
 hotspot.filters.title=Filters
 hotspot.filters.assignee.assigned_to_me=Assigned to me
 hotspot.filters.assignee.all=All
 hotspot.filters.status.to_review=To review
-hotspot.filters.status.fixed=Reviewed as fixed
+hotspot.filters.status.acknowledged=Acknowledged
+hotspot.filters.status.fixed=Fixed
 hotspot.filters.period.since_leak_period=New code
 hotspot.filters.period.overall=Overall code
-hotspot.filters.status.safe=Reviewed as safe
+hotspot.filters.status.safe=Safe
 hotspot.filters.show_all=Show all hotspots
 hotspot.section.activity=Recent activity:
 
-hotspots.reviewed.tooltip=Percentage of Security Hotspots reviewed (fixed or safe) among all non-closed Security Hotspots.
+hotspots.reviewed.tooltip=Percentage of Security Hotspots reviewed (Acknowledged, Fixed or Safe) among all non-closed Security Hotspots.
 hotspots.review_hotspot=Review Hotspot
 
 hotspots.assign.success=Security Hotspot was successfully assigned to {0}