feat(websample): add Cache and Sanitization feature demonstrations - #53
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).