Commit e42299c072

e42299c0725916130117738facc36dc194c68022

parent: 692ad85ae6

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-06-10 06:36 UTC

Repo security overview shown in web

Layout: unified · split

web/src/components/things/SecurityDetailedInfo.astro added +302
@@ -0,0 +1,302 @@
1---
2import type { SecurityReportResponse } from '@utils/fetch-security-info';
3import { formatDate, timeAgo } from '@utils/dates-n-stuff';
4import FontAwesome from '@components/form/FontAwesome.svelte';
5
6interface Props {
7 security: SecurityReportResponse;
8}
9
10const { security } = Astro.props;
11const { scorecard, advisories, fuzzed } = security;
12
13const hasScorecard = scorecard.available && scorecard.checks.length > 0;
14const hasAdvisories = advisories.count > 0;
15
16// Map a 0–10 score to a rating colour, or grey when unknown (-1 / null)
17const scoreColor = (score: number | null): string => {
18 if (score === null || score < 0) return 'var(--rating-unknown)';
19 if (score >= 8) return 'var(--rating-a)';
20 if (score >= 6) return 'var(--rating-b)';
21 if (score >= 4) return 'var(--rating-d)';
22 if (score >= 2) return 'var(--rating-f)';
23 return 'var(--rating-g)';
24};
25
26const scoreLabel = (score: number | null): string =>
27 score === null || score < 0 ? 'N/A' : `${score}/10`;
28
29const severityColor = (severity: string): string => {
30 switch (severity.toLowerCase()) {
31 case 'critical':
32 return 'var(--rating-g)';
33 case 'high':
34 return 'var(--rating-f)';
35 case 'moderate':
36 case 'medium':
37 return 'var(--rating-e)';
38 case 'low':
39 return 'var(--rating-c)';
40 default:
41 return 'var(--rating-unknown)';
42 }
43};
44---
45
46<div class="sec-info-wrap">
47 {
48 hasScorecard && (
49 <div class="left">
50 <div class="overall">
51 <span
52 class="score-ring"
53 style={`--ring: ${scoreColor(scorecard.overallScore)}`}
54 aria-label={`Overall security score: ${scoreLabel(scorecard.overallScore)}`}
55 >
56 {scoreLabel(scorecard.overallScore)}
57 </span>
58 <div class="overall-meta">
59 <h4>Repo Security Summary</h4>
60 <p class="muted">
61 {scorecard.generatedAt && (
62 <span title={timeAgo(scorecard.generatedAt)}>
63 Updated {formatDate(scorecard.generatedAt)}
64 </span>
65 )}
66 {fuzzed && (
67 <span class="badge fuzzed">
68 <FontAwesome iconName="securityAudited" /> Fuzz tested
69 </span>
70 )}
71 </p>
72 </div>
73 </div>
74 <ul class="list-table">
75 {scorecard.checks.map((check) => (
76 <li>
77 <span class="check-name" title={check.reason}>
78 {check.name}
79 {check.url && (
80 <a
81 class="check-link"
82 href={check.url}
83 target="_blank"
84 rel="noopener noreferrer"
85 aria-label={`Open the ${check.name} scorecard documentation in a new tab`}
86 >
87 <FontAwesome iconName="externalLink" />
88 </a>
89 )}
90 </span>
91 <span
92 class="score-pill"
93 style={`--pill: ${scoreColor(check.score)}`}
94 >
95 {scoreLabel(check.score)}
96 </span>
97 </li>
98 ))}
99 </ul>
100 </div>
101 )
102 }
103 {
104 hasAdvisories && (
105 <div class="right">
106 <h4>
107 Security Advisories <span class="count">({advisories.count})</span>
108 </h4>
109 <ul class="advisories">
110 {advisories.items.map((adv) => (
111 <li class="advisory">
112 <div class="adv-head">
113 <span
114 class="badge severity"
115 style={`--sev: ${severityColor(adv.severity)}`}
116 >
117 {adv.severity || 'unknown'}
118 </span>
119 <span
120 class={`badge patch ${adv.isPatched ? 'patched' : 'unpatched'}`}
121 >
122 {adv.isPatched ? 'Patched' : 'Unpatched'}
123 </span>
124 {adv.cvssScore !== null && (
125 <span class="cvss">CVSS {adv.cvssScore}</span>
126 )}
127 </div>
128 <p class="adv-summary">
129 <a href={adv.url} target="_blank" rel="noopener noreferrer">
130 {adv.cveId || adv.ghsaId}
131 </a>
132 {adv.summary}
133 </p>
134 <p class="adv-meta">
135 {adv.publishedAt && (
136 <time
137 datetime={adv.publishedAt}
138 title={timeAgo(adv.publishedAt)}
139 >
140 {formatDate(adv.publishedAt)}
141 </time>
142 )}
143 </p>
144 </li>
145 ))}
146 </ul>
147 </div>
148 )
149 }
150</div>
151
152<style lang="scss">
153 @use '../../styles/mixins' as *;
154 .sec-info-wrap {
155 @include detail-info-layout;
156 align-items: flex-start;
157 }
158
159 @include detail-info-base;
160
161 .left {
162 font-size: var(--text-md);
163 h4 {
164 font-size: var(--text-lg);
165 }
166 ul.list-table {
167 max-height: 500px;
168 font-size: var(--text-base);
169 }
170 }
171
172 .check-name {
173 display: inline-flex;
174 align-items: center;
175 gap: var(--space-xs);
176 .check-link {
177 display: inline-flex;
178 opacity: var(--opacity-muted);
179 &:hover {
180 opacity: 1;
181 }
182 :global(svg) {
183 width: var(--text-sm);
184 }
185 }
186 }
187
188 // Scorecard overall score
189 .overall {
190 display: flex;
191 align-items: center;
192 gap: var(--space-md);
193 margin-bottom: var(--space-sm);
194 .score-ring {
195 flex-shrink: 0;
196 display: grid;
197 place-items: center;
198 width: 4rem;
199 height: 4rem;
200 border-radius: 50%;
201 border: 3px solid var(--ring);
202 color: var(--ring);
203 font-family: var(--font-subtitle);
204 font-weight: bold;
205 font-size: var(--text-md);
206 }
207 .overall-meta h4 {
208 margin-top: 0;
209 }
210 .muted {
211 flex-wrap: wrap;
212 font-size: var(--text-sm);
213 opacity: var(--opacity-muted);
214 }
215 }
216
217 .score-pill {
218 flex-shrink: 0;
219 font-family: var(--font-subtitle);
220 font-weight: bold;
221 font-size: var(--text-sm);
222 color: var(--pill);
223 }
224
225 .badge {
226 @include changelog-badge;
227 border: var(--border-light);
228 :global(svg) {
229 width: var(--text-sm);
230 }
231 &.fuzzed {
232 display: inline-flex;
233 align-items: center;
234 gap: var(--space-xs);
235 background: var(--accent-3-translucent);
236 opacity: var(--opacity-subtle);
237 }
238 &.severity {
239 background: var(--sev);
240 color: var(--box-outline);
241 }
242 &.patch.patched {
243 background: color-mix(in srgb, var(--success-muted) 60%, transparent);
244 }
245 &.patch.unpatched {
246 background: color-mix(in srgb, var(--danger) 60%, transparent);
247 }
248 }
249
250 .count {
251 opacity: var(--opacity-muted);
252 }
253
254 // Advisories list
255 ul.advisories {
256 list-style: none;
257 padding-left: 0;
258 max-height: 500px;
259 overflow-y: auto;
260 .advisory {
261 padding: var(--space-sm) 0;
262 &:not(:last-child) {
263 border-bottom: 1px solid var(--accent-3-translucent);
264 }
265 }
266 .adv-head {
267 display: flex;
268 flex-wrap: wrap;
269 align-items: center;
270 gap: var(--space-xs);
271 .cvss {
272 font-size: var(--text-xs);
273 opacity: var(--opacity-muted);
274 }
275 }
276 .adv-summary {
277 font-size: var(--text-sm);
278 font-weight: 500;
279 display: flex;
280 flex-wrap: wrap;
281 margin: var(--space-xs) 0;
282 @include line-clamp(2);
283 }
284 .adv-meta {
285 justify-content: space-between;
286 font-size: var(--text-sm);
287 opacity: var(--opacity-soft);
288 }
289 .adv-versions {
290 flex-wrap: wrap;
291 gap: var(--space-sm);
292 font-size: var(--text-sm);
293 opacity: var(--opacity-soft);
294 code {
295 background: var(--code-bg);
296 padding: 0.05rem 0.3rem;
297 border-radius: var(--curve-sm);
298 font-family: var(--font-code);
299 }
300 }
301 }
302</style>
web/src/pages/[...listing].astro +16
@@ -4,6 +4,7 @@ import ListingHero from '@components/things/ListingHero.astro';
44import ServiceList from '@components/things/ServiceList.astro';
55import Comments from '@components/things/Comments.svelte';
66import GitHubDetailedInfo from '@components/things/GitHubDetailedInfo.astro';
7import SecurityDetailedInfo from '@components/things/SecurityDetailedInfo.astro';
78import PrivacyPolicyDetails from '@components/things/PrivacyPolicyDetails.astro';
89import WebsiteDetailedInfo from '@components/things/WebsiteDetailedInfo.astro';
910import DockerDetailedInfo from '@components/things/DockerDetailedInfo.astro';
@@ -18,6 +19,7 @@ import { fetchData, slugify } from '@utils/fetch-data';
1819import { codebergUrl } from '@utils/parse-markdown';
1920import { fetchChangelog } from '@utils/fetch-changelog';
2021import { fetchGitHubStats } from '@utils/fetch-repo-info';
22import { fetchSecurityReport } from '@utils/fetch-security-info';
2123import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy';
2224import { fetchWebsiteInfo } from '@utils/fetch-website-info';
2325import { fetchDockerData } from '@utils/fetch-docker-instructions';
@@ -143,6 +145,12 @@ const { previous, next } = makePaginationLinks();
143145const ignoredSites = ['github.com', 'wikipedia.'];
144146
145147const githubData = github ? await fetchGitHubStats(github) : null;
148const securityData = github ? await fetchSecurityReport(github) : null;
149const hasSecurityData =
150 !!securityData &&
151 ((securityData.scorecard.available &&
152 securityData.scorecard.checks.length > 0) ||
153 securityData.advisories.count > 0);
146154const privacyData = tosdrId ? await fetchTosdrPrivacy(tosdrId) : null;
147155const iosData = iosApp ? await fetchIosInfo(iosApp) : null;
148156const androidData = androidApp ? await fetchAndroidInfo(androidApp) : null;
@@ -288,6 +296,14 @@ const makeSoftwareSchema = () => {
288296 </section>
289297 )
290298 }
299 {
300 hasSecurityData && securityData && (
301 <section>
302 <h2>{name} Security</h2>
303 <SecurityDetailedInfo security={securityData} />
304 </section>
305 )
306 }
291307 {
292308 websiteData && (
293309 <section>
web/src/utils/fetch-security-info.ts added +59
@@ -0,0 +1,59 @@
1import { error } from './logger';
2import { safeFetch } from './safe-fetch';
3import { apiBase, enrichHeaders } from './api-config';
4
5const normalizeRepo = (github: string): string =>
6 github.replace(/^https?:\/\/github\.com\//, '').replace(/\/+$/, '');
7
8export const fetchSecurityReport = async (
9 github: string,
10): Promise<SecurityReportResponse | null> => {
11 const repo = normalizeRepo(github);
12 const endpoint = `${apiBase}/v1/enrich/security/${repo}`;
13 try {
14 const res = await safeFetch(endpoint, { headers: enrichHeaders() });
15 if (!res.ok) {
16 error('Security Report', `HTTP ${res.status} for ${repo} (${endpoint})`);
17 return null;
18 }
19 return await res.json();
20 } catch (err) {
21 error('Security Report', `Network error for ${repo}: ${err}`);
22 return null;
23 }
24};
25
26export interface SecurityCheck {
27 name: string;
28 score: number;
29 reason: string;
30 url: string;
31}
32
33export interface SecurityAdvisory {
34 ghsaId: string;
35 cveId: string | null;
36 summary: string;
37 severity: string;
38 cvssScore: number | null;
39 publishedAt: string;
40 url: string;
41 firstPatchedVersion: string | null;
42 vulnerableRange: string;
43 isPatched: boolean;
44}
45
46export interface SecurityReportResponse {
47 repo: string;
48 scorecard: {
49 available: boolean;
50 overallScore: number | null;
51 generatedAt: string;
52 checks: SecurityCheck[];
53 };
54 advisories: {
55 count: number;
56 items: SecurityAdvisory[];
57 };
58 fuzzed: boolean;
59}