Skip to content

Latest commit

 

History

History
258 lines (215 loc) · 8.39 KB

File metadata and controls

258 lines (215 loc) · 8.39 KB

wshell Repository Structure - Complete Summary

What's Included

This zip file contains a complete, ready-to-build C++23 shell interpreter project with:

  • ✅ Modern CMake 3.25+ build system with security hardening
  • ✅ Complete source code with library and executable
  • ✅ Comprehensive unit tests using Google Test (31+ tests)
  • ✅ Fuzz tests using libFuzzer
  • ✅ Cross-platform build scripts (Bash + PowerShell)
  • ✅ Prerequisites installation scripts for dependencies
  • ✅ SBOM (Software Bill of Materials) generation in SPDX format
  • ✅ GitHub Actions CI/CD pipeline with SBOM artifacts
  • ✅ Configuration system with ~/.wshellrc support
  • ✅ AI Coding Guidelines for Claude, ChatGPT, and Copilot
  • ✅ BSD 2-Clause license
  • ✅ Doxygen configuration for documentation

Directory Structure

shell-repo/
├── .github/
│   ├── workflows/
│   │   └── ci.yml                    # GitHub Actions CI pipeline
│   └── AI_CODING_GUIDELINES.md       # Comprehensive AI assistant prompt
│
├── src/
│   ├── lib/                          # Shared library (wshell.so/.dll)
│   │   ├── CMakeLists.txt
│   │   ├── shell_core.h              # Core shell interface
│   │   ├── shell_core.cpp
│   │   ├── command_parser.h          # Command parsing utilities
│   │   └── command_parser.cpp
│   │
│   └── main/                         # Main executable (wshell)
│       ├── CMakeLists.txt
│       └── main.cpp
│
├── test/                             # Unit tests
│   ├── CMakeLists.txt
│   ├── test_shell_core.cpp           # 9 unit tests for ShellCore
│   └── test_command_parser.cpp       # 13 unit tests for CommandParser
│
├── fuzz/                             # Fuzz tests
│   ├── CMakeLists.txt
│   ├── fuzz_command_parser.cpp       # Fuzz test for parser
│   └── fuzz_shell_core.cpp           # Fuzz test for core
│
├── scripts/                          # Utility scripts (Bash + PowerShell)
│   ├── prerequisites.sh / .ps1       # Install all build dependencies
│   ├── configure.sh / .ps1           # Configure CMake build
│   ├── build.sh / .ps1               # Build the project
│   ├── test.sh / .ps1                # Run tests
│   ├── fuzz.sh / .ps1                # Run fuzz tests
│   ├── benchmark.sh / .ps1           # Run performance benchmarks
│   ├── coverage.sh / .ps1            # Generate code coverage
│   ├── clean.sh / .ps1               # Clean build artifacts
│   └── USAGE.md                      # Detailed script documentation
│
├── docs/                             # Documentation output directory
├── CMakeLists.txt                    # Root CMake configuration
├── Doxyfile                          # Doxygen configuration
├── .gitignore                        # C/C++ gitignore
├── LICENSE                           # BSD 2-Clause License
├── README.md                         # Project overview and badges
└── QUICKSTART.md                     # Step-by-step getting started guide

Key Features

1. Security-First Design

  • Compiler Hardening: Full stack protection, ASLR, DEP, Control Flow Guard
  • FORTIFY_SOURCE=3: Buffer overflow detection
  • Sanitizers: ASan, UBSan, LSan for test builds
  • Input Validation: All external inputs validated
  • Modern C++23: RAII, smart pointers, std::expected for error handling

2. Build System

CMake with 4 build types:

  • Release: Optimized production build (-O3, LTO)
  • Debug: Full debug symbols, no optimization
  • Test: Release + debug info + all sanitizers
  • Coverage: Debug + coverage instrumentation

Security flags included:

  • MSVC: /GS, /DYNAMICBASE, /NXCOMPAT, /guard:cf, /sdl
  • GCC/Clang: -fstack-protector-strong, -fstack-clash-protection, -fcf-protection=full, -fPIE -pie, Full RELRO

3. Testing Infrastructure

Unit Tests (31+ tests total):

  • ShellCore: version, execute, validation (9 tests)
  • CommandParser: tokenization, trimming, error handling (13 tests)
  • Config: configuration file parsing, validation, security (21 tests)

