feat: challenge registry-driven platform + XVI/XVII imports + admin toggle + domain rename

- Rename repo/domain: attack-defense-platform / attackdefense.imrnes.team (all refs replaced)
- challenge_registry.json: single source of truth (28 challs across gemastik18/xvi/xvii)
- teams.py: registry-driven CHALLENGES, set_challenge_enabled, sync_challenge_runtime
  (apply enable/disable to live teams: build/up or stop/remove + receiver restart)
- compose_gen.py: render per-team compose from canonical per-challenge templates
  (image reuse, per-team ports 30xxx, flag mounts, passwords)
- gen_canonical_composes.py: canonical docker-compose.yml for all services
- import_new_challenges.py: import XVI/XVII services + EOL base image fixes
  (debian:buster→bookworm, node:14→20, python:3.7-slim→3.11)
- receiver: xvi package (10 checkers) + xvii package (12 generic checkers),
  Challenge base reads PASSWORD_<team_port> from env; gen_receiver_main.py
  generates per-team main.py from registry
- main.py: /api/challenges returns full registry; PATCH /api/challenges/<name>
  toggles enabled + applies to live teams
- index.html: 🏗️ Challenge Manager tab (toggle per challenge, grouped by set)
- SLA bonus now dynamic (all enabled challenges, not hardcoded 6)
This commit is contained in:
MythEclipse committed 2026-09-25 14:04:33 +08:00
1 parent c35b23a37f
commit c6fd9ec268
1317 files changed
+306586 -128

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col h-full w-full">
{{> navbar}}
<main class="flex justify-center items-center h-full w-full my-5">
<div class="rounded-lg border bg-card text-card-foreground shadow-sm w-3/4 h-3/4" data-v0-t="card">
<div class="flex flex-col space-y-1.5 p-6">
<h3 class="whitespace-nowrap text-2xl font-semibold leading-none tracking-tight">Create New Kode</h3>
<p class="text-sm text-muted-foreground">Add a new kode snippet to your collection.</p>
</div>
<form action="/kode" method="POST">
<div class="p-6 space-y-4">
<div class="grid grid-cols-1 gap-4">
<div class="space-y-2">
<textarea
class="flex min-h-[500px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
id="kode"
name="kode"
rows="6"
placeholder="Enter your code here..."
></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="space-y-2">
<select id="lang" name="lang" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option selected value="python">Python</option>
<option value="rust">Rust</option>
<option value="typescript">TypeScript</option>
<option value="go">Golang</option>
<option value="haskell">Haskell</option>
<option value="c">C</option>
<option value="cpp">C++</option>
<option value="markdown">Markdown</option>
<option value="java">Java</option>
<option value="ruby">Ruby</option>
</select>
</div>
<div class="space-y-2">
<input
class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
id="name"
name="name"
placeholder="Enter a name for your kode"
/>
</div>
</div>
<div class="flex items-center justify-between">
<label class="inline-flex items-center cursor-pointer">
<input type="checkbox" class="sr-only peer" id="kind" name="kind">
<div class="relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-200 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-Line truncated
<span class="ms-3 text-sm font-medium">Private</span>
</label>
<div>
<button type="submit" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Create Kode
</button>
</div>
</div>
</div>
</div>
</form>
</div>
</main>
</div>
</html>
+27
View File
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center text-center">
<div class="w-full max-w-md space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-foreground">Oops</h2>
</div>
<div>
<p class="text-center text-foreground">{{ message }}</p>
</div>
<div>
<a href="/kode" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Go back
</a>
</div>
</div>
</main>
</div>
</html>
+25
View File
@@ -0,0 +1,25 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center space-y-4 text-center">
<div class="space-y-2">
<h1 class="text-3xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none">kode-viewer</h1>
<p class="max-w-[600px] text-muted-foreground text-gray-500 md:text-xl">
Elevate your kode-share experience with kode-viewer.
</p>
</div>
<a class="flex justify-center" href="/auth/login">
<button class="rounded-md text-sm font-medium bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Get Started
</button>
</a>
</main>
</div>
</html>
+56
View File
@@ -0,0 +1,56 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/styles/xcode.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/{{ kode.lang }}.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<div class="flex flex-col h-full w-full">
<div class="bg-background border-b flex px-4 sm:px-6 h-14">
<div class="flex flex-row justify-between items-center w-full">
<a class="flex items-center" href="#">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-6 w-6">
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</a>
<div class="flex">
<div>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-5 w-5"
>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
<polyline points="16 17 21 12 16 7" />
<line x1="21" x2="9" y1="12" y2="12" />
</svg>
</div>
</div>
</div>
</div>
<main class="flex justify-center items-center h-full w-full my-5">
<div class="rounded-lg border bg-card text-card-foreground shadow-sm w-3/4 h-3/4" data-v0-t="card">
<div class="flex flex-col space-y-1.5 p-6">
<h3 class="whitespace-nowrap text-2xl font-semibold leading-none tracking-tight">{{ kode.name }}</h3>
<p class="text-sm text-muted-foreground">by {{ kode.email }}</p>
</div>
<pre><code class="language-{{ kode.lang }}">{{ kode.kode }}</code></pre>
</div>
</main>
</div>
</html>
+59
View File
@@ -0,0 +1,59 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center text-center">
<div class="w-full max-w-md space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-foreground">Sign in to Kode Viewer</h2>
</div>
<form class="space-y-4" action="/auth/login" method="POST">
<div>
<input
class="h-10 bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focus:ring-primary sm:text-sm"
type="email"
id="email"
autocomplete="email"
placeholder="Email"
name="email"
required
/>
</div>
<div>
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 sr-only"
for="password"
>
Password
</label>
<input
class="h-10 bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focus:ring-primary sm:text-sm"
type="password"
id="password"
autocomplete="current-password"
required
placeholder="Password"
name="password"
/>
</div>
<div>
<button type="submit" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Sign in
</button>
</div>
<div class="text-center">
<a class="text-sm font-medium text-muted-foreground text-gray-500 hover:text-gray-900" href="/auth/register">
Don't have an account? Register
</a>
</div>
</form>
</div>
</main>
</div>
</html>
@@ -0,0 +1,20 @@
<div class="px-4 lg:px-6 h-14 flex items-center">
<div class="flex items-center justify-center" href="#">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-6 w-6"
>
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</div>
</div>
@@ -0,0 +1,31 @@
<div class="bg-background border-b flex px-4 sm:px-6 h-14">
<div class="flex flex-row justify-between items-center w-full">
<a class="flex items-center" href="/kode">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-6 w-6">
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</a>
<div class="flex">
<a href="/auth/logout">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-5 w-5"
>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
<polyline points="16 17 21 12 16 7" />
<line x1="21" x2="9" y1="12" y2="12" />
</svg>
</a>
</div>
</div>
</div>
+65
View File
@@ -0,0 +1,65 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center text-center">
<div class="w-full max-w-md space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-foreground">Register to Kode Viewer</h2>
</div>
<form class="space-y-4" action="/auth/register" method="POST">
<div>
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 sr-only"
for="email"
>
Email
</label>
<input
class="h-10 bg-background text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focLine truncated
type="email"
id="email"
autocomplete="email"
required
placeholder="Email"
name="email"
/>
</div>
<div>
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 sr-only"
for="password"
>
Password
</label>
<input
class="h-10 bg-background text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focLine truncated
type="password"
id="password"
autocomplete="current-password"
required
placeholder="Password"
name="password"
/>
</div>
<div>
<button type="submit" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Register
</button>
</div>
<div class="text-center">
<a class="text-sm font-medium text-muted-foreground text-gray-500 hover:text-gray-900" href="/auth/login">
Already have an account? Sign in
</a>
</div>
</form>
</div>
</main>
</div>
</html>
+52
View File
@@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col h-full w-full">
{{> navbar}}
<main class="flex flex-col items-center h-full w-full my-5 gap-4">
<form class="flex h-10 w-1/2" action="/kode/find" method="POST">
<div class="flex flex-row justify-center items-center h h-full w-full gap-4">
<input
class="flex w-5/6 bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-lg px-4 py-2 border border-neutral-400 focus:border-primary focus:ring-primary"
placeholder="Search items..."
type="search"
id="pattern"
name="pattern"
required
/>
<button type="submit" class="h-10 rounded-md text-md w-1/6 bg-blue-500 hover:bg-blue-700 text-white font-bold border border-blue-700 rounded">
Search
</button>
</div>
</form>
<div class="w-full gap-4">
<a class="w-full flex justify-center items-center" href="/kode/create">
<button class="h-10 rounded-md text-md w-1/2 bg-blue-500 hover:bg-blue-700 text-white font-bold border border-blue-700 rounded">
Create
</button>
</a>
</div>
{{#if kodes}}
{{#each kodes}}
<a href="/kode/{{ this.id }}" class="block flex flex-col p-6 w-1/2 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 gap-2 justify-center items-center">
<h5 class="mb-2 text-2xl font-bold tracking-tight">{{ this.name }}</h5>
<div class="gap-1">
<span class="bg-blue-500 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.kind }}</span>
<span class="bg-gray-900 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.email }}</span>
<span class="bg-blue-500 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.lang }}</span>
</div>
</a>
{{/each}}
{{else}}
<div class="flex flex-col items-center justify-center gap-4">
<h1 class="text-muted-foreground text-gray-500 md:text-xl">No kodes found</h1>
</div>
{{/if}}
</main>
</div>
</html>