Class SensitiveAttribute
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Classifies a property as containing sensitive business data: it is encrypted at rest and masked in logs and other rendered output.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class SensitiveAttribute : Attribute
- Inheritance
-
SensitiveAttribute
- Inherited Members
Examples
public class ApiConfiguration
{
public string ServiceName { get; set; }
// Encrypted at rest under the configured default key purpose, and redacted in logs.
// [EncryptedField] is not needed to encrypt it; add that only to state a specific key purpose.
[Sensitive(Classification = DataClassification.Restricted)]
public string ApiKey { get; set; }
[Sensitive(Classification = DataClassification.Confidential)]
public string ConnectionString { get; set; }
}
Remarks
A property marked with this attribute is selected for encryption at rest on every field-encryption path, and is read by IDataMasker to redact the value when an object is rendered for logging. The two protections are independent — masking hides a value in output, encryption protects the bytes that are stored.
This attribute states no key purpose, so it never contradicts an annotation beside it. The key comes from EncryptedFieldAttribute when that states a purpose, from the per-subject key when PersonalDataAttribute is present, and otherwise from the configured default purpose. Applying it alongside either one is therefore safe and encrypts the value exactly once.
Only string and byte[] properties can be encrypted. Marking a property of any other type is reported rather than ignored: the value cannot be protected, and silently skipping it would store the data in the clear while the annotation suggested otherwise. A type is checked when an encryption path first uses it, so a rarely-written entity can surface the problem on a write hours after startup rather than at boot.
Sensitive data differs from personal data in that it may not be subject to privacy regulations but still warrants classification and redaction: - Trade secrets - API keys and credentials - Internal business metrics - Competitive intelligence
Use PersonalDataAttribute for data subject to GDPR/privacy regulations. Use this attribute to classify and redact sensitive business data that is not personally identifiable information.
Properties
Category
Gets or sets the category of sensitive data for policy selection.
public SensitiveDataCategory Category { get; set; }
Property Value
Classification
Gets or sets the classification level for this sensitive data. Defaults to Confidential.
public DataClassification Classification { get; set; }
Property Value
MaskInLogs
Gets or sets a value indicating whether this data should be masked in logs. Defaults to true.
public bool MaskInLogs { get; set; }
Property Value
Remarks
Read by IDataMasker when masking an object. It has no effect on output that does not pass through a masker.