1
1
import { http , HttpResponse } from "msw" ;
2
2
import { VulnerabilityHead } from "@app/client" ;
3
3
4
+ import imgAvatar from "../app/images/avatar.svg" ;
5
+ import logo from "../../../branding/images/masthead-logo.svg" ;
6
+
4
7
import getAdvisories from "@mocks/data/advisory/list.json" ;
5
8
import getProducts from "@mocks/data/product/list.json" ;
6
9
import getPurls from "@mocks/data/purl/list.json" ;
@@ -9,6 +12,17 @@ import getVulnerabilities from "@mocks/data/vulnerability/list.json";
9
12
10
13
// DATA IMPORTS
11
14
15
+ import advisory_03bb16dc from "@mocks/data/advisory/details/03bb16dc-3cff-4a7d-8393-9a6a7124ecc2.json" ;
16
+ import advisory_87aa81c3 from "@mocks/data/advisory/details/87aa81c3-2aa5-438e-b5d4-d67ca4e321a9.json" ;
17
+ import advisory_88a4fc6c from "@mocks/data/advisory/details/88a4fc6c-60ae-4e4a-bdbe-4fb2e1d33e9c.json" ;
18
+ import advisory_459c504b from "@mocks/data/advisory/details/459c504b-7e09-4ea9-9cbb-baa8ce040e83.json" ;
19
+ import advisory_671dd85b from "@mocks/data/advisory/details/671dd85b-409f-4509-9a50-c4b2404ac10a.json" ;
20
+ import advisory_673acfc8 from "@mocks/data/advisory/details/673acfc8-ea7d-4c6d-aff9-20cf70caade0.json" ;
21
+ import advisory_32600b15 from "@mocks/data/advisory/details/32600b15-f2c1-4115-bcfb-0d0e1786f86d.json" ;
22
+ import advisory_d99d1421 from "@mocks/data/advisory/details/d99d1421-e2fd-49c2-b2dd-82fe848fff48.json" ;
23
+ import advisory_ea257645 from "@mocks/data/advisory/details/ea257645-f52f-4723-9c73-a4ed589f67ac.json" ;
24
+ import advisory_ee8cff4d from "@mocks/data/advisory/details/ee8cff4d-d6bc-4a27-89ac-a7ad193f5eb6.json" ;
25
+
12
26
import cve_202245787 from "@mocks/data/vulnerability/CVE-2022-45787/details.json" ;
13
27
import cve_20230044 from "@mocks/data/vulnerability/CVE-2023-0044/details.json" ;
14
28
import cve_20230481 from "@mocks/data/vulnerability/CVE-2023-0481/details.json" ;
@@ -57,7 +71,18 @@ import purl_e0b74cfd from "@mocks/data/purl/details/e0b74cfd-e0b0-512b-8814-947f
57
71
import purl_f4f6b460 from "@mocks/data/purl/details/f4f6b460-82e5-59f0-a7f6-da5f226a9b24.json" ;
58
72
import purl_f357b0cc from "@mocks/data/purl/details/f357b0cc-75d5-532e-b7d9-2233f6f752c8.json" ;
59
73
60
- import imgAvatar from "@app/images/avatar.svg" ;
74
+ export const advisoryDetails : { [ identifier : string ] : any } = {
75
+ "urn:uuid:03bb16dc-3cff-4a7d-8393-9a6a7124ecc2" : advisory_03bb16dc ,
76
+ "urn:uuid:87aa81c3-2aa5-438e-b5d4-d67ca4e321a9" : advisory_87aa81c3 ,
77
+ "urn:uuid:88a4fc6c-60ae-4e4a-bdbe-4fb2e1d33e9c" : advisory_88a4fc6c ,
78
+ "urn:uuid:459c504b-7e09-4ea9-9cbb-baa8ce040e83" : advisory_459c504b ,
79
+ "urn:uuid:671dd85b-409f-4509-9a50-c4b2404ac10a" : advisory_671dd85b ,
80
+ "urn:uuid:673acfc8-ea7d-4c6d-aff9-20cf70caade0" : advisory_673acfc8 ,
81
+ "urn:uuid:32600b15-f2c1-4115-bcfb-0d0e1786f86d" : advisory_32600b15 ,
82
+ "urn:uuid:d99d1421-e2fd-49c2-b2dd-82fe848fff48" : advisory_d99d1421 ,
83
+ "urn:uuid:ea257645-f52f-4723-9c73-a4ed589f67ac" : advisory_ea257645 ,
84
+ "urn:uuid:ee8cff4d-d6bc-4a27-89ac-a7ad193f5eb6" : advisory_ee8cff4d ,
85
+ } ;
61
86
62
87
export const cveDetails : { [ identifier : string ] : Partial < VulnerabilityHead > } =
63
88
{
@@ -139,7 +164,19 @@ const advisoryHandlers = [
139
164
http . patch ( "/api/v1/advisory/:id/label" , ( ) => { } ) ,
140
165
141
166
// get an advisory
142
- http . get ( "/api/v1/advisory/:key" , ( ) => { } ) ,
167
+ http . get ( "/api/v1/advisory/:key" , ( { params } ) => {
168
+ const { key } = params ;
169
+ if ( ! key ) {
170
+ return new HttpResponse ( "Advisory for SBOM not found" , { status : 404 } ) ;
171
+ } else {
172
+ const data = sbomAdvisory [ key as string ] ;
173
+ if ( ! data ) {
174
+ return new HttpResponse ( "Advisory for SBOM not found" , { status : 404 } ) ;
175
+ }
176
+
177
+ return HttpResponse . json ( data ) ;
178
+ }
179
+ } ) ,
143
180
144
181
// delete an advisory
145
182
http . delete ( "/api/v1/advisory/:key" , ( ) => { } ) ,
@@ -170,8 +207,9 @@ const analysisHandlers = [
170
207
// ASSET HANDLERS
171
208
172
209
const assetHandlers = [
210
+ http . get ( "/branding/images/placeholder.svg" , ( ) => { } ) ,
173
211
http . get ( "/branding/images/masthead-logo.svg" , ( ) => {
174
- return new HttpResponse ( imgAvatar ) ;
212
+ return new HttpResponse ( logo ) ;
175
213
} ) ,
176
214
] ;
177
215
0 commit comments