Files
my-rook-config/pkg/daemon/ceph/osd/agent_test.go
T
Travis Nielsen 998b3f29ea ceph: reduce the file permissions to fix gosec errors
File permissions need to be reduced to the minimum to avoid config
files from being accessed. While a connection to the pod would be
required to access the files, min privileges are set just as
another layer of security. This fixes gosec error G306.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-28 15:46:24 -06:00

40 lines
1.1 KiB
Go

/*
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package osd
import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func createTestKeyring(t *testing.T, configRoot string, args []string) {
var configDir string
if len(args) > 5 && strings.HasPrefix(args[5], "--id") {
configDir = filepath.Join(configRoot, "osd") + args[5][5:]
err := os.MkdirAll(configDir, 0700)
assert.Nil(t, err)
err = ioutil.WriteFile(path.Join(configDir, "keyring"), []byte("mykeyring"), 0600)
assert.Nil(t, err)
}
}