Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: fix SHOW ALL ZONE CONFIGURATION displaying unprivileged entries
* Made `crdb_internal.zones` not display entries which the executing user does not have access to. * Add a delegate for ShowZoneConfig, which triggers on SHOW ALL ZONE CONFIGURATIONS, to use crdb_internal.zones table and run it as the executing user so rows are hidden if the user does not have permission. Release note (bug fix): Previously, SHOW ALL ZONE CONFIGURATION ZONES and crdb_internal.zones shows results for resources the user does not have access to. This will instead filter out those entries from displaying.
- Loading branch information
Showing
5 changed files
with
127 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package delegate | ||
|
||
import "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" | ||
|
||
// ShowZoneConfig only delegates if it selecting ALL configurations. | ||
func (d *delegator) delegateShowZoneConfig(n *tree.ShowZoneConfig) (tree.Statement, error) { | ||
// Specifying a specific zone; fallback to non-delegation logic. | ||
if n.ZoneSpecifier != (tree.ZoneSpecifier{}) { | ||
return nil, nil | ||
} | ||
return parse(`SELECT target, raw_config_sql FROM crdb_internal.zones`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters