
Product
A Fresh Look for the Socket Dashboard
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
InputSanitizer is a filter used to clear all illegal strings from the data received by the API or MVC Controller.
It is based on HtmlSanitizer as an HTML-related cleaner, and also adds Regex pattern matching cleanup.
It supports data model binding in DTO mode and also supports dynamic types based on Json.
Add InputSanitize to ServiceCollection with policy in Program.cs
var policy = new InputSanitizerPolicy()
{
Name = "Default",
AllowedTags = new HashSet<string>(HtmlSanitizerDefaults.AllowedTags, StringComparer.OrdinalIgnoreCase),
AllowedSchemes = new HashSet<string>(HtmlSanitizerDefaults.AllowedSchemes, StringComparer.OrdinalIgnoreCase),
AllowedAttributes = new HashSet<string>(HtmlSanitizerDefaults.AllowedAttributes, StringComparer.OrdinalIgnoreCase),
UriAttributes = new HashSet<string>(HtmlSanitizerDefaults.UriAttributes, StringComparer.OrdinalIgnoreCase),
AllowedCssProperties = new HashSet<string>(HtmlSanitizerDefaults.AllowedCssProperties, StringComparer.OrdinalIgnoreCase),
AllowedAtRules = new HashSet<CssRuleType>(HtmlSanitizerDefaults.AllowedAtRules),
AllowedCssClasses = new HashSet<string>(HtmlSanitizerDefaults.AllowedClasses),
ExceptionMessage = "What are you doing?",
InvalidInputBehaviour = InvalidInputBehaviour.SetModelState
}
builder.Services.AddInputSanitizer(InputSanitizerPolicies.Policies);
Add To the Controller
[ApiController]
[Route("[controller]")]
[SanitizeAllInputFilter(PolicyName = "Default")] // this line HERE
public class WeatherForecastController : ControllerBase
{
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpPost(Name = "PostWeatherForecast")]
public IActionResult Post(DTOModel data) // OR public IActionResult Post(dynamic data)
{
if (!ModelState.IsValid)
{
return UnprocessableEntity(ModelState);
}
return Ok(data);
}
}
FAQs
Package Description
We found that inputsanitizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
Industry Insights
Terry O’Daniel, Head of Security at Amplitude, shares insights on building high-impact security teams, aligning with engineering, and why AI gives defenders a fighting chance.
Security News
MCP spec updated with structured tool output, stronger OAuth 2.1 security, resource indicators, and protocol cleanups for safer, more reliable AI workflows.