@rh-support/troubleshoot 2.4.5-beta.10 → 2.4.5-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/components/Cve/CveItem.d.ts.map +1 -1
- package/lib/esm/components/Cve/CveItem.js +21 -11
- package/lib/esm/components/Cve/CveModal.d.ts.map +1 -1
- package/lib/esm/components/Cve/CveModal.js +1 -2
- package/lib/esm/components/Cve/CveSidebar.d.ts.map +1 -1
- package/lib/esm/components/Cve/CveSidebar.js +1 -2
- package/lib/esm/components/ProductSelector/AllProductsSelector.d.ts.map +1 -1
- package/lib/esm/components/ProductSelector/AllProductsSelector.js +4 -0
- package/lib/esm/components/ProductSelector/ProductSelector.d.ts.map +1 -1
- package/lib/esm/components/ProductSelector/ProductSelector.js +0 -4
- package/lib/esm/hooks/useFetchCVEData.d.ts.map +1 -1
- package/lib/esm/hooks/useFetchCVEData.js +4 -1
- package/lib/esm/utils/caseUtils.d.ts +12 -0
- package/lib/esm/utils/caseUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseUtils.js +30 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CveItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveItem.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,UAAU,KAAK;IACX,GAAG,EAAE,0BAA0B,CAAC;CACnC;
|
|
1
|
+
{"version":3,"file":"CveItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveItem.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,UAAU,KAAK;IACX,GAAG,EAAE,0BAA0B,CAAC;CACnC;AAaD,eAAO,MAAM,OAAO,UAAW,KAAK,sBAqJnC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { Button, Flex, FlexItem, Label, LabelGroup, Text, TextVariants } from '@
|
|
|
2
2
|
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
|
|
3
3
|
import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
|
|
4
4
|
import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
|
|
5
|
-
import { format } from 'date-fns';
|
|
5
|
+
import { format, isValid, parseISO } from 'date-fns';
|
|
6
6
|
import DOMPurify from 'dompurify';
|
|
7
7
|
import isEmpty from 'lodash/isEmpty';
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
@@ -12,34 +12,43 @@ import React from 'react';
|
|
|
12
12
|
import { Trans } from 'react-i18next';
|
|
13
13
|
import { useCaseSelector } from '../../context/CaseContext';
|
|
14
14
|
const sanitize = (html) => ({ __html: DOMPurify.sanitize(html) });
|
|
15
|
+
function formatDate(dateString) {
|
|
16
|
+
const date = parseISO(dateString);
|
|
17
|
+
if (isValid(date)) {
|
|
18
|
+
return format(date, 'MMM dd, yyyy');
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return dateString;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
15
24
|
export const CveItem = (props) => {
|
|
16
25
|
const { cve } = props;
|
|
17
26
|
const { isCveModalOpened } = useCaseSelector((state) => ({
|
|
18
27
|
isCveModalOpened: state.isCveModalOpened,
|
|
19
28
|
}), isEqual);
|
|
20
|
-
const renderDate = () => (React.createElement("div", { className: "pf-v5-u-disabled-color-100" },
|
|
29
|
+
const renderDate = () => (cve === null || cve === void 0 ? void 0 : cve.publicDate) && (React.createElement("div", { className: "pf-v5-u-disabled-color-100" },
|
|
21
30
|
React.createElement(Trans, null, "Public on"),
|
|
22
31
|
" - ",
|
|
23
|
-
|
|
32
|
+
formatDate(cve.publicDate)));
|
|
24
33
|
const renderLabels = () => (React.createElement(LabelGroup, { defaultIsOpen: true, numLabels: 10 },
|
|
25
34
|
React.createElement(Label, { color: "green", isCompact: true, icon: React.createElement(StarIcon, null) },
|
|
26
35
|
React.createElement(Trans, null, "Exact match")),
|
|
27
|
-
React.createElement(Label, { color: cve.severity === 'Critical'
|
|
36
|
+
!isEmpty(cve === null || cve === void 0 ? void 0 : cve.severity) && (React.createElement(Label, { color: cve.severity === 'Critical'
|
|
28
37
|
? 'red'
|
|
29
38
|
: cve.severity === 'Important'
|
|
30
|
-
? '
|
|
39
|
+
? 'blue'
|
|
31
40
|
: cve.severity === 'Moderate'
|
|
32
|
-
? '
|
|
33
|
-
: undefined, isCompact: true }, cve.severity),
|
|
41
|
+
? 'orange'
|
|
42
|
+
: undefined, isCompact: true }, cve.severity)),
|
|
34
43
|
!isEmpty(cve.errataData) && (React.createElement(Label, { color: "blue", isCompact: true },
|
|
35
44
|
React.createElement(Trans, null, "Fixed"))),
|
|
36
45
|
!isEmpty(cve.mitigation) && (React.createElement(Label, { isCompact: true },
|
|
37
|
-
React.createElement(Trans,
|
|
46
|
+
React.createElement(Trans, { color: "blue" }, "Mitigation available")))));
|
|
38
47
|
const displayErrataTable = () => {
|
|
39
48
|
if (isEmpty(cve === null || cve === void 0 ? void 0 : cve.errataData)) {
|
|
40
49
|
return null;
|
|
41
50
|
}
|
|
42
|
-
return (React.createElement(Table, { "aria-label": "Errata table", variant: 'compact' },
|
|
51
|
+
return (React.createElement(Table, { "aria-label": "Errata table", variant: 'compact', className: "pf-v5-u-mt-md", style: { borderTop: 'var(--pf-v5-global--BorderColor--light-100) solid 1px' } },
|
|
43
52
|
React.createElement(Thead, null,
|
|
44
53
|
React.createElement(Tr, null,
|
|
45
54
|
React.createElement(Th, null,
|
|
@@ -63,7 +72,8 @@ export const CveItem = (props) => {
|
|
|
63
72
|
const displayDescription = () => {
|
|
64
73
|
var _a;
|
|
65
74
|
if (isEmpty(cve === null || cve === void 0 ? void 0 : cve.mitigation) && ((_a = cve === null || cve === void 0 ? void 0 : cve.errataData) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
66
|
-
return (React.createElement("p", { className: "pf-v5-u-mt-md" },
|
|
75
|
+
return (React.createElement("p", { className: "pf-v5-u-mt-md" },
|
|
76
|
+
React.createElement(Trans, null, "for this CVE, mitigation and fix is not available, for more details, go to the CVE page.")));
|
|
67
77
|
}
|
|
68
78
|
const MAX_DESCRIPTION_LENGTH = isCveModalOpened ? 300 : 120;
|
|
69
79
|
const description = !isEmpty(cve === null || cve === void 0 ? void 0 : cve.mitigation) ? cve === null || cve === void 0 ? void 0 : cve.mitigation : cve === null || cve === void 0 ? void 0 : cve.details;
|
|
@@ -72,7 +82,7 @@ export const CveItem = (props) => {
|
|
|
72
82
|
const trimmedDescription = description.length <= MAX_DESCRIPTION_LENGTH
|
|
73
83
|
? description
|
|
74
84
|
: description.slice(0, MAX_DESCRIPTION_LENGTH).trim() + '...';
|
|
75
|
-
return React.createElement("p", { className: "pf-v5-u-mt-md", dangerouslySetInnerHTML: sanitize(trimmedDescription) });
|
|
85
|
+
return React.createElement("p", { className: "pf-v5-u-mt-md pf-v5-u-color-300", dangerouslySetInnerHTML: sanitize(trimmedDescription) });
|
|
76
86
|
};
|
|
77
87
|
return (React.createElement("p", null,
|
|
78
88
|
React.createElement(Flex, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CveModal.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveModal.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAQ1C,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"CveModal.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveModal.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAQ1C,eAAO,MAAM,QAAQ,yBA+DpB,CAAC"}
|
|
@@ -30,8 +30,7 @@ export const CveModal = () => {
|
|
|
30
30
|
return `https://${getAccessHostname()}/labs/cvechecker/?source=pcm&session=${activeSessionId}&id=${cveTitles}`;
|
|
31
31
|
};
|
|
32
32
|
return (React.createElement(Modal, { variant: ModalVariant.medium, title: React.createElement(Flex, { alignItems: { default: 'alignItemsCenter' } },
|
|
33
|
-
React.createElement(FlexItem, { spacer: { default: 'spacerSm' } },
|
|
34
|
-
React.createElement(Trans, null, "Handpicked for this CVEs")),
|
|
33
|
+
React.createElement(FlexItem, { spacer: { default: 'spacerSm' } }, cveWorkflowRecommendation.length > 1 ? (React.createElement(Trans, null, "Handpicked for these CVEs")) : (React.createElement(Trans, null, "Handpicked for this CVE"))),
|
|
35
34
|
React.createElement(Badge, { isRead: true }, size(cveWorkflowRecommendation))), isOpen: isCveModalOpened, onClose: handleModalToggle, titleIconVariant: "info", disableFocusTrap: true, onEscapePress: handleEscapePress, actions: [
|
|
36
35
|
React.createElement(Button, { key: "cve-checker-link", "data-tracking-id": "cve-checker-link", target: "_blank", variant: "secondary", isInline: true, component: "a", href: generateCveCheckerUrl() },
|
|
37
36
|
React.createElement(Trans, null, "Red Hat CVE Checker"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CveSidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveSidebar.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"CveSidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/Cve/CveSidebar.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,UAAU,yBA6BtB,CAAC"}
|
|
@@ -16,8 +16,7 @@ export const CveSidebar = () => {
|
|
|
16
16
|
return (React.createElement(React.Fragment, null,
|
|
17
17
|
React.createElement("div", { className: "card card-white card-support file-diag pf-v5-u-mb-md" },
|
|
18
18
|
React.createElement("h3", { className: "card-heading popular-solutions green-card-heading" },
|
|
19
|
-
React.createElement("span", { className: "pf-v5-u-mr-sm" },
|
|
20
|
-
React.createElement(Trans, null, "Handpicked for this CVEs")),
|
|
19
|
+
React.createElement("span", { className: "pf-v5-u-mr-sm" }, cveWorkflowRecommendation.length > 1 ? (React.createElement(Trans, null, "Handpicked for these CVEs")) : (React.createElement(Trans, null, "Handpicked for this CVE"))),
|
|
21
20
|
React.createElement(Badge, { isRead: true }, size(cveWorkflowRecommendation))),
|
|
22
21
|
React.createElement("div", { className: "card-body" },
|
|
23
22
|
React.createElement(CvePanel, null)))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllProductsSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/AllProductsSelector.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AllProductsSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/AllProductsSelector.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAOvD,OAAO,EAAuC,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAOvG,UAAU,MAAM;IACZ,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAQD;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,4EA4JvB,CAAC;AAGH,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -10,10 +10,12 @@ import { Trans, useTranslation } from 'react-i18next';
|
|
|
10
10
|
import { useCaseDispatch, useCaseSelector } from '../../context/CaseContext';
|
|
11
11
|
import { RouteContext } from '../../context/RouteContext';
|
|
12
12
|
import { TCStateContext } from '../../context/TopContentContext';
|
|
13
|
+
import { useFetchCVEData } from '../../hooks/useFetchCVEData';
|
|
13
14
|
import { setCaseDetails } from '../../reducers/CaseReducer';
|
|
14
15
|
import { AppRouteSections } from '../../reducers/RouteConstNTypes';
|
|
15
16
|
import RouteUtils from '../../utils/routeUtils';
|
|
16
17
|
import OpenCaseIssue from '../CaseInformation/OpenCaseIssue';
|
|
18
|
+
import { CveModal } from '../Cve/CveModal';
|
|
17
19
|
import Suggestions from '../Suggestions/Suggestions';
|
|
18
20
|
import { ProductVersionDropdownSelector } from './ProductVersionDropdownSelector';
|
|
19
21
|
const defaultProps = {
|
|
@@ -38,6 +40,7 @@ const AllProductsSelector = forwardRef((props, ref) => {
|
|
|
38
40
|
version: state.caseDetails.version,
|
|
39
41
|
contactSSOName: state.caseDetails.contactSSOName,
|
|
40
42
|
}), isEqual);
|
|
43
|
+
const { cveRecommendation } = useFetchCVEData();
|
|
41
44
|
const { topContentState: { topContent }, } = useContext(TCStateContext);
|
|
42
45
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
43
46
|
const [showModal, setShowModal] = useState(false);
|
|
@@ -90,6 +93,7 @@ const AllProductsSelector = forwardRef((props, ref) => {
|
|
|
90
93
|
return (React.createElement(React.Fragment, null,
|
|
91
94
|
React.createElement("div", { className: "case-details-summary" },
|
|
92
95
|
React.createElement(OpenCaseIssue, { inlineEditable: false, required: true, isOnSummaryPage: props.isOnSummaryPage })),
|
|
96
|
+
(cveRecommendation === null || cveRecommendation === void 0 ? void 0 : cveRecommendation.length) !== 0 && React.createElement(CveModal, null),
|
|
93
97
|
React.createElement(AlertMessage, { isInline: true, variant: AlertType.DANGER, className: "pf-v5-u-mt-lg", title: t(`${loggedInUserRights.data.isSSOUsernameSameAsLoggedInUser(contactSSOName)
|
|
94
98
|
? 'You are'
|
|
95
99
|
: 'Selected owner is'} not allowed to create case on this product.`), show: !allProducts.isFetching && props.checkEntitledProduct && !isEntitledProduct && !isEmpty(product) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/ProductSelector.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/ProductSelector.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMlE,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACzE,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,aAAa,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,MAAM,qBAmGpD"}
|
|
@@ -7,8 +7,6 @@ import React, { useContext, useRef } from 'react';
|
|
|
7
7
|
import { Trans, useTranslation } from 'react-i18next';
|
|
8
8
|
import { useCaseSelector } from '../../context/CaseContext';
|
|
9
9
|
import { RouteContext } from '../../context/RouteContext';
|
|
10
|
-
import { useFetchCVEData } from '../../hooks/useFetchCVEData';
|
|
11
|
-
import { CveModal } from '../Cve/CveModal';
|
|
12
10
|
import { EARuleWidget } from '../Recommendations/EARules/EARuleWidget';
|
|
13
11
|
import Recommendations from '../Recommendations/Recommendations';
|
|
14
12
|
import { AllProductsSelector } from './AllProductsSelector';
|
|
@@ -22,7 +20,6 @@ import { ProductSelectorLoader } from './ProductSelectorLoader';
|
|
|
22
20
|
* @param props
|
|
23
21
|
*/
|
|
24
22
|
export default function ProductSelector(props) {
|
|
25
|
-
const { cveRecommendation } = useFetchCVEData();
|
|
26
23
|
const { t } = useTranslation();
|
|
27
24
|
const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
|
|
28
25
|
const { product, version, enableGetSupportProductVersion } = useCaseSelector((state) => ({
|
|
@@ -42,7 +39,6 @@ export default function ProductSelector(props) {
|
|
|
42
39
|
React.createElement(AlertMessage, { variant: AlertType.DANGER, className: "pf-v5-u-mt-lg", title: t('There was an error loading products.'), show: allProducts.isError }),
|
|
43
40
|
allProducts.isFetching ? (React.createElement(ProductSelectorLoader, null)) : (!allProducts.isError && (React.createElement(React.Fragment, null,
|
|
44
41
|
React.createElement("form", null,
|
|
45
|
-
(cveRecommendation === null || cveRecommendation === void 0 ? void 0 : cveRecommendation.length) !== 0 && React.createElement(CveModal, null),
|
|
46
42
|
React.createElement(AllProductsSelector, { routeProps: props.routeProps, checkEntitledProduct: isCaseCreate ? true : false, ref: productSelectorRef, isOnSummaryPage: true, isOnGetSupportPage: props === null || props === void 0 ? void 0 : props.isOnGetSupportPage, caseCreateExperience: props.caseCreateExperience }),
|
|
47
43
|
product === 'Subscription Watch' && (React.createElement(Alert, { isInline: true, variant: AlertVariant.warning, title: React.createElement(Trans, null,
|
|
48
44
|
' ',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchCVEData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchCVEData.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,0BAA0B,EAAkB,MAAM,iCAAiC,CAAC;AAI7F,wBAAgB,eAAe;;
|
|
1
|
+
{"version":3,"file":"useFetchCVEData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchCVEData.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,0BAA0B,EAAkB,MAAM,iCAAiC,CAAC;AAI7F,wBAAgB,eAAe;;EAiI9B"}
|
|
@@ -44,8 +44,11 @@ export function useFetchCVEData() {
|
|
|
44
44
|
var _a, _b;
|
|
45
45
|
const product = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.product) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.trim();
|
|
46
46
|
const productVersionMatchConditions = product === selectedProductLower ||
|
|
47
|
+
product === `red hat ${selectedProductLower}` ||
|
|
47
48
|
product === `${selectedProductLower} ${selectedVersionLower}` ||
|
|
48
|
-
|
|
49
|
+
product === `red hat ${selectedProductLower} ${selectedVersionLower}` ||
|
|
50
|
+
(majorVersion && product === `${selectedProductLower} ${majorVersion}`) ||
|
|
51
|
+
(majorVersion && product === `red hat ${selectedProductLower} ${majorVersion}`);
|
|
49
52
|
return productVersionMatchConditions && (obj === null || obj === void 0 ? void 0 : obj.state) === 'Fixed';
|
|
50
53
|
});
|
|
51
54
|
return map(filteredArray, (i) => {
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export declare const extractKTQuestion1FromDescription: (description: any) => any;
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes CVE (Common Vulnerabilities and Exposures) identifiers
|
|
4
|
+
* to the standard format: CVE-YYYY-NNNNN
|
|
5
|
+
*
|
|
6
|
+
* @param {string} input - The input text containing CVE identifiers
|
|
7
|
+
* @returns {string} Normalized text with standardized CVE format
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* normalizeCVE("CVE 2021-44228") and normalizeCVE("CVE2022-1234")
|
|
11
|
+
* // Returns: "CVE-2021-44228" and "CVE-2022-1234"
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeCVE: (input: string) => string;
|
|
2
14
|
/**
|
|
3
15
|
* Finds all CVE identifiers in the given text.
|
|
4
16
|
* @param {string} text - The input text to search for CVE identifiers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseUtils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iCAAiC,2BAa7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,MAAM,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseUtils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iCAAiC,2BAa7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,WAazC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,MAAM,KAAG,MAAM,EAgBrD,CAAC"}
|
|
@@ -14,6 +14,30 @@ export const extractKTQuestion1FromDescription = (description) => {
|
|
|
14
14
|
return description;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes CVE (Common Vulnerabilities and Exposures) identifiers
|
|
19
|
+
* to the standard format: CVE-YYYY-NNNNN
|
|
20
|
+
*
|
|
21
|
+
* @param {string} input - The input text containing CVE identifiers
|
|
22
|
+
* @returns {string} Normalized text with standardized CVE format
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* normalizeCVE("CVE 2021-44228") and normalizeCVE("CVE2022-1234")
|
|
26
|
+
* // Returns: "CVE-2021-44228" and "CVE-2022-1234"
|
|
27
|
+
*/
|
|
28
|
+
export const normalizeCVE = (input) => {
|
|
29
|
+
// Function to format each match
|
|
30
|
+
const formatCVE = (match) => {
|
|
31
|
+
// Remove all spaces, ensure there's a dash after CVE and before the year
|
|
32
|
+
return match
|
|
33
|
+
.toUpperCase()
|
|
34
|
+
.replace(/\s/g, '')
|
|
35
|
+
.replace(/^CVE(?!-)/, 'CVE-')
|
|
36
|
+
.replace(/(\d{4})(\d{4,7})/, '$1-$2');
|
|
37
|
+
};
|
|
38
|
+
// Replace all matches in the input string
|
|
39
|
+
return input.replace(input, formatCVE);
|
|
40
|
+
};
|
|
17
41
|
/**
|
|
18
42
|
* Finds all CVE identifiers in the given text.
|
|
19
43
|
* @param {string} text - The input text to search for CVE identifiers.
|
|
@@ -21,11 +45,14 @@ export const extractKTQuestion1FromDescription = (description) => {
|
|
|
21
45
|
*/
|
|
22
46
|
export const findCVEsInString = (text) => {
|
|
23
47
|
// Regular expression to match CVE identifiers
|
|
24
|
-
|
|
48
|
+
// CVE 2021-44228 , CVE2022-1234 and CVE-2022-1234
|
|
49
|
+
const cveRegex = /\b(CVE[-\s]?\d{4}-\d{4,7})\b/gim;
|
|
25
50
|
// Find all matches in the text
|
|
26
51
|
const matches = text.match(cveRegex);
|
|
27
|
-
//
|
|
28
|
-
const
|
|
52
|
+
// Normalizes CVE
|
|
53
|
+
const normalizedCVEs = matches === null || matches === void 0 ? void 0 : matches.map((cve) => normalizeCVE(cve));
|
|
54
|
+
// Deduplicate the matches
|
|
55
|
+
const uniqueMatches = [...new Set(normalizedCVEs)];
|
|
29
56
|
// Return the unique matches, or an empty array if no matches found
|
|
30
57
|
return uniqueMatches || [];
|
|
31
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/troubleshoot",
|
|
3
|
-
"version": "2.4.5-beta.
|
|
3
|
+
"version": "2.4.5-beta.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -134,5 +134,5 @@
|
|
|
134
134
|
"defaults and supports es6-module",
|
|
135
135
|
"maintained node versions"
|
|
136
136
|
],
|
|
137
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "d867a78014ee4a08aa8d7bf9e0dc9bd08ce6ac5a"
|
|
138
138
|
}
|