Configurations
The content of this article is also available as a video tutorial.
CLI advanced configuration (6 min)Configuration files
Configuration files are a simple option to tell Shield how to protect your application.
There are two types of configuration files:
- From Project : They affect all the applications of a project (except those that contain specific settings).
- Application : Affect an application specifically.
To create a configuration file manually you just have to create a .json file in your Visual Studio project, or in the folder where your compiled application is hosted. The file names are composed in the following form: shield. {Type}. {Name} .json, where {name} will be the name of your application or project, and {type} will be: application or project.
It really is a simple hierarchical structure:
Example Solution
│
├── shield.project.example.json
│ └── shield.application.app1.json
│
├── shield.project.exampleCore.json
│ ├── shield.application.app2.json
│ ├── app3 (Inherit from project)
│ └── shield.application.app2.json
│
└── shield.project.exampleHelpers.jsonExample Solution
│
├── shield.project.example.json
│ └── shield.application.app1.json
│
├── shield.project.exampleCore.json
│ ├── shield.application.app2.json
│ ├── app3 (Inherit from project)
│ └── shield.application.app2.json
│
└── shield.project.exampleHelpers.jsonConfiguration file structure
The configuration files are simple json documents, and are composed as follows:
- For projects:
{
"ProjectPreset": "custom",
"Protections": ["constants mutation","invalid metadata","invalid code" ... ]
}{
"ProjectPreset": "custom",
"Protections": ["constants mutation","invalid metadata","invalid code" ... ]
}- For applications:
{
"InheritFromProject": false,
"ProjectPreset": "custom",
"Protections": ["constants mutation","invalid metadata","invalid code" ... ]
}{
"InheritFromProject": false,
"ProjectPreset": "custom",
"Protections": ["constants mutation","invalid metadata","invalid code" ... ]
}The only difference between the two is that the application contains the InheritFromProject property that determines whether or not it should be used when there are settings at both the project and application levels.
- The
ProjectPresetproperty sets a preset:maximum,balance,optimizationorcustom - The
protectionsproperty is an array ofstringscontaining the ID of the protections to be applied. TheProjectPresetneeds to becustomfor them to apply.
Create a configuration file
If you don't want to worry about the configurations, you can manage it from the CLI.
bytehide shield config:make <NAME> <DIRECTORY PATH> [TYPE] [PRESET]bytehide shield config:make <NAME> <DIRECTORY PATH> [TYPE] [PRESET]- Where the argument
<NAME>will be the name of the project or the application,<DIRECTORY PATH>will be the directory where the configuration file will be saved. - The
TYPEparameter is optional, by default it will beproject, but you can change it toapplication. PRESETis optional, and does not allow custom, to usecustomcall without that argument and the console will show you an interactive configurator.
Read a configuration file
To display information from a configuration file without the need for a text editor use:
bytehide shield config:find <PATH>bytehide shield config:find <PATH>If the <PATH> is specific, it will read that file, if it is a directory it will read all the configuration files it finds in the directory.