Skip to content

Commit

Permalink
fix panic when an output target is wrong
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Labarussias <issif+github@gadz.org>
  • Loading branch information
Issif committed Sep 4, 2024
1 parent 9ab77ca commit 38d9616
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cmd/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ var rulesChecksCmd = &cobra.Command{
if output == nil {
utils.PrintLog("error", utils.LogLine{Error: "unknown target", Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
if len(o.Parameters) == 0 {
} else if len(o.Parameters) == 0 {
utils.PrintLog("error", utils.LogLine{Error: "missing parameters for the output", Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
if err := output.CheckParameters(o); err != nil {
utils.PrintLog("error", utils.LogLine{Error: err.Error(), Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
} else {
if err := output.CheckParameters(o); err != nil {
utils.PrintLog("error", utils.LogLine{Error: err.Error(), Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ var serverCmd = &cobra.Command{
if output == nil {
utils.PrintLog("error", utils.LogLine{Error: "unknown target", Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
if len(o.Parameters) == 0 {
} else if len(o.Parameters) == 0 {
utils.PrintLog("error", utils.LogLine{Error: "missing parameters for the output", Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
if err := output.CheckParameters(o); err != nil {
utils.PrintLog("error", utils.LogLine{Error: err.Error(), Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
} else {
if err := output.CheckParameters(o); err != nil {
utils.PrintLog("error", utils.LogLine{Error: err.Error(), Rule: i.GetName(), Action: j.GetName(), OutputTarget: o.GetTarget(), Message: "rules"})
valid = false
}
}
}
}
Expand Down

0 comments on commit 38d9616

Please sign in to comment.