Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Real-World Examples

This section shows practical, real-world scenarios where strict-path helps secure your applications. Each example includes complete, runnable code that you can adapt to your own projects.

📚 Example Categories

Web Applications

Application Development

Security-Critical Operations

🎯 Common Patterns

All examples follow the same security pattern:

  1. Create a boundary - Define your safe area with PathBoundary or VirtualRoot
  2. Validate external input - Always use strict_join() or virtual_join() for untrusted paths
  3. Use safe types - Operate through StrictPath or VirtualPath for all file operations
  4. Let the compiler help - Type signatures encode security guarantees

🔐 What Makes These Secure?

  • No path escapes - Users can't use ../ or absolute paths to escape boundaries
  • Compile-time safety - Wrong marker types won't compile
  • Clear interfaces - Function signatures document what paths they accept
  • Maintainable - Security isn't something to remember, it's in the type system

💡 Using These Examples

Each example is:

  • Complete - Includes all necessary imports and error handling
  • Runnable - Copy-paste and adapt to your needs
  • Explained - Comments highlight security patterns and key concepts
  • Battle-tested - Shows real attack vectors that are automatically blocked

Choose an example that matches your use case and start building secure applications!