Skip to content

Commit c0aa9c7

Browse files
committed
fix: Fixed nav link of infra test
1 parent b8d7e77 commit c0aa9c7

File tree

2 files changed

+180
-15
lines changed

2 files changed

+180
-15
lines changed

index.html

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>IPF Referee Chief</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link rel="stylesheet" type="text/css" href="/css/boostrap.min.css">
8+
<link rel="stylesheet" type="text/css" href="/css/custom.css">
9+
<script src="/socket.io/socket.io.js"></script>
10+
<script src="/js/jquery.min.js"></script>
11+
<style>
12+
.circle-pefecto {
13+
border-radius: 50% !important; /* makes the button round */
14+
width: 120px; /* width of the button */
15+
height: 120px; /* height of the button */
16+
text-align: center;
17+
padding: 2%;
18+
}
19+
</style>
20+
21+
</head>
22+
<body class="bg-dark">
23+
24+
<script>
25+
const socket = io();
26+
</script>
27+
<div class="container-fluid pb-5">
28+
<section style="height:17vh;" class="bg-dark">
29+
<div class="w-100 justify-content-center" id="refereeLights">
30+
<h1 class="text-center text-light fs-5 position-absolute">Referee's decision</h1>
31+
<svg class="mt-3" height="100" width="100">
32+
<circle id="circleLeft" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
33+
<g transform="translate(30,80)">
34+
<rect id="rectangleLeft" width="40" height="20" stroke="white" stroke-width="2"
35+
fill="transparent"/>
36+
</g>
37+
Sorry, your browser does not support inline SVG.
38+
</svg>
39+
<svg class="mt-3" height="100" width="100">
40+
<circle id="circleChief" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
41+
<g transform="translate(30,80)">
42+
<rect id="rectangleChief" width="40" height="20" stroke="white" stroke-width="2"
43+
fill="transparent"/>
44+
</g>
45+
Sorry, your browser does not support inline SVG.
46+
</svg>
47+
<svg class="mt-3" height="100" width="100">
48+
<circle id="circleRight" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
49+
<g transform="translate(30,80)">
50+
<rect id="rectangleRight" width="40" height="20" stroke="white" stroke-width="2"
51+
fill="transparent"/>
52+
</g>
53+
Sorry, your browser does not support inline SVG.
54+
</svg>
55+
</div>
56+
<div class="w-100 justify-content-center" id="juryLights">
57+
<h1 class="text-center text-light fs-5 position-absolute">Jury decision</h1>
58+
<svg class="mt-3" height="100" width="100">
59+
<circle id="juryCircle" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
60+
<g transform="translate(30,80)">
61+
<rect id="rectangleJury" width="40" height="20" stroke="black" stroke-width="2"
62+
fill="transparent"/>
63+
</g>
64+
Sorry, your browser does not support inline SVG.
65+
</svg>
66+
<svg class="mt-3" id="jury2" height="100" width="100">
67+
<circle id="juryCircle_2" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
68+
<g transform="translate(30,80)">
69+
<rect id="rectangleJury_2" width="40" height="20" stroke="black" stroke-width="2"
70+
fill="transparent"/>
71+
</g>
72+
Sorry, your browser does not support inline SVG.
73+
</svg>
74+
<svg class="mt-3" id="jury3" height="100" width="100">
75+
<circle id="juryCircle_3" cx="50" cy="40" r="30" stroke="black" stroke-width="2" fill="black"/>
76+
<g transform="translate(30,80)">
77+
<rect id="rectangleJury_3" width="40" height="20" stroke="black" stroke-width="2"
78+
fill="transparent"/>
79+
</g>
80+
Sorry, your browser does not support inline SVG.
81+
</svg>
82+
</div>
83+
</section>
84+
<h1 class="text-center text-white">Chief Referee</h1>
85+
<section id="powerliftingLights" class="w-100 justify-content-center flex-wrap">
86+
<div class="mt-5 w-100 d-flex justify-content-evenly align-items-center">
87+
<button onclick="white();" class="circle-pefecto btn border-0 fw-bolder white bg-white"
88+
style="box-shadow: 0 3px 12px black">
89+
GOOD LIFT
90+
</button>
91+
<button onclick="red();" class="circle-pefecto btn border-0 text-white fw-bolder red"
92+
style="background:red;box-shadow: 0 3px 12px black">
93+
RED
94+
</button>
95+
</div>
96+
<div class="mt-5 mb-5 w-100 d-flex justify-content-evenly align-items-center">
97+
<button onclick="blue();" class="circle-pefecto btn border-0 text-white fw-bolder blue"
98+
style="background:blue;box-shadow: 0 3px 12px black">
99+
BLUE
100+
</button>
101+
<button onclick="yellow();" class="circle-pefecto btn border-0 fw-bolder yellow"
102+
style="background:yellow;box-shadow: 0 3px 12px black">
103+
YELLOW
104+
</button>
105+
</div>
106+
</section>
107+
</div>
108+
</body>
109+
</html>

testing/views.py

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
check_security_txt,
4949
get_capture_result,
5050
get_recent_captures,
51-
check_dkim
51+
check_dkim,
52+
extract_domain_from_url
5253
)
5354
from .models import DMARCRecord, DMARCReport, MailDomain, TestReport, CSPReport, CSPEndpoint
5455
import json
@@ -137,7 +138,15 @@ def test_landing(request):
137138
@csrf_exempt
138139
def check_website_security(request):
139140
if request.method == 'POST':
140-
domain = request.POST.get('target')
141+
domain = request.POST.get('target', '').strip()
142+
143+
# Log the input for debugging
144+
logger.debug(f"Web security check requested for: {domain}")
145+
146+
if not domain:
147+
return render(request, 'check_webapp.html', {
148+
'error': 'Please enter a domain to check'
149+
})
141150

