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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ jobs:
run: python -m compileall -q scripts tests
- name: Unit tests
run: python -m unittest discover -s tests -v

pages-disabled:
name: Pages disabled (security policy)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Check GitHub event and committed workflows (no network)
run: |
python -m scripts.pages_policy \
--event "$GITHUB_EVENT_PATH" \
--repository "$GITHUB_REPOSITORY" \
--workflows .github/workflows
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Develop inspectable, reproducible, **defensive** reliability and security resear
## Local testbed gate

- Never enable GitHub Pages, publish a project URL/dashboard, or add a hosted endpoint for this repository.
- Treat repository Pages status as an external admin-controlled security gate: Settings → Pages must have publishing branch None; a source PR cannot disable a GitHub-managed Pages site. Never remove or bypass the no-Pages CI check merely to make CI green.
- Pin trusted host directory/file descriptors for any state-changing VM or evidence operation. Refuse group/other-writable ancestors, unexpected symlinks, and public evidence directories; no path-based revalidation after a slow process call.
- Evidence sealing and verification require a quiescent or externally snapshotted input; SHA-256 does not prove point-in-time consistency against malicious simultaneous writers.
- Keep guest networking disabled by default. No NIC, NAT, bridge, public graphics or host passthrough without separate explicit scope review.
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ RHEL-LAB is an Apache-2.0-licensed research workspace for controlled experiments

> Status: RHEL-LAB-002 virtual-testbed tooling proposed for review. No RHEL VM has been installed, tested or booted by this repository.

## No GitHub Pages / web deployment

**Security policy:** no GitHub Pages site, hosted dashboard or public endpoint. GitHub's server-managed Pages workflow ran after the previous merge even though this repository contains no Pages deployment YAML. The current Pages site must be removed administratively, not by deleting our source-check workflow. See [Pages shutdown and prevention](docs/PAGES_SHUTDOWN.md). The separate CI guard reports a security-policy failure until GitHub's repository metadata explicitly shows Pages disabled.

## Research boundaries

- Run experiments only on owned or explicitly authorized lab systems. No Red Hat-hosted services, third-party targets, or production infrastructure.
Expand All @@ -27,7 +31,8 @@ See [AGENTS.md](AGENTS.md), [SECURITY.md](SECURITY.md), and [docs/RESEARCH_PROTO
| scripts/evidence.py | Dependency-free SHA-256 evidence inventory and verifier |
| scripts/testbed.py | Operator-gated local KVM profile, auditing and offline disk snapshots |
| tests/ | Safe standard-library unit tests |
| .github/workflows/ci.yml | Non-privileged source checks only |
| .github/workflows/ci.yml | Non-privileged source checks and no-Pages status policy |
| scripts/pages_policy.py | Fail-closed offline check of GitHub's Pages metadata and committed workflow contents |

## Quick start

Expand Down
44 changes: 44 additions & 0 deletions docs/PAGES_SHUTDOWN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# No GitHub Pages — shutdown and prevention

## Observed problem

GitHub automatically published Pages from RHEL-LAB's main branch in
run 43184072056 on 2026-11-12, targeting commit
3209cbd9a2dc842c4f89f95336b1f66b15cc3391.
That run has completed successfully and cannot now be cancelled.

The repository has only .github/workflows/ci.yml. Pages uses GitHub's
server-managed dynamic workflow, not a committed deployment workflow.
A pull request alone cannot disable the Pages repository setting.

## Required administrator action

1. Open QSOLKCB/RHEL-LAB > Settings > Pages.
2. Under Build and deployment, change Source to Deploy from a branch
(even if GitHub Actions is currently selected).
3. Select branch None, then Save.
4. Verify repository metadata has_pages is false and no new Pages run
occurs on subsequent main pushes.

This removes the Pages site without deleting the repository or history.
Unpublishing a site alone can allow a later deployment to republish it.

Official GitHub instructions:
https://docs.github.com/en/pages/getting-started-with-github-pages/deleting-a-github-pages-site

## Source-controlled guard

The Pages-disabled job reads the repository metadata from GITHUB_EVENT_PATH
and fails unless has_pages is exactly false for QSOLKCB/RHEL-LAB.
It also rejects known publishing workflow patterns committed to this repo.

This job uses Python's standard library only; it performs no extra network
requests, site mutation, or deployment. Its unit tests use simulated events.

The guard is expected to FAIL while the repository's Pages site is enabled.
It cannot stop a deployment already running or alter GitHub administration
settings. The GitHub event is a snapshot; an administrator can still enable
Pages later. Review the repository configuration as a separate security gate.

No repository security policy should claim the site is disabled until GitHub
reports that it really is disabled.
72 changes: 72 additions & 0 deletions scripts/pages_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""Fail-closed, offline GitHub Pages policy check for QSOLKCB/RHEL-LAB.

GitHub's automatic Pages workflow cannot be disabled by a pull request.
The repository administrator must delete the Pages site through Settings.
"""
from __future__ import annotations

import argparse
import json
import re
import sys
from pathlib import Path


class PolicyError(ValueError):
"""Pages state unknown or repository policy violated."""


PUBLISH_MARKERS = (
re.compile(r"\bactions/(?:deploy-pages|upload-pages-artifact)@", re.I),
re.compile(r"\bpeaceiris/actions-gh-pages@", re.I),
# Equivalent YAML permission mappings: block style (including quoted keys
# and values), plus flow style with a first or later map entry.
re.compile(r"""(?im)^[ \t]*["']?pages["']?[ \t]*:[ \t]*["']?write["']?(?=[ \t]*(?:#|$))"""),
re.compile(r"""(?i)[,{][ \t\r\n]*["']?pages["']?[ \t]*:[ \t]*["']?write["']?(?=[ \t]*(?:,|\}|#|$))"""),
re.compile(r"\bgh-pages\b", re.I),
)


