Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The maintainer must approve every pull request.
* @Muawiya-contact

# Lessons and course files belong to the maintainer only.
/lessons/ @Muawiya-contact
/course.yml @Muawiya-contact
/ROADMAP.md @Muawiya-contact
/LESSON_TEMPLATE.md @Muawiya-contact
/scripts/ @Muawiya-contact
/.github/ @Muawiya-contact
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/lesson-feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lesson feedback
description: Report a mistake, an outdated command, or something unclear in a lesson
title: "[Lesson feedback] "
labels: ["lesson-feedback"]
body:
- type: input
id: lesson
attributes:
label: Which lesson?
description: File path or link
placeholder: lessons/01-networking-fundamentals/01-tcp-ip/01-what-is-an-ip-address.md
validations:
required: true
- type: dropdown
id: kind
attributes:
label: Type of feedback
options:
- Wrong information
- Command doesn't work / outdated
- Unclear explanation
- Missing topic or example
- Typo / small fix
- Other
validations:
required: true
- type: textarea
id: problem
attributes:
label: What is the problem?
validations:
required: true
- type: textarea
id: fix
attributes:
label: Suggested fix
description: How should it be written? Add a source link if you have one.
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## What does this PR add?

<!-- Project name and a short description -->

## Checklist

- [ ] My changes are only inside `projects/<my-project>/`
- [ ] My project has a README (from `projects/PROJECT_TEMPLATE.md`)
- [ ] No passwords, API keys, personal data or real target addresses
- [ ] Any scanning/testing feature is for authorized targets only
- [ ] I tested it

## How did you test it?

<!-- OS, versions, and what you ran -->

---
<!-- Want to fix a lesson? Contributors can't edit lessons. Please open a "Lesson feedback" issue instead. -->
114 changes: 114 additions & 0 deletions .github/workflows/pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Course PDF

# • Pull request → builds a preview PDF (download it from the run's "Artifacts")
# • Merge to main → updates the "latest" release with the new PDF
# • Every 1 January (or run by hand) → saves a yearly edition, e.g. "2027 Edition"
#
# Download link that never changes:
# https://github.com/<owner>/<repo>/releases/download/latest/network-security-lab.pdf

on:
pull_request:
branches: [main]
push:
branches: [main]
schedule:
- cron: "10 0 1 1 *" # 1 January, 00:10 UTC
workflow_dispatch:
inputs:
edition:
description: "Edition name (leave empty for '<year> Edition')"
required: false

concurrency:
group: pdf-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history → growth chart in the PDF

- name: Skip PRs that don't touch the course
id: scope
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "build=true" >> "$GITHUB_OUTPUT"; exit 0
fi
if git diff --name-only "${{ github.event.pull_request.base.sha }}...HEAD" \
| grep -qE '^(lessons/|projects/|course.yml|scripts/)'; then
echo "build=true" >> "$GITHUB_OUTPUT"
else
echo "No course changes — no preview needed."
echo "build=false" >> "$GITHUB_OUTPUT"
fi

- uses: actions/setup-python@v5
if: steps.scope.outputs.build == 'true'
with:
python-version: "3.12"

- name: Install
if: steps.scope.outputs.build == 'true'
run: |
sudo apt-get update -q
sudo apt-get install -y -q libpango-1.0-0 libpangoft2-1.0-0 fonts-noto-core fonts-dejavu-core
pip install -r scripts/requirements.txt

- name: Pick edition name
if: steps.scope.outputs.build == 'true'
id: ed
run: |
case "${{ github.event_name }}" in
schedule) echo "name=$(date +%Y) Edition" >> "$GITHUB_OUTPUT" ;;
workflow_dispatch) n="${{ github.event.inputs.edition }}"; echo "name=${n:-$(date +%Y) Edition}" >> "$GITHUB_OUTPUT" ;;
pull_request) echo "name=Preview — PR #${{ github.event.number }}" >> "$GITHUB_OUTPUT" ;;
*) echo "name=Latest edition" >> "$GITHUB_OUTPUT" ;;
esac

- name: Build PDF
if: steps.scope.outputs.build == 'true'
run: python scripts/build_pdf.py --edition "${{ steps.ed.outputs.name }}"

# ── PR: preview only ──
- name: Upload preview
if: github.event_name == 'pull_request' && steps.scope.outputs.build == 'true'
uses: actions/upload-artifact@v4
with:
name: course-pdf-preview
path: dist/network-security-lab.pdf
retention-days: 14

# ── main: refresh the "latest" release ──
- name: Update latest release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release delete latest --cleanup-tag --yes 2>/dev/null || true
gh release create latest dist/network-security-lab.pdf \
--target "${{ github.sha }}" \
--title "Course PDF — latest" \
--notes "Auto-built from \`${{ github.sha }}\` on $(date -u +'%d %b %Y'). Lessons not written yet are marked *Coming soon*." \
--latest

# ── yearly edition ──
- name: Save yearly edition
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ github.token }}
EDITION: ${{ steps.ed.outputs.name }}
run: |
TAG="edition-$(echo "$EDITION" | tr '[:upper:] ' '[:lower:]-' | tr -cd 'a-z0-9-')"
cp dist/network-security-lab.pdf "dist/network-security-lab-${TAG#edition-}.pdf"
gh release delete "$TAG" --cleanup-tag --yes 2>/dev/null || true
gh release create "$TAG" "dist/network-security-lab-${TAG#edition-}.pdf" \
--target "${{ github.sha }}" \
--title "Course PDF — $EDITION" \
--notes "Snapshot of the course on $(date -u +'%d %b %Y')." \
--latest=false
51 changes: 51 additions & 0 deletions .github/workflows/protect-lessons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Protect lessons

