Skip to content

Commit 89e8082

Browse files
committed
CVERecord: allow subsequent lookups for the same CVE ID
1 parent 46c184f commit 89e8082

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

src/components/cveRecordSearchModule.vue

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,23 @@ let searchTypeBoolean = computed(() => {
9696
});
9797
9898
// The watch is set up first and then the initialization of the searchType
99-
// value so that the watch is triggered, which resets the state.
99+
// value so that the watch is triggered, which resets the state. This only
100+
// applies to non-production (e.g., dev, test) websites.
100101
101-
watch(searchType, () => {resetStates();});
102+
if (!cveGenericGlobalsStore.isProductionWebsite)
103+
watch(searchType, () => {
104+
resetStates();
105+
106+
if (searchType.value == legacyOptionLabel && route.query?.id) {
107+
108+
// For the legacy find, the route has a valid ID, which is inserted
109+
// in the input field. Because it's a valid CVEID, the search button
110+
// is enabled.
111+
112+
cveId = route.query.id;
113+
cveListSearchStore.isSearchButtonDisabled = false;
114+
}
115+
});
102116
103117
searchType.value = searchOptionLabel;
104118
@@ -151,8 +165,22 @@ function startSearch() {
151165
query: {query: cveListSearchStore.query}});
152166
} else
153167
cveListSearchStore.search();
168+
} else if (route.name !== 'CVERecord' || !route.query?.id
169+
|| (route.query.id !== cveId)) {
170+
171+
// This is for the legacy find and is only applicable on the non-production
172+
// websites. This push to the router will trigger a lookup for the CVE
173+
// record.
174+
175+
router.push({name: cveRecordRouteName, query: {id: cveId}});
154176
} else {
155-
router.push({name: cveRecordRouteName, query: {id: cveId}})
177+
178+
// Non-production website in legacy find, with the user possibly wanting
179+
// a reload with the same CVEID. Probably the easiest option is to
180+
// reload the page; otherwise, without doing this there's no way to trigger
181+
// another lookup for the same CVEID.
182+
183+
router.go(0);
156184
}
157185
}
158186

src/views/CVERecord/CVERecord.vue

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,20 @@ export default {
164164
usecveRecordStore().$reset();
165165
},
166166
startLookup() {
167-
if (this.cveId !== usecveRecordStore().cveId) {
168-
this.resetStates();
169-
usecveRecordStore().cveId = this.cveId;
170-
const newPath = `/CVERecord?id=${usecveRecordStore().cveId}`;
171-
this.$router.push(newPath);
172-
this.lookupId()
173-
}
167+
168+
// Previously, this lookup would be skipped if the current CVE ID
169+
// (this.cveId) was the same as the one in the CVE record store.
170+
// That would prevent a subsequent search for the same CVE ID.
171+
// However, it is possible that the CVE record may change from the
172+
// prior search, and so the user would not see any update to the
173+
// CVE record data. This is no longer the case, as a lookup is
174+
// always done.
175+
176+
this.resetStates();
177+
usecveRecordStore().cveId = this.cveId;
178+
const newPath = `/CVERecord?id=${usecveRecordStore().cveId}`;
179+
this.$router.push(newPath);
180+
this.lookupId()
174181
},
175182
async lookupId() {
176183
usecveRecordStore().isSearching = true;

0 commit comments

Comments
 (0)