Repository navigation
Ship the Exercise 12 student download and complete the local classroom through Exercise 12 #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
af20baa
347f9a7
7d6825a
9c32eb1
f7aecc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| Choose a new tag of the form `classroom-YYYY.MM.DD`. For a second release that day, append a positive sequence number such as `.2`. Use the tested commit you plan to teach. The course build embeds that commit in `/opt/classroom/course-revision.txt`. | ||
|
|
||
| 1. Open a pull request and wait for **Course release** to pass for amd64 and arm64. You can also use **Run workflow** on a branch for a read-only rehearsal. | ||
| 2. After merging, create and push the chosen tag at the reviewed commit. The initial tag push starts publication. Moving or deleting an existing tag has no release job. | ||
| 2. After merging, check out the reviewed commit and fetch `origin/main`. Run `containers/tag-student-edition.sh TAG` with the website dependencies installed. Inspect the local tag with `git ls-tree --name-only TAG` and push it with `git push origin refs/tags/TAG`. Its parentless source archive contains the prepared student materials and records the reviewed course commit in `materials/course-revision.txt`. CI checks the workflow matches that commit and compares the archived student files with a fresh export before building both images from the recorded source. The initial tag push starts publication. Moving or deleting an existing tag has no release job. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Require a clean preparation script before tagging. If
|
||
| 3. In the tag's **Course release** run, check that both architecture jobs and **publish** passed. The job prints the Docker index digest. Confirm that instructors can download the SIFs from the matching GitHub Release and pull the GHCR image. For a first public release, check the package's visibility in GitHub Packages. | ||
|
|
||
| ## What the checks cover | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/sh | ||
| # Launch the editable Exercise 11 app behind Docker's loopback port mapping. | ||
| set -eu | ||
| exec node --input-type=module -e ' | ||
| import { createServer } from "./server.mjs"; | ||
| const server = createServer(); | ||
| server.listen(3000, "0.0.0.0", () => console.log("Open http://127.0.0.1:3000")); | ||
| ' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,29 @@ server=$! | |
| trap 'kill "$server" 2>/dev/null || true; wait "$server" || true' EXIT | ||
| crawl | ||
| kill -0 "$server" | ||
| kill "$server" | ||
| wait "$server" || true | ||
| trap - EXIT | ||
|
|
||
| # Exercise 11 runs independently of the course site. Check the app over the | ||
| # same loopback ports and with the same working-directory mounts as a student. | ||
| work=$(mktemp -d) | ||
| chmod 755 "$work" | ||
| lab=/opt/classroom/11-security-logging-alerting/app | ||
| trap 'rm -rf "$work"' EXIT | ||
| apptainer exec --containall --cleanenv --no-mount cwd --bind "$work:/work" "$sif" cp -R "$lab/." /work/ | ||
| check_logging() { | ||
| curl --retry 20 --retry-delay 1 --retry-all-errors --max-time 5 -fsS http://127.0.0.1:3000/ -o "$work/page.html" | ||
| grep -Fq '<h1>What did the logs miss?</h1>' "$work/page.html" | ||
| curl --max-time 5 -fsS http://127.0.0.1:3000/api/state | python3 -c 'import json,sys; state = json.load(sys.stdin); assert state["attemptCount"] == 0 and state["events"] == []' | ||
| } | ||
| container=$(docker run -d --init -p 127.0.0.1:3000:3000 -v "$work:/work" -w /work "$image" classroom-logging) | ||
| trap 'docker rm -f "$container" >/dev/null; rm -rf "$work"' EXIT | ||
| check_logging | ||
| docker rm -f "$container" >/dev/null | ||
| trap 'rm -rf "$work"' EXIT | ||
| apptainer exec --containall --cleanenv --no-mount cwd --bind "$work:/work" --pwd /work "$sif" node server.mjs & | ||
| server=$! | ||
| trap 'kill "$server" 2>/dev/null || true; wait "$server" || true; rm -rf "$work"' EXIT | ||
| check_logging | ||
| kill -0 "$server" | ||
|
Comment on lines
20
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exercise 11 readiness probe fails on connection reset. The first Retry any connection error during startup. Curl 7.71 and later support Suggested fix
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env bash | ||
| # Create a local release tag from the reviewed checkout. | ||
| set -euo pipefail | ||
| tag=${1:?Usage: tag-student-edition.sh classroom-YYYY.MM.DD} | ||
| root=$(git rev-parse --show-toplevel) | ||
| cd "$root" | ||
| [[ $tag =~ ^classroom-[0-9]{4}\.[0-9]{2}\.[0-9]{2}(\.[1-9][0-9]*)?$ ]] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate the calendar date before creating the tag.
|
||
| revision=$(git rev-parse HEAD) | ||
| git merge-base --is-ancestor "$revision" origin/main | ||
| scratch=$(mktemp -d) | ||
| trap 'rm -rf "$scratch"' EXIT | ||
| context="$scratch/context" | ||
| "$root/containers/prepare.sh" "$context" | ||
| mkdir -p "$scratch/tree/.github/workflows" | ||
| cd "$scratch/tree" | ||
| cp -R "$context/materials" . | ||
| git -C "$root" show "$revision:.github/workflows/course-release.yml" > .github/workflows/course-release.yml | ||
| git -C "$root" show "$revision:LICENSE" > LICENSE | ||
| cat > README.md <<NOTES | ||
| # CVE Lite Classroom $tag | ||
|
|
||
| Open \`materials/README.md\` to find your exercise. The release assets and Docker image | ||
| include the course website and classroom tools. | ||
|
|
||
| [Reviewed course source](https://github.com/sonukapoor/cve-lite-classroom/commit/$revision) | ||
| NOTES | ||
| export GIT_DIR | ||
| GIT_DIR=$(git -C "$root" rev-parse --absolute-git-dir) | ||
| export GIT_WORK_TREE="$scratch/tree" GIT_INDEX_FILE="$scratch/index" | ||
| git add -f -- . | ||
| tree=$(git write-tree) | ||
| snapshot=$(git commit-tree "$tree" -m "Student materials for $tag from $revision") | ||
| git tag -a "$tag" "$snapshot" -m "CVE Lite Classroom $tag from $revision" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve student snapshots for manual tag runs too.
If a maintainer dispatches this workflow on a student-edition tag,
TAG_BUILDisfalse. This skips the checkout of the recorded course revision. The snapshot lackscontainersandwebsite, so staging cannot complete. GitHub supports tag references forworkflow_dispatch. (docs.github.com)Before this change, classroom tags contained the course source. The new script creates materials-only snapshots. Resolve those snapshots for manual tag runs too, and fetch the required history. Keep the push-only publication gate unchanged. (raw.githubusercontent.com)