diff --git a/go.mod b/go.mod index 7cc33d88b91..f384e970590 100644 --- a/go.mod +++ b/go.mod @@ -132,7 +132,6 @@ require ( github.com/liamg/iamgo v0.0.9 github.com/liamg/memoryfs v1.6.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/olekukonko/tablewriter v0.0.5 github.com/owenrumney/squealer v1.2.2 github.com/zclconf/go-cty v1.14.1 github.com/zclconf/go-cty-yaml v1.0.3 diff --git a/go.sum b/go.sum index d1b2fc815df..5af42e617a5 100644 --- a/go.sum +++ b/go.sum @@ -1283,7 +1283,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= @@ -1375,8 +1374,6 @@ github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/pkg/iac/scanners/terraform/executor/statistics.go b/pkg/iac/scanners/terraform/executor/statistics.go deleted file mode 100644 index fc42985747a..00000000000 --- a/pkg/iac/scanners/terraform/executor/statistics.go +++ /dev/null @@ -1,92 +0,0 @@ -package executor - -import ( - "encoding/json" - "fmt" - "io" - "sort" - "strconv" - "strings" - - "github.com/olekukonko/tablewriter" - - "github.com/aquasecurity/trivy/pkg/iac/scan" -) - -type StatisticsItem struct { - RuleID string `json:"rule_id"` - RuleDescription string `json:"rule_description"` - Links []string `json:"links"` - Count int `json:"count"` -} - -type Statistics []StatisticsItem - -type StatisticsResult struct { - Result Statistics `json:"results"` -} - -func SortStatistics(statistics Statistics) Statistics { - sort.Slice(statistics, func(i, j int) bool { - return statistics[i].Count > statistics[j].Count - }) - return statistics -} - -func (statistics Statistics) PrintStatisticsTable(format string, w io.Writer) error { - // lovely is the default so we keep it like that - if format != "lovely" && format != "markdown" && format != "json" { - return fmt.Errorf("you must specify only lovely, markdown or json format with --run-statistics") - } - - sorted := SortStatistics(statistics) - - if format == "json" { - result := StatisticsResult{Result: sorted} - val, err := json.MarshalIndent(result, "", " ") - if err != nil { - return err - } - - _, _ = fmt.Fprintln(w, string(val)) - - return nil - } - - table := tablewriter.NewWriter(w) - table.SetHeader([]string{"Rule ID", "Description", "Link", "Count"}) - table.SetRowLine(true) - - if format == "markdown" { - table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) - table.SetCenterSeparator("|") - } - - for _, item := range sorted { - table.Append([]string{item.RuleID, - item.RuleDescription, - strings.Join(item.Links, "\n"), - strconv.Itoa(item.Count)}) - } - - table.Render() - - return nil -} - -func AddStatisticsCount(statistics Statistics, result scan.Result) Statistics { - for i, statistic := range statistics { - if statistic.RuleID == result.Rule().LongID() { - statistics[i].Count += 1 - return statistics - } - } - statistics = append(statistics, StatisticsItem{ - RuleID: result.Rule().LongID(), - RuleDescription: result.Rule().Summary, - Links: result.Rule().Links, - Count: 1, - }) - - return statistics -}