# Contributors may only change files inside projects/.
# Pull requests from maintainers are allowed to change anything.

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
check-paths:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Only projects/ can be changed by contributors
env:
AUTHOR: ${{ github.event.pull_request.user.login }}
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
# Add more maintainers separated by spaces.
MAINTAINERS="Muawiya-contact"

for m in $MAINTAINERS; do
if [ "${AUTHOR,,}" = "${m,,}" ]; then
echo "Maintainer PR ($AUTHOR) — skipping check."
exit 0
fi
done

CHANGED=$(git diff --name-only "$BASE...$HEAD")
echo "Changed files:"
echo "$CHANGED"

BLOCKED=$(echo "$CHANGED" | grep -Ev '^projects/' || true)

if [ -n "$BLOCKED" ]; then
echo "::error::Contributors can only change files inside projects/."
echo "These files are not allowed in your PR:"
echo "$BLOCKED"
echo "Want to suggest a lesson fix? Open a 'Lesson feedback' issue instead."
exit 1
fi

echo "All changes are inside projects/ — OK."
33 changes: 33 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check course

# Runs on every PR, for everyone (maintainer too).
# If the PR doesn't touch lessons/, projects/, course.yml or ROADMAP.md
# the check passes straight away.
#
# Note: no "paths:" filter on purpose — if this check is "required",
# a filtered-out PR would wait forever for it.

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
check-course:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install
run: pip install pyyaml

- name: Check lessons, projects and roadmap
run: python scripts/validate.py --base "${{ github.event.pull_request.base.sha }}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
__pycache__/
*.pyc
.venv/
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,30 @@ Thanks for helping! Please read this before opening a pull request.
**Contributors cannot change lesson files** (or anything outside `projects/`).
A check runs on every pull request. If your PR changes files outside `projects/`, it will fail and can't be merged.

## Automatic checks on every PR

| Check | What it looks at |
| ----- | ---------------- |
| **Protect lessons** | Contributors only changed files in `projects/` |
| **Check course** | Lesson names and folders match `course.yml` · required sections are there and in order · links and images work · `ROADMAP.md` is up to date · project folder name and README sections · no secrets or huge files |
| **Course PDF** | Builds a preview PDF — download it from the PR's check run (Artifacts) |

PRs that don't touch lessons, projects or the roadmap pass straight away.
Run the same check on your computer before you push:

```bash
pip install -r scripts/requirements.txt
python scripts/validate.py
```

---

## 1. Adding a project

1. Fork the repo.
2. Create a new folder: `projects/your-project-name/` (lowercase, use `-` between words).
3. Add a `README.md` inside it using the [project template](projects/PROJECT_TEMPLATE.md).
Required sections: What it does · How to run · How I tested it · Safety note, plus the `**Author:**` line.
4. Add your code in the same folder.
5. Open a pull request.

Expand Down
17 changes: 12 additions & 5 deletions LESSON_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Lesson title

> **Phase:** 01 — Networking Fundamentals
> **Module:** TCP/IP
> **Module:** TCP/IP and IP Addressing
> **Lesson:** 01
> **Tested on:** (OS / tool version, if relevant)

<!--
File name must match course.yml, e.g.
lessons/01-networking-fundamentals/01-tcp-ip/01-what-is-an-ip-address.md

Required sections: Objective, Explanation, Check your understanding, References.
Optional sections: delete the ones you don't need, but keep the order below.
Images → assets/ next to this file: ![diagram](assets/ip-diagram.png)
Code → code/<this-file-name>/: [script](code/01-what-is-an-ip-address/show_ip.py)
Code files are listed with GitHub links in the PDF automatically.
-->

## Objective
What will you learn today? (1–2 lines)

Expand All @@ -21,7 +32,6 @@ Real, easy-to-follow examples. Add a diagram if it helps.
```bash
# command — what it does
```
(Skip this section if the topic has no commands.)

## Practical work
A safe exercise you can do on your own machine or lab.
Expand All @@ -39,6 +49,3 @@ How this topic connects to attacks or defense.

## References
- [Official source](https://example.com)

---
*Not every lesson needs every section. Fit the lesson to the topic.*
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ Every lesson is small, focused on one topic, and has a practical exercise.
One lesson = one topic. A new lesson is added about once a day.

```
course.yml → the course plan (source of the roadmap)
ROADMAP.md → generated from course.yml
lessons/ → the course (written by the maintainer)
01-networking-fundamentals/
01-tcp-ip/
01-what-is-an-ip-address.md
code/01-what-is-an-ip-address/ → practice code for that lesson
assets/ → images
projects/ → projects built by the community
scripts/ → checks, roadmap and PDF builders
```

## Download the course as a PDF

📘 **[Download the latest PDF](../../releases/download/latest/network-security-lab.pdf)**

The PDF is rebuilt automatically every time something is merged. It has every published lesson, "Coming soon" for the rest, clickable links to each lesson, its practice code and the community projects on GitHub, and a progress page showing how the course grows. A yearly edition is saved every 1 January in [Releases](../../releases).

## Where to start

1. Read the [Roadmap](ROADMAP.md) to see what's coming.
Expand Down
Loading
Loading