osctrl
osctrl copied to clipboard
osctrl-admin SIGSEGV when `_SERVICE` is undefined
I know _SERVICE_NAME
should be admin
. However, when if this value is not set the osctrl-admin component
SIGSEGV. An output should be generated that config is invalid.
service.json:
{
"_SERVICE_NAME": {
"listener": "0.0.0.0",
"port": "9001",
"host": "0.0.0.0",
"auth": "db",
"logger": "stdout"
}
}
error output:
osctrl@ubuntuvm:/home/superadmin$ /usr/local/bin/osctrl-admin \ --config \
--config-file /etc/osctrl/osctrl-admin/service.json \
--redis \
--redis-file /etc/osctrl/redis.json \
--db \
--db-file /etc/osctrl/db.json \
--jwt \
--jwt-file /etc/osctrl/osctrl-admin/jwt.json \
--carved /var/osctrl/carves \
--templates /usr/share/osctrl/tmpl_admin \
--static /usr/share/osctrl/static \
--osquery-tables /etc/osctrl/osctrl-admin/osquery-5.2.2.json
main.go:176: Loading /etc/osctrl/osctrl-admin/service.json
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x160 pc=0x89aab8]
goroutine 1 [running]:
github.com/spf13/viper.(*Viper).AllKeys(0x0)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/viper.go:1960 +0x98
github.com/spf13/viper.(*Viper).AllSettings(0x0)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/viper.go:2041 +0x48
github.com/spf13/viper.(*Viper).Unmarshal(0xc00024e000?, {0xb531e0, 0xc00012c9c0}, {0x0, 0x0, 0x0})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/viper.go:1043 +0x32
main.loadConfiguration({0x7ffc7fc4d6ae, 0x25}, {0xc66c00, 0x5})
/home/runner/work/osctrl/osctrl/admin/main.go:184 +0x145
main.cliAction(0xc000170b00?)
/home/runner/work/osctrl/osctrl/admin/main.go:772 +0x74
github.com/urfave/cli/v2.(*App).RunContext(0xc00024e340, {0xd91fa8?, 0xc00011c000}, {0xc000114160, 0x15, 0x16})
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:322 +0x953
github.com/urfave/cli/v2.(*App).Run(...)
/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:224
main.main()
/home/runner/work/osctrl/osctrl/admin/main.go:832 +0x23e