Skip to content

Commit

Permalink
add log-json option (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadayuki-matsuno authored and kotakanbe committed Apr 26, 2018
1 parent 340cef7 commit a7b63a4
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 13 deletions.
24 changes: 24 additions & 0 deletions README.md
Expand Up @@ -83,6 +83,7 @@ fetch-redhat:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-redhat 5 6 7
Expand All @@ -103,6 +104,8 @@ For the first time, run the blow command to fetch data for all versions.
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
```
- Import OVAL data from Internet
Expand All @@ -126,6 +129,7 @@ fetch-debian:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-debian 7 8 9 10
Expand All @@ -144,6 +148,8 @@ For the first time, run the blow command to fetch data for all versions.
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
```
- Import OVAL data from Internet
Expand All @@ -167,6 +173,7 @@ fetch-ubuntu:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-ubuntu 12 14 16
Expand All @@ -185,6 +192,8 @@ For the first time, run the blow command to fetch data for all versions.
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
```
- Import OVAL data from Internet
Expand Down Expand Up @@ -213,6 +222,7 @@ fetch-suse:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-suse -opensuse 13.2
Expand All @@ -231,6 +241,8 @@ For the first time, run the blow command to fetch data for all versions.
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
-opensuse
OpenSUSE
-opensuse-leap
Expand Down Expand Up @@ -265,6 +277,7 @@ fetch-oracle:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-oracle
Expand All @@ -283,6 +296,8 @@ For the first time, run the blow command to fetch data for all versions.
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
```
- Import OVAL data from Internet
Expand All @@ -307,6 +322,7 @@ fetch-alpine:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

The version list is here https://git.alpinelinux.org/cgit/alpine-secdb/tree/
$ goval-dictionary fetch-alpine 3.3 3.4 3.5 3.6
Expand All @@ -323,6 +339,8 @@ The version list is here https://git.alpinelinux.org/cgit/alpine-secdb/tree/
http://proxy-url:port (default: empty)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
-quiet
quiet mode (no output)
```
Expand All @@ -349,6 +367,7 @@ fetch-amazon:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

$ goval-dictionary fetch-amazon

Expand All @@ -364,6 +383,8 @@ fetch-amazon:
http://proxy-url:port (default: empty)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
-quiet
quiet mode (no output)
```
Expand Down Expand Up @@ -815,6 +836,7 @@ server:
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]

-bind string
HTTP server bind to IP address (default: loop back interface) (default "127.0.0.1")
Expand All @@ -830,6 +852,8 @@ server:
quiet mode (no output)
-log-dir string
/path/to/log (default "/var/log/vuls")
-log-json
output log as JSON
-port string
HTTP server port number (default: 1324)

Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-alpine.go
Expand Up @@ -25,6 +25,7 @@ type FetchAlpineCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -47,6 +48,7 @@ func (*FetchAlpineCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
The version list is here https://git.alpinelinux.org/cgit/alpine-secdb/tree/
$ goval-dictionary fetch-alpine 3.3 3.4 3.5 3.6
Expand All @@ -62,6 +64,7 @@ func (p *FetchAlpineCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -87,7 +90,7 @@ func (p *FetchAlpineCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-amazon.go
Expand Up @@ -24,6 +24,7 @@ type FetchAmazonCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -46,6 +47,7 @@ func (*FetchAmazonCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
$ goval-dictionary fetch-amazon
`
Expand All @@ -59,6 +61,7 @@ func (p *FetchAmazonCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -84,7 +87,7 @@ func (p *FetchAmazonCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-debian.go
Expand Up @@ -25,6 +25,7 @@ type FetchDebianCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -47,6 +48,7 @@ func (*FetchDebianCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
For details, see https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-debian
$ goval-dictionary fetch-debian 7 8 9 10
Expand All @@ -62,6 +64,7 @@ func (p *FetchDebianCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -87,7 +90,7 @@ func (p *FetchDebianCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-oracle.go
Expand Up @@ -24,6 +24,7 @@ type FetchOracleCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -46,6 +47,7 @@ func (*FetchOracleCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
For details, see https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-oracle
$ goval-dictionary fetch-oracle
Expand All @@ -61,6 +63,7 @@ func (p *FetchOracleCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as json")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -86,7 +89,7 @@ func (p *FetchOracleCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-redhat.go
Expand Up @@ -25,6 +25,7 @@ type FetchRedHatCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -47,6 +48,7 @@ func (*FetchRedHatCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
For details, see https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-redhat
Expand All @@ -65,6 +67,7 @@ func (p *FetchRedHatCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -90,7 +93,7 @@ func (p *FetchRedHatCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-suse.go
Expand Up @@ -30,6 +30,7 @@ type FetchSUSECmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand Down Expand Up @@ -58,6 +59,7 @@ func (*FetchSUSECmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
For details, see https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-suse
$ goval-dictionary fetch-suse -opensuse 13.2
Expand All @@ -80,6 +82,7 @@ func (p *FetchSUSECmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -102,7 +105,7 @@ func (p *FetchSUSECmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfac
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/fetch-ubuntu.go
Expand Up @@ -24,6 +24,7 @@ type FetchUbuntuCmd struct {
DebugSQL bool
Quiet bool
LogDir string
LogJSON bool
DBPath string
DBType string
HTTPProxy string
Expand All @@ -46,6 +47,7 @@ func (*FetchUbuntuCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
For the first time, run the blow command to fetch data for all versions.
$ goval-dictionary fetch-ubuntu 12 14 16
Expand All @@ -61,6 +63,7 @@ func (p *FetchUbuntuCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -86,7 +89,7 @@ func (p *FetchUbuntuCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interf
c.Conf.DBType = p.DBType
c.Conf.HTTPProxy = p.HTTPProxy

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if !c.Conf.Validate() {
return subcommands.ExitUsageError
}
Expand Down
5 changes: 4 additions & 1 deletion commands/select.go
Expand Up @@ -22,6 +22,7 @@ type SelectCmd struct {
DBType string
Quiet bool
LogDir string
LogJSON bool

ByPackage bool
ByCveID bool
Expand All @@ -42,6 +43,7 @@ func (*SelectCmd) Usage() string {
[-debug-sql]
[-quiet]
[-log-dir=/path/to/log]
[-log-json]
[-by-package] redhat 7 bind
[-by-cveid] redhat 7 CVE-2017-6009
Expand All @@ -56,6 +58,7 @@ func (p *SelectCmd) SetFlags(f *flag.FlagSet) {

defaultLogDir := util.GetDefaultLogDir()
f.StringVar(&p.LogDir, "log-dir", defaultLogDir, "/path/to/log")
f.BoolVar(&p.LogJSON, "log-json", false, "output log as JSON")

pwd := os.Getenv("PWD")
f.StringVar(&p.DBPath, "dbpath", pwd+"/oval.sqlite3",
Expand All @@ -74,7 +77,7 @@ func (p *SelectCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
c.Conf.DBPath = p.DBPath
c.Conf.DBType = p.DBType

util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug)
util.SetLogger(p.LogDir, c.Conf.Quiet, c.Conf.Debug, p.LogJSON)
if f.NArg() != 3 {
log15.Crit(`
Usage:
Expand Down

0 comments on commit a7b63a4

Please sign in to comment.