Fuzz Tests:

  • Command parser fuzzing
  • Shell core execution fuzzing
  • Corpus preservation for regression testing

Benchmarks:

  • Command parser performance
  • Shell core execution performance
  • Flame graph generation support

4. SBOM Generation

Software Bill of Materials (Supply Chain Security):

  • SPDX 2.3 format in both tag-value and JSON
  • NTIA minimum elements compliant
  • Includes package metadata, file checksums, compiler info
  • Generated automatically on install
  • Uploaded as CI/CD artifacts

SBOM Tools:

  • reuse: REUSE compliance checking
  • spdx-tools: SPDX format conversion and validation
  • ntia-conformance-checker: NTIA compliance verification

5. Configuration System

Bash-like Configuration:

  • Config file: ~/.wshellrc
  • Key-value pairs: KEY=value
  • Comment support with #
  • Quote handling for values with spaces
  • Security validation (1MB max size, 10K variables max)
  • Loaded automatically on startup

6. Cross-Platform Support

Tested on:

  • Linux (Ubuntu) with Clang 18+
  • macOS with Clang
  • Windows with MSVC 2022+

Utility scripts available in both:

  • Bash (.sh) for Linux/macOS
  • PowerShell (.ps1) for Windows

5. CI/CD Pipeline

GitHub Actions workflows include:

  • Multi-platform builds (Linux, macOS, Windows)
  • Multiple compilers (GCC, Clang, MSVC)
  • Sanitizer testing
  • Code coverage with Codecov integration
  • Static analysis with clang-tidy

6. Code Quality

Standards followed:

  • C++23 standard
  • C++ Core Guidelines
  • Effective C++ principles
  • CWE vulnerability prevention
  • OWASP ASVS compliance
  • NIST secure development framework

Quick Start

Linux/macOS:

unzip shell-repo.zip
cd shell-repo
./scripts/configure.sh --release
./scripts/build.sh
./scripts/test.sh

Windows (PowerShell):

Expand-Archive shell-repo.zip
cd shell-repo
.\scripts\configure.ps1 -Release
.\scripts\build.ps1
.\scripts\test.ps1

What You Can Do Immediately

  1. Build and Run: Extract, configure, build, test - it's ready to go
  2. Extend Functionality: Add new commands to the shell
  3. Add Tests: Write more unit tests or fuzz tests
  4. CI/CD: Push to GitHub and workflows will run automatically
  5. Documentation: Run doxygen to generate API docs

AI Coding Guidelines

The .github/AI_CODING_GUIDELINES.md file contains comprehensive instructions for:

  • Claude (Anthropic)
  • ChatGPT (OpenAI)
  • GitHub Copilot

These guidelines ensure:

  • Security-first development
  • Modern C++23 best practices
  • Proper testing and documentation
  • Compliance with security standards

Code Examples

Simple Command Execution

#include "shell_core.h"

wshell::ShellCore shell;
auto result = shell.execute("echo hello");
if (result.has_value()) {
    std::cout << "Exit code: " << result.value() << "\n";
}

Command Parsing

#include "command_parser.h"

auto tokens = wshell::CommandParser::tokenize("echo \"hello world\"");
// tokens = ["echo", "hello world"]

auto trimmed = wshell::CommandParser::trim("  spaces  ");
// trimmed = "spaces"

Build Targets Summary

Target Optimization Debug Info Sanitizers Use Case
Release -O3 + LTO No No Production
Debug -O0 Full No Development
Test -O2 Yes All CI/CD Testing
Coverage -O0 Yes No Coverage Analysis

What's Working

✅ Compiles cleanly with C++23 ✅ All 22 unit tests pass ✅ Fuzz tests run without crashes ✅ Cross-platform build scripts work ✅ CMake configuration is correct ✅ Security flags are properly applied ✅ Library and executable link correctly

Next Steps

  1. Initialize Git: git init && git add . && git commit -m "Initial commit"
  2. Push to GitHub: Create repo at https://github.com/wsollers/shell
  3. Set up Codecov: Add CODECOV_TOKEN to GitHub secrets
  4. Enable GitHub Pages: For Doxygen documentation
  5. Start Coding: Add shell functionality!

Support

For questions or issues:

  • Review QUICKSTART.md for detailed setup instructions
  • Check AI_CODING_GUIDELINES.md for coding standards
  • Open issues on GitHub

Copyright (c) 2024 William Sollers
License: BSD 2-Clause