From 0b9ede5f843fb39e4a8bd65a4a5f4fbd960218c5 Mon Sep 17 00:00:00 2001 From: Charles N Wyble Date: Tue, 17 Feb 2026 11:34:11 -0500 Subject: [PATCH] fix: resolve all shellcheck warnings and security issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix(shellcheck): SC2016 in encryption-setup.sh - remove non-expanding $(blkid...) - fix(shellcheck): SC1091 in firewall-setup.sh and security-hardening.sh - add disable directives - security: SSH PasswordAuthentication yes -> no (PRD FR-006 violation) - fix: date expansion in encryption-validation.sh heredoc - docs: create SDLC.md with TDD workflow and security requirements - docs: update AGENTS.md to reference SDLC.md - chore: update STATUS.md with build completion - chore: minor build-iso.sh output formatting All 78 tests pass (63 run, 15 skip for libvirt). Zero shellcheck warnings. πŸ’˜ Generated with Crush Assisted-by: GLM-5 via Crush --- AGENTS.md | 2 + SDLC.md | 338 ++++++++++++++++++ STATUS.md | 40 ++- config/hooks/installed/encryption-setup.sh | 4 +- .../hooks/installed/encryption-validation.sh | 5 +- config/hooks/live/firewall-setup.sh | 3 +- config/hooks/live/security-hardening.sh | 3 +- monitor-build.sh | 43 +++ src/build-iso.sh | 10 +- src/security-hardening.sh | 3 +- 10 files changed, 421 insertions(+), 30 deletions(-) create mode 100644 SDLC.md create mode 100755 monitor-build.sh diff --git a/AGENTS.md b/AGENTS.md index 8456b40..d4946f0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -143,6 +143,7 @@ β”œβ”€β”€ JOURNAL.md # AI memory - ADRs, patterns, lessons learned β”œβ”€β”€ PRD.md # Product requirements β”œβ”€β”€ AGENTS.md # Agent guidelines (START HERE) +β”œβ”€β”€ SDLC.md # Software Development Lifecycle (READ THIS) └── docs/ # Detailed documentation β”œβ”€β”€ TEST-COVERAGE.md # Test suite coverage β”œβ”€β”€ VERIFICATION-REPORT.md # Compliance verification @@ -243,6 +244,7 @@ git log --oneline -10 #### 2. UNDERSTAND REQUIREMENTS - Read MANDATORY SECURITY REQUIREMENTS (above) - Review PRD.md for detailed requirements +- Read SDLC.md for development workflow (CRITICAL) - Check AGENTS.md for critical constraints - Understand Docker-only workflow diff --git a/SDLC.md b/SDLC.md new file mode 100644 index 0000000..6475954 --- /dev/null +++ b/SDLC.md @@ -0,0 +1,338 @@ +# KNEL-Football Secure OS - Software Development Lifecycle (SDLC) + +**Version:** 1.0 +**Status:** Active +**Last Updated:** 2026-02-17 + +--- + +## Overview + +This document defines the mandatory Software Development Lifecycle (SDLC) for the KNEL-Football Secure OS project. As a **critical infrastructure project** supporting CMMC/FedRAMP/ITAR compliance, we maintain zero tolerance for security defects and require strict adherence to these processes. + +--- + +## Core Principles + +### 1. Security First +- Every change must preserve or enhance security +- No shortcuts, no exceptions, no "temporary" bypasses +- All code is security-critical code + +### 2. Test-Driven Development (TDD) +- **Red β†’ Green β†’ Refactor** - Mandatory workflow +- No code without tests +- No merge without passing tests + +### 3. Defense in Depth +- Multiple layers of verification +- Automated + manual review +- Build-time + runtime validation + +--- + +## Test-Driven Development (TDD) Workflow + +### Mandatory TDD Process + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ TDD WORKFLOW β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ β”‚ +β”‚ 1. RED: Write a failing test β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ β€’ Write test FIRST (before implementation) β”‚ β”‚ +β”‚ β”‚ β€’ Test MUST fail initially β”‚ β”‚ +β”‚ β”‚ β€’ Run: ./run.sh test: β”‚ β”‚ +β”‚ β”‚ β€’ Confirm test fails for RIGHT reason β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ ↓ β”‚ +β”‚ 2. GREEN: Write minimal code to pass β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ β€’ Write MINIMUM code to make test pass β”‚ β”‚ +β”‚ β”‚ β€’ Do not over-engineer β”‚ β”‚ +β”‚ β”‚ β€’ Run: ./run.sh test: β”‚ β”‚ +β”‚ β”‚ β€’ Confirm test passes β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ ↓ β”‚ +β”‚ 3. REFACTOR: Improve code quality β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ β€’ Clean up implementation β”‚ β”‚ +β”‚ β”‚ β€’ Remove duplication β”‚ β”‚ +β”‚ β”‚ β€’ Improve readability β”‚ β”‚ +β”‚ β”‚ β€’ Run: ./run.sh test (ALL tests must pass) β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ ↓ β”‚ +β”‚ REPEAT AS NEEDED β”‚ +β”‚ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +### TDD Rules + +1. **Rule 1**: You MUST write a failing test before writing implementation code +2. **Rule 2**: You MUST NOT write more implementation than needed to pass the test +3. **Rule 3**: You MUST run ALL tests after refactoring + +### Test Execution Commands + +```bash +# Run all tests +./run.sh test + +# Run specific test suites +./run.sh test:unit # Unit tests only +./run.sh test:integration # Integration tests only +./run.sh test:security # Security/compliance tests only + +# Run linting (shellcheck) +./run.sh lint +``` + +### Test Coverage Requirements + +| Category | Minimum Coverage | Target | +|----------|------------------|--------| +| Security functions | 100% | 100% | +| Encryption setup | 100% | 100% | +| Password policy | 100% | 100% | +| Firewall rules | 100% | 100% | +| Build scripts | 80% | 95% | +| Utility functions | 80% | 90% | + +--- + +## Pre-Commit Checklist + +**Before committing ANY change, verify:** + +- [ ] All tests pass: `./run.sh test` +- [ ] Lint passes with zero warnings: `./run.sh lint` +- [ ] Security tests pass: `./run.sh test:security` +- [ ] Code follows existing style +- [ ] Commit message follows conventional format +- [ ] No secrets, credentials, or sensitive data in commit + +--- + +## Code Quality Standards + +### Shell Script Standards + +1. **Zero Shellcheck Warnings** + - All shell scripts MUST pass shellcheck with zero warnings + - No exceptions, no suppressions without documented justification + - Run: `./run.sh lint` + +2. **Strict Mode** + - All scripts MUST use: `set -euo pipefail` + - No uninitialized variables + - No unset variable access + +3. **Error Handling** + - All errors must be handled explicitly + - Use `|| true` only when failure is expected and acceptable + - Log all errors with context + +4. **Security Conventions** + - Quote all variables: `"$variable"` + - Use `[[ ]]` for tests (not `[ ]`) + - Avoid `eval` and other code injection vectors + - Never log secrets or credentials + +### Documentation Standards + +1. **Code Comments** + - Explain WHY, not WHAT + - Reference requirements (e.g., "PRD FR-006: Key-based auth only") + - Document security implications + +2. **Function Documentation** + ```bash + # Function: configure_ssh + # Purpose: Configure SSH server with security hardening + # Requirements: PRD FR-006 (Key-Based Authentication Only) + # Security: Disables password auth per NIST guidelines + configure_ssh() { + ``` + +--- + +## Git Workflow + +### Branch Strategy + +``` +main (protected) + β”‚ + β”œβ”€β”€ feature/ # New features + β”œβ”€β”€ fix/ # Bug fixes + β”œβ”€β”€ security/ # Security fixes (priority) + └── docs/ # Documentation updates +``` + +### Commit Message Format + +``` +: + + + +