web/src/components/things/WebsiteDetailedInfo.astro
329 lines · 8543 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
44---
45
46<div class="website-info-wrapper">
47 <div class="left">
48 <h4>Website</h4>
49 <p class="website-title">
50 <img src={`https://favicone.com/${websiteInfo.url_parts.host}`} width="16" />
51 {websiteInfo.web_page.title}
52 </p>
53 <p class="website-description">{websiteInfo.web_page.description}</p>
54 <h4>Redirects</h4>
55 {websiteInfo.redirection.found ? (
56 <p>
57 <FontAwesome iconName="redirectFound" />
58 Redirects to {websiteInfo.redirection.url}
59 </p>
60 ) : (
61 <p class="all-good">
62 <FontAwesome iconName="redirectNotFound" />
63 Does not redirect
64 </p>
65 )}
66 <h4>Security Checks</h4>
67 { securityChecks.failedChecks.length > 0 ? (
68 <>
69 <p class="explainer">
70 {securityChecks.failedChecks.length} security checks failed ({securityChecks.passedChecks.length} passed)
71 </p>
72 <ul>
73 {securityChecks.failedChecks.map((check) => (
74 <li class="all-bad">
75 <FontAwesome iconName="blacklistFound" /> {check}
76 </li>
77 ))}
78 </ul>
79 </>
80 ) : (
81 <p class="all-good">
82 <FontAwesome iconName="redirectNotFound" />
83 All {securityChecks.passedChecks.length} security checks passed
84 </p>
85 )}
86 <h4>Server Details</h4>
87 <ul class="list-table">
88 <li>
89 <span class="lbl">IP Address</span>
90 <span class="val">{websiteInfo.server_details.ip}</span>
91 </li>
92 {websiteInfo.server_details.hostname && (
93 <li>
94 <span class="lbl">Hostname</span>
95 <span class="val">{websiteInfo.server_details.hostname}</span>
96 </li>
97 )}
98 <li>
99 <span class="lbl">Location</span>
100 <span class="val">
101 {websiteInfo.server_details.city_name},
102 {websiteInfo.server_details.region_name},
103 {websiteInfo.server_details.country_name},
104 {websiteInfo.server_details.continent_code}
105 </span>
106 </li>
107 <li>
108 <span class="lbl">ISP</span>
109 <span class="val">{websiteInfo.server_details.isp}</span>
110 </li>
111 <li>
112 <span class="lbl">ASN</span>
113 <span class="val">{websiteInfo.server_details.asn}</span>
114 </li>
115 </ul>
116
117 {siteCategories.length > 0 && (
118 <h4>Categories</h4>
119 <p class="explainer">Some proxies may block this service, as it falls into the following categories</p>
120 <ul>
121 {siteCategories.map((category) => (
122 <li>{category}</li>
123 ))}
124 </ul>
125 )}
126 <h4>Associated Countries</h4>
127 <ul>
128 {websiteInfo.geo_location.countries.map((country) => (
129 <li>
130 <img width="16" src={`https://flagcdn.com/48x36/${country.toLowerCase()}.png`} />
131 {country}
132 </li>
133 ))}
134 </ul>
135 <h4>Saftey Score</h4>
136 <p class="explainer">Website marked as {riskText}</p>
137 <div class={`risk risk-${riskText.replaceAll(' ', '-').toLocaleLowerCase()}`}>
138 <p>{100-risk}%</p>
139 </div>
140 </div>
141 <div class="right">
142 <h4>Blacklist Check</h4>
143 <p>{websiteInfo.url_parts.host} was found on <b>{websiteInfo.domain_blacklist.detections}</b> blacklists</p>
144 <ul>
145 {
146 websiteInfo.domain_blacklist.engines
147 .sort((a, b) => Number(b.detected) - Number(a.detected))
148 .map((engine) => (
149 engine.detected ? (
150 <li class="blacklist-check blacklisted">
151 <FontAwesome iconName="blacklistFound" />
152 {engine.name}
153 </li>
154 ) : (
155 <li class="blacklist-check not-blacklisted">
156 <FontAwesome iconName="blacklistNotFound" />
157 {engine.name}
158 </li>
159 )
160 ))}
161 </ul>
162 <h4>Website Preview</h4>
163 <img class="preview-shot" src={screenshotUrl} width="300" height="50" />
164 <div class="link-to-web-check">
165 <Button url={`https://web-check.xyz/results/${url}`}>
166 <span>View full report at</span><br /><b class="web-check-title">web-check.xyz</b>
167 </Button>
168 </div>
169
170 </div>
171</div>
172
173
174<style lang="scss">
175.website-info-wrapper {
176 display: flex;
177 flex-wrap: wrap;
178 justify-content: space-between;
179 gap: 1rem;
180 .left, .right {
181 width: calc(50% - 1rem);
182 @media screen and (max-width: 768px){
183 width: 100%;
184 }
185 }
186}
187
188h4 {
189 margin: 1rem 0 0 0;
190 font-size: 1.2rem;
191 }
192 p {
193 margin: 0;
194 display: flex;
195 align-items: center;
196 gap: 0.25rem;
197 :global(svg) {
198 width: 1rem;
199 }
200 img {
201 border-radius: var(--curve-sm);
202 }
203 &.all-good {
204 :global(svg) {
205 color: #35b969;
206 }
207 }
208 &.all-bad {
209 :global(svg) {
210 color: #e3154f;
211 }
212 }
213 }
214 li {
215 :global(svg) {
216 width: 1rem;
217 }
218
219 &.not-blacklisted :global(svg) { color: #35b969; }
220 &.blacklisted :global(svg), &.all-bad :global(svg) { color: #e3154f; }
221
222 }
223 ul {
224 padding-left: 0;
225 list-style: none;
226 max-height: 300px;
227 overflow-y: auto;
228 overflow-x: hidden;
229 img {
230 border-radius: var(--curve-sm);
231 }
232 .list-item {
233 display: flex;
234 flex-direction: column;
235 margin-bottom: 0.5rem;
236 .date-block {
237
238 font-size: 0.8rem;
239 opacity: 0.7;
240 }
241 }
242 &.list-table {
243 font-size: 0.9rem;
244 padding-left: 0;
245 li {
246 display: flex;
247 justify-content: space-between;
248 padding: 0.1rem 0;
249 .lbl {
250 font-weight: 500;
251 }
252 &:not(:last-child) {
253 border-bottom: 1px solid #5f53f440;
254 }
255 }
256 }
257 }
258
259 .website-title, .website-description {
260 font-size: 0.9rem;
261 opacity: 0.8;
262 display: -webkit-box;
263 -webkit-line-clamp: 1;
264 -webkit-box-orient: vertical;
265 overflow: hidden;
266 border-left: 2px solid var(--accent-3);
267 padding-left: 0.5rem;
268 }
269 .website-title {
270 font-weight: 500;
271 }
272 .website-description {
273 font-style: italic;
274 -webkit-line-clamp: 3;
275 }
276 .explainer {
277 font-size: 0.8rem;
278 opacity: 0.8;
279 font-style: italic;
280 }
281
282 .risk {
283 font-size: 2rem;
284 width: fit-content;
285 padding: 0.5rem 0.5rem;
286 border-radius: var(--curve-lg);
287 border: 4px solid;
288 margin: 0.5rem 0;
289 font-weight: bold;
290
291 &.risk-unknown { --rating-color: grey; }
292 &.risk-safe { --rating-color: #35b969; }
293 &.risk-moderately-safe { --rating-color: #c7cc22; }
294 &.risk-risky { --rating-color: #df8b1e; }
295 &.risk-dangerous { --rating-color: #df541e; }
296 &.risk-very-dangerous { --rating-color: #df1e1e; }
297 color: var(--rating-color);
298 border-color: var(--rating-color);
299 }
300
301 .preview-shot {
302 width: 95%;
303 height: auto;
304 border-radius: var(--curve-sm);
305 border: 2px solid var(--accent-3);
306 margin: 0.5rem auto;
307 display: flex;
308 }
309
310 .link-to-web-check {
311 width: 180px;
312 float: right;
313 font-size: 1rem;
314 transform: scale(0.8);
315 opacity: 0.85;
316 transition: all 0.2s ease-in-out;
317 &:hover { transform: scale(0.85); opacity: 1; }
318 :global(.button) {
319 background: var(--accent-3);
320 }
321 span {
322 font-size: 0.8rem;
323 }
324 .web-check-title {
325 font-size: 1.4rem;
326 }
327 }
328
329</style>