web/src/components/things/WebsiteDetailedInfo.astro
338 lines · 9461 bytes
1---
2
3import type { WebsiteData } from '@utils/fetch-website-info';
4import type { WebsiteTracker } from '@utils/fetch-trackers-info';
5import { analyzeSecurityChecks } from '@utils/security-check-mappings';
6import FontAwesome from "@components/form/FontAwesome.svelte"
7import Button from '@components/form/Button.astro';
8
9interface Props {
10 websiteInfo: WebsiteData;
11 url: string;
12 trackers?: WebsiteTracker[];
13};
14
15const { websiteInfo, url, trackers } = Astro.props;
16
17const categoryLabels: {[key: string]: string} = {
18 is_torrent: 'Torrenting',
19 is_vpn_provider: 'VPN Provider',
20 is_free_hosting: 'Free Hosting',
21 is_anonymizer: 'Anonymizer',
22 is_url_shortener: 'URL Shortner',
23 is_free_dynamic_dns: 'Free Dynamic DNS',
24 is_code_sandbox: 'Code Sandbox',
25 is_form_builder: 'Form Builder',
26 is_free_file_sharing: 'File Sharing',
27 is_pastebin: 'Pastebin'
28};
29
30const siteCategories = Object.entries(websiteInfo.site_category)
31 .filter(([_key, value]) => value)
32 .map(([key]) => categoryLabels[key]);
33
34const securityChecks = analyzeSecurityChecks(websiteInfo.security_checks);
35
36const risk = websiteInfo.risk_score.result;
37let riskText = 'unknown';
38if (risk < 5) riskText = 'safe';
39else if (risk < 15) riskText = 'moderately safe';
40else if (risk < 50) riskText = 'risky';
41else if (risk < 75) riskText = 'dangerous';
42else if (risk >= 75) riskText = 'very dangerous';
43
44const screenshotUrl = `https://screenshot-cache.as93.workers.dev/${url}`;
45
46let webCheckTarget: string;
47try {
48 webCheckTarget = new URL(/^https?:\/\//i.test(url) ? url : `https://${url}`).host;
49} catch {
50 webCheckTarget = encodeURIComponent(url);
51}
52const webCheckLink = `https://web-check.xyz/check/${webCheckTarget}`;
53
54---
55
56<div class="website-info-wrapper">
57 <div class="left">
58 <h4>Website</h4>
59 <p class="website-title">
60 <img src={`https://favicone.com/${websiteInfo.url_parts.host}`} alt="" width="16" loading="lazy" />
61 {websiteInfo.web_page.title}
62 </p>
63 <p class="website-description">{websiteInfo.web_page.description}</p>
64 <h4>Redirects</h4>
65 {websiteInfo.redirection.found ? (
66 <p>
67 <FontAwesome iconName="redirectFound" />
68 Redirects to {websiteInfo.redirection.url}
69 </p>
70 ) : (
71 <p class="all-good">
72 <FontAwesome iconName="redirectNotFound" />
73 Does not redirect
74 </p>
75 )}
76 <h4>Security Checks</h4>
77 { securityChecks.failedChecks.length > 0 ? (
78 <>
79 <p class="explainer">
80 {securityChecks.failedChecks.length} security checks failed ({securityChecks.passedChecks.length} passed)
81 </p>
82 <ul>
83 {securityChecks.failedChecks.map((check) => (
84 <li class="all-bad">
85 <FontAwesome iconName="blacklistFound" /> {check}
86 </li>
87 ))}
88 </ul>
89 </>
90 ) : (
91 <p class="all-good">
92 <FontAwesome iconName="redirectNotFound" />
93 All {securityChecks.passedChecks.length} security checks passed
94 </p>
95 )}
96 <h4>Server Details</h4>
97 <ul class="list-table">
98 <li>
99 <span class="lbl">IP Address</span>
100 <span class="val">{websiteInfo.server_details.ip}</span>
101 </li>
102 {websiteInfo.server_details.hostname && (
103 <li>
104 <span class="lbl">Hostname</span>
105 <span class="val">{websiteInfo.server_details.hostname}</span>
106 </li>
107 )}
108 <li>
109 <span class="lbl">Location</span>
110 <span class="val">
111 {websiteInfo.server_details.city_name},
112 {websiteInfo.server_details.region_name},
113 {websiteInfo.server_details.country_name},
114 {websiteInfo.server_details.continent_code}
115 </span>
116 </li>
117 <li>
118 <span class="lbl">ISP</span>
119 <span class="val">{websiteInfo.server_details.isp}</span>
120 </li>
121 <li>
122 <span class="lbl">ASN</span>
123 <span class="val">{websiteInfo.server_details.asn}</span>
124 </li>
125 </ul>
126
127 {siteCategories.length > 0 && (
128 <h4>Categories</h4>
129 <p class="explainer">Some proxies may block this service, as it falls into the following categories</p>
130 <ul>
131 {siteCategories.map((category) => (
132 <li>{category}</li>
133 ))}
134 </ul>
135 )}
136 <h4>Associated Countries</h4>
137 <ul>
138 {websiteInfo.geo_location.countries.map((country) => (
139 <li>
140 <img width="16" src={`https://flagcdn.com/48x36/${country.toLowerCase()}.png`} alt={country} loading="lazy" />
141 {country}
142 </li>
143 ))}
144 </ul>
145 <h4>Safety Score</h4>
146 <p class="explainer">Website marked as {riskText}</p>
147 <div class={`risk risk-${riskText.replaceAll(' ', '-').toLocaleLowerCase()}`}>
148 <p>{100-risk}%</p>
149 </div>
150 </div>
151 <div class="right">
152 {trackers && (
153 <>
154 <h4>Trackers</h4>
155 { trackers.length > 0 ? (
156 <>
157 <p class="explainer">
158 Loads {trackers.length} third-party tracker{trackers.length === 1 ? '' : 's'}
159 </p>
160 <ul>
161 {trackers.map((tracker) => (
162 <li class="all-bad" title={tracker.categories.join(', ') || undefined}>
163 <FontAwesome iconName="warning" /> {tracker.domain}
164 {tracker.owner && <span class="tracker-owner">{tracker.owner}</span>}
165 </li>
166 ))}
167 </ul>
168 </>
169 ) : (
170 <p class="all-good">
171 <FontAwesome iconName="noTrackers" />
172 No known trackers found
173 </p>
174 )}
175 </>
176 )}
177 <h4>Blacklist Check</h4>
178 <p>{websiteInfo.url_parts.host} was found on <b>{websiteInfo.domain_blacklist.detections}</b> blacklists</p>
179 <ul>
180 {
181 websiteInfo.domain_blacklist.engines
182 .sort((a, b) => Number(b.detected) - Number(a.detected))
183 .map((engine) => (
184 engine.detected ? (
185 <li class="blacklist-check blacklisted">
186 <FontAwesome iconName="blacklistFound" />
187 {engine.name}
188 </li>
189 ) : (
190 <li class="blacklist-check not-blacklisted">
191 <FontAwesome iconName="blacklistNotFound" />
192 {engine.name}
193 </li>
194 )
195 ))}
196 </ul>
197 <h4>Website Preview</h4>
198 <img class="preview-shot" src={screenshotUrl} alt="Website preview" width="300" height="50" loading="lazy" />
199 <div class="link-to-web-check">
200 <Button url={webCheckLink} target="_blank" rel="noopener">
201 <img width="32" height="32" src="/web-check.svg" alt="" loading="lazy" />
202 <div class="btn-text">
203 <span>View full report at</span>
204 <b class="web-check-title">web-check.xyz</b>
205 </div>
206 </Button>
207 </div>
208
209 </div>
210</div>
211
212
213<style lang="scss">
214@use '../../styles/mixins' as *;
215.website-info-wrapper {
216 @include detail-info-layout;
217}
218
219@include detail-info-base;
220
221 p {
222 &.all-good {
223 :global(svg) {
224 color: var(--rating-a);
225 }
226 }
227 &.all-bad {
228 :global(svg) {
229 color: var(--rating-g);
230 }
231 }
232 }
233 li {
234 :global(svg) {
235 width: var(--text-base);
236 }
237
238 &.not-blacklisted :global(svg) { color: var(--rating-a); }
239 &.blacklisted :global(svg), &.all-bad :global(svg) { color: var(--rating-g); }
240
241 }
242 ul {
243 .list-item {
244 .date-block {
245 font-size: var(--text-sm);
246 opacity: var(--opacity-soft);
247 }
248 }
249 &.list-table li {
250 .lbl {
251 font-weight: 500;
252 }
253 }
254 }
255
256 .website-title, .website-description {
257 font-size: var(--text-sm);
258 opacity: var(--opacity-subtle);
259 @include line-clamp(1);
260 border-left: 2px solid var(--accent-3);
261 padding-left: var(--space-sm);
262 }
263 .website-title {
264 font-weight: 500;
265 }
266 .website-description {
267 font-style: italic;
268 -webkit-line-clamp: 3;
269 }
270 .explainer {
271 font-size: var(--text-sm);
272 opacity: var(--opacity-subtle);
273 font-style: italic;
274 }
275 .tracker-owner {
276 margin-left: var(--space-xs);
277 font-size: var(--text-sm);
278 opacity: var(--opacity-soft);
279 }
280
281 .risk {
282 font-size: var(--text-3xl);
283 width: fit-content;
284 padding: var(--space-sm) var(--space-sm);
285 border-radius: var(--curve-lg);
286 border: 4px solid;
287 margin: var(--space-sm) 0;
288 font-weight: bold;
289
290 &.risk-unknown { --rating-color: var(--rating-unknown); }
291 &.risk-safe { --rating-color: var(--rating-a); }
292 &.risk-moderately-safe { --rating-color: var(--rating-c); }
293 &.risk-risky { --rating-color: var(--rating-e); }
294 &.risk-dangerous { --rating-color: var(--rating-f); }
295 &.risk-very-dangerous { --rating-color: var(--rating-g); }
296 color: var(--rating-color);
297 border-color: var(--rating-color);
298 }
299
300 .preview-shot {
301 width: 95%;
302 height: auto;
303 border-radius: var(--curve-sm);
304 border: 2px solid var(--accent-3);
305 margin: var(--space-sm) auto;
306 display: flex;
307 }
308
309 .link-to-web-check {
310 width: 260px;
311 float: right;
312 font-size: var(--text-base);
313 transform: scale(0.8);
314 transition: var(--transition-normal);
315 :global(.button) {
316 background: var(--accent-3);
317 }
318 :global(.button a) {
319 color: var(--accent-3-fg);
320 }
321 span {
322 font-size: var(--text-sm);
323 }
324 .web-check-title {
325 font-size: var(--text-lg);
326 }
327 :global(a) {
328 display: flex;
329 gap: var(--space-md);
330 .btn-text {
331 display: flex;
332 flex-direction: column;
333 text-align: left;
334 }
335 }
336 }
337
338</style>