Skip to content

Commit

Permalink
added ability in risk sheet to hide columns and group by columns
Browse files Browse the repository at this point in the history
  • Loading branch information
joreiche committed Mar 23, 2024
1 parent b29a8fb commit 0bf87c1
Show file tree
Hide file tree
Showing 13 changed files with 955 additions and 689 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RM = rm -rf
GOSEC = /opt/homebrew/bin/gosec

# Targets
.phony: all prep run_tests clean tidy install uninstall gosec
.phony: all prep run_tests clean tidy install uninstall gosec gv

default: all

Expand Down Expand Up @@ -60,6 +60,11 @@ uninstall:
gosec:
$(GOSEC) ./...

gv: out/tmp/diagram.png

out/tmp/diagram.png: out/tmp/diagram.gv
dot -Tpng $< -o $@

bin/raa_calc: cmd/raa/main.go
$(GO) build $(GOFLAGS) -o $@ $<

Expand Down
4 changes: 2 additions & 2 deletions internal/threagile/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Aliases:
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasHelpSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Title "help"))}}
{{rpad .Title .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}
Expand Down
10 changes: 10 additions & 0 deletions pkg/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Config struct {
RiskRulesPlugins []string
SkipRiskRules string
ExecuteModelMacro string
HideColumns []string
GroupByColumns []string

ServerMode bool
DiagramDPI int
Expand Down Expand Up @@ -81,6 +83,8 @@ func (c *Config) Defaults(buildTimestamp string) *Config {
TemplateFilename: TemplateFilename,
RAAPlugin: RAAPluginName,
RiskRulesPlugins: make([]string, 0),
HideColumns: make([]string, 0),
GroupByColumns: make([]string, 0),
SkipRiskRules: "",
ExecuteModelMacro: "",
ServerMode: false,
Expand Down Expand Up @@ -259,6 +263,12 @@ func (c *Config) Merge(config Config, values map[string]any) {
case strings.ToLower("RiskRulesPlugins"):
c.RiskRulesPlugins = config.RiskRulesPlugins

case strings.ToLower("HideColumns"):
c.HideColumns = append(c.HideColumns, config.HideColumns...)

case strings.ToLower("GroupByColumns"):
c.GroupByColumns = append(c.GroupByColumns, config.GroupByColumns...)

case strings.ToLower("SkipRiskRules"):
c.SkipRiskRules = config.SkipRiskRules

Expand Down
65 changes: 65 additions & 0 deletions pkg/report/excel-column.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package report

import (
"github.com/xuri/excelize/v2"
"strings"
)

type ExcelColumns map[string]ExcelColumn

func (what *ExcelColumns) GetColumns() ExcelColumns {
*what = map[string]ExcelColumn{
"A": {Title: "Severity", Width: 12},
"B": {Title: "Likelihood", Width: 15},
"C": {Title: "Impact", Width: 15},
"D": {Title: "STRIDE", Width: 22},
"E": {Title: "Function", Width: 16},
"F": {Title: "CWE", Width: 12},
"G": {Title: "Risk Category", Width: 50},
"H": {Title: "Technical Asset", Width: 50},
"I": {Title: "Communication Link", Width: 50},
"J": {Title: "RAA %", Width: 10},
"K": {Title: "Identified Risk", Width: 75},
"L": {Title: "Action", Width: 45},
"M": {Title: "Mitigation", Width: 75},
"N": {Title: "Check", Width: 40},
"O": {Title: "ID", Width: 10},
"P": {Title: "Status", Width: 18},
"Q": {Title: "Justification", Width: 80},
"R": {Title: "Date", Width: 18},
"S": {Title: "Checked by", Width: 20},
"T": {Title: "Ticket", Width: 20},
}

return *what
}

func (what *ExcelColumns) FindColumnNameByTitle(title string) string {
for column, excelColumn := range *what {
if strings.EqualFold(excelColumn.Title, title) {
return column
}
}

return ""
}

func (what *ExcelColumns) FindColumnIndexByTitle(title string) int {
for column, excelColumn := range *what {
if strings.EqualFold(excelColumn.Title, title) {
columnNumber, columnNumberError := excelize.ColumnNameToNumber(column)
if columnNumberError != nil {
return -1
}

return columnNumber - 1
}
}

return -1
}

type ExcelColumn struct {
Title string
Width float64
}
Loading

0 comments on commit 0bf87c1

Please sign in to comment.