Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(mcp): let MCP sessions grant and revoke masking exemptions after the user confirms (#21627)

Vincent Huang3bd810828599
diff --git a/backend/api/mcp/server.go b/backend/api/mcp/server.go
index 495e8d3a64..56f6c348c9 100644
--- a/backend/api/mcp/server.go
+++ b/backend/api/mcp/server.go
@@ -237,6 +237,7 @@ func (s *Server) registerTools() {
s.registerChangeTool()
s.registerDecideIssueTool()
s.registerSetJustInTimeAccessTool()
+ s.registerMaskingExemptionTools()
s.registerReauthorizeTool()
}
diff --git a/backend/api/mcp/tool_change.go b/backend/api/mcp/tool_change.go
index 1130fe13c7..2b9fdc851a 100644
--- a/backend/api/mcp/tool_change.go
+++ b/backend/api/mcp/tool_change.go
@@ -487,6 +487,13 @@ func planChecksHaveErrors(info *PlanCheckInfo) bool {
return false
}
+// consoleLink returns the console URL of a resource, under the workspace's
+// external URL.
+func (s *Server) consoleLink(ctx context.Context, resourceName string) string {
+ externalURL, _ := utils.GetEffectiveExternalURL(ctx, s.store, s.profile, getWorkspaceID(ctx))
+ return buildResourceURL(externalURL, resourceName)
+}
+
// buildResourceURL constructs a URL from externalURL and resource name.
func buildResourceURL(externalURL, resourceName string) string {
if externalURL == "" {
diff --git a/backend/api/mcp/tool_decide.go b/backend/api/mcp/tool_decide.go
index 847e49a28d..0f6d4fc218 100644
--- a/backend/api/mcp/tool_decide.go
+++ b/backend/api/mcp/tool_decide.go
@@ -21,7 +21,6 @@ import (
"github.com/bytebase/bytebase/backend/component/audit"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
- "github.com/bytebase/bytebase/backend/utils"
)
// DecideIssueInput is the input for the decide_issue tool.
@@ -590,8 +589,7 @@ func (s *Server) readResource(ctx context.Context, path, name, operation, permis
}
func (s *Server) issueLink(ctx context.Context, issue string) string {
- externalURL, _ := utils.GetEffectiveExternalURL(ctx, s.store, s.profile, getWorkspaceID(ctx))
- return buildResourceURL(externalURL, issue)
+ return s.consoleLink(ctx, issue)
}
// describeApprovalStep names the step a decision would record. It mirrors
diff --git a/backend/api/mcp/tool_exemption.go b/backend/api/mcp/tool_exemption.go
new file mode 100644
index 0000000000..cbf7c3f622
--- /dev/null
+++ b/backend/api/mcp/tool_exemption.go
@@ -0,0 +1,578 @@
+package mcp
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "maps"
+ "net/http"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/google/cel-go/cel"
+ celast "github.com/google/cel-go/common/ast"
+ "github.com/google/cel-go/common/operators"
+ "github.com/google/cel-go/common/types"
+ "github.com/google/cel-go/parser"
+ "github.com/modelcontextprotocol/go-sdk/mcp"
+ "github.com/pkg/errors"
+
+ "github.com/bytebase/bytebase/backend/api/auth"
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
+)
+
+// GrantMaskingExemptionInput is the input for the grant_masking_exemption tool.
+type GrantMaskingExemptionInput struct {
+ Project string `json:"project"`
+ Member string `json:"member"`
+ Database string `json:"database,omitempty"`
+ AllDatabases bool `json:"allDatabases,omitempty"`
+ Schema string `json:"schema,omitempty"`
+ Table string `json:"table,omitempty"`
+ Column string `json:"column,omitempty"`
+ ExpireTime string `json:"expireTime,omitempty"`
+ Reason string `json:"reason,omitempty"`
+}
+
+// RevokeMaskingExemptionInput is the input for the revoke_masking_exemption tool.
+type RevokeMaskingExemptionInput struct {
+ Project string `json:"project"`
+ Member string `json:"member"`
+ Condition string `json:"condition"`
+}
+
+// MaskingExemptionOutput is the output for both masking exemption tools.
+type MaskingExemptionOutput struct {
+ Project string `json:"project"`
+ Member string `json:"member"`
+ Condition string `json:"condition"`
+ Link string `json:"link"`
+}
+
+const grantMaskingExemptionDescription = `Exempt one member from data masking in a Bytebase project, for one database (optionally one schema, table or column) or for every database in the project. The user confirms the exemption in this client first.
+
+| Parameter | Required | Description |
+|--------------|----------|-------------|
+| project | Yes | Project name, e.g. "projects/hr" |
+| member | Yes | "user:{email}", "group:{email}", "serviceAccount:{email}" or "workloadIdentity:{email}" |
+| database | One of | Database name, e.g. "instances/prod/databases/hr"; it must belong to the project |
+| allDatabases | One of | true for every database in the project, current and future |
+| schema | No | Narrow to one schema (needs database) |
+| table | No | Narrow to one table (needs database) |
+| column | No | Narrow to one column (needs table) |
+| expireTime | No | RFC 3339 time the exemption ends, e.g. "2026-10-27T00:00:00Z"; without it, it does not expire |
+| reason | No | Why, recorded with the exemption |
+
+An exemption is a standing policy change: the member then sees the covered data unmasked in query and export results. For a one-off query, request an access grant instead (AccessGrantService/CreateAccessGrant).
+
+The tool adds one exemption and leaves every other entry as it is. It shows the user the member, the scope, the expiry and the effect, and asks them to confirm in a form; it writes only when they accept. A client that cannot show the form gets the project's masking exemption page, to grant it in the Bytebase console instead. Do not ask in chat first: the form is the question.
+
+The same permissions apply as in the console. This and revoke_masking_exemption are the only ways to change exemptions over MCP; call_api refuses OrgPolicyService/UpdatePolicy.`
+
+const revokeMaskingExemptionDescription = `Remove one member's masking exemption in a Bytebase project. The user confirms in this client first.
+
+| Parameter | Required | Description |
+|-----------|----------|-------------|
+| project | Yes | Project name, e.g. "projects/hr" |
+| member | Yes | The member as the policy lists it, e.g. "user:[email protected]" |
+| condition | Yes | The exemption's condition expression, exactly as OrgPolicyService/GetPolicy returns it for "{project}/policies/masking_exemption"; "" for an exemption with no condition |
+
+The member is removed from every exemption whose condition matches exactly; an exemption left with no member is removed. Other members and other exemptions stay as they are. The tool asks the user to confirm in a form, and writes only when they accept. A client that cannot show the form gets the project's masking exemption page.
+
+The same permissions apply as in the console.`
+
+func (s *Server) registerMaskingExemptionTools() {
+ mcp.AddTool(s.mcpServer, &mcp.Tool{
+ Name: "grant_masking_exemption",
+ Description: grantMaskingExemptionDescription,
+ }, s.handleGrantMaskingExemption)
+ mcp.AddTool(s.mcpServer, &mcp.Tool{
+ Name: "revoke_masking_exemption",
+ Description: revokeMaskingExemptionDescription,
+ }, s.handleRevokeMaskingExemption)
+}
+
+// exemptionWrite is one confirmed change to a project's masking exemption
+// policy.
+type exemptionWrite struct {
+ policy string
+}
+
+func (*exemptionWrite) confirmedProcedure() string {
+ return v1connect.OrgPolicyServiceUpdatePolicyProcedure
+}
+
+func (w *exemptionWrite) confirmedResource() string { return w.policy }
+
+func maskingExemptionPolicyName(project string) string {
+ return project + "/policies/masking_exemption"
+}
+
+// exemptionGrant is a validated grant_masking_exemption request.
+type exemptionGrant struct {
+ project, member string
+ database, instanceID, databaseName string
+ schema, table, column, expireTime, note string
+}
+
+func parseExemptionGrant(input GrantMaskingExemptionInput) (*exemptionGrant, error) {
+ invalid := func(message, suggestion string) error {
+ return &toolError{Code: "INVALID_ARGUMENT", Message: message, Suggestion: suggestion}
+ }
+ if err := checkProjectName(input.Project); err != nil {
+ return nil, err
+ }
+ if !isNamedMember(input.Member) {
+ return nil, invalid(fmt.Sprintf("invalid member %q: an exemption names one user, group, service account or workload identity", input.Member),
+ `pass the member, e.g. "user:[email protected]"; allUsers, which the policy API also accepts, would unmask the scope for everyone`)
+ }
+ g := &exemptionGrant{
+ project: input.Project, member: input.Member,
+ schema: input.Schema, table: input.Table, column: input.Column, note: input.Reason,
+ }
+ switch {
+ case input.Database != "" && input.AllDatabases:
+ return nil, invalid("pass database or allDatabases, not both", "")
+ case input.Database == "" && !input.AllDatabases:
+ return nil, invalid("the exemption needs a scope: database, or allDatabases set to true",
+ "pass the database, or allDatabases: true for every database in the project, current and future")
+ case input.Database != "":
+ // A database on a project-owned instance is named under its project.
+ _, instanceID, databaseName, err := common.GetDatabaseResourceName(input.Database)
+ if err != nil {
+ return nil, invalid(fmt.Sprintf("invalid database %q", input.Database), "pass the database name, e.g. instances/prod/databases/hr")
+ }
+ g.database, g.instanceID, g.databaseName = input.Database, instanceID, databaseName
+ default:
+ if input.Schema != "" || input.Table != "" || input.Column != "" {
+ return nil, invalid("schema, table and column narrow one database, so they need database", "")
+ }
+ }
+ if input.Column != "" && input.Table == "" {
+ return nil, invalid("column needs table", "pass the table the column belongs to")
+ }
+ if input.ExpireTime != "" {
+ expireTime, err := time.Parse(time.RFC3339, input.ExpireTime)
+ if err != nil {
+ return nil, invalid(fmt.Sprintf("invalid expireTime %q", input.ExpireTime), `pass an RFC 3339 time, e.g. "2026-10-27T00:00:00Z"`)
+ }
+ // The console writes the expiry with JavaScript's toISOString.
+ g.expireTime = expireTime.UTC().Format("2006-01-02T15:04:05.000Z")
+ }
+ return g, nil
+}
+
+// isNamedMember reports whether member names one principal, as the tool's
+// contract and the console's exemption picker do.
+func isNamedMember(member string) bool {
+ for _, prefix := range []string{common.UserBindingPrefix, common.GroupBindingPrefix, common.ServiceAccountBindingPrefix, common.WorkloadIdentityBindingPrefix} {
+ if name, found := strings.CutPrefix(member, prefix); found && strings.TrimSpace(name) != "" {
+ return true
+ }
+ }
+ return false
+}
+
+func checkProjectName(project string) error {
+ if _, err := common.GetProjectID(project); err != nil {
+ return &toolError{Code: "INVALID_ARGUMENT", Message: fmt.Sprintf("invalid project %q", project), Suggestion: "pass the project name, e.g. projects/hr"}
+ }
+ return nil
+}
+
+// condition builds the exemption's CEL expression in the form the console
+// writes, so a condition the tool writes matches one the console writes
+// character for character when a revoke compares them.
+func (g *exemptionGrant) condition() string {
+ var parts []string
+ if g.expireTime != "" {
+ parts = append(parts, fmt.Sprintf("request.time < timestamp(%s)", strconv.Quote(g.expireTime)))
+ }
+ if g.database != "" {
+ scope := []string{
+ "resource.instance_id == " + strconv.Quote(g.instanceID),
+ "resource.database_name == " + strconv.Quote(g.databaseName),
+ }
+ for _, narrowing := range []struct{ attribute, value string }{
+ {"resource.schema_name", g.schema},
+ {"resource.table_name", g.table},
+ {"resource.column_name", g.column},
+ } {
+ if narrowing.value != "" {
+ scope = append(scope, narrowing.attribute+" == "+strconv.Quote(narrowing.value))
+ }
+ }
+ parts = append(parts, "("+strings.Join(scope, " && ")+")")
+ }
+ return strings.Join(parts, " && ")
+}
+
+// readMaskingExemptions returns the project's exemption entries as the API
+// returns them, so an entry the tool does not change is written back with every
+// field it read. A project with no exemption policy has none.
+func (s *Server) readMaskingExemptions(ctx context.Context, policy string) ([]map[string]any, error) {
+ resp, err := s.apiRequest(ctx, "/bytebase.v1.OrgPolicyService/GetPolicy", map[string]any{"name": policy})
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to read %s", policy)
+ }
+ if resp.Status == http.StatusNotFound {
+ return nil, nil
+ }
+ if err := checkAPIResponse(resp, "get policies", "bb.policies.getMaskingExemptionPolicy"); err != nil {
+ return nil, err
+ }
+ var view struct {
+ MaskingExemptionPolicy struct {
+ Exemptions []map[string]any `json:"exemptions"`
+ } `json:"maskingExemptionPolicy"`
+ }
+ if err := json.Unmarshal(resp.Body, &view); err != nil {
+ return nil, errors.Wrapf(err, "failed to parse %s", policy)
+ }
+ return view.MaskingExemptionPolicy.Exemptions, nil
+}
+
+// exemptionUpdateBody is the UpdatePolicy request the user is asked to
+// confirm. allowMissing creates the policy for a project's first exemption, as
+// the console does.
+func exemptionUpdateBody(policy string, exemptions []map[string]any) map[string]any {
+ return map[string]any{
+ "policy": map[string]any{
+ "name": policy,
+ "type": "MASKING_EXEMPTION",
+ "maskingExemptionPolicy": map[string]any{"exemptions": exemptions},
+ },
+ "updateMask": "maskingExemptionPolicy",
+ "allowMissing": true,
+ }
+}
+
+func (s *Server) handleGrantMaskingExemption(ctx context.Context, req *mcp.CallToolRequest, input GrantMaskingExemptionInput) (*mcp.CallToolResult, any, error) {
+ grant, err := parseExemptionGrant(input)
+ if err != nil {
+ return formatToolError(err), nil, nil
+ }
+ link := s.maskingExemptionLink(ctx, grant.project)
+ if grant.database == "" {
+ // An exemption written under a project ID that does not exist would
+ // apply to a project created later with that ID.
+ var project struct{}
+ if err := s.readResource(ctx, "/bytebase.v1.ProjectService/GetProject", grant.project, "get projects", "bb.projects.get", &project); err != nil {
+ return formatToolError(err), nil, nil
+ }
+ } else {
+ var database struct {
+ Project string `json:"project"`
+ }
+ if err := s.readResource(ctx, "/bytebase.v1.DatabaseService/GetDatabase", grant.database, "get databases", "bb.databases.get", &database); err != nil {
+ return formatToolError(err), nil, nil
+ }
+ if database.Project != grant.project {
+ return formatToolError(&toolError{
+ Code: "INVALID_ARGUMENT",
+ Message: fmt.Sprintf("%s belongs to %s, not %s, so an exemption in %s would not cover it", grant.database, database.Project, grant.project, grant.project),
+ Suggestion: "grant it in the project the database belongs to",
+ }), nil, nil
+ }
+ }
+ if !canShowConfirmation(req) {
+ return formatToolError(&toolError{
+ Code: "CONFIRMATION_UNAVAILABLE",
+ Message: fmt.Sprintf("this MCP client cannot show the confirmation form grant_masking_exemption needs, so %s was not exempted and nothing changed",
+ grant.member),
+ Suggestion: "grant it signed in to the Bytebase console: " + link,
+ }), nil, nil
+ }
+
+ write := &exemptionWrite{policy: maskingExemptionPolicyName(grant.project)}
+ exemptions, err := s.readMaskingExemptions(ctx, write.policy)
+ if err != nil {
+ return formatToolError(err), nil, nil
+ }
+ condition := map[string]any{"expression": grant.condition()}
+ if grant.note != "" {
+ condition["description"] = grant.note
+ }
+ written := append(slices.Clone(exemptions), map[string]any{"members": []string{grant.member}, "condition": condition})
+ body := exemptionUpdateBody(write.policy, written)
+ output := &MaskingExemptionOutput{Project: grant.project, Member: grant.member, Condition: grant.condition(), Link: link}
+ return s.confirmExemptionWrite(ctx, req, write, exemptions, body, describeExemptionGrant(ctx, grant), output,
+ "Exempt this member from masking",
+ fmt.Sprintf("the exemption for %s was not granted", grant.member),
+ fmt.Sprintf("Exempted %s from masking in %s.", grant.member, grant.project),
+ )
+}
+
+func (s *Server) handleRevokeMaskingExemption(ctx context.Context, req *mcp.CallToolRequest, input RevokeMaskingExemptionInput) (*mcp.CallToolResult, any, error) {
+ if err := checkProjectName(input.Project); err != nil {
+ return formatToolError(err), nil, nil
+ }
+ link := s.maskingExemptionLink(ctx, input.Project)
+ write := &exemptionWrite{policy: maskingExemptionPolicyName(input.Project)}
+ exemptions, err := s.readMaskingExemptions(ctx, write.policy)
+ if err != nil {
+ return formatToolError(err), nil, nil
+ }
+ remaining, matched, held := removeExemptionMember(exemptions, input.Member, input.Condition)
+ if matched == 0 {
+ suggestion := fmt.Sprintf("%s holds no exemption in %s", input.Member, input.Project)
+ if len(held) > 0 {
+ suggestion = fmt.Sprintf("%s holds exemptions with these conditions: %s", input.Member, quoteAll(held))
+ }
+ return formatToolError(&toolError{
+ Code: "NOT_FOUND",
+ Message: fmt.Sprintf("%s holds no exemption in %s with the condition %q, so nothing changed", input.Member, input.Project, input.Condition),
+ Suggestion: suggestion,
+ }), nil, nil
+ }
+ if !canShowConfirmation(req) {
+ return formatToolError(&toolError{
+ Code: "CONFIRMATION_UNAVAILABLE",
+ Message: fmt.Sprintf("this MCP client cannot show the confirmation form revoke_masking_exemption needs, so %s's exemption was not removed and nothing changed",
+ input.Member),
+ Suggestion: "remove it signed in to the Bytebase console: " + link,
+ }), nil, nil
+ }
+ body := exemptionUpdateBody(write.policy, remaining)
+ output := &MaskingExemptionOutput{Project: input.Project, Member: input.Member, Condition: input.Condition, Link: link}
+ return s.confirmExemptionWrite(ctx, req, write, exemptions, body, describeExemptionRevoke(ctx, input, matched), output,
+ "Remove this masking exemption",
+ fmt.Sprintf("the exemption for %s was not removed", input.Member),
+ fmt.Sprintf("Removed %s's masking exemption in %s.", input.Member, input.Project),
+ )
+}
+
+// removeExemptionMember removes member from every entry whose condition is
+// exactly condition, and drops an entry left with no member. The console can
+// add the same member and condition twice, and removing only one would leave
+// the access in place. It returns the entries to write, how many matched, and
+// the conditions member holds, for a refusal.
+func removeExemptionMember(exemptions []map[string]any, member, condition string) ([]map[string]any, int, []string) {
+ var remaining []map[string]any
+ var held []string
+ matched := 0
+ for _, entry := range exemptions {
+ members := stringList(entry["members"])
+ expression := ""
+ if c, ok := entry["condition"].(map[string]any); ok {
+ if e, ok := c["expression"].(string); ok {
+ expression = e
+ }
+ }
+ if !slices.Contains(members, member) {
+ remaining = append(remaining, entry)
+ continue
+ }
+ held = append(held, expression)
+ if expression != condition {
+ remaining = append(remaining, entry)
+ continue
+ }
+ matched++
+ members = slices.DeleteFunc(members, func(m string) bool { return m == member })
+ if len(members) == 0 {
+ continue
+ }
+ kept := maps.Clone(entry)
+ kept["members"] = members
+ remaining = append(remaining, kept)
+ }
+ return remaining, matched, held
+}
+
+func stringList(v any) []string {
+ items, ok := v.([]any)
+ if !ok {
+ return nil
+ }
+ out := make([]string, 0, len(items))
+ for _, item := range items {
+ if s, ok := item.(string); ok {
+ out = append(out, s)
+ }
+ }
+ return out
+}
+
+// confirmExemptionWrite asks the user to confirm body, or acts on their answer.
+// The digest covers the list as read and the exact request built from it, so an
+// answer is acted on only while the arguments and every entry, including one a
+// revoke would drop, read as they did when the user was asked.
+func (s *Server) confirmExemptionWrite(ctx context.Context, req *mcp.CallToolRequest, write *exemptionWrite, read []map[string]any, body map[string]any, message string, output *MaskingExemptionOutput, title, notDone, done string) (*mcp.CallToolResult, any, error) {
+ encoded, err := json.Marshal(map[string]any{"read": read, "write": body})
+ if err != nil {
+ return formatToolError(errors.Wrap(err, "failed to build the update")), nil, nil
+ }
+ digest := sha256.Sum256(encoded)
+ reply, answered := s.signedReply(ctx, req, write, digest[:])
+ if !answered {
+ return s.askToConfirm(ctx, write, digest[:], message, title,
+ "Check to make the change described above. Leaving it unchecked, declining or cancelling changes nothing."), nil, nil
+ }
+ if confirmed, why := confirmationOutcome(reply.response); !confirmed {
+ return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: fmt.Sprintf(
+ "%s: %s, so nothing changed. Do not retry unless the user asks.\nMasking exemptions: %s", capitalize(notDone), why, output.Link)}}}, nil, nil
+ }
+ if why := reply.staleReason("what the user confirmed no longer matches this call and the project's exemptions as they are now"); why != "" {
+ return formatToolError(&toolError{
+ Code: "STALE_CONFIRMATION",
+ Message: fmt.Sprintf("%s, so %s and nothing changed", why, notDone),
+ Suggestion: "call the tool again to ask the user about the exemptions as they are now",
+ }), nil, nil
+ }
+ confirmedCtx := auth.WithMCPConfirmedDecision(ctx, auth.MCPConfirmedDecision{
+ Procedure: write.confirmedProcedure(),
+ Resource: write.policy,
+ })
+ resp, err := s.apiRequest(confirmedCtx, write.confirmedProcedure(), body)
+ if err != nil {
+ return formatToolError(errors.Wrapf(err, "failed to update %s", write.policy)), nil, nil
+ }
+ if resp.Status >= 400 {
+ return formatToolError(errors.Errorf("failed to update %s: HTTP %d: %s", write.policy, resp.Status, parseError(resp.Body))), nil, nil
+ }
+ return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: done + "\nMasking exemptions: " + output.Link}}}, output, nil
+}
+
+// describeExemptionGrant builds the grant's confirmation message. On each line
+// the value a cut would most mislead about comes first, and the rest is ordered
+// so a cut makes the scope look broader, never narrower: the member right after
+// the verb, the database name before its narrowing. `Instance "` and
+// `Database "` leave room for a 63-character ID or PostgreSQL database name.
+// Values enter through %q, so none can pose as a line of the message.
+func describeExemptionGrant(ctx context.Context, g *exemptionGrant) string {
+ question := fmt.Sprintf("Exempt %q from masking", g.member)
+ if email := getUserEmail(ctx); email != "" {
+ question += ", as " + email
+ }
+ lines := []string{question + "?"}
+ if g.database == "" {
+ projectID, _ := common.GetProjectID(g.project)
+ lines = append(lines, fmt.Sprintf("Project %q", projectID), "Scope: all databases in the project, current and future")
+ } else {
+ lines = append(lines, fmt.Sprintf("Instance %q", g.instanceID), fmt.Sprintf("Database %q, %s", g.databaseName, describeNarrowing(g)))
+ }
+ effect := "Unmasked in query and export results, with no expiry."
+ if g.expireTime != "" {
+ effect = fmt.Sprintf("Unmasked in query and export results until %q.", g.expireTime)
+ }
+ if g.note != "" {
+ effect += fmt.Sprintf(" Reason: %q", g.note)
+ }
+ return strings.Join(append(lines, effect), "\n")
+}
+
+// describeNarrowing names what the grant covers within the database. A table
+// named without a schema matches that table in every schema, so "any schema"
+// comes before it, where a cut keeps the broader reading.
+func describeNarrowing(g *exemptionGrant) string {
+ switch {
+ case g.schema == "" && g.column != "":
+ return fmt.Sprintf("any schema, column %q in %q", g.column, g.table)
+ case g.schema == "" && g.table != "":
+ return fmt.Sprintf("any schema, table %q", g.table)
+ case g.column != "":
+ return fmt.Sprintf("column %q in %q.%q", g.column, g.schema, g.table)
+ case g.table != "":
+ return fmt.Sprintf("table %q.%q", g.schema, g.table)
+ case g.schema != "":
+ return fmt.Sprintf("schema %q", g.schema)
+ default:
+ return "all tables"
+ }
+}
+
+// describeExemptionRevoke builds the revoke's confirmation message.
+func describeExemptionRevoke(ctx context.Context, input RevokeMaskingExemptionInput, matched int) string {
+ question := fmt.Sprintf("Revoke masking exemption: %q", input.Member)
+ if email := getUserEmail(ctx); email != "" {
+ question += ", as " + email
+ }
+ projectID, _ := common.GetProjectID(input.Project)
+ condition := "Condition"
+ if matched > 1 {
+ condition += fmt.Sprintf(" (%d entries)", matched)
+ }
+ scope, expiry := splitExemptionExpiry(input.Condition)
+ condition += " " + strconv.Quote(scope)
+ switch {
+ case scope == "" && expiry == "":
+ condition += " (all databases, no expiry)"
+ case scope == "":
+ condition += fmt.Sprintf(" (all databases), until %q", expiry)
+ case expiry != "":
+ condition += fmt.Sprintf(", until %q", expiry)
+ default:
+ }
+ return strings.Join([]string{
+ question + "?",
+ fmt.Sprintf("Project %q", projectID),
+ condition,
+ "Masked again in their results unless another exemption covers the data.",
+ }, "\n")
+}
+
+// splitExemptionExpiry splits a condition whose top level is an expiry and'ed
+// with a scope, as the console writes it, into the scope and the expiry, so the
+// form can show the scope first, where a cut does not hide what is revoked. It
+// parses the condition, so CEL's precedence and literal forms decide: the
+// expiry of "T && A || B" does not cover B, and that condition is returned
+// whole, with no expiry, as is any other shape.
+func splitExemptionExpiry(condition string) (string, string) {
+ env, err := cel.NewEnv(common.MaskingExemptionPolicyCELAttributes...)
+ if err != nil {
+ return condition, ""
+ }
+ parsed, issues := env.Parse(condition)
+ if issues != nil && issues.Err() != nil {
+ return condition, ""
+ }
+ native := parsed.NativeRep()
+ root := native.Expr()
+ if expiry, ok := exemptionExpiry(root); ok {
+ return "", expiry
+ }
+ if root.Kind() != celast.CallKind || root.AsCall().FunctionName() != operators.LogicalAnd || len(root.AsCall().Args()) != 2 {
+ return condition, ""
+ }
+ expiry, ok := exemptionExpiry(root.AsCall().Args()[0])
+ if !ok {
+ return condition, ""
+ }
+ scope, err := parser.Unparse(root.AsCall().Args()[1], native.SourceInfo())
+ if err != nil {
+ return condition, ""
+ }
+ return scope, expiry
+}
+
+// exemptionExpiry returns the time of `request.time < timestamp("…")`.
+func exemptionExpiry(e celast.Expr) (string, bool) {
+ if e.Kind() != celast.CallKind || e.AsCall().FunctionName() != operators.Less || len(e.AsCall().Args()) != 2 {
+ return "", false
+ }
+ left, right := e.AsCall().Args()[0], e.AsCall().Args()[1]
+ if left.Kind() != celast.SelectKind || left.AsSelect().FieldName() != "time" {
+ return "", false
+ }
+ if operand := left.AsSelect().Operand(); operand.Kind() != celast.IdentKind || operand.AsIdent() != "request" {
+ return "", false
+ }
+ if right.Kind() != celast.CallKind || right.AsCall().FunctionName() != "timestamp" || len(right.AsCall().Args()) != 1 {
+ return "", false
+ }
+ literal := right.AsCall().Args()[0]
+ if literal.Kind() != celast.LiteralKind {
+ return "", false
+ }
+ value, ok := literal.AsLiteral().(types.String)
+ return string(value), ok
+}
+
+func (s *Server) maskingExemptionLink(ctx context.Context, project string) string {
+ return s.consoleLink(ctx, project) + "/masking-exemption"
+}
diff --git a/backend/api/mcp/tool_exemption_test.go b/backend/api/mcp/tool_exemption_test.go
new file mode 100644
index 0000000000..441dd23721
--- /dev/null
+++ b/backend/api/mcp/tool_exemption_test.go
@@ -0,0 +1,628 @@
+package mcp
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/labstack/echo/v5"
+ "github.com/modelcontextprotocol/go-sdk/mcp"
+ "github.com/stretchr/testify/require"
+
+ "github.com/bytebase/bytebase/backend/api/auth"
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/component/config"
+ "github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
+)
+
+const exemptionPolicyName = "projects/hr/policies/masking_exemption"
+
+// policyMock is the internal API behind the masking exemption tools: the
+// project, policy and database reads, and the update, recorded with the
+// confirmation its context carried. A read for another name is not found.
+type policyMock struct {
+ mu sync.Mutex
+ // exemptions is the policy's list; nil means the project has no policy.
+ exemptions []map[string]any
+ // databaseProject is the project GetDatabase reports.
+ databaseProject string
+ // policyReadStatus, when set, is the status GetPolicy fails with.
+ policyReadStatus int
+ refusal string
+ updates []decisionCall
+}
+
+func (m *policyMock) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ reply := func(v any) { _ = json.NewEncoder(w).Encode(v) }
+ notFound := func() {
+ w.WriteHeader(http.StatusNotFound)
+ reply(map[string]any{"code": "not_found", "message": "not found"})
+ }
+ var request map[string]any
+ _ = json.NewDecoder(r.Body).Decode(&request)
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ switch r.URL.Path {
+ case "/bytebase.v1.ProjectService/GetProject":
+ if request["name"] != "projects/hr" {
+ notFound()
+ return
+ }
+ reply(map[string]any{"name": "projects/hr"})
+ case "/bytebase.v1.OrgPolicyService/GetPolicy":
+ if m.policyReadStatus != 0 {
+ w.WriteHeader(m.policyReadStatus)
+ reply(map[string]any{"code": "internal", "message": "the read failed"})
+ return
+ }
+ if request["name"] != exemptionPolicyName || m.exemptions == nil {
+ notFound()
+ return
+ }
+ reply(map[string]any{"name": exemptionPolicyName, "type": "MASKING_EXEMPTION",
+ "maskingExemptionPolicy": map[string]any{"exemptions": m.exemptions}})
+ case "/bytebase.v1.DatabaseService/GetDatabase":
+ // A database on a project-owned instance always reports its owner.
+ project := m.databaseProject
+ if name, ok := request["name"].(string); ok {
+ if owner, _, _, err := common.GetDatabaseResourceName(name); err == nil && owner != nil {
+ project = common.FormatProject(*owner)
+ }
+ }
+ reply(map[string]any{"name": request["name"], "project": project})
+ case v1connect.OrgPolicyServiceUpdatePolicyProcedure:
+ call := decisionCall{path: r.URL.Path, body: request}
+ if confirmed, ok := auth.MCPConfirmedDecisionFromContext(r.Context()); ok {
+ call.confirmed = &confirmed
+ }
+ m.updates = append(m.updates, call)
+ if m.refusal != "" {
+ w.WriteHeader(http.StatusForbidden)
+ reply(map[string]any{"code": "permission_denied", "message": m.refusal})
+ return
+ }
+ reply(map[string]any{"name": exemptionPolicyName})
+ default:
+ w.WriteHeader(http.StatusNotFound)
+ }
+}
+
+func (m *policyMock) calls() []decisionCall {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ return append([]decisionCall(nil), m.updates...)
+}
+
+func newPolicyServer(t *testing.T, mock *policyMock) *Server {
+ t.Helper()
+ profile := &config.Profile{Mode: common.ReleaseModeDev, ExternalURL: "https://bb.example.com"}
+ s, err := newServerWithStore(newTestServerStore(), profile, revalidationSecret, mock)
+ require.NoError(t, err)
+ return s
+}
+
+func connectToPolicyServer(t *testing.T, mock *policyMock, opts *mcp.ClientOptions) *mcp.ClientSession {
+ t.Helper()
+ e := echo.New()
+ newPolicyServer(t, mock).RegisterRoutes(e)
+ ts := httptest.NewServer(e)
+ t.Cleanup(ts.Close)
+ token := mintMCPToken(t, "[email protected]", "client-A", "ws-test", "mcp:read-write", time.Hour)
+ return connectLegacy(t, ts.URL+mcpResourcePath, token, opts)
+}
+
+func callExemptionTool(t *testing.T, session *mcp.ClientSession, name string, arguments map[string]any) *mcp.CallToolResult {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
+ defer cancel()
+ res, err := session.CallTool(ctx, &mcp.CallToolParams{Name: name, Arguments: arguments})
+ require.NoError(t, err)
+ return res
+}
+
+func writtenExemptions(t *testing.T, call decisionCall) []any {
+ t.Helper()
+ policy, ok := call.body["policy"].(map[string]any)
+ require.True(t, ok, "%v", call.body)
+ payload, ok := policy["maskingExemptionPolicy"].(map[string]any)
+ require.True(t, ok, "%v", policy)
+ exemptions, ok := payload["exemptions"].([]any)
+ require.True(t, ok, "%v", payload)
+ return exemptions
+}
+
+func salaryGrant() map[string]any {
+ return map[string]any{
+ "project": "projects/hr", "member": "user:[email protected]", "database": "instances/prod/databases/hr",
+ "schema": "public", "table": "employee", "column": "salary",
+ "expireTime": "2026-10-27T00:00:00Z", "reason": "payroll audit",
+ }
+}
+
+func TestGrantMaskingExemptionCreatesTheFirstExemption(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", salaryGrant())
+ require.False(t, res.IsError, resultText(t, res))
+ require.Equal(t, int32(1), user.asked.Load())
+ require.Equal(t, strings.Join([]string{
+ `Exempt "user:[email protected]" from masking, as [email protected]?`,
+ `Instance "prod"`,
+ `Database "hr", column "salary" in "public"."employee"`,
+ `Unmasked in query and export results until "2026-10-27T00:00:00.000Z". Reason: "payroll audit"`,
+ }, "\n"), user.lastParams(t).Message)
+
+ calls := mock.calls()
+ require.Len(t, calls, 1)
+ require.Equal(t, map[string]any{
+ "policy": map[string]any{
+ "name": exemptionPolicyName,
+ "type": "MASKING_EXEMPTION",
+ "maskingExemptionPolicy": map[string]any{"exemptions": []any{map[string]any{
+ "members": []any{"user:[email protected]"},
+ "condition": map[string]any{
+ "expression": `request.time < timestamp("2026-10-27T00:00:00.000Z") && (resource.instance_id == "prod" && resource.database_name == "hr" && resource.schema_name == "public" && resource.table_name == "employee" && resource.column_name == "salary")`,
+ "description": "payroll audit",
+ },
+ }}},
+ },
+ "updateMask": "maskingExemptionPolicy",
+ "allowMissing": true,
+ }, calls[0].body, "the first exemption creates the policy, as the console does, in the console's condition form")
+ require.Equal(t, &auth.MCPConfirmedDecision{
+ Procedure: v1connect.OrgPolicyServiceUpdatePolicyProcedure,
+ Resource: exemptionPolicyName,
+ }, calls[0].confirmed)
+ require.Contains(t, resultText(t, res), "Exempted user:[email protected] from masking in projects/hr.\nMasking exemptions: https://bb.example.com/projects/hr/masking-exemption")
+}
+
+func TestGrantMaskingExemptionKeepsEveryOtherEntry(t *testing.T) {
+ existing := map[string]any{
+ "members": []any{"group:[email protected]", "user:[email protected]"},
+ "condition": map[string]any{
+ "title": "Q3", "description": "made in the console", "location": "console",
+ "expression": `(resource.instance_id == "prod" && resource.database_name == "hr") || (resource.instance_id == "prod" && resource.database_name == "finance")`,
+ },
+ }
+ mock := &policyMock{databaseProject: "projects/hr", exemptions: []map[string]any{existing}}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: (&asker{answer: confirmAnswer(true)}).handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", map[string]any{
+ "project": "projects/hr", "member": "user:[email protected]", "database": "instances/prod/databases/hr",
+ })
+ require.False(t, res.IsError, resultText(t, res))
+ calls := mock.calls()
+ require.Len(t, calls, 1)
+ written := writtenExemptions(t, calls[0])
+ require.Len(t, written, 2)
+ require.Equal(t, map[string]any{
+ "members": []any{"group:[email protected]", "user:[email protected]"},
+ "condition": map[string]any{
+ "title": "Q3", "description": "made in the console", "location": "console",
+ "expression": `(resource.instance_id == "prod" && resource.database_name == "hr") || (resource.instance_id == "prod" && resource.database_name == "finance")`,
+ },
+ }, written[0], "an entry the tool does not change is written back with every field it read")
+ require.Equal(t, map[string]any{"expression": `(resource.instance_id == "prod" && resource.database_name == "hr")`}, written[1].(map[string]any)["condition"])
+}
+
+func TestGrantMaskingExemptionNamesADatabaseOnAProjectOwnedInstance(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", map[string]any{
+ "project": "projects/hr", "member": "user:[email protected]", "database": "projects/hr/instances/team/databases/payroll",
+ })
+ require.False(t, res.IsError, resultText(t, res))
+ require.Contains(t, user.lastParams(t).Message, "Instance \"team\"\nDatabase \"payroll\", all tables")
+ calls := mock.calls()
+ require.Len(t, calls, 1)
+ require.Equal(t, map[string]any{"expression": `(resource.instance_id == "team" && resource.database_name == "payroll")`}, writtenExemptions(t, calls[0])[0].(map[string]any)["condition"])
+
+ res = callExemptionTool(t, session, "grant_masking_exemption", map[string]any{
+ "project": "projects/hr", "member": "user:[email protected]", "database": "projects/finance/instances/team/databases/payroll",
+ })
+ require.True(t, res.IsError)
+ require.Contains(t, resultText(t, res), "belongs to projects/finance, not projects/hr")
+ require.Len(t, mock.calls(), 1)
+}
+
+func TestGrantMaskingExemptionSaysWhenATableIsInAnySchema(t *testing.T) {
+ for name, tc := range map[string]struct {
+ arguments map[string]any
+ want string
+ }{
+ "a table": {map[string]any{"table": "employee"}, `Database "hr", any schema, table "employee"`},
+ "a column": {map[string]any{"table": "employee", "column": "salary"}, `Database "hr", any schema, column "salary" in "employee"`},
+ "a schema": {map[string]any{"schema": "public"}, `Database "hr", schema "public"`},
+ } {
+ t.Run(name, func(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+ arguments := map[string]any{"project": "projects/hr", "member": "user:[email protected]", "database": "instances/prod/databases/hr"}
+ for k, v := range tc.arguments {
+ arguments[k] = v
+ }
+ res := callExemptionTool(t, session, "grant_masking_exemption", arguments)
+ require.False(t, res.IsError, resultText(t, res))
+ require.Contains(t, user.lastParams(t).Message, tc.want)
+ })
+ }
+}
+
+func TestGrantMaskingExemptionForEveryDatabaseIsExplicit(t *testing.T) {
+ mock := &policyMock{}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", map[string]any{
+ "project": "projects/hr", "member": "user:[email protected]", "allDatabases": true,
+ })
+ require.False(t, res.IsError, resultText(t, res))
+ require.Equal(t, strings.Join([]string{
+ `Exempt "user:[email protected]" from masking, as [email protected]?`,
+ `Project "hr"`,
+ `Scope: all databases in the project, current and future`,
+ `Unmasked in query and export results, with no expiry.`,
+ }, "\n"), user.lastParams(t).Message)
+ calls := mock.calls()
+ require.Len(t, calls, 1)
+ require.Equal(t, map[string]any{"expression": ""}, writtenExemptions(t, calls[0])[0].(map[string]any)["condition"],
+ "an empty condition is every database without expiry, as the proto documents")
+
+ res = callExemptionTool(t, session, "grant_masking_exemption", map[string]any{
+ "project": "projects/ghost", "member": "user:[email protected]", "allDatabases": true,
+ })
+ require.True(t, res.IsError, "an exemption under a project that does not exist would apply to one created later with that ID")
+ require.Len(t, mock.calls(), 1)
+}
+
+func TestGrantMaskingExemptionRefusesBadArguments(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: (&asker{answer: confirmAnswer(true)}).handle})
+ base := map[string]any{"project": "projects/hr", "member": "user:[email protected]"}
+ with := func(extra map[string]any) map[string]any {
+ out := map[string]any{}
+ for k, v := range base {
+ out[k] = v
+ }
+ for k, v := range extra {
+ out[k] = v
+ }
+ return out
+ }
+ for name, tc := range map[string]struct {
+ arguments map[string]any
+ want string
+ }{
+ "no scope": {base, "needs a scope: database, or allDatabases set to true"},
+ "both scopes": {with(map[string]any{"database": "instances/prod/databases/hr", "allDatabases": true}), "not both"},
+ "narrowing without one": {with(map[string]any{"allDatabases": true, "table": "employee"}), "they need database"},
+ "column without table": {with(map[string]any{"database": "instances/prod/databases/hr", "column": "salary"}), "column needs table"},
+ "a malformed time": {with(map[string]any{"allDatabases": true, "expireTime": "next week"}), "invalid expireTime"},
+ "a malformed database": {with(map[string]any{"database": "hr"}), "invalid database"},
+ "no member": {map[string]any{"project": "projects/hr", "member": " ", "allDatabases": true}, "invalid member"},
+ "every user": {map[string]any{"project": "projects/hr", "member": "allUsers", "allDatabases": true}, "would unmask the scope for everyone"},
+ "no prefix": {map[string]any{"project": "projects/hr", "member": "[email protected]", "allDatabases": true}, "invalid member"},
+ "a prefix alone": {map[string]any{"project": "projects/hr", "member": "user:", "allDatabases": true}, "invalid member"},
+ "an invalid project": {map[string]any{"project": "hr", "member": "user:[email protected]", "allDatabases": true}, "invalid project"},
+ } {
+ t.Run(name, func(t *testing.T) {
+ res := callExemptionTool(t, session, "grant_masking_exemption", tc.arguments)
+ require.True(t, res.IsError)
+ require.Contains(t, resultText(t, res), tc.want)
+ })
+ }
+ require.Empty(t, mock.calls())
+}
+
+func TestGrantMaskingExemptionRefusesADatabaseInAnotherProject(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/finance"}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", salaryGrant())
+ require.True(t, res.IsError)
+ require.Contains(t, resultText(t, res), "instances/prod/databases/hr belongs to projects/finance, not projects/hr")
+ require.Zero(t, user.asked.Load())
+ require.Empty(t, mock.calls())
+}
+
+func TestGrantMaskingExemptionIsStaleWhenTheListChangesWhileAsking(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ user := &asker{answer: confirmAnswer(true), whileAsked: func() {
+ mock.mu.Lock()
+ defer mock.mu.Unlock()
+ mock.exemptions = []map[string]any{{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}}}
+ }}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", salaryGrant())
+ require.True(t, res.IsError, resultText(t, res))
+ require.Contains(t, resultText(t, res), "STALE_CONFIRMATION")
+ require.Empty(t, mock.calls(), "an exemption added while the form was open must not be overwritten by the old list")
+}
+
+func TestMaskingExemptionToolsBindTheAnswerToTheArguments(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr", exemptions: []map[string]any{
+ {"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}},
+ }}
+ token := mintMCPToken(t, "[email protected]", "client-A", "ws-test", "mcp:read-write", time.Hour)
+ session := connectMRTR(t, mrtrEndpoint(t, newPolicyServer(t, mock)), token)
+ call := func(name string, arguments map[string]any, responses mcp.InputResponseMap, state string) *mcp.CallToolResult {
+ ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
+ defer cancel()
+ res, err := session.CallTool(ctx, &mcp.CallToolParams{Name: name, Arguments: arguments, InputResponses: responses, RequestState: state})
+ require.NoError(t, err)
+ return res
+ }
+ accept := mcp.InputResponseMap{confirmDecisionRequestID: confirmAnswer(true)}
+
+ first := call("grant_masking_exemption", salaryGrant(), nil, "")
+ require.True(t, first.NeedsInput())
+ wider := salaryGrant()
+ delete(wider, "column")
+ stale := call("grant_masking_exemption", wider, accept, first.RequestState)
+ require.True(t, stale.IsError, resultText(t, stale))
+ require.Contains(t, resultText(t, stale), "STALE_CONFIRMATION", "an answer resent with a wider scope is not what the user confirmed")
+
+ revoke := map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": ""}
+ first = call("revoke_masking_exemption", revoke, nil, "")
+ require.True(t, first.NeedsInput())
+ mock.mu.Lock()
+ mock.exemptions = append(mock.exemptions, map[string]any{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}})
+ mock.mu.Unlock()
+ stale = call("revoke_masking_exemption", revoke, accept, first.RequestState)
+ require.True(t, stale.IsError, resultText(t, stale))
+ require.Contains(t, resultText(t, stale), "STALE_CONFIRMATION", "a revoke would now drop an entry the form did not count")
+ require.Empty(t, mock.calls())
+}
+
+func TestGrantMaskingExemptionChangesNothingUnlessConfirmed(t *testing.T) {
+ for name, tc := range map[string]struct {
+ answer *mcp.ElicitResult
+ want string
+ }{
+ "declined": {&mcp.ElicitResult{Action: "decline"}, "the user declined"},
+ "cancelled": {&mcp.ElicitResult{Action: "cancel"}, "the user cancelled"},
+ "accepted, unticked": {confirmAnswer(false), "the form was submitted without the confirmation checked"},
+ } {
+ t.Run(name, func(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr"}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: (&asker{answer: tc.answer}).handle})
+ res := callExemptionTool(t, session, "grant_masking_exemption", salaryGrant())
+ require.False(t, res.IsError, resultText(t, res))
+ require.Contains(t, resultText(t, res), "The exemption for user:[email protected] was not granted: "+tc.want+", so nothing changed")
+ require.Empty(t, mock.calls())
+ })
+ }
+}
+
+func TestMaskingExemptionToolsRefuseAClientThatCannotConfirm(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr", exemptions: []map[string]any{
+ {"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}},
+ }}
+ session := connectToPolicyServer(t, mock, nil)
+
+ res := callExemptionTool(t, session, "grant_masking_exemption", salaryGrant())
+ require.True(t, res.IsError)
+ require.Contains(t, resultText(t, res), "CONFIRMATION_UNAVAILABLE")
+ require.Contains(t, resultText(t, res), "grant it signed in to the Bytebase console: https://bb.example.com/projects/hr/masking-exemption")
+
+ res = callExemptionTool(t, session, "revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": ""})
+ require.True(t, res.IsError)
+ require.Contains(t, resultText(t, res), "CONFIRMATION_UNAVAILABLE")
+ require.Empty(t, mock.calls())
+}
+
+func TestMaskingExemptionToolsChangeNothingWhenThePolicyReadFails(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr", policyReadStatus: http.StatusInternalServerError}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ for _, call := range []struct {
+ name string
+ arguments map[string]any
+ }{
+ {"grant_masking_exemption", salaryGrant()},
+ {"revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": ""}},
+ } {
+ res := callExemptionTool(t, session, call.name, call.arguments)
+ require.True(t, res.IsError, call.name)
+ require.Contains(t, resultText(t, res), "HTTP 500", call.name)
+ }
+ require.Zero(t, user.asked.Load(), "a failed read is not an empty list: the user is not asked about a write that would erase every exemption")
+ require.Empty(t, mock.calls())
+}
+
+func TestMaskingExemptionToolsReportTheRefusalInTheServersWords(t *testing.T) {
+ mock := &policyMock{databaseProject: "projects/hr", refusal: "permission denied: bb.policies.updateMaskingExemptionPolicy",
+ exemptions: []map[string]any{{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}}}}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: (&asker{answer: confirmAnswer(true)}).handle})
+
+ for _, call := range []struct {
+ name string
+ arguments map[string]any
+ done string
+ }{
+ {"grant_masking_exemption", salaryGrant(), "Exempted"},
+ {"revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": ""}, "Removed"},
+ } {
+ res := callExemptionTool(t, session, call.name, call.arguments)
+ require.True(t, res.IsError, call.name)
+ require.Contains(t, resultText(t, res), "HTTP 403: permission denied: bb.policies.updateMaskingExemptionPolicy", call.name)
+ require.NotContains(t, resultText(t, res), call.done, call.name)
+ require.Nil(t, res.StructuredContent, call.name)
+ }
+}
+
+func TestRevokeMaskingExemptionRemovesTheMemberFromEveryMatch(t *testing.T) {
+ condition := `(resource.instance_id == "prod" && resource.database_name == "hr")`
+ untouched := map[string]any{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": condition, "title": "dave's"}}
+ mock := &policyMock{exemptions: []map[string]any{
+ {"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": condition}},
+ untouched,
+ {"members": []any{"user:[email protected]", "user:[email protected]"}, "condition": map[string]any{"expression": condition, "description": "kept"}},
+ {"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}},
+ }}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": condition})
+ require.False(t, res.IsError, resultText(t, res))
+ require.Equal(t, strings.Join([]string{
+ `Revoke masking exemption: "user:[email protected]", as [email protected]?`,
+ `Project "hr"`,
+ `Condition (2 entries) "(resource.instance_id == \"prod\" && resource.database_name == \"hr\")"`,
+ `Masked again in their results unless another exemption covers the data.`,
+ }, "\n"), user.lastParams(t).Message)
+ calls := mock.calls()
+ require.Len(t, calls, 1)
+ require.Equal(t, []any{
+ map[string]any{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": condition, "title": "dave's"}},
+ map[string]any{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": condition, "description": "kept"}},
+ map[string]any{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}},
+ }, writtenExemptions(t, calls[0]), "the member leaves every exact match, an entry left empty is dropped, and every other entry stays")
+ require.Contains(t, resultText(t, res), "Removed user:[email protected]'s masking exemption in projects/hr.")
+ output, err := json.Marshal(res.StructuredContent)
+ require.NoError(t, err)
+ require.JSONEq(t, fmt.Sprintf(`{"project":"projects/hr","member":"user:[email protected]","condition":%q,"link":"https://bb.example.com/projects/hr/masking-exemption"}`, condition), string(output))
+}
+
+func TestRevokeMaskingExemptionChangesNothingUnlessConfirmed(t *testing.T) {
+ mock := &policyMock{exemptions: []map[string]any{{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": ""}}}}
+ user := &asker{answer: &mcp.ElicitResult{Action: "decline"}}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+
+ res := callExemptionTool(t, session, "revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": ""})
+ require.False(t, res.IsError, resultText(t, res))
+ require.Contains(t, resultText(t, res), "The exemption for user:[email protected] was not removed: the user declined, so nothing changed")
+ require.Contains(t, user.lastParams(t).Message, `Condition "" (all databases, no expiry)`)
+ require.Empty(t, mock.calls())
+}
+
+func TestRevokeMaskingExemptionShowsTheScopeBeforeTheExpiry(t *testing.T) {
+ ctx := withUserEmail(context.Background(), "[email protected]")
+ for name, tc := range map[string]struct {
+ condition, want string
+ }{
+ "the console's form": {
+ `request.time < timestamp("2026-10-27T00:00:00.000Z") && (resource.instance_id == "prod" && resource.database_name == "hr")`,
+ `Condition "resource.instance_id == \"prod\" && resource.database_name == \"hr\"", until "2026-10-27T00:00:00.000Z"`,
+ },
+ "an expiry only": {`request.time < timestamp("2026-10-27T00:00:00.000Z")`, `Condition "" (all databases), until "2026-10-27T00:00:00.000Z"`},
+ "an expiry last": {
+ `resource.database_name == "hr" && request.time < timestamp("2026-10-27T00:00:00.000Z")`,
+ `Condition "resource.database_name == \"hr\" && request.time < timestamp(\"2026-10-27T00:00:00.000Z\")"`,
+ },
+ "a top-level or": {
+ `request.time < timestamp("2026-10-27T00:00:00.000Z") && (resource.database_name == "hr") || (resource.database_name == "finance")`,
+ `Condition "request.time < timestamp(\"2026-10-27T00:00:00.000Z\") && (resource.database_name == \"hr\") || (resource.database_name == \"finance\")"`,
+ },
+ "single-quoted parentheses around a top-level or": {
+ `request.time < timestamp("2026-10-27T00:00:00.000Z") && (resource.table_name == '(') || (resource.database_name == ')')`,
+ `Condition "request.time < timestamp(\"2026-10-27T00:00:00.000Z\") && (resource.table_name == '(') || (resource.database_name == ')')"`,
+ },
+ "a parenthesis in a name": {
+ `request.time < timestamp("2026-10-27T00:00:00.000Z") && (resource.table_name == "a)b")`,
+ `Condition "resource.table_name == \"a)b\"", until "2026-10-27T00:00:00.000Z"`,
+ },
+ "not CEL": {`((`, `Condition "(("`},
+ } {
+ t.Run(name, func(t *testing.T) {
+ lines := strings.Split(describeExemptionRevoke(ctx, RevokeMaskingExemptionInput{Project: "projects/hr", Member: "user:[email protected]", Condition: tc.condition}, 1), "\n")
+ require.Equal(t, tc.want, lines[2])
+ })
+ }
+}
+
+func TestRevokeMaskingExemptionRefusesWithoutAMatch(t *testing.T) {
+ for name, tc := range map[string]struct {
+ exemptions []map[string]any
+ want string
+ }{
+ "no policy": {nil, "user:[email protected] holds no exemption in projects/hr"},
+ "another condition": {
+ []map[string]any{{"members": []any{"user:[email protected]"}, "condition": map[string]any{"expression": "resource.database_name == \"finance\""}}},
+ "holds exemptions with these conditions",
+ },
+ } {
+ t.Run(name, func(t *testing.T) {
+ mock := &policyMock{exemptions: tc.exemptions}
+ user := &asker{answer: confirmAnswer(true)}
+ session := connectToPolicyServer(t, mock, &mcp.ClientOptions{ElicitationHandler: user.handle})
+ res := callExemptionTool(t, session, "revoke_masking_exemption", map[string]any{"project": "projects/hr", "member": "user:[email protected]", "condition": `resource.database_name == "hr"`})
+ require.True(t, res.IsError)
+ var refusal toolError
+ require.NoError(t, json.Unmarshal([]byte(resultText(t, res)), &refusal))
+ require.Equal(t, "NOT_FOUND", refusal.Code)
+ require.Contains(t, refusal.Suggestion, tc.want)
+ if len(tc.exemptions) > 0 {
+ require.Contains(t, refusal.Suggestion, `resource.database_name == \"finance\"`, "the refusal names the conditions the member holds")
+ }
+ require.Zero(t, user.asked.Load())
+ require.Empty(t, mock.calls())
+ })
+ }
+}
+
+func TestMaskingExemptionFormsKeepAMemberOnItsLine(t *testing.T) {
+ ctx := withUserEmail(context.Background(), "[email protected]")
+ forged := "user:[email protected]\nInstance \"dev\"\nDatabase \"sandbox\", table \"t\""
+ for name, message := range map[string]string{
+ "grant": describeExemptionGrant(ctx, &exemptionGrant{project: "projects/hr", member: forged}),
+ "revoke": describeExemptionRevoke(ctx, RevokeMaskingExemptionInput{Project: "projects/hr", Member: forged}, 1),
+ } {
+ view := claudeCodeView(message, 120)
+ require.Len(t, view, 4, "%s: %q", name, view)
+ require.Equal(t, `Project "hr"`, view[1], "%s: a line break in the member stays on line 1, escaped: %q", name, view)
+ }
+}
+
+func TestMaskingExemptionFormsShowTheScopeInClaudeCodesDialog(t *testing.T) {
+ ctx := withUserEmail(context.Background(), "[email protected]")
+ longest := strings.Repeat("x", 63)
+ grantView := func(g *exemptionGrant, columns int) []string {
+ return claudeCodeView(describeExemptionGrant(ctx, g), columns)
+ }
+ for _, columns := range []int{80, 120} {
+ t.Run(fmt.Sprintf("%d columns", columns), func(t *testing.T) {
+ member := "serviceAccount:[email protected]"
+ view := grantView(&exemptionGrant{project: "projects/hr", member: member, database: "d", instanceID: longest, databaseName: longest, table: "t", column: "c"}, columns)
+ require.Len(t, view, 4, "%q", view)
+ require.True(t, strings.HasPrefix(view[0], fmt.Sprintf("Exempt %q", member)), "a %d-character member shows whole, its project included: %q", len(member), view)
+ require.Equal(t, fmt.Sprintf("Instance %q", longest), view[1], "the longest instance ID shows whole")
+ require.True(t, strings.HasPrefix(view[2], `Database "`+longest), "the longest PostgreSQL database name shows whole, and the narrowing after it is cut: %q", view)
+ require.True(t, strings.HasPrefix(view[3], "Unmasked in query and export results"), "%q", view)
+
+ west := grantView(&exemptionGrant{member: "user:[email protected]", database: "d", instanceID: "production-analytics-platform-west", databaseName: "hr"}, columns)
+ east := grantView(&exemptionGrant{member: "user:[email protected]", database: "d", instanceID: "production-analytics-platform-east", databaseName: "hr"}, columns)
+ require.NotEqual(t, west, east, "two instances that differ only at the end must not look the same")
+ prod := grantView(&exemptionGrant{member: "user:[email protected]", database: "d", instanceID: longest, databaseName: "payroll_reporting_prod"}, columns)
+ test := grantView(&exemptionGrant{member: "user:[email protected]", database: "d", instanceID: longest, databaseName: "payroll_reporting_test"}, columns)
+ require.NotEqual(t, prod, test, "two databases that differ only at the end must not look the same")
+
+ all := grantView(&exemptionGrant{project: "projects/" + longest, member: "user:[email protected]", expireTime: "2026-10-27T00:00:00.000Z", note: strings.Repeat("r", 80)}, columns)
+ require.Len(t, all, 4, "%q", all)
+ require.Equal(t, fmt.Sprintf("Project %q", longest), all[1])
+ require.Equal(t, "Scope: all databases in the project, current and future", all[2])
+ require.True(t, strings.HasPrefix(all[3], `Unmasked in query and export results until "2026-10-27T00:00:00.000Z".`), "the expiry shows before the reason is cut: %q", all)
+
+ revoke := claudeCodeView(describeExemptionRevoke(ctx, RevokeMaskingExemptionInput{Project: "projects/" + longest, Member: "user:[email protected]", Condition: strings.Repeat("c", 200)}, 3), columns)
+ require.Len(t, revoke, 4, "%q", revoke)
+ require.Equal(t, fmt.Sprintf("Project %q", longest), revoke[1])
+ require.True(t, strings.HasPrefix(revoke[2], "Condition (3 entries) \""), "%q", revoke)
+ require.NotContains(t, revoke[3], "…", "the effect line fits whole: %q", revoke)
+ })
+ }
+}
diff --git a/backend/api/mcp/tool_jit.go b/backend/api/mcp/tool_jit.go
index a726e22e92..e98af27599 100644
--- a/backend/api/mcp/tool_jit.go
+++ b/backend/api/mcp/tool_jit.go
@@ -13,7 +13,6 @@ import (
"github.com/bytebase/bytebase/backend/api/auth"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
- "github.com/bytebase/bytebase/backend/utils"
)
// SetJustInTimeAccessInput is the input for the set_just_in_time_access tool.
@@ -79,12 +78,8 @@ func (c *justInTimeChange) body() map[string]any {
}
func parseJustInTimeChange(input SetJustInTimeAccessInput) (*justInTimeChange, error) {
- if _, err := common.GetProjectID(input.Project); err != nil {
- return nil, &toolError{
- Code: "INVALID_ARGUMENT",
- Message: fmt.Sprintf("invalid project %q", input.Project),
- Suggestion: "pass the project name, e.g. projects/hr",
- }
+ if err := checkProjectName(input.Project); err != nil {
+ return nil, err
}
return &justInTimeChange{project: input.Project, enabled: input.Enabled}, nil
}
@@ -189,6 +184,5 @@ func (s *Server) setJustInTimeAccessOnAnswer(ctx context.Context, change *justIn
}
func (s *Server) projectSettingsLink(ctx context.Context, project string) string {
- externalURL, _ := utils.GetEffectiveExternalURL(ctx, s.store, s.profile, getWorkspaceID(ctx))
- return buildResourceURL(externalURL, project) + "/settings"
+ return s.consoleLink(ctx, project) + "/settings"
}
diff --git a/backend/api/v1/mcp_gate.go b/backend/api/v1/mcp_gate.go
index b19b9feee6..83d8eda346 100644
--- a/backend/api/v1/mcp_gate.go
+++ b/backend/api/v1/mcp_gate.go
@@ -474,6 +474,8 @@ var mcpRequestShapeRefusals = map[string]func(ctx context.Context, msg any) (rea
rejectedIssueName, mcpIssueDecisionUnconfirmed, mcpDecideIssueWayOut),
v1connect.ProjectServiceUpdateProjectProcedure: refuseUnconfirmed(v1connect.ProjectServiceUpdateProjectProcedure,
updatedProjectName, mcpProjectUpdateUnconfirmed, mcpProjectUpdateWayOut),
+ v1connect.OrgPolicyServiceUpdatePolicyProcedure: refuseUnconfirmed(v1connect.OrgPolicyServiceUpdatePolicyProcedure,
+ updatedPolicyName, mcpPolicyUpdateUnconfirmed, mcpPolicyUpdateWayOut),
v1connect.SheetServiceCreateSheetProcedure: inTheConsole(refuseMaskedWriteSheet),
v1connect.SheetServiceBatchCreateSheetsProcedure: inTheConsole(refuseMaskedWriteSheetBatch),
v1connect.ReleaseServiceCreateReleaseProcedure: inTheConsole(refuseMaskedWriteRelease),
@@ -514,6 +516,10 @@ const (
"and this request carries no such confirmation"
mcpProjectUpdateWayOut = "To turn just-in-time access on or off, use the set_just_in_time_access tool, which asks the user to confirm. " +
"Change other project settings signed in to the Bytebase console"
+ mcpPolicyUpdateUnconfirmed = "a policy changes over MCP only through grant_masking_exemption and revoke_masking_exemption, after the user confirms the change in the MCP client, " +
+ "and this request carries no such confirmation"
+ mcpPolicyUpdateWayOut = "To grant or revoke a masking exemption, use those tools, which ask the user to confirm. " +
+ "Change other policies signed in to the Bytebase console"
)
// refuseUnconfirmed serves procedure only when the request context carries a
@@ -548,6 +554,11 @@ func updatedProjectName(msg any) (string, bool) {
return request.GetProject().GetName(), ok
}
+func updatedPolicyName(msg any) (string, bool) {
+ request, ok := msg.(*v1pb.UpdatePolicyRequest)
+ return request.GetPolicy().GetName(), ok
+}
+
// refuseGrantIssueCreation applies grantIssueRefusal to CreateIssue. UpdateIssue's
// allow_missing creation is guarded in its handler (rejectMCPOriginatedGrantIssue).
func refuseGrantIssueCreation(_ context.Context, msg any) (string, string) {
diff --git a/backend/api/v1/mcp_gate_test.go b/backend/api/v1/mcp_gate_test.go
index 7183924e32..379dcd70ee 100644
--- a/backend/api/v1/mcp_gate_test.go
+++ b/backend/api/v1/mcp_gate_test.go
@@ -740,6 +740,12 @@ func TestTheJourneyOneWritesAreServed(t *testing.T) {
"an agent that requested access must be able to revoke the grant once the work is done (BYT-9292)")
require.Equal(t, v1pb.MCPMethodClass_WRITE, class[v1connect.ProjectServiceUpdateProjectProcedure],
"an agent must be able to turn just-in-time access on, through set_just_in_time_access (BYT-9292)")
+ require.Equal(t, v1pb.MCPMethodClass_WRITE, class[v1connect.OrgPolicyServiceUpdatePolicyProcedure],
+ "an agent must be able to grant and revoke a masking exemption, through the exemption tools (BYT-9292)")
+ for _, procedure := range []string{v1connect.OrgPolicyServiceCreatePolicyProcedure, v1connect.OrgPolicyServiceDeletePolicyProcedure} {
+ require.Equal(t, v1pb.MCPMethodClass_EXCLUDED, class[procedure],
+ "%s stays EXCLUDED: the exemption tools create the first policy through UpdatePolicy's allow_missing and write an empty list for the last entry", procedure)
+ }
}
func TestMCPGateServesAProjectUpdateOnlyWithItsConfirmation(t *testing.T) {
@@ -791,6 +797,60 @@ func TestMCPGateServesAProjectUpdateOnlyWithItsConfirmation(t *testing.T) {
})
}
+func TestMCPGateServesAPolicyUpdateOnlyWithItsConfirmation(t *testing.T) {
+ const policy = "projects/p/policies/masking_exemption"
+ write := classContext(v1pb.MCPMethodClass_WRITE)
+ procedure := v1connect.OrgPolicyServiceUpdatePolicyProcedure
+ request := func(name string) connect.AnyRequest {
+ return connect.NewRequest(&v1pb.UpdatePolicyRequest{
+ Policy: &v1pb.Policy{
+ Name: name,
+ Type: v1pb.PolicyType_MASKING_EXEMPTION,
+ Policy: &v1pb.Policy_MaskingExemptionPolicy{MaskingExemptionPolicy: &v1pb.MaskingExemptionPolicy{}},
+ },
+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"masking_exemption_policy"}},
+ AllowMissing: true,
+ })
+ }
+ confirmed := func(procedure, name string) context.Context {
+ return auth.WithMCPConfirmedDecision(context.Background(), auth.MCPConfirmedDecision{Procedure: procedure, Resource: name})
+ }
+
+ t.Run("an unconfirmed request, as call_api sends it, is refused", func(t *testing.T) {
+ got := invokeMCPGate(t, readWriteCeiling(), write, procedure, request(policy))
+ require.Error(t, got.err)
+ require.False(t, got.dispatched)
+ require.Equal(t, connect.CodePermissionDenied, connect.CodeOf(got.err))
+ require.Contains(t, got.err.Error(), "grant_masking_exemption", "the denial must name the paths that can confirm")
+ require.Contains(t, got.err.Error(), "Bytebase console", "the denial must name where other policies change")
+ require.True(t, got.auditMarked)
+ })
+
+ t.Run("the confirmed request is served", func(t *testing.T) {
+ got := invokeMCPGateFrom(confirmed(procedure, policy), t, readWriteCeiling(), write, procedure, request(policy))
+ require.NoError(t, got.err)
+ require.True(t, got.dispatched)
+ })
+
+ t.Run("a confirmation for another policy is refused", func(t *testing.T) {
+ got := invokeMCPGateFrom(confirmed(procedure, "projects/q/policies/masking_exemption"), t, readWriteCeiling(), write, procedure, request(policy))
+ require.Equal(t, connect.CodePermissionDenied, connect.CodeOf(got.err))
+ require.False(t, got.dispatched)
+ })
+
+ t.Run("a confirmation for another procedure is refused", func(t *testing.T) {
+ got := invokeMCPGateFrom(confirmed(v1connect.ProjectServiceUpdateProjectProcedure, policy), t, readWriteCeiling(), write, procedure, request(policy))
+ require.Equal(t, connect.CodePermissionDenied, connect.CodeOf(got.err))
+ require.False(t, got.dispatched)
+ })
+
+ t.Run("a confirmed request is still held to the ceiling", func(t *testing.T) {
+ got := invokeMCPGateFrom(confirmed(procedure, policy), t, readOnlyCeiling(), write, procedure, request(policy))
+ require.Error(t, got.err)
+ require.False(t, got.dispatched)
+ })
+}
+
// TestDeprecatedSQLServiceAliasesMatchTheirCanonicalMethod pins the three
// query-history RPCs that SQLService still carries as deprecated aliases of
// QueryHistoryService. They have no HTTP binding, but the MCP surface indexes
diff --git a/backend/api/v1/mcp_masking_test.go b/backend/api/v1/mcp_masking_test.go
index f455c0285d..4ec6da3de7 100644
--- a/backend/api/v1/mcp_masking_test.go
+++ b/backend/api/v1/mcp_masking_test.go
@@ -152,6 +152,7 @@ func TestMaskedWriteGuardIsWiredIntoTheGate(t *testing.T) {
v1connect.IssueServiceApproveIssueProcedure,
v1connect.IssueServiceRejectIssueProcedure,
v1connect.ProjectServiceUpdateProjectProcedure,
+ v1connect.OrgPolicyServiceUpdatePolicyProcedure,
}
listed := slices.Clone(notDoors)
for _, door := range doors {
diff --git a/backend/api/v1/testdata/mcp_method_classification.md b/backend/api/v1/testdata/mcp_method_classification.md
index 62179c9f0d..fa142caf9a 100644
--- a/backend/api/v1/testdata/mcp_method_classification.md
+++ b/backend/api/v1/testdata/mcp_method_classification.md
@@ -17,8 +17,8 @@ served by no ceiling.
| Class | Methods | Meaning |
|---|---|---|
| READ | 68 | served to a read-only session and above |
-| WRITE | 41 | served to a read-write session only |
-| EXCLUDED | 76 | served by no ceiling this phase ships |
+| WRITE | 42 | served to a read-write session only |
+| EXCLUDED | 75 | served by no ceiling this phase ships |
| FORBIDDEN | 34 | never served, whatever the ceiling |
| MCP_METHOD_CLASS_UNSPECIFIED | 0 | unclassified — CI rejects this, and the gate refuses it |
| **total** | **219** | |
@@ -115,7 +115,7 @@ served by no ceiling.
| OrgPolicyService/DeletePolicy | EXCLUDED | ADMINISTERS_THE_WORKSPACE | bb.policies.delete |
| OrgPolicyService/GetPolicy | READ | — | bb.policies.get |
| OrgPolicyService/ListPolicies | READ | — | bb.policies.list |
-| OrgPolicyService/UpdatePolicy | EXCLUDED | ADMINISTERS_THE_WORKSPACE | bb.policies.update |
+| OrgPolicyService/UpdatePolicy | WRITE | — | bb.policies.update |
| PlanService/CancelPlanCheckRun | WRITE | — | bb.planCheckRuns.run |
| PlanService/CreatePlan | WRITE | — | bb.plans.create |
| PlanService/GetPlan | READ | — | bb.plans.get |
diff --git a/backend/generated-go/v1/org_policy_service.pb.go b/backend/generated-go/v1/org_policy_service.pb.go
index 9e7da1dbd5..fd4ab9735e 100644
--- a/backend/generated-go/v1/org_policy_service.pb.go
+++ b/backend/generated-go/v1/org_policy_service.pb.go
@@ -1334,13 +1334,13 @@ const file_v1_org_policy_service_proto_rawDesc = "" +
"\x19RESOURCE_TYPE_UNSPECIFIED\x10\x00\x12\r\n" +
"\tWORKSPACE\x10\x01\x12\x0f\n" +
"\vENVIRONMENT\x10\x02\x12\v\n" +
- "\aPROJECT\x10\x032\x88\n" +
+ "\aPROJECT\x10\x032\x84\n" +
"\n" +
"\x10OrgPolicyService\x12\xda\x01\n" +
"\tGetPolicy\x12\x1d.bytebase.v1.GetPolicyRequest\x1a\x13.bytebase.v1.Policy\"\x98\x01\xdaA\x04name\x8a\xea0\x0fbb.policies.get\x90\xea0\x02\xa0\xea0\x01\x82\xd3\xe4\x93\x02pZ\"\x12 /v1/{name=projects/*/policies/*}Z&\x12$/v1/{name=environments/*/policies/*}\x12\"/v1/{name=workspaces/*/policies/*}\x12\xeb\x01\n" +
"\fListPolicies\x12 .bytebase.v1.ListPoliciesRequest\x1a!.bytebase.v1.ListPoliciesResponse\"\x95\x01\xdaA\x00\x8a\xea0\x10bb.policies.list\x90\xea0\x01\xa0\xea0\x01\x82\xd3\xe4\x93\x02pZ\"\x12 /v1/{parent=projects/*}/policiesZ&\x12$/v1/{parent=environments/*}/policies\x12\"/v1/{parent=workspaces/*}/policies\x12\x8d\x02\n" +
- "\fCreatePolicy\x12 .bytebase.v1.CreatePolicyRequest\x1a\x13.bytebase.v1.Policy\"\xc5\x01\xdaA\rparent,policy\x8a\xea0\x12bb.policies.create\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02\x88\x01:\x06policyZ*:\x06policy\" /v1/{parent=projects/*}/policiesZ.:\x06policy\"$/v1/{parent=environments/*}/policies\"\"/v1/{parent=workspaces/*}/policies\x12\xa7\x02\n" +
- "\fUpdatePolicy\x12 .bytebase.v1.UpdatePolicyRequest\x1a\x13.bytebase.v1.Policy\"\xdf\x01\xdaA\x12policy,update_mask\x8a\xea0\x12bb.policies.update\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02\x9d\x01:\x06policyZ1:\x06policy2'/v1/{policy.name=projects/*/policies/*}Z5:\x06policy2+/v1/{policy.name=environments/*/policies/*}2)/v1/{policy.name=workspaces/*/policies/*}\x12\xee\x01\n" +
+ "\fCreatePolicy\x12 .bytebase.v1.CreatePolicyRequest\x1a\x13.bytebase.v1.Policy\"\xc5\x01\xdaA\rparent,policy\x8a\xea0\x12bb.policies.create\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02\x88\x01:\x06policyZ*:\x06policy\" /v1/{parent=projects/*}/policiesZ.:\x06policy\"$/v1/{parent=environments/*}/policies\"\"/v1/{parent=workspaces/*}/policies\x12\xa3\x02\n" +
+ "\fUpdatePolicy\x12 .bytebase.v1.UpdatePolicyRequest\x1a\x13.bytebase.v1.Policy\"\xdb\x01\xdaA\x12policy,update_mask\x8a\xea0\x12bb.policies.update\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x02\x82\xd3\xe4\x93\x02\x9d\x01:\x06policyZ1:\x06policy2'/v1/{policy.name=projects/*/policies/*}Z5:\x06policy2+/v1/{policy.name=environments/*/policies/*}2)/v1/{policy.name=workspaces/*/policies/*}\x12\xee\x01\n" +
"\fDeletePolicy\x12 .bytebase.v1.DeletePolicyRequest\x1a\x16.google.protobuf.Empty\"\xa3\x01\xdaA\x04name\x8a\xea0\x12bb.policies.delete\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02pZ\"* /v1/{name=projects/*/policies/*}Z&*$/v1/{name=environments/*/policies/*}*\"/v1/{name=workspaces/*/policies/*}B\xab\x01\n" +
"\x0fcom.bytebase.v1B\x15OrgPolicyServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"
diff --git a/backend/tests/mcp_gate_test.go b/backend/tests/mcp_gate_test.go
index 15b1d1410b..859c41bb15 100644
--- a/backend/tests/mcp_gate_test.go
+++ b/backend/tests/mcp_gate_test.go
@@ -605,3 +605,76 @@ func TestMCPDefaultRowIsReadOnly(t *testing.T) {
a.Equal(http.StatusForbidden, sheet.Status,
"the default READ_ONLY policy must refuse a WRITE method: %s", sheet.Error)
}
+
+// TestMCPGrantsAndRevokesAMaskingExemption drives both exemption tools over one
+// live session, and pins that call_api cannot write the policy itself.
+func TestMCPGrantsAndRevokesAMaskingExemption(t *testing.T) {
+ t.Parallel()
+ a := require.New(t)
+ ctx := context.Background()
+ ctl, ctx := startWorkspace(ctx, t)
+
+ project, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{
+ ProjectId: "mcp-exemption",
+ Project: &v1pb.Project{Title: "MCP exemption"},
+ }))
+ a.NoError(err)
+ a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_READ_WRITE))
+ pgContainer := sharedPgTarget(t)
+ instance, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{
+ InstanceId: generateRandomString("inst"),
+ Instance: &v1pb.Instance{
+ SyncDatabases: &v1pb.SyncDatabases{},
+ Title: "MCP exemption instance",
+ Engine: v1pb.Engine_POSTGRES,
+ Environment: new("environments/prod"),
+ Activation: true,
+ DataSources: []*v1pb.DataSource{pgContainer.adminDataSource()},
+ },
+ }))
+ a.NoError(err)
+ dbName := generateRandomString("db")
+ a.NoError(ctl.createDatabase(ctx, project.Msg, instance.Msg, nil, dbName, ""))
+ database := fmt.Sprintf("%s/databases/%s", instance.Msg.Name, dbName)
+ policyName := project.Msg.Name + "/policies/masking_exemption"
+
+ var asked atomic.Int32
+ session := openMCPSessionWithOptions(ctx, t, ctl, ctl.authInterceptor.token, &mcp.ClientOptions{
+ ElicitationHandler: func(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error) {
+ asked.Add(1)
+ return &mcp.ElicitResult{Action: "accept", Content: map[string]any{"confirm": true}}, nil
+ },
+ })
+ defer session.Close()
+
+ direct := callAPIOnSession(ctx, t, session, "OrgPolicyService/UpdatePolicy", map[string]any{
+ "policy": map[string]any{"name": policyName, "type": "MASKING_EXEMPTION", "maskingExemptionPolicy": map[string]any{}},
+ "updateMask": "maskingExemptionPolicy",
+ "allowMissing": true,
+ })
+ a.Equal(http.StatusForbidden, direct.Status, direct.Error)
+ a.Contains(direct.Error, "grant_masking_exemption")
+
+ failed, granted := callToolOnSession(ctx, t, session, "grant_masking_exemption", map[string]any{
+ "project": project.Msg.Name, "member": "user:[email protected]", "database": database,
+ "table": "employee", "column": "salary", "expireTime": "2099-01-01T00:00:00Z",
+ })
+ a.False(failed, granted)
+ policy, err := ctl.orgPolicyServiceClient.GetPolicy(ctx, connect.NewRequest(&v1pb.GetPolicyRequest{Name: policyName}))
+ a.NoError(err)
+ exemptions := policy.Msg.GetMaskingExemptionPolicy().GetExemptions()
+ a.Len(exemptions, 1)
+ a.Equal([]string{"user:[email protected]"}, exemptions[0].Members)
+ condition := exemptions[0].GetCondition().GetExpression()
+ a.Equal(fmt.Sprintf(`request.time < timestamp("2099-01-01T00:00:00.000Z") && (resource.instance_id == %q && resource.database_name == %q && resource.table_name == "employee" && resource.column_name == "salary")`,
+ strings.TrimPrefix(instance.Msg.Name, "instances/"), dbName), condition)
+
+ failed, revoked := callToolOnSession(ctx, t, session, "revoke_masking_exemption", map[string]any{
+ "project": project.Msg.Name, "member": "user:[email protected]", "condition": condition,
+ })
+ a.False(failed, revoked)
+ policy, err = ctl.orgPolicyServiceClient.GetPolicy(ctx, connect.NewRequest(&v1pb.GetPolicyRequest{Name: policyName}))
+ a.NoError(err)
+ a.Empty(policy.Msg.GetMaskingExemptionPolicy().GetExemptions())
+ a.Equal(int32(2), asked.Load(), "the grant and the revoke each ask the user once")
+}
diff --git a/docs/design/mcp-capability-ladder.md b/docs/design/mcp-capability-ladder.md
index 552b0045fe..a23fb6b58a 100644
--- a/docs/design/mcp-capability-ladder.md
+++ b/docs/design/mcp-capability-ladder.md
@@ -6,7 +6,7 @@ The MCP settings page offers three modes (Disabled, Read-only, Read-write) and d
one sentence. Since [#21324](https://github.com/bytebase/bytebase/pull/21324) removed the per-mode
method drawer, nothing on the page says what a mode actually serves, and an admin choosing between
Read-only and Read-write has nothing to compare beyond two sentences. The rule this doc lands on:
-**show capabilities, not methods or permissions — one ordered list of eleven capability rows in
+**show capabilities, not methods or permissions — one ordered list of twelve capability rows in
which each mode is a prefix, collapsed by default inside the existing Access policy section, and
following the picked mode while editing.** The page also gets shorter: the mode cards shrink to an
icon, a label and a three-word caption, with the selected mode's "Best for" under them; the
@@ -59,7 +59,7 @@ What follows from it:
## The rows
-Eleven rows: four read, seven write. Each has a title and a one-line list of sub-items in plain
+Twelve rows: four read, eight write. Each has a title and a one-line list of sub-items in plain
words. The right column records which classified methods the row's wording has to cover; it is
documentation for whoever rereads these rows after a classification change, and never appears in
the product.
@@ -73,17 +73,18 @@ the product.
| — | *Read-only stops here* | | 68 methods |
| write | Propose changes | Create sheets · Create and edit plans and issues · Run plan checks and reviews · Create, delete and restore releases · Create and delete revisions · Generate schema diffs. The project's approval policy decides whether a change needs approval | 22 WRITE methods: sheet, plan, issue, release and revision writes, `RequestIssue`, `RunReview`, `DiffSchema`, `DiffMetadata` |
| write | Request access grants | Ask for a time-boxed grant to run a specific statement, optionally with results unmasked or exported; the statement must be a read as far as the engine can check it · The grant starts only after it is approved, and a request that would need no one's approval is refused · A grant applies only where the project allows access grants · Revoke an active grant · Turn a project's "Allow access grants" on or off, after the user confirms | 3 WRITE methods: `AccessGrantService/CreateAccessGrant` and `RevokeAccessGrant`, served like any WRITE method; and `ProjectService/UpdateProject`, served only through the `set_just_in_time_access` tool, which asks the user to confirm and changes only that setting |
+| write | Grant or revoke masking exemptions | Exempt one member from masking for a database, a schema, a table or a column, or for every database in a project, with an optional expiry · Each exemption and each removal is confirmed in the user's MCP client before it is made · Exempted data shows unmasked in query and export results | 1 WRITE method: `OrgPolicyService/UpdatePolicy`, served only through the `grant_masking_exemption` and `revoke_masking_exemption` tools, which ask the user to confirm, then add one exemption entry or remove one member from the entries whose condition matches exactly; other policy types and `CreatePolicy` and `DeletePolicy` stay refused |
| write | Approve or reject issues | Each decision is confirmed in the user's MCP client before it is made · Role requests are decided in the console · The approval rules and the project's self-approval setting apply, as in the console | 2 WRITE methods: `ApproveIssue`, `RejectIssue`, served only through the `decide_issue` tool, which asks the user to confirm each decision and refuses role requests |
| write | Run rollouts and tasks | Create a rollout · Run, skip or cancel its tasks, under the project's approval policy | 4 WRITE methods: `CreateRollout`, `BatchRunTasks`, `BatchSkipTasks`, `BatchCancelTaskRuns` |
| write | Run DML and DDL statements | INSERT, UPDATE, DELETE, CREATE, ALTER, DROP through queries, as far as the engine and the user's own permissions allow | Not a method: the statement clamp in `mcp_sql_clamp.go`, which Read-write lifts |
| write | Export query results | Download results as a file. Data leaves Bytebase | 1 WRITE method: `SQLService/Export` |
| write | Manage database housekeeping | Sync instances and databases · Saved queries | 9 WRITE methods: sync, saved-query writes |
-| — | *Read-write stops here* | | 109 methods |
-| floor | Never, in any mode: administer the workspace, handle credentials, open an Admin mode session, or read anyone else's query history. | | 110 methods: 34 FORBIDDEN, 76 EXCLUDED |
+| — | *Read-write stops here* | | 110 methods |
+| floor | Never, in any mode: administer the workspace, handle credentials, open an Admin mode session, or read anyone else's query history. | | 109 methods: 34 FORBIDDEN, 75 EXCLUDED |
Every row is displayed under every mode — served, or muted with a `—` — and against every engine a
workspace happens to hold, so **every line on this card must be true on both axes: mode and engine.**
-That covers the eleven rows, and equally the collapsed summary, the card captions and the "Best for"
+That covers the twelve rows, and equally the collapsed summary, the card captions and the "Best for"
lines, which are not rows and were missed the first time the rule was applied. The summary is the
line most admins read and often the only one. A
claim whose truth depends on the mode names the mode as a condition; a claim whose truth depends on
@@ -244,7 +245,8 @@ The verb names the row's effect on the customer's databases. *Read*: none. *Prop
is approved. *Request*: none until it is approved, and then access to one statement's results,
unmasked or exported if asked for. *Approve*: none directly; the issue proceeds: a change rolls out
as the project's rollout policy allows, and an access request takes effect. Role requests stay in
-the console. *Run*: direct. *Export*: data leaves the product. *Manage*:
+the console. *Grant*: direct and standing: an exempted member sees the covered data unmasked in
+query and export results until the exemption ends or is revoked. *Run*: direct. *Export*: data leaves the product. *Manage*:
configuration only, no data path. Within a tier the verb repeats; it changes only where the effect
changes.
@@ -292,7 +294,7 @@ its tier tag, nothing else. "Show details" reveals the sub-item line for every r
there is one second-level control rather than one per row; per-row expanders were rejected as fiddly. No
method names, no permission names, no counts, no link to a method list. The floor is kept as one
short line because it is what a security-minded admin reads first, and it is what keeps the list
-honest about the 110 methods no mode reaches. There is no constants line under the list; the facts
+honest about the 109 methods no mode reaches. There is no constants line under the list; the facts
it would carry (capped by the user's own permissions, refusals audited) move into the section
description.
@@ -433,7 +435,7 @@ under
- Section description: "The most any MCP session may do here. Sessions are also capped by each user's permissions, and policy refusals are streamed to stdout when audit logging to stdout is enabled."
- Disclosure line, collapsed — Read-only: "Read schemas, data, the change workflow, members, roles and policies; a request carrying anything that cannot be shown to be a read is refused, and nothing is exported".
- Read-write: "Read schemas, data, the change workflow, members, roles and policies; propose, request and revoke access, approve, run, export and manage".
+ Read-write: "Read schemas, data, the change workflow, members, roles and policies; propose, request and revoke access, grant masking exemptions, approve, run, export and manage".
Expanded heading: "{mode} allows". Details control: "Show details" / "Hide details".
- Disabled — view sentence: "No MCP session can connect to this workspace." Edit static line:
"Nothing is allowed; no MCP session can connect."
diff --git a/frontend/src/components/mcp/mcpCapabilityRows.ts b/frontend/src/components/mcp/mcpCapabilityRows.ts
index d885baeeaa..98b2d91a89 100644
--- a/frontend/src/components/mcp/mcpCapabilityRows.ts
+++ b/frontend/src/components/mcp/mcpCapabilityRows.ts
@@ -22,6 +22,7 @@ export type MCPCapabilityRowId =
| "read-access"
| "propose"
| "request-access"
+ | "masking-exemptions"
| "approve"
| "run-rollouts"
| "run-statements"
@@ -56,6 +57,7 @@ export const MCP_CAPABILITY_ROWS: readonly MCPCapabilityRow[] = [
{ id: "read-access", tier: "read" },
{ id: "propose", tier: "write" },
{ id: "request-access", tier: "write" },
+ { id: "masking-exemptions", tier: "write" },
{ id: "approve", tier: "write" },
{ id: "run-rollouts", tier: "write" },
{ id: "run-statements", tier: "write" },
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index edccdeac06..18d8803dea 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2857,6 +2857,10 @@
"details": "Sync instances and databases · Saved queries",
"title": "Manage database housekeeping"
},
+ "masking-exemptions": {
+ "details": "Exempt one member from masking for a database, a schema, a table or a column, or for every database in a project, with an optional expiry · Each exemption and each removal is confirmed in the user's MCP client before it is made · Exempted data shows unmasked in query and export results",
+ "title": "Grant or revoke masking exemptions"
+ },
"propose": {
"details": "Create sheets · Create and edit plans and issues · Run plan checks and reviews · Create, delete and restore releases · Create and delete revisions · Generate schema diffs. The project's approval policy decides whether a change needs approval.",
"title": "Propose changes"
@@ -2897,7 +2901,7 @@
},
"summary": {
"read-only": "Read schemas, data, the change workflow, members, roles and policies; a request carrying anything that cannot be shown to be a read is refused, and nothing is exported",
- "read-write": "Read schemas, data, the change workflow, members, roles and policies; propose, request and revoke access, approve, run, export and manage"
+ "read-write": "Read schemas, data, the change workflow, members, roles and policies; propose, request and revoke access, grant masking exemptions, approve, run, export and manage"
},
"tier": {
"read": "read",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 35e061341e..545235b013 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2857,6 +2857,10 @@
"details": "Sincronizar instancias y bases de datos · Consultas guardadas",
"title": "Gestionar el mantenimiento de bases de datos"
},
+ "masking-exemptions": {
+ "details": "Eximir a un miembro del enmascaramiento para una base de datos, un esquema, una tabla o una columna, o para todas las bases de datos de un proyecto, con vencimiento opcional · Cada exención y cada retirada se confirma en el cliente MCP del usuario antes de aplicarse · Los datos exentos se muestran sin enmascarar en los resultados de consultas y exportaciones",
+ "title": "Conceder o revocar exenciones de enmascaramiento"
+ },
"propose": {
"details": "Crear hojas · Crear y editar plans e issues · Ejecutar comprobaciones de plan y revisiones · Crear, eliminar y restaurar versiones · Crear y eliminar revisiones · Generar diferencias de esquema. La política de aprobación del proyecto decide si un cambio necesita aprobación",
"title": "Proponer cambios"
@@ -2897,7 +2901,7 @@
},
"summary": {
"read-only": "Leer esquemas, datos, el flujo de cambios, miembros, roles y políticas; una solicitud que lleve algo que no pueda demostrarse que es una lectura se rechaza, y no se exporta nada",
- "read-write": "Leer esquemas, datos, el flujo de cambios, miembros, roles y políticas; proponer, solicitar y revocar acceso, aprobar, ejecutar, exportar y gestionar"
+ "read-write": "Leer esquemas, datos, el flujo de cambios, miembros, roles y políticas; proponer, solicitar y revocar acceso, conceder exenciones de enmascaramiento, aprobar, ejecutar, exportar y gestionar"
},
"tier": {
"read": "lectura",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 86cbe8589a..e71fed7d12 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2857,6 +2857,10 @@
"details": "インスタンスとデータベースの同期 · 保存済みクエリ",
"title": "データベースの運用設定を管理する"
},
+ "masking-exemptions": {
+ "details": "データベース、スキーマ、テーブル、列、またはプロジェクト内のすべてのデータベースについて、メンバー1人をマスキングから免除します(有効期限は任意) · 各免除とその取り消しは、適用前にユーザーのMCPクライアントで確認されます · 免除されたデータは、クエリとエクスポートの結果でマスクなしで表示されます",
+ "title": "マスキング免除を付与・取り消す"
+ },
"propose": {
"details": "シートの作成 · Plan と Issue の作成・編集 · プランチェックとレビューの実行 · リリースの作成・削除・復元 · リビジョンの作成・削除 · スキーマ差分の生成。変更に承認が必要かどうかはプロジェクトの承認ポリシーが決めます",
"title": "変更を提案する"
@@ -2897,7 +2901,7 @@
},
"summary": {
"read-only": "スキーマ・データ・変更ワークフロー・メンバー・ロール・ポリシーの読み取り。読み取りだと確認できないものを含むリクエストは拒否され、エクスポートもできません",
- "read-write": "スキーマ・データ・変更ワークフロー・メンバー・ロール・ポリシーの読み取り。提案・アクセスのリクエストと取り消し・承認・実行・エクスポート・管理"
+ "read-write": "スキーマ・データ・変更ワークフロー・メンバー・ロール・ポリシーの読み取り。提案・アクセスのリクエストと取り消し・マスキング免除の付与・承認・実行・エクスポート・管理"
},
"tier": {
"read": "読み取り",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 01606fdd22..43e6362be9 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2857,6 +2857,10 @@
"details": "Đồng bộ phiên bản và cơ sở dữ liệu · Truy vấn đã lưu",
"title": "Quản lý vận hành cơ sở dữ liệu"
},
+ "masking-exemptions": {
+ "details": "Miễn che giấu cho một thành viên trên một cơ sở dữ liệu, lược đồ, bảng hoặc cột, hoặc trên mọi cơ sở dữ liệu của dự án, có thể đặt thời hạn · Mỗi miễn trừ và mỗi lần thu hồi được xác nhận trong ứng dụng MCP của người dùng trước khi thực hiện · Dữ liệu được miễn trừ hiển thị không che trong kết quả truy vấn và xuất",
+ "title": "Cấp hoặc thu hồi miễn trừ che giấu"
+ },
"propose": {
"details": "Tạo sheet · Tạo và sửa Plan và Issue · Chạy kiểm tra plan và rà soát · Tạo, xóa và khôi phục bản phát hành · Tạo và xóa bản sửa đổi · Tạo khác biệt lược đồ. Chính sách phê duyệt của dự án quyết định liệu một thay đổi có cần phê duyệt hay không",
"title": "Đề xuất thay đổi"
@@ -2897,7 +2901,7 @@
},
"summary": {
"read-only": "Đọc lược đồ, dữ liệu, quy trình thay đổi, thành viên, vai trò và chính sách; yêu cầu chứa bất kỳ thứ gì không thể chứng minh là đọc đều bị từ chối, và không xuất được gì",
- "read-write": "Đọc lược đồ, dữ liệu, quy trình thay đổi, thành viên, vai trò và chính sách; đề xuất, yêu cầu và thu hồi truy cập, phê duyệt, chạy, xuất và quản lý"
+ "read-write": "Đọc lược đồ, dữ liệu, quy trình thay đổi, thành viên, vai trò và chính sách; đề xuất, yêu cầu và thu hồi truy cập, cấp miễn trừ che giấu, phê duyệt, chạy, xuất và quản lý"
},
"tier": {
"read": "đọc",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index a3a0a59ed2..5335e7109b 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2857,6 +2857,10 @@
"details": "同步实例和数据库 · 已保存的查询",
"title": "管理数据库日常维护"
},
+ "masking-exemptions": {
+ "details": "为一名成员在某个数据库、模式、表或列上,或在项目的所有数据库上豁免脱敏,可设置到期时间 · 每次豁免和每次撤销都会先在用户的 MCP 客户端中确认 · 被豁免的数据在查询和导出结果中以未脱敏形式显示",
+ "title": "授予或撤销脱敏豁免"
+ },
"propose": {
"details": "创建工作表 · 创建和编辑 Plan 与工单 · 执行计划检查和审核 · 创建、删除和恢复发布 · 创建和删除修订 · 生成模式差异。变更是否需要审批由项目的审批策略决定",
"title": "提议变更"
@@ -2897,7 +2901,7 @@
},
"summary": {
"read-only": "读取模式、数据、变更流程、成员、角色和策略;只要请求中含有无法被确认为读取的内容就会被拒绝,也不能导出",
- "read-write": "读取模式、数据、变更流程、成员、角色和策略;提议、申请和撤销访问、批准、执行、导出和管理"
+ "read-write": "读取模式、数据、变更流程、成员、角色和策略;提议、申请和撤销访问、授予脱敏豁免、批准、执行、导出和管理"
},
"tier": {
"read": "读取",
diff --git a/frontend/src/types/proto-es/v1/org_policy_service_pb.js b/frontend/src/types/proto-es/v1/org_policy_service_pb.js
index 578786e07f..c909b65b13 100644
--- a/frontend/src/types/proto-es/v1/org_policy_service_pb.js
+++ b/frontend/src/types/proto-es/v1/org_policy_service_pb.js
@@ -16,7 +16,7 @@ import { file_v1_review_rule } from "./review_rule_pb";
* Describes the file v1/org_policy_service.proto.
*/
export const file_v1_org_policy_service = /*@__PURE__*/
- fileDesc("Cht2MS9vcmdfcG9saWN5X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIpMBChNDcmVhdGVQb2xpY3lSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EigKBnBvbGljeRgCIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEiUKBHR5cGUYAyABKA4yFy5ieXRlYmFzZS52MS5Qb2xpY3lUeXBlIocBChNVcGRhdGVQb2xpY3lSZXF1ZXN0EigKBnBvbGljeRgBIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCg1hbGxvd19taXNzaW5nGAMgASgIIkAKE0RlbGV0ZVBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5Ij0KEEdldFBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5IpsBChNMaXN0UG9saWNpZXNSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EjEKC3BvbGljeV90eXBlGAIgASgOMhcuYnl0ZWJhc2UudjEuUG9saWN5VHlwZUgAiAEBEhQKDHNob3dfZGVsZXRlZBgDIAEoCEIOCgxfcG9saWN5X3R5cGUiPQoUTGlzdFBvbGljaWVzUmVzcG9uc2USJQoIcG9saWNpZXMYASADKAsyEy5ieXRlYmFzZS52MS5Qb2xpY3ki7wUK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Y2llcyIiL3YxL3twYXJlbnQ9d29ya3NwYWNlcy8qfS9wb2xpY2llcxKnAgoMVXBkYXRlUG9saWN5EiAuYnl0ZWJhc2UudjEuVXBkYXRlUG9saWN5UmVxdWVzdBoTLmJ5dGViYXNlLnYxLlBvbGljeSLfAdpBEnBvbGljeSx1cGRhdGVfbWFza4rqMBJiYi5wb2xpY2llcy51cGRhdGWQ6jACmOowAaDqMASo6jAJgtPkkwKdAToGcG9saWN5WjE6BnBvbGljeTInL3YxL3twb2xpY3kubmFtZT1wcm9qZWN0cy8qL3BvbGljaWVzLyp9WjU6BnBvbGljeTIrL3YxL3twb2xpY3kubmFtZT1lbnZpcm9ubWVudHMvKi9wb2xpY2llcy8qfTIpL3YxL3twb2xpY3kubmFtZT13b3Jrc3BhY2VzLyovcG9saWNpZXMvKn0S7gEKDERlbGV0ZVBvbGljeRIgLmJ5dGViYXNlLnYxLkRlbGV0ZVBvbGljeVJlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkiowHaQQRuYW1liuowEmJiLnBvbGljaWVzLmRlbGV0ZZDqMAKY6jABoOowBKjqMAmC0+STAnBaIiogL3YxL3tuYW1lPXByb2plY3RzLyovcG9saWNpZXMvKn1aJiokL3YxL3tuYW1lPWVudmlyb25tZW50cy8qL3BvbGljaWVzLyp9KiIvdjEve25hbWU9d29ya3NwYWNlcy8qL3BvbGljaWVzLyp9QqsBCg9jb20uYnl0ZWJhc2UudjFCFU9yZ1BvbGljeVNlcnZpY2VQcm90b1ABWjRnaXRodWIuY29tL2J5dGViYXNlL2J5dGViYXNlL2JhY2tlbmQvZ2VuZXJhdGVkLWdvL3YxogIDQlhYqgILQnl0ZWJhc2UuVjHKAgtCeXRlYmFzZVxWMeICF0J5dGViYXNlXFYxXEdQQk1ldGFkYXRh6gIMQnl0ZWJhc2U6OlYxYgZwcm90bzM", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_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XNlLnYxLlBvbGljeSLbAdpBEnBvbGljeSx1cGRhdGVfbWFza4rqMBJiYi5wb2xpY2llcy51cGRhdGWQ6jACmOowAaDqMAKC0+STAp0BOgZwb2xpY3laMToGcG9saWN5MicvdjEve3BvbGljeS5uYW1lPXByb2plY3RzLyovcG9saWNpZXMvKn1aNToGcG9saWN5MisvdjEve3BvbGljeS5uYW1lPWVudmlyb25tZW50cy8qL3BvbGljaWVzLyp9MikvdjEve3BvbGljeS5uYW1lPXdvcmtzcGFjZXMvKi9wb2xpY2llcy8qfRLuAQoMRGVsZXRlUG9saWN5EiAuYnl0ZWJhc2UudjEuRGVsZXRlUG9saWN5UmVxdWVzdBoWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eSKjAdpBBG5hbWWK6jASYmIucG9saWNpZXMuZGVsZXRlkOowApjqMAGg6jAEqOowCYLT5JMCcFoiKiAvdjEve25hbWU9cHJvamVjdHMvKi9wb2xpY2llcy8qfVomKiQvdjEve25hbWU9ZW52aXJvbm1lbnRzLyovcG9saWNpZXMvKn0qIi92MS97bmFtZT13b3Jrc3BhY2VzLyovcG9saWNpZXMvKn1CqwEKD2NvbS5ieXRlYmFzZS52MUIVT3JnUG9saWN5U2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation, file_v1_review_rule]);
/**
* Describes the message bytebase.v1.CreatePolicyRequest.
diff --git a/proto/v1/v1/org_policy_service.proto b/proto/v1/v1/org_policy_service.proto
index 85162a89e0..8db367cc2a 100644
--- a/proto/v1/v1/org_policy_service.proto
+++ b/proto/v1/v1/org_policy_service.proto
@@ -90,8 +90,10 @@ service OrgPolicyService {
option (bytebase.v1.permission) = "bb.policies.update";
option (bytebase.v1.auth_method) = CUSTOM;
option (bytebase.v1.audit) = true;
- option (bytebase.v1.mcp_method_class) = EXCLUDED;
- option (bytebase.v1.mcp_denial_reason) = ADMINISTERS_THE_WORKSPACE;
+ // An MCP session reaches it only through the grant_masking_exemption and
+ // revoke_masking_exemption tools, after the user confirms the change in the
+ // MCP client.
+ option (bytebase.v1.mcp_method_class) = WRITE;
}
// Deletes an organizational policy.