Test Sensitive Field Masking Rules¶
POST /api/v1/workspace/sensitive_mask_rule/test
Overview¶
Preview the sensitive field masking result for a specified role combination using mock data.
Before Calling and Usage Steps¶
- Check the data type, roles, enabled status, fields, and regular expressions of the rules in the Sensitive Field Rule List.
- Use a Key with the
routine.defaultAccesspermission in the current workspace to submit mock data and the UUIDs of the roles to test; do not send unnecessary real sensitive data. - Use the results in
content[]to assert which top-level fields should be replaced; if the result is returned unchanged, check the rules and role combination first.
Use a Key for the current workspace with routine.defaultAccess. First check the namespace, enabled status, fields, regular expression, and roles in the Sensitive Field Rule List, then pass the mock data and the roleUUIDs to combine. This API only evaluates the submitted samples; it does not query raw data, save rules or samples, or change the permissions of the current Key.
The combination is calculated based on both role read permissions and masking rules: if a participating readable role has no applicable rule for that type, the combination may not mask, and multiple roles cannot be understood as unconditionally applying the strictest rule. An empty role array/no rules or rule query fault tolerance may also return the input unchanged, which does not prove that the rule is valid or that the rule does not exist.
Only the top-level fields of each object are traversed, matching field names against the * wildcard rule; matching fragments are replaced with *** using Python re.sub in the existing rule order, without deep recursion or automatic conversion of numbers to strings. Data shape mismatch, an invalid regular expression in a valid rule, or a number processed by a regular expression may cause a 500. The example assumes that logging/general already has a valid rule where phone matches [0-9]{11}; if it is not configured, returning the original string is a possible result, and you must assert against the rules and expectations.
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or fill: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| roleUUIDs[*] | string | A single string; use a valid role in the current workspace; do not treat * as a real role that replaces all roles. Example: generalHow to obtain or fill: Use the actual role UUID, not name; simulate a real combination with multiple roles together. |
|
| data[*] | json | A single object; {} is retained; an incorrect shape may cause a 500 when rules exist; do not treat type looseness as support for all data formats. Example: {"phone": "13800138000", "message": "示例记录"}How to obtain or fill: Construct a mock record with the same fields as the real record but fictitious values. |
|
| data[*].Field name | any | Dynamic field value; when a field or a * wildcard field matches, the matching fragment is replaced with *** by Python regular expression in rule order; multiple rules apply consecutively, and the original field value is not written to business storage. Example: 13800138000How to obtain or fill: Use the real field name to verify, and construct matching/non-matching samples with fictitious strings. |
|
| roleUUIDs | array | Y | Required array of role UUIDs, representing a simulated identity combination, not a modification of the calling Key's role. The server does not verify item by item that each role is still valid; unknown roles/no applicable rules or role permission mismatch may return the input unchanged. [] with no roles means no masking. Allowed null: False Example: ["general"]How to obtain or fill: Obtain the roles to simulate from content.data[].uuid in the Role List. |
| namespace | string | Y | Required. Candidates: lineage,logging,metric,object,custom_object,keyevent,tracing,rum,security,network,profiling,billing. This is not a log index name; this endpoint does not query actual logs. Allowed null: False Allowed empty string: False Allowed values: ['lineage', 'logging', 'metric', 'object', 'custom_object', 'keyevent', 'tracing', 'rum', 'security', 'network', 'profiling', 'billing'] Example: loggingHow to obtain or fill: Select the data type to which the sample belongs, and first confirm the same type in the complete rule list. |
| data | array | Y | Required array; each item is recommended to be a JSON object; only top-level fields are processed, and nested JSON is not recursed. Values that do not match rules are retained; fields with matching rules should be strings, and numeric values are not automatically converted. Allowed null: False Example: [{"phone": "13800138000", "message": "示例记录"}]How to obtain or fill: Provide your own array of mock JSON objects that does not contain real customer sensitive information; the replacement field names should correspond to existing rules. |
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/workspace/sensitive_mask_rule/test' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"roleUUIDs":["general"],"namespace":"logging","data":[{"phone":"13800138000","message":"示例记录"}]}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content | array | Mock result array, in the same order as the input; declaration is not inserted. If no rule applies, it may be exactly the same as the input. |
| content[] | object or original input value | A single sample; an input object is recommended, and an empty object is retained. |
| content[].Field name | JSON | Input field and its original type; string matching fragments affected by the regular expression are replaced with ***, other values remain unchanged, and no metadata is added. |
{
"code": 200,
"content": [
{
"phone": "***",
"message": "示例记录"
}
],
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Response¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | Request field is missing, or the field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Invalid request JSON syntax | Request JSON format error | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | JSON top level is not an object | Some json file format error | Submit the JSON object in the parameter table. |
| 500 | ft.InternalServerError | Database failure before rule query, non-object item, non-string field, or invalid regular expression error during processing | Internal error | Use object arrays/string samples to check fields and rules, and reproduce with controlled samples; configuration errors should be corrected by an administrator with permission, and provide traceId. |