Skip to content

Commit 46f7c1e

Browse files
authored
[Feature] Sensitive information protection (#1092)
1 parent de360d9 commit 46f7c1e

File tree

7 files changed

+87
-6
lines changed

7 files changed

+87
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- (Feature) Immutable spec
2121
- (Bugfix) Proper agent cleanout
2222
- (Bugfix) Fix ClusterScaling integration
23+
- (Feature) Sensitive information protection
2324

2425
## [1.2.15](https://github.com/arangodb/kube-arangodb/tree/1.2.15) (2022-07-20)
2526
- (Bugfix) Ensure pod names not too long

pkg/deployment/agency/definitions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const (
3737
TargetHotBackupKey = "HotBackup"
3838

3939
PlanCollectionsKey = "Collections"
40+
PlanDatabasesKey = "Databases"
4041

4142
SupervisionKey = "Supervision"
4243
SupervisionMaintenanceKey = "Maintenance"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package agency
22+
23+
type PlanDatabases map[string]PlanDatabase
24+
25+
type PlanDatabase struct {
26+
ID string `json:"id"`
27+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package agency
22+
23+
import (
24+
"encoding/json"
25+
"testing"
26+
27+
"github.com/stretchr/testify/require"
28+
)
29+
30+
func Test_Databases(t *testing.T) {
31+
var s DumpState
32+
require.NoError(t, json.Unmarshal(agencyDump39HotBackup, &s))
33+
34+
require.Contains(t, s.Agency.Arango.Plan.Databases, "_system")
35+
}

pkg/deployment/agency/state.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (c *cache) loadState(ctx context.Context, client agency.Agency) (State, err
4444
readKeys := []string{
4545
GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey),
4646
GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey),
47+
GetAgencyKey(ArangoKey, PlanKey, PlanDatabasesKey),
4748
GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey),
4849
GetAgencyKey(ArangoKey, CurrentKey, CurrentMaintenanceServers),
4950
GetAgencyKey(ArangoKey, TargetKey, TargetHotBackupKey),
@@ -107,6 +108,7 @@ type StateCurrent struct {
107108

108109
type StatePlan struct {
109110
Collections StatePlanCollections `json:"Collections"`
111+
Databases PlanDatabases `json:"Databases,omitempty"`
110112
}
111113

112114
type StateSupervision struct {

pkg/deployment/features/security.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package features
2222

2323
func init() {
2424
registerFeature(ephemeralVolumes)
25+
registerFeature(sensitiveInformationProtection)
2526
}
2627

2728
var ephemeralVolumes = &feature{

pkg/deployment/old_metrics.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/prometheus/client_golang/prometheus"
2727

2828
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
29+
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
2930
"github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions"
3031
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
3132
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
@@ -111,21 +112,34 @@ func (i *inventory) Collect(m chan<- prometheus.Metric) {
111112

112113
if spec.Mode.Get() == api.DeploymentModeCluster {
113114
for db, collections := range agency.Current.Collections {
115+
dbName := db
116+
if features.SensitiveInformationProtection().Enabled() {
117+
dbName = "UNKNOWN"
118+
119+
if v, ok := agency.Plan.Databases[db]; ok && v.ID != "" {
120+
dbName = v.ID
121+
}
122+
}
123+
114124
for collection, shards := range collections {
115125
for shard, details := range shards {
116126
for id, server := range details.Servers {
117-
name := "UNKNOWN"
118-
if _, ok := agency.Plan.Collections[db]; ok {
119-
if _, ok := agency.Plan.Collections[db][collection]; ok {
120-
name = agency.Plan.Collections[db][collection].GetName(name)
127+
collectionName := "UNKNOWN"
128+
if features.SensitiveInformationProtection().Enabled() {
129+
collectionName = collection
130+
} else {
131+
if _, ok := agency.Plan.Collections[db]; ok {
132+
if _, ok := agency.Plan.Collections[db][collection]; ok {
133+
collectionName = agency.Plan.Collections[db][collection].GetName(collectionName)
134+
}
121135
}
122136
}
123137

124138
m := []string{
125139
deployment.GetNamespace(),
126140
deployment.GetName(),
127-
db,
128-
name,
141+
dbName,
142+
collectionName,
129143
shard,
130144
string(server),
131145
}

0 commit comments

Comments
 (0)