-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
728 additions
and
725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
package app | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
|
||
"github.com/jedib0t/go-pretty/table" | ||
"github.com/spf13/cobra" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// List checks of config file | ||
func List(cmd *cobra.Command, args []string) { | ||
|
||
configFile, _ := cmd.Flags().GetString("config-file") | ||
severity, _ := cmd.Flags().GetString("severity") | ||
|
||
file, err := os.Open(configFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
defer file.Close() | ||
data, err := ioutil.ReadAll(file) | ||
y := Config{} | ||
|
||
err = yaml.Unmarshal([]byte(data), &y) | ||
if err != nil { | ||
log.Fatalf("error: %v", err) | ||
} | ||
cpt := 0 | ||
t := table.NewWriter() | ||
t.SetOutputMirror(os.Stdout) | ||
t.AppendHeader(table.Row{"URL", "Plugin Name", "Severity", "Description"}) | ||
for index, plugin := range y.Plugins { | ||
_ = index | ||
for index, check := range plugin.Checks { | ||
_ = index | ||
// If the user wants a specific severity, collect only specified severity checks | ||
if severity != "" { | ||
if severity == string(*check.Severity) { | ||
t.AppendRow([]interface{}{plugin.URI, check.PluginName, *check.Severity, *check.Description}) | ||
cpt++ | ||
} | ||
} else { | ||
t.AppendRow([]interface{}{plugin.URI, check.PluginName, *check.Severity, *check.Description}) | ||
cpt++ | ||
} | ||
} | ||
} | ||
t.AppendFooter(table.Row{"", "", "Total Checks", cpt}) | ||
t.Render() | ||
} | ||
package app | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
|
||
"github.com/jedib0t/go-pretty/table" | ||
"github.com/spf13/cobra" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// List checks of config file | ||
func List(cmd *cobra.Command, args []string) { | ||
|
||
configFile, _ := cmd.Flags().GetString("config-file") | ||
severity, _ := cmd.Flags().GetString("severity") | ||
|
||
file, err := os.Open(configFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
defer file.Close() | ||
data, err := ioutil.ReadAll(file) | ||
y := Config{} | ||
|
||
err = yaml.Unmarshal([]byte(data), &y) | ||
if err != nil { | ||
log.Fatalf("error: %v", err) | ||
} | ||
cpt := 0 | ||
t := table.NewWriter() | ||
t.SetOutputMirror(os.Stdout) | ||
t.AppendHeader(table.Row{"URL", "Plugin Name", "Severity", "Description"}) | ||
for index, plugin := range y.Plugins { | ||
_ = index | ||
for index, check := range plugin.Checks { | ||
_ = index | ||
// If the user wants a specific severity, collect only specified severity checks | ||
if severity != "" { | ||
if severity == string(*check.Severity) { | ||
t.AppendRow([]interface{}{plugin.URI, check.PluginName, *check.Severity, *check.Description}) | ||
cpt++ | ||
} | ||
} else { | ||
t.AppendRow([]interface{}{plugin.URI, check.PluginName, *check.Severity, *check.Description}) | ||
cpt++ | ||
} | ||
} | ||
} | ||
t.AppendFooter(table.Row{"", "", "Total Checks", cpt}) | ||
t.Render() | ||
} |
Oops, something went wrong.