Skip to content

Commit 732577f

Browse files
committed
Code refactoring
1 parent 7167502 commit 732577f

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

cli/cli.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
const (
4242
APP = "SSLScan Client"
43-
VER = "3.0.2"
43+
VER = "3.0.3"
4444
DESC = "Command-line client for the SSL Labs API"
4545
)
4646

@@ -159,7 +159,7 @@ func Run(gitRev string, gomod []byte) {
159159

160160
if !errs.IsEmpty() {
161161
terminal.Error("Options parsing errors:")
162-
terminal.Error(errs.Error("- "))
162+
terminal.Error(errs.Error(" - "))
163163
os.Exit(1)
164164
}
165165

@@ -272,7 +272,7 @@ func registerUser() (error, bool) {
272272

273273
if err != nil {
274274
if !options.GetB(OPT_FORMAT) {
275-
return fmt.Errorf("Error while sending request to SSL Labs API: %v", err), false
275+
return fmt.Errorf("Error while sending request to SSL Labs API: %w", err), false
276276
}
277277

278278
return nil, false
@@ -302,7 +302,7 @@ func registerUser() (error, bool) {
302302
})
303303

304304
if err != nil {
305-
return fmt.Errorf("Can't register user: %v", err), false
305+
return fmt.Errorf("Can't register user: %w", err), false
306306
}
307307

308308
fmtc.Printfn("{g}%s{!}\n", resp.Message)
@@ -320,7 +320,7 @@ func runHostCheck(args options.Arguments) (error, bool) {
320320

321321
if err != nil {
322322
if !options.GetB(OPT_FORMAT) {
323-
return fmt.Errorf("Error while sending request to SSL Labs API: %v", err), false
323+
return fmt.Errorf("Error while sending request to SSL Labs API: %w", err), false
324324
}
325325

326326
return nil, false
@@ -704,7 +704,7 @@ func checkAPIAvailability() support.Check {
704704
} else if resp.StatusCode != 200 {
705705
return support.Check{
706706
support.CHECK_ERROR, "SSLLabs API", fmt.Sprintf(
707-
"API returned non-ok status code %s", resp.StatusCode,
707+
"API returned non-ok status code %d", resp.StatusCode,
708708
),
709709
}
710710
}
@@ -756,6 +756,8 @@ func genUsage() *usage.Info {
756756
info.AddOption(OPT_HELP, "Show this help message")
757757
info.AddOption(OPT_VER, "Show version")
758758

759+
info.AddEnv("SSLLABS_EMAIL", "User account email {s-}(String){!}")
760+
759761
info.AddExample(
760762
"--register --email john@domain.com --org 'Some Organization' --name 'John Doe'",
761763
"Register new user account for scanning",

cli/details.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ package cli
99

1010
import (
1111
"fmt"
12+
"slices"
1213
"strings"
1314
"time"
1415

1516
"github.com/essentialkaos/ek/v13/fmtc"
1617
"github.com/essentialkaos/ek/v13/fmtutil"
1718
"github.com/essentialkaos/ek/v13/httputil"
1819
"github.com/essentialkaos/ek/v13/pluralize"
19-
"github.com/essentialkaos/ek/v13/sliceutil"
2020
"github.com/essentialkaos/ek/v13/strutil"
2121
"github.com/essentialkaos/ek/v13/terminal"
2222
"github.com/essentialkaos/ek/v13/timeutil"
@@ -603,11 +603,11 @@ func printProtocolSuiteInfo(suite *sslscan.Suite, chaCha20Preference bool) {
603603
}
604604

605605
switch {
606-
case insecure == true:
606+
case insecure:
607607
fmtc.Printf(" {r}%-52s{!} {s}|{!} {r}%d (INSECURE){!} ", suite.Name, suite.CipherStrength)
608-
case weak == true:
608+
case weak:
609609
fmtc.Printf(" {y}%-52s{!} {s}|{!} {y}%d (WEAK){!} ", suite.Name, suite.CipherStrength)
610-
case preferred == true:
610+
case preferred:
611611
fmtc.Printf(" {*}%-52s{!} {s}|{!} %d ", suite.Name, suite.CipherStrength)
612612
default:
613613
fmtc.Printf(" %-52s {s}|{!} %d ", suite.Name, suite.CipherStrength)
@@ -1458,12 +1458,12 @@ func getTrustInfo(certID string, endpoints []*sslscan.EndpointInfo) (map[string]
14581458
for _, endpoint := range endpoints {
14591459
for _, chain := range endpoint.Details.CertChains {
14601460
for _, path := range chain.TrustPaths {
1461-
if !sliceutil.Contains(path.CertIDs, certID) {
1461+
if !slices.Contains(path.CertIDs, certID) {
14621462
continue
14631463
}
14641464

14651465
for _, store := range path.Trust {
1466-
if store.IsTrusted && result[store.RootStore] == false {
1466+
if store.IsTrusted && !result[store.RootStore] {
14671467
result[store.RootStore] = true
14681468
}
14691469
}

common/sslcli.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Summary: Pretty awesome command-line client for public SSLLabs API
1212
Name: sslcli
13-
Version: 3.0.2
13+
Version: 3.0.3
1414
Release: 0%{?dist}
1515
Group: Applications/System
1616
License: Apache License, Version 2.0
@@ -103,6 +103,10 @@ fi
103103
################################################################################
104104

105105
%changelog
106+
* Thu May 15 2025 Anton Novojilov <andy@essentialkaos.com> - 3.0.3-0
107+
- Code refactoring
108+
- Dependencies update
109+
106110
* Tue Aug 06 2024 Anton Novojilov <andy@essentialkaos.com> - 3.0.2-0
107111
- Package ek updated to v13
108112
- Dependencies update

0 commit comments

Comments
 (0)