1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-23 22:15:04 +02:00

address review comments

This commit is contained in:
Grant Murphy
2017-12-14 10:04:22 +10:00
parent af25ac1f6e
commit 25d74c6b20
4 changed files with 41 additions and 5 deletions

View File

@@ -8,6 +8,12 @@ import (
"io/ioutil"
)
const (
// Globals are applicable to all rules and used for general
// configuration settings for gas.
Globals = "global"
)
// Config is used to provide configuration and customization to each of the rules.
type Config map[string]interface{}
@@ -16,7 +22,7 @@ type Config map[string]interface{}
// or from a *os.File.
func NewConfig() Config {
cfg := make(Config)
cfg["global"] = make(map[string]string)
cfg[Globals] = make(map[string]string)
return cfg
}
@@ -60,7 +66,7 @@ func (c Config) Set(section string, value interface{}) {
// GetGlobal returns value associated with global configuration option
func (c Config) GetGlobal(option string) (string, error) {
if globals, ok := c["global"]; ok {
if globals, ok := c[Globals]; ok {
if settings, ok := globals.(map[string]string); ok {
if value, ok := settings[option]; ok {
return value, nil
@@ -74,7 +80,7 @@ func (c Config) GetGlobal(option string) (string, error) {
// SetGlobal associates a value with a global configuration ooption
func (c Config) SetGlobal(option, value string) {
if globals, ok := c["global"]; ok {
if globals, ok := c[Globals]; ok {
if settings, ok := globals.(map[string]string); ok {
settings[option] = value
}