diff --git a/pkg/cli/analyze.go b/pkg/cli/analyze.go index 4262318..2d3e2de 100644 --- a/pkg/cli/analyze.go +++ b/pkg/cli/analyze.go @@ -64,16 +64,16 @@ To find out more, run 'doa %s --help' `, command, command) } -func PrintPrettifyJsonOutput(errs []analyzer.Result) { +func PrintPrettifyJsonOutput(results []analyzer.Result) { var bytes []byte var err error - if bytes, err = json.MarshalIndent(errs, "", " "); err != nil { + if bytes, err = json.MarshalIndent(results, "", " "); err != nil { fmt.Println("error while converting output to json. Please try again without the output (--o) flag") } fmt.Println(string(bytes)) } -func PrintPrettifyOutput(errs []analyzer.Result) { +func PrintPrettifyOutput(results []analyzer.Result) { for i, sug := range errs { fmt.Printf("%d - %s (%s): %s\n\n", i+1, sug.Name, sug.Severity, sug.Description) } diff --git a/pkg/command/expose.go b/pkg/command/expose.go index cd344a0..9014054 100644 --- a/pkg/command/expose.go +++ b/pkg/command/expose.go @@ -23,7 +23,7 @@ type Expose struct { } func (e Expose) Analyze(node *parser.Node, source utils.Source, line Line) []Result { - errs := []Result{} + results := []Result{} str := node.Value index := strings.IndexByte(node.Value, '/') if index >= 0 { @@ -31,7 +31,7 @@ func (e Expose) Analyze(node *parser.Node, source utils.Source, line Line) []Res } port, err := strconv.Atoi(str) if err != nil { - errs = append(errs, Result{ + results = append(results, Result{ Name: "Wrong port value", Status: StatusFailed, Severity: SeverityCritical, @@ -39,7 +39,7 @@ func (e Expose) Analyze(node *parser.Node, source utils.Source, line Line) []Res }) } if port < 1024 { - errs = append(errs, Result{ + results = append(results, Result{ Name: "Privileged port exposed", Status: StatusFailed, Severity: SeverityHigh, diff --git a/pkg/command/from.go b/pkg/command/from.go index d966f72..cc7f97d 100644 --- a/pkg/command/from.go +++ b/pkg/command/from.go @@ -27,11 +27,11 @@ func (f From) Analyze(node *parser.Node, source utils.Source, line Line) []Resul if node.Value == SCRATCH_IMAGE_NAME { return nil } - errs := []Result{} + results := []Result{} decompiledNode, err := decompiler.Decompile(node.Value) if err != nil { // unable to decompile base image - errs = append(errs, Result{ + results = append(results, Result{ Name: "Analyze error", Status: StatusFailed, Severity: SeverityLow, diff --git a/pkg/command/run.go b/pkg/command/run.go index 0454d50..92c7ad2 100644 --- a/pkg/command/run.go +++ b/pkg/command/run.go @@ -22,7 +22,7 @@ import ( type Run struct{} func (r Run) Analyze(node *parser.Node, source utils.Source, line Line) []Result { - errs := []Result{} + results := []Result{} // let's split the run command by &&. E.g chmod 070 /app && chmod 070 /app/routes && chmod 070 /app/bin splittedCommands := strings.Split(node.Value, "&&") @@ -30,12 +30,12 @@ func (r Run) Analyze(node *parser.Node, source utils.Source, line Line) []Result if r.isChmodCommand(command) { err := r.analyzeChmodCommand(command, source, line) if err != nil { - errs = append(errs, *err) + results = append(results, *err) } } else if r.isChownCommand(command) { err := r.analyzeChownCommand(command, source, line) if err != nil { - errs = append(errs, *err) + results = append(results, *err) } } else if r.isSudoOrSuCommand(command) { err := r.analyzeSudoAndSuCommand(command, source, line)