Skip to content

Commit d178db2

Browse files
refactor: use a map of only the relevant valid ssvc decision point properties
1 parent 151a439 commit d178db2

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_48.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ export function mandatoryTest_6_1_48(doc) {
7474
}
7575

7676
const registeredSsvcNamespaces = ['ssvc', 'cvss']
77+
// subset of all the valid decision points containing only the relevant properties
78+
const relevantSsvcDecisionPointsSubset =
79+
ssvcDecisionPoints.decisionPoints.map((dp) =>
80+
JSON.stringify({
81+
name: dp.name ?? '',
82+
namespace: dp.namespace ?? '',
83+
version: dp.version ?? '',
84+
values: dp.values ?? '',
85+
})
86+
)
7787

7888
doc.vulnerabilities.forEach((vulnerability, vulnerabilityIndex) => {
7989
vulnerability.metrics?.forEach((metric, metricIndex) => {
@@ -87,12 +97,14 @@ export function mandatoryTest_6_1_48(doc) {
8797
(selection, selectionIndex) => {
8898
// check if a decision point with these properties exists
8999
const filteredDecisionPoints =
90-
ssvcDecisionPoints.decisionPoints.filter(
91-
(dp) =>
100+
relevantSsvcDecisionPointsSubset.filter((jsonDp) => {
101+
const dp = JSON.parse(jsonDp)
102+
return (
92103
dp.name === selection.name &&
93104
dp.namespace === selection.namespace &&
94105
dp.version === selection.version
95-
)
106+
)
107+
})
96108
if (filteredDecisionPoints.length === 0) {
97109
ctx.isValid = false
98110
ctx.errors.push({
@@ -106,7 +118,9 @@ export function mandatoryTest_6_1_48(doc) {
106118
if (
107119
selection.values &&
108120
!areValuesValidAndinOrder(
109-
filteredDecisionPoints[0].values.map((value) => value.name),
121+
JSON.parse(filteredDecisionPoints[0]).values.map(
122+
(/** @type {{ name: string; }} */ value) => value.name
123+
),
110124
selection.values
111125
)
112126
) {

0 commit comments

Comments
 (0)