def check(event: object, repository: str, workflows: Path) -> None:
if repository != "QSOLKCB/RHEL-LAB":
raise PolicyError("incorrect repository for RHEL-LAB guard")
if not isinstance(event, dict) or not isinstance(event.get("repository"), dict):
raise PolicyError("GitHub event missing repository metadata")
metadata = event["repository"]
if metadata.get("full_name") != repository:
raise PolicyError("GitHub event repository identity mismatch")
if metadata.get("has_pages") is not False:
raise PolicyError("GitHub Pages is enabled or status missing; set Settings > Pages > Source: Deploy from a branch > Branch: None > Save")
if not workflows.is_dir() or workflows.is_symlink():
raise PolicyError("workflow directory missing or unsafe")
for path in sorted((*workflows.glob("*.yml"), *workflows.glob("*.yaml"))):
if not path.is_file() or path.is_symlink():
raise PolicyError(f"unsafe workflow: {path.name!r}")
active = "\n".join(
line for line in path.read_text(encoding="utf-8").splitlines()
if not line.lstrip().startswith("#")
)
if any(marker.search(active) for marker in PUBLISH_MARKERS):
raise PolicyError(f"Pages deployment reference in {path.name!r}")


def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--event", type=Path, required=True)
parser.add_argument("--repository", required=True)
parser.add_argument("--workflows", type=Path, required=True)
args = parser.parse_args(argv)
try:
with args.event.open(encoding="utf-8") as handle:
event = json.load(handle)
check(event, args.repository, args.workflows)
except (PolicyError, OSError, ValueError) as exc:
print(f"FAIL: Pages policy: {exc}", file=sys.stderr)
return 1
print("PASS: GitHub event declares Pages disabled; no publishing workflow found")
return 0


if __name__ == "__main__":
raise SystemExit(main())
120 changes: 120 additions & 0 deletions tests/test_pages_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""Pure, offline regression checks for the no-Pages repository policy."""
from __future__ import annotations

import json
import tempfile
import unittest
from pathlib import Path

from scripts import pages_policy as policy


class PagesPolicyTests(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup)
self.root = Path(self.tmp.name)
self.workflows = self.root / "workflows"
self.workflows.mkdir()
(self.workflows / "ci.yml").write_text(
"name: Source checks\npermissions:\n contents: read\n",
encoding="utf-8")
self.event = {"repository": {
"full_name": "QSOLKCB/RHEL-LAB", "has_pages": False
}}

def test_disabled_and_no_publish_workflow(self):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_enabled_pages_fails(self):
self.event["repository"]["has_pages"] = True
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_missing_pages_state_fails_closed(self):
del self.event["repository"]["has_pages"]
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_string_false_is_not_valid(self):
self.event["repository"]["has_pages"] = "false"
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_wrong_repository_rejected(self):
self.event["repository"]["full_name"] = "wrong/repo"
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_pages_write_permission_rejected(self):
(self.workflows / "bad.yml").write_text(
"permissions:\n pages: write\n", encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_inline_pages_write_permission_rejected(self):
(self.workflows / "inline.yml").write_text(
"permissions: {pages: write}\n", encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_quoted_pages_write_permission_rejected(self):
(self.workflows / "quoted.yml").write_text(
'permissions:\n "pages": write\n', encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_inline_quoted_mapping_and_value_rejected(self):
(self.workflows / "quoted.yml").write_text(
'permissions: {contents: read, "pages": "write"}\n',
encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_single_quoted_permissions_rejected(self):
(self.workflows / "quoted.yml").write_text(
"permissions:\n 'pages': 'write'\n", encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_similar_permission_value_not_rejected(self):
(self.workflows / "other.yml").write_text(
'permissions: {pages: readonly, contents: read}\n',
encoding="utf-8")
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_deployment_action_rejected(self):
(self.workflows / "bad.yaml").write_text(
"steps:\n - uses: actions/deploy-pages@v4\n", encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_gh_pages_branch_rejected(self):
(self.workflows / "bad.yml").write_text(
"run: git push origin HEAD:gh-pages\n", encoding="utf-8")
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_comment_alone_not_a_publishing_workflow(self):
(self.workflows / "safe.yaml").write_text(
"# This workflow never calls actions/deploy-pages@v4\nname: Safe\n",
encoding="utf-8")
policy.check(self.event, "QSOLKCB/RHEL-LAB", self.workflows)

def test_cli_fail_closed(self):
self.event["repository"]["has_pages"] = True
file = self.root / "event.json"
file.write_text(json.dumps(self.event), encoding="utf-8")
self.assertEqual(policy.main([
"--event", str(file), "--repository", "QSOLKCB/RHEL-LAB",
"--workflows", str(self.workflows)
]), 1)

def test_missing_workflow_directory_fails(self):
with self.assertRaises(policy.PolicyError):
policy.check(self.event, "QSOLKCB/RHEL-LAB",
self.root / "missing")


if __name__ == "__main__":
unittest.main()
Loading