summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-04-01 20:32:28 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-04-01 20:32:28 +0000
commit53fea983a90447865c429c2573bfb36cba179054 (patch)
tree42a0fa57a43103378144607d16e575e82071f7e1
parent2fe40ec78ce6ab3a8c2c5659713b7f947a5686fc (diff)
added hints to task results
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@296 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rw-r--r--kpov_judge/tasks/copy_rename_100_files/task.py26
-rw-r--r--kpov_judge/tasks/copy_rename_20_files_tail_env/task.py9
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py7
-rw-r--r--kpov_judge/tasks/dhcp_dns_predefined_ip/task.py14
-rw-r--r--kpov_judge/tasks/isc_dhcp_live_boot/task.py14
-rw-r--r--kpov_judge/tasks/ldap_import/task.py3
-rw-r--r--kpov_judge/tasks/ldap_search/task.py13
-rw-r--r--kpov_judge/tasks/nat_port_forward/task.py29
-rw-r--r--kpov_judge/tasks/nat_vlc/task.py3
-rw-r--r--kpov_judge/tasks/network_boot_custom_program/task.py3
-rw-r--r--kpov_judge/tasks/openvpn_multiple_hops/task.py3
-rw-r--r--kpov_judge/tasks/openvpn_simple_smb/task.py4
-rw-r--r--kpov_judge/tasks/openwrt/task.py3
-rw-r--r--kpov_judge/tasks/public_ip_ssh/task.py6
-rw-r--r--kpov_judge/tasks/public_ssh_motd_http/task.py3
-rw-r--r--kpov_judge/tasks/radius_multiple_realms/task.py3
-rw-r--r--kpov_judge/tasks/radius_mysql_pam/task.py3
-rw-r--r--kpov_judge/tasks/rdate_64bit/task.py3
-rw-r--r--kpov_judge/tasks/set_ip_dhcp_hostname/task.py3
-rw-r--r--kpov_judge/tasks/set_ip_static_dhcp/task.py3
-rw-r--r--kpov_judge/tasks/set_motd/task.py3
-rw-r--r--kpov_judge/tasks/smb_nfs/task.py3
-rw-r--r--kpov_judge/tasks/snmp_agent_uptime/task.py4
-rw-r--r--kpov_judge/tasks/snmp_alarms_interfaces/task.py3
-rw-r--r--kpov_judge/tasks/vlc_stream_rtp/task.py4
-rwxr-xr-xkpov_judge/test_task.py4
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py11
27 files changed, 124 insertions, 63 deletions
diff --git a/kpov_judge/tasks/copy_rename_100_files/task.py b/kpov_judge/tasks/copy_rename_100_files/task.py
index ff82956..1b8326b 100644
--- a/kpov_judge/tasks/copy_rename_100_files/task.py
+++ b/kpov_judge/tasks/copy_rename_100_files/task.py
@@ -89,16 +89,24 @@ def task_check(results, params):
import os
score = 0
-
+ hints = []
matched = 0
files = os.listdir(params['folder'])
for fn in files:
if fn in results['files']:
matched += 1
- score += matched > 0
- score += 2 * (matched > len(files)/2)
- score += 3 * (matched == len(files))
-
+ if matched > 0:
+ score = 1
+ else:
+ hints += ["no files"]
+ if matched > len(files)/2:
+ score += 2
+ else:
+ hints += ["less than half the files"]
+ if (matched == len(files)):
+ score += 3
+ else:
+ hints += ["wrong number of files"]
rl = results['contents'].split('\n')
rl.sort()
tl = []
@@ -106,9 +114,11 @@ def task_check(results, params):
with open(fn) as f:
tl += f.read().upper().split('\n')
tl.sort()
- score += 4 * (rl == tl)
-
- return score
+ if rl == tl:
+ score += 4
+ else:
+ hints += ["wrong files"]
+ return hints, score
def prepare_disks(templates, params):
pass
diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
index 00d4daf..856d311 100644
--- a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
+++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
@@ -215,6 +215,7 @@ def task_check(results, params):
import re
import random
score = 0
+ hints = []
r = random.Random(params['file_creator_random_seed'])
fnames = []
for i in xrange(20):
@@ -234,6 +235,8 @@ def task_check(results, params):
task1_ok = task1_ok and results['preimenuj'].find(fname) > 0
if task1_ok:
score += 2
+ else:
+ hints += ["wrong dash rename"]
# premakni datoteke s cim krajsim ukazom
fnames = []
for i in xrange(40):
@@ -253,6 +256,8 @@ def task_check(results, params):
task2_ok = task2_ok and len(post_src) < 2
if task2_ok:
score += 2
+ else:
+ hints += ["wrong rename cmd"]
# mama_ukaz
#
task3_ok = True
@@ -285,11 +290,13 @@ def task_check(results, params):
task3_ok = False
if task3_ok:
score += 2
+ else:
+ hints += ["mama cries"]
# sledenje syslog
#print( results['syslog_start_time'])
#print( results['syslog_result'])
#print( results['syslog_end_time'])
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
index 3a72b5d..ee1e245 100644
--- a/kpov_judge/tasks/custom_rdate/task.py
+++ b/kpov_judge/tasks/custom_rdate/task.py
@@ -125,6 +125,7 @@ def task_check(results, params):
# print results
r = random.Random(params['PROGRAM_FILENAME'])
score = 0.0
+ hints = []
for i in xrange(10):
data = results['in_' + str(i)]
if data != struct.pack("!I", r.randint(0, 2**32)):
@@ -133,12 +134,14 @@ def task_check(results, params):
if str(struct.unpack("!I", data)[0]) == res.strip():
score += 0.5
else:
- pass
+ hints += ["wrong convert"]
# print str(struct.unpack("!I", data)[0]), res.strip()
if abs(int(results['ldate']) + \
int(params['RDATE_OFFSET']) - int(results['date'])) < 3:
score += 5
- return score
+ else:
+ hints += ["wrong offset"]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
index d251ebd..f6e0ded 100644
--- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
+++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
@@ -100,17 +100,25 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
- score = -9
+ score = 0
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
+ else:
+ hint += ["NM DNS wrong"]
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
score += 3
+ else:
+ hint += ["Static DNS wrong"]
if re.search(r'eth0 +802-.*connected', results['NM_nmcli']):
score += 2
+ else:
+ hint += ["NM wrong"]
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
- score = 0
- return score
+ else:
+ hint += ["static wrong"]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py
index 78dd05c..0e86c11 100644
--- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py
+++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py
@@ -163,26 +163,36 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = 0
-
+ hints = []
#TO FINISH SCORING WE REQUIRE DICT KEYS AND FUNCTIONS gen_params AND task TO BE FINISHED
#POINTS FOR EACH TASK MAY BE ADJUSTED IN THE FUTURE
if results['dhcping_other'].find(params['IP_DHCP']) >= 0:
score += 1
+ else:
+ hints += ["DHCP wrong"]
if results['dhcping_SA'].find(params['IP_DHCP']) >= 0:
score += 1
+ else:
+ hints += ["DHCP wrong"]
p = re.search(r"FNAME:(.*)\r",
results['dhcpdump_other_reply'])
other_fname = p.group(1)
if other_fname == params['BOOT_FNAME']:
score += 3
+ else:
+ hints += ["special fname wrong"]
p = re.search(r"FNAME:(.*)\r",
results['dhcpdump_SA_reply'])
sa_fname = p.group(1)
if sa_fname == params['BOOT_FNAME']:
score += 3
+ else:
+ hints += ["fname wrong"]
if results['tftp_string'].split('\r\r\n')[-2] == "# " + params['TFTP_STRING']:
score += 2
- return score
+ else:
+ hints += ["tftp wrong"]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/ldap_import/task.py b/kpov_judge/tasks/ldap_import/task.py
index b86e878..cfbe7d1 100644
--- a/kpov_judge/tasks/ldap_import/task.py
+++ b/kpov_judge/tasks/ldap_import/task.py
@@ -106,6 +106,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -115,7 +116,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py
index 5612c01..bbc636f 100644
--- a/kpov_judge/tasks/ldap_search/task.py
+++ b/kpov_judge/tasks/ldap_search/task.py
@@ -153,6 +153,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = 0
+ hints = []
s = """.*dn: dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si\r
objectClass: top\r
objectClass: dcObject\r
@@ -163,27 +164,29 @@ objectClass: organization\r
if re.match(s, results['ldapsearch_before'], re.DOTALL):
score += 2
else:
- print (s, results['ldapsearch_before'])
+ hints += [s + str(results['ldapsearch_before'])]
s = ".*uid: {}.*".format(re.escape(params['LDAP_USERNAME']))
if re.search(s, results['ldapsearch_before']):
score += 2
else:
- print (s, results['ldapsearch_before'])
+ hints += [s + str(results['ldapsearch_before'])]
s = ".*uid: {0}.*description: {1}.*".format(
re.escape(params['LDAP_USERNAME']), re.escape(fortune[:40]))
if re.match(s, results['ldapsearch_after'], re.DOTALL):
score += 2
else:
- print (s, results['ldapsearch_after'])
+ hints += [s + str(results['ldapsearch_after'])]
if results['ldapsearch_before'][:100] == results['ldapsearch_after'][:100]:
score += 2
+ else:
+ hints += ["ldapsearch wrong"]
s = '.*\r\nmodifying entry "uid={LDAP_USERNAME},ou=Users,dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si".*'.format(
**params)
if re.match(s, results['modify'], re.DOTALL):
score += 2
else:
- print (s, results['modify'])
- return score
+ hints += [s + str(results['modify'])]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py
index a3fc740..0996d97 100644
--- a/kpov_judge/tasks/nat_port_forward/task.py
+++ b/kpov_judge/tasks/nat_port_forward/task.py
@@ -127,13 +127,14 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
import cPickle
- if results is None:
- with open('bla.pickle') as f:
- results = cPickle.load(f)
- else:
- with open('bla.pickle', 'w') as f:
- cPickle.dump(results, f)
+ #if results is None:
+ # with open('bla.pickle') as f:
+ # results = cPickle.load(f)
+ #else:
+ # with open('bla.pickle', 'w') as f:
+ # cPickle.dump(results, f)
score = 0
+ hints = []
local_net = params['NET'][:params['NET'].rfind('.')]
s = "default via ({}\\.[0-9]+)".format(re.escape(local_net))
res = re.search(s, results['route'])
@@ -152,33 +153,33 @@ def task_check(results, params):
if re.search(s, results['traceroute'], re.DOTALL):
score += 1
else:
- print (s, results['traceroute'],)
+ hints += [s + str(results['traceroute'])]
if len(results['post_nc']) == 100:
score += 1
else:
- print (results['post_nc'], len(results['post_nc']))
+ hints += [str(results['post_nc']) + str(len(results['post_nc']))]
if results['nc_ret'] == (results['post_nc'] + '\n').replace('\n', '\r\n'):
score += 1
else:
- print (results['post_nc'], results['nc_ret'],)
+ hints += ['wrong nc']
s = "Connection refused"
res = re.findall(s, results['nc_pre'])
if len(res) >= 2:
score += 3
else:
- print (s, results['nc_pre'],)
+ hints += [s + str(results['nc_pre'])]
s = "\r\n"
if re.search(s, results['nc_post']):
score += 1
else:
- print (s, results['nc_post'],)
+ hints += [s + str(results['nc_post'])]
rejected_count = int(results['pre_nc'])
accepted_count = results['nc_ret'].count('\r\n')
s = ".*verbose output suppressed.*listening on.*dropped by kernel.*"
if re.match(s, results['tcpdump'], re.DOTALL):
score += 1
else:
- print (s, results['tcpdump'],)
+ hints += [s + str(results['tcpdump'])]
res = re.findall("length .*\r\n", results['tcpdump'])
total_len = 0
n_empty = 0
@@ -191,8 +192,8 @@ def task_check(results, params):
if total_len == 101 and rejected_count <= n_empty:
score += 1
else:
- print (s, results['tcpdump'],)
- return score
+ hints += [s + str(results['tcpdump'])]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/nat_vlc/task.py b/kpov_judge/tasks/nat_vlc/task.py
index c393267..556535c 100644
--- a/kpov_judge/tasks/nat_vlc/task.py
+++ b/kpov_judge/tasks/nat_vlc/task.py
@@ -119,6 +119,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = 0
+ hints = []
if re.search(r'0% packet loss',results['IP_simple ping to NAT']):
score += 2
if results['IP_NAT ip forward']=='1':
@@ -130,7 +131,7 @@ def task_check(results, params):
gateway='0.0.0.0\t'+params['IP_NAT']
if re.search(gateway,results['IP_simple routing table']):
score += 2
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/network_boot_custom_program/task.py b/kpov_judge/tasks/network_boot_custom_program/task.py
index 843b15a..89e3194 100644
--- a/kpov_judge/tasks/network_boot_custom_program/task.py
+++ b/kpov_judge/tasks/network_boot_custom_program/task.py
@@ -104,6 +104,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -113,7 +114,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/openvpn_multiple_hops/task.py b/kpov_judge/tasks/openvpn_multiple_hops/task.py
index 7ef835b..25a4229 100644
--- a/kpov_judge/tasks/openvpn_multiple_hops/task.py
+++ b/kpov_judge/tasks/openvpn_multiple_hops/task.py
@@ -105,6 +105,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -114,7 +115,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py
index edaeef7..09ad026 100644
--- a/kpov_judge/tasks/openvpn_simple_smb/task.py
+++ b/kpov_judge/tasks/openvpn_simple_smb/task.py
@@ -190,7 +190,7 @@ def task_check(results, params):
import re
score = 0
-
+ hints = []
# zal si se nisem prišla na jasno s pingi
IP_SA = params['IP_SimpleArbiterVPN'].replace('.', '\.')
IP_C1 = params['IP_VPNClient1'].replace('.', '\.')
@@ -272,7 +272,7 @@ def task_check(results, params):
if results['VPNClient1_ps'].find('openvpn') > 0:
score += 1
- return score
+ return score, hints
def prepare_disks(templates, params):
diff --git a/kpov_judge/tasks/openwrt/task.py b/kpov_judge/tasks/openwrt/task.py
index a4c5836..799bcfd 100644
--- a/kpov_judge/tasks/openwrt/task.py
+++ b/kpov_judge/tasks/openwrt/task.py
@@ -103,6 +103,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -112,7 +113,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/public_ip_ssh/task.py b/kpov_judge/tasks/public_ip_ssh/task.py
index e308184..fdbcc45 100644
--- a/kpov_judge/tasks/public_ip_ssh/task.py
+++ b/kpov_judge/tasks/public_ip_ssh/task.py
@@ -42,9 +42,9 @@ def task_check(results, params):
try:
s.login(peer_ip, peer_user, peer_passwd)
s.logout()
- except:
- return 0
- return 10
+ except Exception, e:
+ return 0, [str(e)]
+ return 10, []
def prepare_disks(templates, params):
pass
diff --git a/kpov_judge/tasks/public_ssh_motd_http/task.py b/kpov_judge/tasks/public_ssh_motd_http/task.py
index 9ad60ee..8093fae 100644
--- a/kpov_judge/tasks/public_ssh_motd_http/task.py
+++ b/kpov_judge/tasks/public_ssh_motd_http/task.py
@@ -103,6 +103,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -112,7 +113,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/radius_multiple_realms/task.py b/kpov_judge/tasks/radius_multiple_realms/task.py
index f4e2d11..75df722 100644
--- a/kpov_judge/tasks/radius_multiple_realms/task.py
+++ b/kpov_judge/tasks/radius_multiple_realms/task.py
@@ -109,6 +109,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -118,7 +119,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/radius_mysql_pam/task.py b/kpov_judge/tasks/radius_mysql_pam/task.py
index 839090f..7dbfe8c 100644
--- a/kpov_judge/tasks/radius_mysql_pam/task.py
+++ b/kpov_judge/tasks/radius_mysql_pam/task.py
@@ -157,6 +157,7 @@ def task_check(results, params):
import re
import pickle
score = 0
+ hints = []
r = random.Random(params['MYSQL_SEED'])
MYSQL_TEST_USER = kpov_random_helpers.username_gen(r)
MYSQL_TEST_PASSWORD = kpov_random_helpers.alnum_gen(r, 7)
@@ -206,7 +207,7 @@ def task_check(results, params):
score += 1
else:
print (results['login_test'],s)
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/rdate_64bit/task.py b/kpov_judge/tasks/rdate_64bit/task.py
index 9e6af21..656cb7a 100644
--- a/kpov_judge/tasks/rdate_64bit/task.py
+++ b/kpov_judge/tasks/rdate_64bit/task.py
@@ -104,6 +104,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -113,7 +114,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
index 16c689e..5cf5b54 100644
--- a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
+++ b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
@@ -92,9 +92,10 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['bla']:
score += 3
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py
index 1bd6cc9..a703213 100644
--- a/kpov_judge/tasks/set_ip_static_dhcp/task.py
+++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py
@@ -113,6 +113,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = 0
+ hints = []
#print results, params
if results['NM_nslookup'].find(params['DNS_NM']) > -1:
# print "NM_nslookup OK"
@@ -126,7 +127,7 @@ def task_check(results, params):
if re.search(r'eth0 +802-.*unmanaged', results['static_nmcli']):
# print "static_nmcli OK"
score += 3
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py
index 3f24cb2..ee82765 100644
--- a/kpov_judge/tasks/set_motd/task.py
+++ b/kpov_judge/tasks/set_motd/task.py
@@ -103,9 +103,10 @@ def task_check(results, params):
#print results
niz = params['niz']
score = 0
+ hints = []
if (results['motd'].find(niz) > -1):
score += 10
- return score
+ return score, hints
def prepare_disks(templates, params):
# print d1.ls('/')
diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py
index 6da7c88..6623248 100644
--- a/kpov_judge/tasks/smb_nfs/task.py
+++ b/kpov_judge/tasks/smb_nfs/task.py
@@ -111,6 +111,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
score = 0
+ hints = []
r = random.Random(params['SHARED_FILE_SEED'])
testfile = kpov_random_helpers.fname_gen(r)
teststring = kpov_random_helpers.alnum_gen(r, 200)
@@ -132,7 +133,7 @@ def task_check(results, params):
filels = set(results['filels'].split())
if "".join(filels - filels_later).find(testfile) >= 0:
score += 2
- return score
+ return score, hints
def prepare_disks(templates, params):
d = templates['FileServer']
diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py
index b0c4dd9..dd8880e 100644
--- a/kpov_judge/tasks/snmp_agent_uptime/task.py
+++ b/kpov_judge/tasks/snmp_agent_uptime/task.py
@@ -169,6 +169,7 @@ def task_check(results, params):
#TODO improve regex
import re
score = 0
+ hints = []
client_script_uptime = int(results['client_script'].strip())
client_uptime = int(results['client_uptime'].strip())
d = client_uptime - client_script_uptime*60
@@ -195,8 +196,7 @@ def task_check(results, params):
score += 3
if results['client_script2'].find(params['SNMP_VALUE']) >= 0:
score += 4
- print score
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/snmp_alarms_interfaces/task.py b/kpov_judge/tasks/snmp_alarms_interfaces/task.py
index bac26a7..74bf2c8 100644
--- a/kpov_judge/tasks/snmp_alarms_interfaces/task.py
+++ b/kpov_judge/tasks/snmp_alarms_interfaces/task.py
@@ -107,6 +107,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
score = -9
+ hints = []
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 3
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
@@ -116,7 +117,7 @@ def task_check(results, params):
if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
score += 2
score = 0
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/tasks/vlc_stream_rtp/task.py b/kpov_judge/tasks/vlc_stream_rtp/task.py
index 246a743..f292ed1 100644
--- a/kpov_judge/tasks/vlc_stream_rtp/task.py
+++ b/kpov_judge/tasks/vlc_stream_rtp/task.py
@@ -73,6 +73,8 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
+ score = 0
+ hints = []
packs = results['tcpdump_hex'].split('> 239.255.255.255.9875: UDP, length')
p1 = packs[1]
p1_l = p1.split('\n')
@@ -88,7 +90,7 @@ def task_check(results, params):
params['PORT'])
if re.search(s, results['tcpdump']):
score += 5
- return score
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index 36fa910..702304c 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -212,8 +212,8 @@ if __name__ == '__main__':
print(e)
exit(1)
try:
- result = task_check(task_result, task_params)
- print result
+ result, hints = task_check(task_result, task_params)
+ print result, hints
except Exception as e:
print("Error running task_check(results, params):")
print(e)
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index ef7d542..b2636e2 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -56,6 +56,7 @@ def auth_greeting():
return "To je past!" + str(flask.app.request.__dict__)
def results_post(task_id, results):
+ student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody')
db = g.db
params = db.task_params.find_one({'task_id': task_id, 'student_id': student_id})
if params is None:
@@ -72,6 +73,7 @@ def results_post(task_id, results):
if param_meta.get('w', False) and param_name in user_params:
params[param_name] = user_params[param_name]
task_check_source = db.task_checkers.find_one({'task_id':task_id})
+ hints = []
if task_check_source is None:
task_check_source = dummy_checker
else:
@@ -79,16 +81,17 @@ def results_post(task_id, results):
try:
task_check_code = compile(task_check_source, 'checker.py', 'exec')
exec(task_check_code)
- res = task_check(results, params)
+ res, hints = task_check(results, params)
except Exception, e:
- res = "Checker crashed: " + str(e)
+ hints += ["Checker crashed: " + str(e)]
+ res = 0
# flask.app.logger.error(str(e))
if (type(res) is int and res > 0):
res_status = 'OK'
else:
res_status = 'NOT OK'
- db.results.insert({'task_id': task_id, 'result': res, 'status': res_status,'student_id': student_id, 'response': results, 'time': datetime.datetime.now()})
- return {'result': res, 'status': res_status}
+ db.results.insert({'task_id': task_id, 'result': res, 'hints': hints, 'status': res_status,'student_id': student_id, 'response': results, 'time': datetime.datetime.now()})
+ return {'result': res, 'hints': hints, 'status': res_status}
def results_dict(task_id):
student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody')