From 43af64decffceecfbb81d712667412e5935445fd Mon Sep 17 00:00:00 2001 From: David Cho-Lerat Date: Mon, 25 Nov 2024 11:58:43 +0100 Subject: SONAR-23741 Backport fixes for SSF-656 & SSF-657 --- .../components/ActivationFormModal.tsx | 14 +++-- .../components/CustomRuleFormModal.tsx | 14 +++-- .../components/RuleDetailsDescription.tsx | 44 ++++++++------- .../components/RuleDetailsParameters.tsx | 15 +++-- .../ActivationFormModal-test.tsx.snap | 64 +++++++++++----------- .../CustomRuleFormModal-test.tsx.snap | 32 +++++------ .../RuleDetailsParameters-test.tsx.snap | 26 ++++----- 7 files changed, 111 insertions(+), 98 deletions(-) (limited to 'server/sonar-web/src/main/js/apps/coding-rules') diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx index 70851441576..531c0162257 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx @@ -17,6 +17,7 @@ * 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 { OptionTypeBase } from 'react-select'; @@ -26,7 +27,7 @@ import Modal from '../../../components/controls/Modal'; import Select from '../../../components/controls/Select'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; -import { sanitizeString } from '../../../helpers/sanitize'; +import { SafeHTMLInjection, SanitizeLevel } from '../../../helpers/sanitize'; import { Dict, Rule, RuleActivation, RuleDetails } from '../../../types/types'; import { sortProfiles } from '../../quality-profiles/utils'; import { SeveritySelect } from './SeveritySelect'; @@ -218,11 +219,12 @@ export default class ActivationFormModal extends React.PureComponent )} {param.htmlDesc !== undefined && ( -
+ +
+ )}
)) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx index 57c8f242761..55d67cebfad 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + import * as React from 'react'; import { components, OptionProps, OptionTypeBase, SingleValueProps } from 'react-select'; import { createRule, updateRule } from '../../../api/rules'; @@ -31,7 +32,7 @@ import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsEx import { RULE_STATUSES, RULE_TYPES } from '../../../helpers/constants'; import { csvEscape } from '../../../helpers/csv'; import { translate } from '../../../helpers/l10n'; -import { sanitizeString } from '../../../helpers/sanitize'; +import { SafeHTMLInjection, SanitizeLevel } from '../../../helpers/sanitize'; import { latinize } from '../../../helpers/strings'; import { Dict, RuleDetails, RuleParameter } from '../../../types/types'; import { SeveritySelect } from './SeveritySelect'; @@ -317,11 +318,12 @@ export default class CustomRuleFormModal extends React.PureComponent )} {param.htmlDesc !== undefined && ( -
+ +
+ )}
); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx index a7fd2cb2c89..8fe97276bc6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx @@ -17,13 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + import * as React from 'react'; import { updateRule } from '../../../api/rules'; import FormattingTips from '../../../components/common/FormattingTips'; import { Button, ResetButtonLink } from '../../../components/controls/buttons'; import RuleTabViewer from '../../../components/rules/RuleTabViewer'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { sanitizeString, sanitizeUserInput } from '../../../helpers/sanitize'; +import { SafeHTMLInjection, SanitizeLevel } from '../../../helpers/sanitize'; import { RuleDetails } from '../../../types/types'; import { RuleDescriptionSections } from '../rule'; import RemoveExtendedDescriptionModal from './RemoveExtendedDescriptionModal'; @@ -112,14 +113,14 @@ export default class RuleDetailsDescription extends React.PureComponent (
{this.props.ruleDetails.htmlNote !== undefined && ( -
+ +
+ )} + {this.props.canWrite && (