Skip to content

Commit d137c04

Browse files
committed
test of CVE violation
1 parent a32081e commit d137c04

2 files changed

Lines changed: 68 additions & 6 deletions

File tree

src/components/AdpVulnerabilityEnrichment.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@
120120
</span>
121121
</nav>
122122
</div>
123-
<div id="cve-description" v-if="!container.isSadp">
124-
<h4 class="title is-size-5">Description</h4>
125-
<p class="content cve-x-scroll">
123+
</div>
124+
<div id="cve-description" class="mt-5"
125+
v-if="(container.isCna || container.isCveProgram)
126+
&& container.englishDescription.length">
127+
<h4 class="title is-size-5">Description</h4>
128+
<p class="content cve-x-scroll">
126129
{{container.englishDescription}}
127-
</p>
128-
</div>
130+
</p>
129131
</div>
130132
<div v-if="!container.isCveProgram">
131133
<div id="cve-cwes" v-if="container.cwes.length > 0" class="mt-5">

src/views/CVERecord/PublishedRecord.vue

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
<div class="mt-2">
6666
<div :id="onPageMenu[cveRecordHeading].anchorId">
6767
<h2 class="title">{{cveRecordHeading}}</h2>
68-
<AdpVulnerabilityEnrichment v-if="publishedRecord.hasCna"
68+
<AdpVulnerabilityEnrichment
69+
v-if="publishedRecord.hasCna && !cnaViolation"
6970
:datePublished="publishedRecord.datePublished"
7071
:containerObject="publishedRecord.cna"
7172
:orgId="`cna-${publishedRecord.cna.orgId}`"
@@ -82,6 +83,16 @@
8283
{{onPageMenu[cveRecordHeading].items['CVE Program'].label}}
8384
</h1>
8485
</AdpVulnerabilityEnrichment>
86+
<AdpVulnerabilityEnrichment
87+
v-if="cnaViolation"
88+
:datePublished="publishedRecord.datePublished"
89+
:containerObject="publishedRecord.cna"
90+
:orgId="`cna-${publishedRecord.cna.orgId}`"
91+
:id="onPageMenu[cveRecordHeading].items['CNA'].anchorId">
92+
<h1 class="mb-1 has-text-white">
93+
{{ onPageMenu[cveRecordHeading].items['CNA'].label }}
94+
</h1>
95+
</AdpVulnerabilityEnrichment>
8596
</div>
8697
<div v-if="publishedRecord.hasAdp"
8798
:id="onPageMenu[adpRecordHeading].anchorId" class="mt-6">
@@ -155,6 +166,7 @@ export default {
155166
isMessageExpanded: false,
156167
isHelpTestShown: false,
157168
originalRecordData: usecveRecordStore().recordData || {},
169+
cnaViolation: false,
158170
cveServicesBaseUrl: this.GenericGlobalsStore.currentServicesUrl,
159171
cveRecordStore: usecveRecordStore(),
160172
partnerStore: usePartnerStore(),
@@ -280,12 +292,60 @@ export default {
280292
this.publishedRecord = new CveObject(this.cveRecordStore.idData);
281293
this.publishedRecord.apply(this.originalRecordData);
282294
this.onPageMenuData();
295+
this.cnaViolation = this.isViolatingCna();
296+
283297
},
298+
isViolatingCna() {
299+
300+
// If a CVE Program container exists for this CVE record, and one of
301+
// the references' URLs ends with the following, then the CVE is
302+
// considered "in violation" and the CNA will be displayed differently
303+
// to indicate this violation.
304+
305+
const targetUrl = '/preserving-vulnerability-level-identification';
306+
307+
const isViolating = this.publishedRecord.cveProgram?.references.some((ref) => {
308+
309+
return ref.url.toLowerCase().endsWith(targetUrl);
310+
})
311+
312+
return !!isViolating;
313+
},
314+
handleCnaViolation() {
315+
316+
// For a CVE record violation, both the subtitle on the on-page menu and
317+
// the accordion section heading for the CNA are changed to indicate the
318+
// violation. The CNA accordion section is initially collapsed, which is
319+
// also a difference from a "conforming" CVE record.
320+
321+
const cnaLabelRegex = /^CNA:\s+(?<cnaName>.*)$/i;
322+
const onPageMenuItems = this.onPageMenu[this.cveRecordHeading].items;
323+
const cnaItem = onPageMenuItems['CNA'];
324+
const newMenuItems = {};
325+
const violationText = 'CNA (incomplete; multiple vulnerabilities)';
326+
327+
for (const [key, item] of Object.entries(onPageMenuItems)) {
328+
329+
if (key !== 'CNA') {
330+
newMenuItems[key] = item;
331+
}
332+
}
333+
334+
cnaItem.label = cnaItem.label.replace(cnaLabelRegex,
335+
`${violationText}: $<cnaName>`);
336+
337+
newMenuItems['CNA'] = cnaItem;
338+
339+
this.cveRecordStore.accordionState[cnaItem.anchorId] = false;
340+
}
284341
},
285342
beforeMount() {
286343
287344
this.initializeFields();
288345
this.setupAccordionStateOnPageMenu();
346+
347+
if (this.isViolatingCna())
348+
this.handleCnaViolation();
289349
}
290350
};
291351

0 commit comments

Comments
 (0)