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