Skip to content

Commit

Permalink
add silent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
5amu committed Jul 9, 2022
1 parent f550f16 commit dd35030
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/checks/dnschecks/dnssec.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *DNSSECCheck) Start(domain string, nameservers *common.Nameservers) erro
}

c.output = &output.CheckOutput{
Name: "DNS amplification",
Name: "DNSSEC implementation",
Domain: domain,
Nameservers: nameservers.FQDNs,
Vulnerable: isVuln,
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/dnschecks/spf.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *SPFCheck) recursiveSPFCheck(record string, domain string, message strin
if record == "" {
message += common.SpfNotOK(fmt.Sprintf("%vNo SPF for %v\n", spacing, domain))
} else if strings.Contains(record, "-all") {
message += common.SpfOK(fmt.Sprintf("%vSecure (-all) SPF for %v\n", spacing, domain))
message += common.OK(fmt.Sprintf("%vSecure (-all) SPF for %v\n", spacing, domain))
stop = true
} else if strings.Contains(record, "~all") {
*isVuln = true
Expand Down
4 changes: 2 additions & 2 deletions internal/common/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func Error(s string) string {
return generic(fmt.Sprintf("[ERROR]: %v", s), colors[ErrorLevel])
}

func SpfOK(s string) string {
return fmt.Sprintf("[OKAY]: %v", s)
func OK(s string) string {
return generic(fmt.Sprintf("[OKAY]: %v", s), colors[HeaderLevel])
}

func SpfNotOK(s string) string {
Expand Down
7 changes: 7 additions & 0 deletions internal/runner/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type Args struct {
HelpFlag bool
VersionFlag bool
Silent bool
Outfile string
NSFile string
Domain string
Expand All @@ -28,6 +29,7 @@ func usage() {
fmt.Println(" -o|--outfile save output in JSON format")
fmt.Println(" -n|--nsfile file with nameservers (line separated)")
fmt.Println(" -c|--checklist specify a single check (flag can be repeated)")
fmt.Println(" -s|--silent Print less information")
fmt.Println("")
fmt.Println("POSITIONAL:")
fmt.Println("")
Expand Down Expand Up @@ -65,6 +67,10 @@ func ParseArgs() (*Args, error) {
mainFlagSet.BoolVar(&vers1, "v", false, "")
mainFlagSet.BoolVar(&vers2, "version", false, "")

var silent1, silent2 bool
mainFlagSet.BoolVar(&silent1, "s", false, "")
mainFlagSet.BoolVar(&silent2, "silent", false, "")

var outfile1, outfile2 string
mainFlagSet.StringVar(&outfile1, "o", "", "")
mainFlagSet.StringVar(&outfile2, "outfile", "", "")
Expand Down Expand Up @@ -109,6 +115,7 @@ func ParseArgs() (*Args, error) {
return &Args{
HelpFlag: help1 || help2,
VersionFlag: vers1 || vers2,
Silent: silent1 || silent2,
Outfile: outfile1 + outfile2,
NSFile: nsfile1 + nsfile2,
Domain: mainFlagSet.Arg(0),
Expand Down
14 changes: 13 additions & 1 deletion internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,20 @@ func (a *Args) Run() error {
}
return nil
case r := <-resChan:
fmt.Println(r)
if a.Silent {
synteticPrint(r)
} else {
fmt.Println(r)
}
results = append(results, r)
}
}
}

func synteticPrint(r *output.CheckOutput) {
if r.Vulnerable {
fmt.Println(common.Warn(fmt.Sprintf("%v is positive to check: %v", r.Domain, r.Name)))
} else {
fmt.Println(common.OK(fmt.Sprintf("%v is negative to check: %v", r.Domain, r.Name)))
}
}

0 comments on commit dd35030

Please sign in to comment.