Skip to content

feat(websample): add Cache and Sanitization feature demonstrations - #53

Merged
marioarce merged 5 commits into
developfrom
feature/websample-feature-samples
Jul 23, 2026
Merged

feat(websample): add Cache and Sanitization feature demonstrations#53
marioarce merged 5 commits into
developfrom
feature/websample-feature-samples

Conversation

@marioarce

Copy link
Copy Markdown
Owner

This PR adds working sample endpoints to the WebSample application that demonstrate the Cache and Sanitization features integrated into the Features Framework, providing developers with concrete examples of feature usage and configuration.

Changes include:

  • CacheSampleEndpoints: demonstrates the Cache feature via DI-resolved ICacheService, showing a cache miss followed by a set/hit round-trip. Falls back to NoOp cache if the feature is disabled.

  • SanitizationSampleEndpoints: demonstrates all four Sanitization concerns — log injection prevention (CWE-117), file-path traversal prevention (CWE-22), sensitive data masking (CWE-200), and regex injection/ReDoS prevention (CWE-400/CWE-730) — using the DI-resolved ISanitizationService.

  • WebSample.csproj: added references to PowerCSharp.Features, PowerCSharp.Feature.Cache, PowerCSharp.Feature.Cache.BitFaster, and PowerCSharp.Feature.Sanitization packages.

  • Program.cs: integrated PowerFeatures Framework initialization via AddPowerCSharpFeatures() and UsePowerCSharpFeatures() pipeline hook, with endpoints mapped via MapPowerCSharpDemoEndpoints().

  • appsettings.json: added PowerFeatures configuration section enabling both Cache (BitFaster provider) and Sanitization features with sensible defaults.

  • ServiceCollectionExtensions and WebApplicationExtensions: added helper methods to encapsulate framework setup and endpoint registration, keeping Program.cs clean and maintainable.

Developers can now clone the sample, run it, and interact with both features via Swagger UI to understand feature configuration, DI integration, and expected behavior (including graceful fallback to NoOp implementations when features are disabled).

 - Add project references to the Features engine and its abstractions
 - Add project references to the Cache feature and BitFaster provider
 - Add project references to the Sanitization feature and its abstractions
 - Register the Features Framework via auto discovery, opting in the Cache and Sanitization modules
 - Register the BitFaster cache provider so the cache demo has an active backend
 - Run the Features Framework pipeline hook after building the app
 - Map new demo endpoints for the cache and sanitization features
 - Demonstrate a cache miss followed by a set and hit round trip
 - Resolve the cache service via dependency injection
 - Demonstrate log injection, file path traversal, sensitive data masking, and regex injection sanitization
 - Resolve the sanitization service via dependency injection
 - Add a PowerFeatures configuration section enabling both features
 - Configure the BitFaster provider and capacity for the cache demo
@marioarce marioarce self-assigned this Jul 23, 2026
@marioarce
marioarce merged commit 0d44377 into develop Jul 23, 2026
6 checks passed
@github-actions
github-actions Bot deleted the feature/websample-feature-samples branch July 23, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Epic] Sanitization Feature — log injection, path traversal, sensitive-data & regex-injection prevention

1 participant