Skip to content

Commit f401207

Browse files
committed
oh-something-went-wrong-imgmanifastvul-page
1 parent 962ab7b commit f401207

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

frontend/packages/container-security/src/components/image-manifest-vuln.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const highestSeverityIndex = (obj: ImageManifestVuln) =>
5555

5656
export const ImageManifestVulnDetails: React.FC<ImageManifestVulnDetailsProps> = (props) => {
5757
const { t } = useTranslation();
58+
const queryURL = quayURLFor(props.obj);
5859
return (
5960
<>
6061
<div className="co-m-pane__body">
@@ -78,10 +79,11 @@ export const ImageManifestVulnDetails: React.FC<ImageManifestVulnDetailsProps> =
7879
obj={props.obj}
7980
path="obj.spec.manifest"
8081
>
81-
<ExternalLink
82-
text={shortenHash(props.obj.spec.manifest)}
83-
href={quayURLFor(props.obj)}
84-
/>
82+
{queryURL ? (
83+
<ExternalLink text={shortenHash(props.obj.spec.manifest)} href={queryURL} />
84+
) : (
85+
<span className="small text-muted">-</span>
86+
)}
8587
</DetailsItem>
8688
</dl>
8789
</div>
@@ -157,6 +159,7 @@ export const ImageManifestVulnTableRow: React.FC<RowFunctionArgs<ImageManifestVu
157159
obj,
158160
}) => {
159161
const { name, namespace } = obj.metadata;
162+
const queryURL = quayURLFor(obj);
160163
return (
161164
<>
162165
<TableData className={tableColumnClasses[0]}>
@@ -184,7 +187,11 @@ export const ImageManifestVulnTableRow: React.FC<RowFunctionArgs<ImageManifestVu
184187
<TableData className={tableColumnClasses[4]}>{obj.status?.fixableCount || 0}</TableData>
185188
<TableData className={tableColumnClasses[5]}>{totalCount(obj)}</TableData>
186189
<TableData className={tableColumnClasses[6]}>
187-
<ExternalLink text={shortenHash(obj.spec.manifest)} href={quayURLFor(obj)} />
190+
{queryURL ? (
191+
<ExternalLink text={shortenHash(obj.spec.manifest)} href={queryURL} />
192+
) : (
193+
<span className="small text-muted">-</span>
194+
)}
188195
</TableData>
189196
</>
190197
);

frontend/packages/container-security/src/components/summary.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ export const securityHealthHandler: ResourceHealthHandler<WatchImageVuln> = ({
3737
return { state: HealthState.OK, message: '0 vulnerable images' };
3838
};
3939

40-
export const quayURLFor = (vuln: ImageManifestVuln) => {
41-
const base = vuln.spec.image
42-
.replace('@sha256', '')
43-
.split('/')
44-
.reduce((url, part, i) => [...url, part, ...(i === 0 ? ['repository'] : [])], [])
45-
.join('/');
46-
return `//${base}/manifest/${vuln.spec.manifest}?tab=vulnerabilities`;
47-
};
40+
export const quayURLFor = (vuln: ImageManifestVuln) =>
41+
// The first part of the url is the base
42+
vuln?.spec?.image
43+
? `//${vuln.spec.image
44+
.replace('@sha256', '')
45+
.split('/')
46+
.reduce((url, part, i) => [...url, part, ...(i === 0 ? ['repository'] : [])], [])
47+
.join('/')}/manifest/${vuln.spec?.manifest}?tab=vulnerabilities`
48+
: '';
4849

4950
export const SecurityBreakdownPopup: React.FC<SecurityBreakdownPopupProps> = ({
5051
imageManifestVuln,
@@ -184,7 +185,11 @@ export const SecurityBreakdownPopup: React.FC<SecurityBreakdownPopupProps> = ({
184185
</Link>
185186
</span>
186187
<div className="text-secondary">
187-
<ExternalLink href={quayURLFor(v)} text={getVulnerabilityCountText(v)} />
188+
{quayURLFor(v) ? (
189+
<ExternalLink href={quayURLFor(v)} text={getVulnerabilityCountText(v)} />
190+
) : (
191+
<span className="small text-muted">-</span>
192+
)}
188193
</div>
189194
</div>
190195
))}

0 commit comments

Comments
 (0)