Skip to content

Commit 434c415

Browse files
authored
Merge pull request #200 from essentialkaos/develop
Version 14.1.2
2 parents 6034b37 + 02e67d6 commit 434c415

File tree

9 files changed

+90
-96
lines changed

9 files changed

+90
-96
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* @essentialkaos/go
2+
/.github/workflows/* @essentialkaos/devops

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ updates:
1212
- "PR • MAINTENANCE"
1313
assignees:
1414
- "andyone"
15-
reviewers:
16-
- "andyone"
1715
groups:
1816
all:
1917
applies-to: version-updates
@@ -32,5 +30,3 @@ updates:
3230
- "PR • MAINTENANCE"
3331
assignees:
3432
- "andyone"
35-
reviewers:
36-
- "andyone"

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
strategy:
3939
matrix:
40-
go: [ '1.22.x', '1.23.x' ]
40+
go: [ 'oldstable', 'stable' ]
4141

4242
steps:
4343
- name: Checkout
@@ -72,13 +72,14 @@ jobs:
7272
- name: Set up Go
7373
uses: actions/setup-go@v5
7474
with:
75-
go-version: '1.22.x'
75+
go-version: 'stable'
7676

7777
- name: Download dependencies
7878
run: make deps
7979

8080
- name: Check Golang sources with Aligo
8181
uses: essentialkaos/aligo-action@v2
82+
continue-on-error: true
8283
with:
8384
files: ./...
8485

@@ -93,5 +94,5 @@ jobs:
9394
uses: actions/checkout@v4
9495

9596
- name: Check spelling
96-
continue-on-error: true
9797
uses: crate-ci/typos@master
98+
continue-on-error: true

Makefile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22

3-
# This Makefile generated by GoMakeGen 3.2.3 using next command:
3+
# This Makefile generated by GoMakeGen 3.3.1 using next command:
44
# gomakegen --mod .
55
#
66
# More info: https://kaos.sh/gomakegen
@@ -27,7 +27,7 @@ GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)
2727
################################################################################
2828

2929
.DEFAULT_GOAL := help
30-
.PHONY = fmt vet deps update test init vendor mod-init mod-update mod-download mod-vendor help
30+
.PHONY = fmt vet deps update test init vendor tidy mod-init mod-update mod-download mod-vendor help
3131

3232
################################################################################
3333

@@ -47,43 +47,53 @@ else
4747
@go test $(VERBOSE_FLAG) -covermode=count .
4848
endif
4949

50+
tidy: ## Cleanup dependencies
51+
@echo "•• Tidying up dependencies…"
52+
ifdef COMPAT ## Compatible Go version (String)
53+
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
54+
else
55+
@go mod tidy $(VERBOSE_FLAG)
56+
endif
57+
@echo "•• Updating vendored dependencies…"
58+
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
59+
5060
mod-init:
51-
@echo "[37m[1/3][0m [36;1mModules initialization…[0m"
61+
@echo "[32m•[0m[90m••[0m [36;1mModules initialization…[0m"
5262
@rm -f go.mod go.sum
5363
ifdef MODULE_PATH ## Module path for initialization (String)
5464
@go mod init $(MODULE_PATH)
5565
else
5666
@go mod init
5767
endif
5868

59-
@echo "[37m[2/3][0m [36;1mDependencies cleanup…[0m"
69+
@echo "[32m••[0m[90m•[0m [36;1mDependencies cleanup…[0m"
6070
ifdef COMPAT ## Compatible Go version (String)
6171
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
6272
else
6373
@go mod tidy $(VERBOSE_FLAG)
6474
endif
65-
@echo "[37m[3/3][0m [36;1mStripping toolchain info…[0m"
75+
@echo "[32m•••[0m [36;1mStripping toolchain info…[0m"
6676
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
6777

6878
mod-update:
69-
@echo "[37m[1/4][0m [36;1mUpdating dependencies…[0m"
79+
@echo "[32m•[0m[90m•••[0m [36;1mUpdating dependencies…[0m"
7080
ifdef UPDATE_ALL ## Update all dependencies (Flag)
7181
@go get -u $(VERBOSE_FLAG) all
7282
else
7383
@go get -u $(VERBOSE_FLAG) ./...
7484
endif
7585

76-
@echo "[37m[2/4][0m [36;1mStripping toolchain info…[0m"
86+
@echo "[32m••[0m[90m••[0m [36;1mStripping toolchain info…[0m"
7787
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
7888

79-
@echo "[37m[3/4][0m [36;1mDependencies cleanup…[0m"
89+
@echo "[32m•••[0m[90m•[0m [36;1mDependencies cleanup…[0m"
8090
ifdef COMPAT
8191
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
8292
else
8393
@go mod tidy $(VERBOSE_FLAG)
8494
endif
8595

86-
@echo "[37m[4/4][0m [36;1mUpdating vendored dependencies…[0m"
96+
@echo "[32m••••[0m [36;1mUpdating vendored dependencies…[0m"
8797
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
8898

8999
mod-download:
@@ -112,6 +122,6 @@ help: ## Show this info
112122
| sort -h \
113123
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}'
114124
@echo -e ''
115-
@echo -e '\033[90mGenerated by GoMakeGen 3.2.3\033[0m\n'
125+
@echo -e '\033[90mGenerated by GoMakeGen 3.3.1\033[0m\n'
116126

117127
################################################################################

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<p align="center">
44
<a href="https://kaos.sh/g/sslscan.v14"><img src=".github/images/godoc.svg"/></a>
5-
<a href="https://kaos.sh/l/sslscan"><img src="https://kaos.sh/l/35f63606e26d8588f906.svg" alt="Code Climate Maintainability" /></a>
65
<a href="https://kaos.sh/w/sslscan/ci"><img src="https://kaos.sh/w/sslscan/ci.svg" alt="GitHub Actions CI Status" /></a>
76
<a href="https://kaos.sh/w/sslscan/codeql"><img src="https://kaos.sh/w/sslscan/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
87
<a href="#license"><img src=".github/images/license.svg"/></a>
@@ -23,7 +22,7 @@ Package for Go for working with [SSLLabs](https://www.ssllabs.com) public API ([
2322

2423
### Contributing
2524

26-
Before contributing to this project please read our [Contributing Guidelines](https://github.com/essentialkaos/contributing-guidelines#contributing-guidelines).
25+
Before contributing to this project please read our [Contributing Guidelines](https://github.com/essentialkaos/.github/blob/master/CONTRIBUTING.md).
2726

2827
### Terms of Use
2928

@@ -38,4 +37,4 @@ Also you should:
3837

3938
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
4039

41-
<p align="center"><a href="https://essentialkaos.com"><img src="https://gh.kaos.st/ekgh.svg"/></a></p>
40+
<p align="center"><a href="https://kaos.dev"><img src="https://raw.githubusercontent.com/essentialkaos/.github/refs/heads/master/images/ekgh.svg"/></a></p>

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module github.com/essentialkaos/sslscan/v14
22

3-
go 1.22.8
3+
go 1.23.6
44

55
require (
66
github.com/essentialkaos/check v1.4.1
7-
github.com/essentialkaos/ek/v13 v13.15.3
7+
github.com/essentialkaos/ek/v13 v13.26.2
88
)
99

1010
require (
1111
github.com/kr/pretty v0.3.1 // indirect
1212
github.com/kr/text v0.2.0 // indirect
13-
github.com/rogpeppe/go-internal v1.13.1 // indirect
13+
github.com/rogpeppe/go-internal v1.14.1 // indirect
1414
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
22
github.com/essentialkaos/check v1.4.1 h1:SuxXzrbokPGTPWxGRnzy0hXvtb44mtVrdNxgPa1s4c8=
33
github.com/essentialkaos/check v1.4.1/go.mod h1:xQOYwFvnxfVZyt5Qvjoa1SxcRqu5VyP77pgALr3iu+M=
4-
github.com/essentialkaos/ek/v13 v13.15.3 h1:lDJ0qMs6wQRXWFuFRKnPvNX1SxvW2AowKgz6pRoMhAs=
5-
github.com/essentialkaos/ek/v13 v13.15.3/go.mod h1:ez9V1qvfXvjI6gqT24fZfkdVefHzYi6bm/c2NrD7B3s=
4+
github.com/essentialkaos/ek/v13 v13.26.2 h1:PTPaqGvmUIgoHjf2Kru4sC/Mb+Fnwna2XBlVKXhVGnI=
5+
github.com/essentialkaos/ek/v13 v13.26.2/go.mod h1:8/TJJ/5C5F1MC1iCMyepkRHoKGjPt4U6OzQvmgFN+9U=
66
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
77
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
88
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
99
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1010
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
1111
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
12-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
13-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
12+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
13+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=

sslscan.go

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ import (
1313
"time"
1414

1515
"github.com/essentialkaos/ek/v13/req"
16+
"github.com/essentialkaos/ek/v13/strutil"
1617
)
1718

1819
// ////////////////////////////////////////////////////////////////////////////////// //
1920

21+
const VERSION = "14"
22+
23+
// ////////////////////////////////////////////////////////////////////////////////// //
24+
2025
const (
2126
API_URL_INFO = "https://api.ssllabs.com/api/v4/info"
2227
API_URL_REGISTER = "https://api.ssllabs.com/api/v4/register"
@@ -549,18 +554,15 @@ func NewAPI(name, version, email string) (*API, error) {
549554
return nil, ErrEmptyEmail
550555
}
551556

552-
api := &API{
553-
Engine: &req.Engine{},
554-
email: email,
555-
}
557+
api := &API{Engine: &req.Engine{}, email: email}
556558

557559
api.Engine.Init()
558-
api.Engine.SetUserAgent(name, version, "SSLScan/14")
560+
api.Engine.SetUserAgent(name, version, "SSLScan/"+VERSION)
559561

560562
api.Engine.Client.Timeout = 10 * time.Second
561563

562564
info := &Info{}
563-
err := api.doRequest(API_URL_INFO, nil, info)
565+
err := api.doRequest(API_URL_INFO, nil, nil, info)
564566

565567
if err != nil {
566568
return nil, err
@@ -591,7 +593,7 @@ func (a *API) Register(reg *RegisterRequest) (*RegisterResponse, error) {
591593
}
592594

593595
response := &RegisterResponse{}
594-
err := a.doRequest(API_URL_REGISTER, reg, response)
596+
err := a.doRequest(API_URL_REGISTER, nil, reg, response)
595597

596598
return response, err
597599
}
@@ -603,9 +605,11 @@ func (a *API) Analyze(host string, params AnalyzeParams) (*AnalyzeProgress, erro
603605
}
604606

605607
progress := &AnalyzeProgress{host: host, api: a, maxAge: params.MaxAge}
606-
query := "host=" + host + params.ToQuery()
607608

608-
err := a.doRequest(API_URL_ANALYZE+"?"+query, nil, nil)
609+
query := params.ToQuery()
610+
query.Set("host", host)
611+
612+
err := a.doRequest(API_URL_ANALYZE, query, nil, nil)
609613

610614
if err != nil {
611615
return nil, err
@@ -620,22 +624,13 @@ func (p *AnalyzeProgress) Info(detailed, fromCache bool) (*AnalyzeInfo, error) {
620624
return nil, ErrInvalid
621625
}
622626

623-
query := "host=" + p.host
624-
625-
if detailed {
626-
query += "&all=on"
627-
}
628-
629-
if fromCache {
630-
query += "&fromCache=" + formatBoolParam(fromCache)
631-
632-
if p.maxAge > 0 {
633-
query += "&maxAge=" + fmt.Sprintf("%d", p.maxAge)
634-
}
635-
}
627+
query := req.Query{"host": p.host}
628+
query.SetIf(detailed, "all", formatBoolParam(detailed))
629+
query.SetIf(fromCache, "fromCache", formatBoolParam(fromCache))
630+
query.SetIf(fromCache && p.maxAge > 0, "maxAge", fmt.Sprintf("%d", p.maxAge))
636631

637632
info := &AnalyzeInfo{}
638-
err := p.api.doRequest(API_URL_ANALYZE+"?"+query, nil, info)
633+
err := p.api.doRequest(API_URL_ANALYZE, query, nil, info)
639634

640635
if err != nil {
641636
return nil, err
@@ -666,18 +661,16 @@ func (p *AnalyzeProgress) GetEndpointInfo(ip string, fromCache bool) (*EndpointI
666661
}
667662
}
668663

669-
query := "host=" + p.host + "&s=" + ip
670-
671-
if fromCache {
672-
query += "&fromCache=" + formatBoolParam(fromCache)
673-
674-
if p.maxAge > 0 {
675-
query += "&maxAge=" + fmt.Sprintf("%d", p.maxAge)
676-
}
664+
query := req.Query{
665+
"host": p.host,
666+
"s": ip,
677667
}
678668

669+
query.SetIf(fromCache, "fromCache", formatBoolParam(fromCache))
670+
query.SetIf(fromCache && p.maxAge > 0, "maxAge", fmt.Sprintf("%d", p.maxAge))
671+
679672
info := &EndpointInfo{}
680-
err = p.api.doRequest(API_URL_DETAILED+"?"+query, nil, info)
673+
err = p.api.doRequest(API_URL_DETAILED, query, nil, info)
681674

682675
if err != nil {
683676
return nil, err
@@ -699,35 +692,32 @@ func (e *APIErrors) ToError() error {
699692

700693
// ////////////////////////////////////////////////////////////////////////////////// //
701694

702-
// String combines params into query
703-
func (p AnalyzeParams) ToQuery() string {
704-
var result string
705-
706-
result += "publish=" + formatBoolParam(p.Public) + "&"
707-
result += "startNew=" + formatBoolParam(p.StartNew) + "&"
708-
result += "fromCache=" + formatBoolParam(p.FromCache) + "&"
709-
710-
if p.MaxAge != 0 {
711-
result += "maxAge=" + fmt.Sprintf("%d", p.MaxAge) + "&"
695+
// ToQuery converts params into request query
696+
func (p AnalyzeParams) ToQuery() req.Query {
697+
query := req.Query{
698+
"publish": formatBoolParam(p.Public),
699+
"startNew": formatBoolParam(p.StartNew),
700+
"fromCache": formatBoolParam(p.FromCache),
701+
"ignoreMismatch": formatBoolParam(p.IgnoreMismatch),
712702
}
713703

714-
result += "ignoreMismatch=" + formatBoolParam(p.IgnoreMismatch)
715-
716-
if len(result) != 0 {
717-
return "&" + result
704+
if p.MaxAge != 0 {
705+
query.Set("maxAge", fmt.Sprintf("%d", p.MaxAge))
718706
}
719707

720-
return ""
708+
return query
721709
}
722710

723711
// ////////////////////////////////////////////////////////////////////////////////// //
724712

725713
// doRequest sends request using http client
726-
func (a *API) doRequest(uri string, request, response any) error {
714+
func (a *API) doRequest(url string, query req.Query, request, response any) error {
727715
r := req.Request{
728716
Method: req.GET,
729-
URL: uri,
717+
URL: url,
718+
Query: query,
730719
Headers: req.Headers{"email": a.email},
720+
Accept: req.CONTENT_TYPE_JSON,
731721
}
732722

733723
if request != nil {
@@ -766,9 +756,5 @@ func (a *API) doRequest(uri string, request, response any) error {
766756

767757
// formatBoolParam formats boolean parameter
768758
func formatBoolParam(v bool) string {
769-
if v == false {
770-
return "off"
771-
}
772-
773-
return "on"
759+
return strutil.B(v, "on", "off")
774760
}

0 commit comments

Comments
 (0)