Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.2
3.8.3
5 changes: 5 additions & 0 deletions docs/data-sources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Required:
- `id` (String) The unique rule id
- `semantic_type` (String) The semantic type id

Optional:

- `title` (String) The title for the rule



<a id="nestedblock--masking_exception_policy"></a>
Expand All @@ -91,6 +95,7 @@ Optional:

- `column` (String)
- `expire_timestamp` (String) The expiration timestamp in YYYY-MM-DDThh:mm:ss.000Z format
- `reason` (String) The reason for the masking exemption
- `schema` (String)
- `table` (String)

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/policy_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Read-Only:
- `condition` (String)
- `id` (String)
- `semantic_type` (String)
- `title` (String)



Expand All @@ -71,6 +72,7 @@ Read-Only:
- `database` (String)
- `expire_timestamp` (String)
- `member` (String)
- `reason` (String)
- `schema` (String)
- `table` (String)

Expand Down
5 changes: 5 additions & 0 deletions docs/resources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Required:
- `id` (String) The unique rule id
- `semantic_type` (String) The semantic type id

Optional:

- `title` (String) The title for the rule



<a id="nestedblock--masking_exception_policy"></a>
Expand All @@ -91,6 +95,7 @@ Optional:

- `column` (String)
- `expire_timestamp` (String) The expiration timestamp in YYYY-MM-DDThh:mm:ss.000Z format
- `reason` (String) The reason for the masking exemption
- `schema` (String)
- `table` (String)

Expand Down
3 changes: 3 additions & 0 deletions examples/setup/data_masking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ resource "bytebase_policy" "masking_exception_policy" {
column = "amount"
member = "user:[email protected]"
action = "EXPORT"
reason = "Grant access to ed for export"
}
exceptions {
database = "instances/test-sample-instance/databases/employee"
Expand Down Expand Up @@ -142,11 +143,13 @@ resource "bytebase_policy" "global_masking_policy" {
condition = "environment_id in [\"test\"]"
id = "69df1d15-abe5-4bc9-be38-f2a4bef3f7e0"
semantic_type = "bb.default-partial"
title = "Partial masking for test environment"
}
rules {
condition = "instance_id in [\"prod-sample-instance\"]"
id = "90adb734-0808-4c9f-b281-1f76f7a1a29a"
semantic_type = "bb.default"
title = "Default masking for prod instance"
}
}
}
12 changes: 12 additions & 0 deletions provider/data_source_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func getMaskingExceptionPolicySchema(computed bool) *schema.Schema {
v1pb.MaskingExceptionPolicy_MaskingException_EXPORT.String(),
}, false),
},
"reason": {
Type: schema.TypeString,
Optional: true,
Description: "The reason for the masking exemption",
},
"expire_timestamp": {
Type: schema.TypeString,
Computed: computed,
Expand Down Expand Up @@ -169,6 +174,11 @@ func getGlobalMaskingPolicySchema(computed bool) *schema.Schema {
ValidateFunc: validation.StringIsNotEmpty,
Description: "The unique rule id",
},
"title": {
Type: schema.TypeString,
Optional: true,
Description: "The title for the rule",
},
"semantic_type": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -404,6 +414,7 @@ func flattenGlobalMaskingPolicy(p *v1pb.MaskingRulePolicy) ([]interface{}, error
raw["id"] = rule.Id
raw["semantic_type"] = rule.SemanticType
raw["condition"] = rule.Condition.Expression
raw["title"] = rule.Condition.Title

ruleList = append(ruleList, raw)
}
Expand All @@ -424,6 +435,7 @@ func flattenMaskingExceptionPolicy(p *v1pb.MaskingExceptionPolicy) ([]interface{
if exception.Condition == nil || exception.Condition.Expression == "" {
return nil, errors.Errorf("invalid exception policy condition")
}
raw["reason"] = exception.Condition.Description

expressions := strings.Split(exception.Condition.Expression, " && ")
instanceID := ""
Expand Down
5 changes: 4 additions & 1 deletion provider/resource_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,12 @@ func convertToMaskingRulePolicy(d *schema.ResourceData) (*v1pb.MaskingRulePolicy

for _, rule := range ruleList {
rawRule := rule.(map[string]interface{})
title := rawRule["title"].(string)
policy.Rules = append(policy.Rules, &v1pb.MaskingRulePolicy_MaskingRule{
Id: rawRule["id"].(string),
SemanticType: rawRule["semantic_type"].(string),
Condition: &expr.Expr{
Title: title,
Expression: rawRule["condition"].(string),
},
})
Expand Down Expand Up @@ -380,7 +382,8 @@ func convertToMaskingExceptionPolicy(d *schema.ResourceData) (*v1pb.MaskingExcep
v1pb.MaskingExceptionPolicy_MaskingException_Action_value[rawException["action"].(string)],
),
Condition: &expr.Expr{
Expression: strings.Join(expressions, " && "),
Description: rawException["reason"].(string),
Expression: strings.Join(expressions, " && "),
},
})
}
Expand Down