JSanitizer 1.0.3

Additional Details

Code update and add custom json configurations.

There is a newer version of this package available.
See the version list below for details.
dotnet add package JSanitizer --version 1.0.3
NuGet\Install-Package JSanitizer -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JSanitizer" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JSanitizer --version 1.0.3
#r "nuget: JSanitizer, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JSanitizer as a Cake Addin
#addin nuget:?package=JSanitizer&version=1.0.3

// Install JSanitizer as a Cake Tool
#tool nuget:?package=JSanitizer&version=1.0.3

JSanitizer

Configurable sanitizer for XML and JSON string value through extension method.

Features

  • Default sanitizer to replace password value
  • Sanitize with options
    • Default value replacer
    • Add property to sanitize value

Requirements

  • .NET Core 3.1
  • Visual Studio or VS Code

How to use:

  • Go to Tools and select Manage Nuget Packages and Search for JSanitizer library
    Install-Package JSanitizer -Version 1.0.3

Extension:
.SanitizeJsonValue()
.SanitizeXmlValue()
.SanitizeXmlValue(options)
.SanitizeJsonValue(options)

How to create you custom JSON configurations.

  • Create folder with name JSOptions under your project then create json file with name SanitizerOptions.json under the said folder as your default configuration and follow the object format below.
{Project.Name}/JSOptions/SanitizerOptions.json
{
  "DefaultMaskValue": "####-####",
  "ConfigurationValue": [
    {
      "id": 1,
      "XmlMask": {
        "MaskValue": "###-###-###",
        "Sensitivity": [
          "Password",
          "password",
          "PASSWROD"
        ]
      },
      "JsonMask": {
        "MaskValue": "###-###-###",
        "Sensitivity": [
          "Password",
          "password",
          "PASSWROD"
        ]
      }
    }
  ]
}
note: It will throw an exception if you use the default json or xml extension methods without providing default json configurations.

remarks: You can add more properties under Sensitivity for value masking.

  1. Sanitize without options
   [HttpGet, Route("GetWithoutOptions")]
   public IActionResult Get()
   {
       Data data = new Data()
       {
        JsonArrayResult = "[{\"password\":\"password@412\", \"data\": \"sample\" }]".SanitizeJsonValue(),
        Name = "{\"name\":\"John\", \"age\":30, \"password\":\"password@123\"}".SanitizeJsonValue(),
        XMLResult = _xmlValue.SanitizeXmlValue()
       };

        return Ok(data);
     }
  1. Sanitize withoptions
   [HttpGet, Route("GetWithOptions")]
   public IActionResult GetWithOptions()
   {
      Data data = new Data()
       {
        XMLResult = _xmlValue.SanitizeXmlValue(new Sanitizer.JOptions()
        {
         DefaultMaskValue = "####-####",
         Sensitivity = new List<string>() { "password" }}),
        };

        return Ok(data);
    }

License

License: MIT
Copyright (c) 2020 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 6,021 3/25/2022
3.0.0 479 3/23/2022
2.0.1 524 3/16/2022
2.0.0 471 3/16/2022
1.0.4 486 3/16/2022
1.0.3 472 3/16/2022
1.0.2 2,627 1/15/2021
1.0.1 616 1/15/2021
1.0.0 695 10/15/2020

Update default json configurations.