aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-10-09 17:03:04 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2024-10-09 17:03:04 +0200
commit92fa955d1db1495d9edddd4db0148ad969bc4749 (patch)
treef4c46808a4f7b376a3125fd3a1492cdfb5e1fa59
parent437cf6fbe9b07d2379d6a54afad1842634ee2a00 (diff)
downloadunterricht-92fa955d1db1495d9edddd4db0148ad969bc4749.tar.gz
unterricht-92fa955d1db1495d9edddd4db0148ad969bc4749.zip
add script to detect possible leaks of exams through git
-rwxr-xr-xscripts/detect-leak19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/detect-leak b/scripts/detect-leak
new file mode 100755
index 00000000..f27b11cc
--- /dev/null
+++ b/scripts/detect-leak
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+for f in "$@"; do
+
+ if ! printf "%s" "$f" | grep -q test; then
+ continue
+ fi
+
+ if ! grep -q '\\Datum' "$f"; then
+ continue
+ fi
+
+ datum="$(sed -n -r -e 's/\\Datum\{([[:digit:]]{2})\.([[:digit:]]{2})\.([[:digit:]]{4})\}/\3-\2-\1/p' "$f")"
+ today="$(date +%s)"
+ if [ "$(date -d"${datum}" +%s)" -gt "${today}" ]; then
+ echo Test "${f}" am "${datum}" liegt in der Zukunft >&2
+ exit 1
+ fi
+done