-
Notifications
You must be signed in to change notification settings - Fork 0
Home
If you're asking this question, then I guarantee that you're in need of it!
noun: hygiene conditions or practices conducive to maintaining health and preventing disease, especially through cleanliness.
Hygiene for .NET is a library meant to keep your code, data, and inputs clean and sanitary. By formalizing and outlining the good habits for sanitization, this project seeks to assist developers in writing more resilient, maintainable code.
Anytime code crosses an integration point, control over the data passing through your system is lost to another consumer. In order to ensure that data conforms to the system's expectations, it is necessary to validate data and make attempts to normalize that data to the supported formats.
Refusing to clean your inputs means that you can open your system to potential vulnerabilities. However, being overzealous with your cleaning habits may lead to your system supporting too broad a set of data. For example, trimming whitespace from a credit card number means that consumers of your service will be able to expect arbitrary whitespace at the end of a card number as valid input, and may become a "hidden feature" requiring support into the future. Consciously consider the constraints that make your data valid, and what needs to be cleaned will become clear.
var configuration = new SanitizerConfigurationProvider(builder
=> builder.ForType((ref string input)
=> input = input.Trim('-')));
var sanitizer = configuration.CreateSanitizer<string>();
- Libraries
- Validation (AArnott)
- Fluent Validations
- Polly
- Humanizer
- Code Contracts
- Analyzers