Class SecurityConfiguration
Namespace: Belay.Core.Security
Assembly: Belay.Core.dll
Configuration options for security validation and protection features in Belay.NET. Controls the strictness of input validation, code injection protection, and other security measures.
public class SecurityConfiguration
Inheritance
object ← SecurityConfiguration
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Examples
Basic Security Configuration
var config = new SecurityConfiguration {
ValidationLevel = ValidationStrictness.Strict,
AllowFileOperations = true,
AllowNetworking = false,
LogSecurityEvents = true
};
var device = Device.FromConnectionString("serial:COM3")
.WithSecurityConfiguration(config);
Development Environment (Relaxed)
var devConfig = SecurityConfiguration.ForDevelopment();
var device = Device.FromConnectionString("subprocess:micropython")
.WithSecurityConfiguration(devConfig);
Production Environment (Strict)
var prodConfig = SecurityConfiguration.ForProduction();
var device = Device.FromConnectionString("serial:/dev/ttyUSB0")
.WithSecurityConfiguration(prodConfig);
Remarks
The security configuration allows fine-tuning the balance between security and functionality. More restrictive settings provide better protection but may prevent legitimate use cases, while more permissive settings enable broader functionality but with increased risk.
Configuration can be applied at the device level or globally, with device-specific settings taking precedence over global settings.
Properties
Gets or sets a value indicating whether file operations are allowed in executed code.
Gets or sets a value indicating whether networking operations are allowed in executed code.
Gets or sets custom patterns that should be allowed even if they would normally be blocked.
Gets or sets custom patterns that should be blocked in addition to the default security patterns.
Gets or sets a value indicating whether to log security-related events and warnings.
Gets or sets the maximum allowed length for Python code before it's considered a security risk.
Gets or sets the maximum allowed nesting level for code structures before triggering security warnings.
Gets or sets a value indicating whether parameter substitution in PythonCodeAttribute should be validated.
Gets or sets the level of strictness for input validation.
Methods
Creates a copy of the current configuration.
Creates a security configuration suitable for development environments.
Creates a security configuration suitable for production environments.
Creates a security configuration suitable for testing environments.