Skip to content

Commit

Permalink
sort analysis array before showing it. fixes #131
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdiba committed Oct 4, 2016
1 parent 681a6e1 commit b671ca1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tlsobs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func printAnalysis(ars []database.Analysis) {
return
}
fmt.Println("\n--- Analyzers ---")
sortAnalysis(ars)
for _, a := range ars {
var (
results []string
Expand All @@ -287,6 +288,22 @@ func printAnalysis(ars []database.Analysis) {
}
}

func sortAnalysis(ars []database.Analysis) {
//Perform a simple bubblesort of the Analysis slice using the Analyzer name
swap := true
for swap {
swap = false
for i := 0; i < len(ars)-1; i++ {
if ars[i+1].Analyzer < ars[i].Analyzer {
tmp := ars[i+1]
ars[i+1] = ars[i]
ars[i] = tmp
swap = true
}
}
}
}

func getCert(id int64) (cert certificate.Certificate) {
resp, err := http.Get(fmt.Sprintf("%s/api/v1/certificate?id=%d", *observatory, id))
if err != nil {
Expand Down

0 comments on commit b671ca1

Please sign in to comment.