Fix noinlineerr findings: internal/config (refs #61)
This commit is contained in:
@@ -174,7 +174,8 @@ func Load(path string) (*Config, error) {
|
|||||||
return nil, fmt.Errorf("failed to marshal config data: %w", err)
|
return nil, fmt.Errorf("failed to marshal config data: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := yaml.Unmarshal(yamlBytes, cfg); err != nil {
|
err = yaml.Unmarshal(yamlBytes, cfg)
|
||||||
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse config: %w", err)
|
return nil, fmt.Errorf("failed to parse config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +222,8 @@ func Load(path string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check config file permissions (warn if world or group readable)
|
// Check config file permissions (warn if world or group readable)
|
||||||
if info, err := os.Stat(path); err == nil {
|
info, err := os.Stat(path)
|
||||||
|
if err == nil {
|
||||||
mode := info.Mode().Perm()
|
mode := info.Mode().Perm()
|
||||||
if mode&0044 != 0 { // group or world readable
|
if mode&0044 != 0 { // group or world readable
|
||||||
log.Warn("Config file has insecure permissions (contains S3 credentials)",
|
log.Warn("Config file has insecure permissions (contains S3 credentials)",
|
||||||
@@ -231,7 +233,8 @@ func Load(path string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cfg.Validate(); err != nil {
|
err = cfg.Validate()
|
||||||
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid config: %w", err)
|
return nil, fmt.Errorf("invalid config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ const (
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
testConfigPath := filepath.Join("..", "..", "test", "config.yaml")
|
testConfigPath := filepath.Join("..", "..", "test", "config.yaml")
|
||||||
if absPath, err := filepath.Abs(testConfigPath); err == nil {
|
|
||||||
|
absPath, err := filepath.Abs(testConfigPath)
|
||||||
|
if err == nil {
|
||||||
_ = os.Setenv("VAULTIK_CONFIG", absPath)
|
_ = os.Setenv("VAULTIK_CONFIG", absPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ type Size int64
|
|||||||
func (s *Size) UnmarshalYAML(unmarshal func(any) error) error {
|
func (s *Size) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
// Try to unmarshal as int64 first
|
// Try to unmarshal as int64 first
|
||||||
var intVal int64
|
var intVal int64
|
||||||
if err := unmarshal(&intVal); err == nil {
|
|
||||||
|
err := unmarshal(&intVal)
|
||||||
|
if err == nil {
|
||||||
*s = Size(intVal)
|
*s = Size(intVal)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -26,7 +28,9 @@ func (s *Size) UnmarshalYAML(unmarshal func(any) error) error {
|
|||||||
|
|
||||||
// Try to unmarshal as string
|
// Try to unmarshal as string
|
||||||
var strVal string
|
var strVal string
|
||||||
if err := unmarshal(&strVal); err != nil {
|
|
||||||
|
err = unmarshal(&strVal)
|
||||||
|
if err != nil {
|
||||||
return errors.New("size must be a number or string")
|
return errors.New("size must be a number or string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user