142151
csp_result = check_csp(domain)
143152
cookies_result = check_cookies(domain)
@@ -162,6 +171,17 @@ def check_website_security(request):
162171
'security_txt_result': security_txt_result
163172
}
164173

174+
# Check if we had errors with any of the tests
175+
has_errors = any(
176+
isinstance(result, dict) and result.get('error')
177+
for result in [csp_result, cookies_result, cors_result, https_redirect_result,
178+
referrer_policy_result, sri_result, x_content_type_options_result,
179+
hsts_result, security_txt_result]
180+
)
181+
182+
if has_errors:
183+
context['validation_error'] = f"Some tests couldn't be completed for {domain}. Please verify the domain name."
184+
165185
try:
166186
test_report = TestReport.objects.get(tested_site=domain, test_ran="web-test")
167187
test_report.report = context
@@ -190,7 +210,14 @@ def email_test(request):
190210
"You reached the maximum number of tests. Please create an account.",
191211
)
192212
return redirect("signup")
193-
target = request.POST["target"]
213+
214+
target = request.POST["target"].strip()
215+
# Log the input for debugging
216+
logger.debug(f"Email test requested for: {target}")
217+
218+
# Extract domain from URL-like inputs without re-importing
219+
target = extract_domain_from_url(target)
220+
194221
if not check_soa_record(target):
195222
context = {"status": False, "statusmessage": "The given domain is invalid!"}
196223
else:
@@ -253,8 +280,16 @@ def ipv6_test(request):
253280
"You reached the maximum number of tests. Please create an account.",
254281
)
255282
return redirect("signup")
283+
284+
target = request.POST["target"].strip()
285+
# Log the input for debugging
286+
logger.debug(f"IPv6 test requested for: {target}")
287+
288+
# Extract domain from URL-like inputs without re-importing
289+
target = extract_domain_from_url(target)
290+
256291
context = {}
257-
context.update(ipv6_check(request.POST["target"], None))
292+
context.update(ipv6_check(target, None))
258293
nb_tests += 1
259294
response = render(request, "check_ipv6.html", context)
260295
response.set_cookie("nb_tests", nb_tests)
@@ -275,7 +310,14 @@ def web_server_test(request):
275310
"You reached the maximum number of tests. Please create an account.",
276311
)
277312
return redirect("signup")
278-
domain = request.POST["target"]
313+
314+
domain = request.POST["target"].strip()
315+
# Log the input for debugging
316+
logger.debug(f"Web server test requested for: {domain}")
317+
318+
# Extract domain from URL-like inputs without re-importing
319+
domain = extract_domain_from_url(domain)
320+
279321
context = {'domain': domain}
280322
context.update(web_server_check(domain))
281323

@@ -599,18 +641,32 @@ def url_test(request):
599641
lookyloo = Lookyloo('https://lookyloo.circl.lu')
600642
if request.method == 'POST':
601643
url = request.POST.get('target')
644+
645+
# Ensure URL has a proper protocol prefix
646+
if url and not url.startswith(('http://', 'https://')):
647+
url = 'https://' + url
648+
logger.info(f"Added https:// prefix to URL: {url}")
649+
602650
if lookyloo.is_up:
603651
context = {'lookyloo_status': lookyloo.is_up}
604-
capture_uuid = lookyloo.submit(url=url, quiet=True)
605-
while lookyloo.get_status(capture_uuid)['status_code'] != 1:
606-
if lookyloo.get_status(capture_uuid)['status_code'] == -1:
607-
context['error'] = 'Lookyloo has encountered an issue with the requested capture. Please try again.'
608-
sleep(5)
609-
capture = get_capture_result(lookyloo, capture_uuid)
610-
context['capture'] = capture
611-
screenshot_stream = lookyloo.get_screenshot(capture_uuid)
612-
screenshot = base64.b64encode(screenshot_stream.read()).decode('utf-8')
613-
context['screenshot'] = screenshot
652+
try:
653+
capture_uuid = lookyloo.submit(url=url, quiet=True)
654+
while lookyloo.get_status(capture_uuid)['status_code'] != 1:
655+
if lookyloo.get_status(capture_uuid)['status_code'] == -1:
656+
context['error'] = 'Lookyloo has encountered an issue with the requested capture. Please try again.'
657+
break
658+
sleep(5)
659+
660+
if 'error' not in context:
661+
capture = get_capture_result(lookyloo, capture_uuid)
662+
context['capture'] = capture
663+
screenshot_stream = lookyloo.get_screenshot(capture_uuid)
664+
screenshot = base64.b64encode(screenshot_stream.read()).decode('utf-8')
665+
context['screenshot'] = screenshot
666+
except Exception as e:
667+
logger.error(f"Error in URL test for {url}: {str(e)}")
668+
context['error'] = f"An error occurred during the capture: {str(e)}"
669+
614670
return render(request, 'check_lookyloo.html', context)
615671
else:
616672
recent_captures = get_recent_captures(lookyloo)

0 commit comments

Comments
 (0)