diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9340875..b78bb52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - SRC_DIR: src/github.com/${{ github.repository }} - jobs: Go: name: Go @@ -37,22 +34,18 @@ jobs: go: [ '1.19.x', '1.20.x' ] steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} - - name: Checkout - uses: actions/checkout@v3 - with: - path: ${{env.SRC_DIR}} - - name: Download dependencies - working-directory: ${{env.SRC_DIR}} run: make deps - name: Build binary - working-directory: ${{env.SRC_DIR}} run: make all Aligo: @@ -62,24 +55,20 @@ jobs: needs: Go steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.19.x' - - name: Checkout - uses: actions/checkout@v3 - with: - path: ${{env.SRC_DIR}} - - name: Download dependencies - working-directory: ${{env.SRC_DIR}} run: make deps - name: Check Golang sources with Aligo - uses: essentialkaos/aligo-action@v1 + uses: essentialkaos/aligo-action@v2 with: - path: ${{env.SRC_DIR}} files: ./... Perfecto: @@ -119,6 +108,19 @@ jobs: with: files: .docker/*.docker + Typos: + name: Typos + runs-on: ubuntu-latest + + needs: Go + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Check spelling + uses: crate-ci/typos@master + DockerBuild: name: Docker Build Check runs-on: ubuntu-latest diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..55aead8 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,2 @@ +[files] +extend-exclude = ["go.sum"] diff --git a/README.md b/README.md index 5f13cc3..b3ae523 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ ### Usage demo -[![demo](https://gh.kaos.st/sslcli-200.gif)](#usage-demo) +[![demo](https://gh.kaos.st/sslcli-275.gif)](#usage-demo) ### Installation #### From source -To build the SSLScan Client from scratch, make sure you have a working Go 1.19+ workspace ([instructions](https://golang.org/doc/install)), then: +To build the SSLScan Client from scratch, make sure you have a working Go 1.19+ workspace ([instructions](https://go.dev/doc/install)), then: ``` go install github.com/essentialkaos/sslcli@latest @@ -50,10 +50,8 @@ bash <(curl -fsSL https://apps.kaos.st/get) sslcli The latest version of `sslcli` also available as container image on [GitHub Container Registry](https://kaos.sh/p/sslcli) and [Docker Hub](https://kaos.sh/d/sslcli): ```bash -podman pull ghcr.io/essentialkaos/sslcli:latest podman run --rm -it ghcr.io/essentialkaos/sslcli:latest mydomain.com # or -docker pull ghcr.io/essentialkaos/sslcli:latest docker run --rm -it ghcr.io/essentialkaos/sslcli:latest mydomain.com ``` diff --git a/cli/cli.go b/cli/cli.go index f9253fa..243318f 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -38,7 +38,7 @@ import ( const ( APP = "SSLScan Client" - VER = "2.7.4" + VER = "2.7.5" DESC = "Command-line client for the SSL Labs API" ) @@ -85,9 +85,9 @@ type HostCheckInfo struct { } type EndpointCheckInfo struct { - IPAdress string `json:"ipAddress"` - Grade string `json:"grade"` - GradeNum float64 `json:"gradeNum"` + IPAddress string `json:"ipAddress"` + Grade string `json:"grade"` + GradeNum float64 `json:"gradeNum"` } // ////////////////////////////////////////////////////////////////////////////////// // @@ -104,7 +104,7 @@ var optMap = options.Map{ OPT_NOTIFY: {Type: options.BOOL}, OPT_NO_COLOR: {Type: options.BOOL}, OPT_HELP: {Type: options.BOOL}, - OPT_VER: {Type: options.BOOL}, + OPT_VER: {Type: options.MIXED}, OPT_VERB_VER: {Type: options.BOOL}, OPT_COMPLETION: {}, @@ -154,7 +154,7 @@ func Run(gitRev string, gomod []byte) { printMan() os.Exit(0) case options.GetB(OPT_VER): - genAbout(gitRev).Print() + genAbout(gitRev).Print(options.GetS(OPT_VER)) os.Exit(0) case options.GetB(OPT_VERB_VER): support.Print(APP, VER, gitRev, gomod) @@ -182,10 +182,6 @@ func preConfigureUI() { } } - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - } - if os.Getenv("NO_COLOR") != "" { fmtc.DisableColors = true } @@ -477,7 +473,7 @@ func getColoredGrades(endpoints []*sslscan.EndpointInfo) string { var result string for _, endpoint := range endpoints { - result += getColoredGrade(endpoint.Grade) + "{s-}/" + endpoint.IPAdress + "{!} " + result += getColoredGrade(endpoint.Grade) + "{s-}/" + endpoint.IPAddress + "{!} " } return result @@ -572,9 +568,9 @@ func appendEndpointsInfo(checkInfo *HostCheckInfo, endpoints []*sslscan.Endpoint grade := getNormGrade(endpoint.Grade) checkInfo.Endpoints = append(checkInfo.Endpoints, &EndpointCheckInfo{ - IPAdress: endpoint.IPAdress, - Grade: grade, - GradeNum: gradeNumMap[grade], + IPAddress: endpoint.IPAddress, + Grade: grade, + GradeNum: gradeNumMap[grade], }) } } diff --git a/cli/details.go b/cli/details.go index 9b33a09..1818ad7 100644 --- a/cli/details.go +++ b/cli/details.go @@ -14,6 +14,7 @@ import ( "github.com/essentialkaos/ek/v12/fmtc" "github.com/essentialkaos/ek/v12/fmtutil" + "github.com/essentialkaos/ek/v12/httputil" "github.com/essentialkaos/ek/v12/pluralize" "github.com/essentialkaos/ek/v12/sliceutil" "github.com/essentialkaos/ek/v12/strutil" @@ -74,7 +75,7 @@ func printDetailedInfo(ap *sslscan.AnalyzeProgress, fromCache bool) { printCertificateInfo(info.Certs, info.Endpoints) for index, endpoint := range info.Endpoints { - fmtc.Printf("\n{c*} %s {!*}#%d (%s){!}\n", info.Host, index+1, endpoint.IPAdress) + fmtc.Printf("\n{c*} %s {!*}#%d (%s){!}\n", info.Host, index+1, endpoint.IPAddress) printDetailedEndpointInfo(endpoint, info.Certs) } } @@ -333,8 +334,9 @@ func printCertValidityInfo(cert *sslscan.Cert) { ) } else { fmtc.Printf( - "%s {s-}(expires in %s){!}\n", + "%s {s-}(expires in %s %s){!}\n", timeutil.Format(validUntilDate, "%Y/%m/%d %H:%M:%S"), + fmtutil.PrettyNum(validDays), pluralize.Pluralize(int(validDays), "day", "days"), ) } @@ -503,8 +505,9 @@ func printChainCertInfo(cert *sslscan.Cert) { fmtc.Printf(" %-24s {s}|{!} {s-}Pin: %s{!}\n", "", cert.PINSHA256) fmtc.Printf( - " %-24s {s}|{!} %s {s-}(expires in %s){!}\n", "Valid until", + " %-24s {s}|{!} %s {s-}(expires in %s %s){!}\n", "Valid until", timeutil.Format(validUntilDate, "%Y/%m/%d %H:%M:%S"), + fmtutil.PrettyNum(validDays), pluralize.Pluralize(int(validDays), "day", "days"), ) @@ -637,9 +640,19 @@ func printSimulationInfo(sim *sslscan.SIM, suites []*sslscan.ProtocolSuites) { } if sim.Client.IsReference { - fmtc.Printf(" %-29s {s}|{!} ", sim.Client.Name+" "+sim.Client.Version+" "+fmtc.Sprintf("{g}R")) + fmtc.Printf( + " %s {s}|{!} ", + fmtutil.Align(fmtc.Sprintf( + "%s %s {g}R{!}", sim.Client.Name, sim.Client.Version, + ), fmtutil.LEFT, 20), + ) } else { - fmtc.Printf(" %-20s {s}|{!} ", sim.Client.Name+" "+sim.Client.Version) + fmtc.Printf( + " %s {s}|{!} ", + fmtutil.Align(fmtc.Sprintf( + "%s %s", sim.Client.Name, sim.Client.Version, + ), fmtutil.LEFT, 20), + ) } switch protocolsNames[sim.ProtocolID] { @@ -1178,7 +1191,11 @@ func printTestInfo(info *sslscan.EndpointInfo) { if details.HTTPStatusCode == 0 { fmtc.Printf(" %-24s {s}|{!} {y}Request failed{!}\n", "HTTP status code") } else { - fmtc.Printf(" %-24s {s}|{!} %d\n", "HTTP status code", details.HTTPStatusCode) + fmtc.Printf( + " %-24s {s}|{!} %d {s-}(%s){!}\n", "HTTP status code", + details.HTTPStatusCode, + httputil.GetDescByCode(details.HTTPStatusCode), + ) } } @@ -1506,7 +1523,8 @@ func getExpiryMessage(ap *sslscan.AnalyzeProgress, dur int64) string { validDays := (validUntilDate.Unix() - time.Now().Unix()) / 86400 return fmt.Sprintf( - " {r}(expires in %s){!}", + " {r}(expires in %s %s){!}", + fmtutil.PrettyNum(validDays), pluralize.Pluralize(int(validDays), "day", "days"), ) } diff --git a/cli/encoder.go b/cli/encoder.go index 7b42a8b..fbac2b1 100644 --- a/cli/encoder.go +++ b/cli/encoder.go @@ -57,7 +57,7 @@ func encodeAsXML(checksInfo []*HostCheckInfo) { for _, endpoint := range info.Endpoints { fmt.Printf( " \n", - endpoint.IPAdress, endpoint.Grade, endpoint.GradeNum, + endpoint.IPAddress, endpoint.Grade, endpoint.GradeNum, ) } @@ -84,7 +84,7 @@ func encodeAsYAML(checksInfo []*HostCheckInfo) { fmt.Println(" -") fmt.Printf(" grade: %s\n", endpoint.Grade) fmt.Printf(" gradeNum: %.1f\n", endpoint.GradeNum) - fmt.Printf(" ipAddress: \"%s\"\n", endpoint.IPAdress) + fmt.Printf(" ipAddress: \"%s\"\n", endpoint.IPAddress) } fmt.Printf(" host: %s\n", info.Host) diff --git a/common/sslcli.spec b/common/sslcli.spec index fa90524..dff9065 100644 --- a/common/sslcli.spec +++ b/common/sslcli.spec @@ -10,7 +10,7 @@ Summary: Pretty awesome command-line client for public SSLLabs API Name: sslcli -Version: 2.7.4 +Version: 2.7.5 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -22,7 +22,7 @@ Source100: checksum.sha512 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.20 Provides: %{name} = %{version}-%{release} @@ -101,6 +101,11 @@ fi ################################################################################ %changelog +* Thu Apr 27 2023 Anton Novojilov - 2.7.5-0 +- Fixed the bug with showing the number of certificate validity days +- Fixed the bug with text alignment if colors are disabled +- Typos fixed + * Mon Mar 06 2023 Anton Novojilov - 2.7.4-0 - Added verbose info output - Dependencies update @@ -212,7 +217,7 @@ fi * Tue Oct 11 2016 Anton Novojilov - 1.1.0-0 - EK package updated to v5 -- SSLScan package udated to v2 +- SSLScan package updated to v2 * Fri Sep 23 2016 Anton Novojilov - 1.0.2-0 - Minor UI improvements diff --git a/go.mod b/go.mod index ec608cf..ce29485 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/essentialkaos/sslcli go 1.19 require ( - github.com/essentialkaos/depsy v1.0.0 - github.com/essentialkaos/ek/v12 v12.63.0 - github.com/essentialkaos/sslscan/v13 v13.1.4 + github.com/essentialkaos/depsy v1.1.0 + github.com/essentialkaos/ek/v12 v12.67.0 + github.com/essentialkaos/sslscan/v13 v13.2.0 ) require ( github.com/andybalholm/brotli v1.0.5 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.16.5 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.44.0 // indirect - golang.org/x/sys v0.6.0 // indirect + github.com/valyala/fasthttp v1.47.0 // indirect + golang.org/x/sys v0.8.0 // indirect ) diff --git a/go.sum b/go.sum index cc579b1..f38d9ea 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,20 @@ -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/depsy v1.0.0 h1:FikBtTnNhk+xFO/hFr+CfiKs6QnA3wMD6tGL0XTEUkc= -github.com/essentialkaos/depsy v1.0.0/go.mod h1:XVsB2eVUonEzmLKQP3ig2P6v2+WcHVgJ10zm0JLqFMM= -github.com/essentialkaos/ek/v12 v12.63.0 h1:9yaEu5W3bx//9y52ShqYCoFDKOcwEdrnvgSkUYyatgI= -github.com/essentialkaos/ek/v12 v12.63.0/go.mod h1:9MlSuHpewu7OZ9tM9dLFHvoA8dflBIUPCA0Ctt97wRs= -github.com/essentialkaos/sslscan/v13 v13.1.4 h1:MQaaVdp7TRBP92ci90vIq1x9BZfKfrfdMMdhAOSrrsY= -github.com/essentialkaos/sslscan/v13 v13.1.4/go.mod h1:xAzDhR8d+QyugSLJoWvUH1MCz7seaLUwayIqRCEjFGg= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= +github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= +github.com/essentialkaos/ek/v12 v12.67.0 h1:ii15t0O+3Mu7uI3Te5X5BIqYXi1V7ovtSIYi5LyiltU= +github.com/essentialkaos/ek/v12 v12.67.0/go.mod h1:sRgw+F7PeeoNsmLLVMKy5ccugwGSljk8/rTXC9dyT+M= +github.com/essentialkaos/sslscan/v13 v13.2.0 h1:myHahuvrPkjIL9PKGeaBz+8NglpWE55WsvRgQ1QDS8A= +github.com/essentialkaos/sslscan/v13 v13.2.0/go.mod h1:8gPBJnA41juOmUsqGol0dJysXJ1+baXNgGqGp0AYvZs= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.44.0 h1:R+gLUhldIsfg1HokMuQjdQ5bh9nuXHPIfvkYUu9eR5Q= -github.com/valyala/fasthttp v1.44.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +github.com/valyala/fasthttp v1.47.0 h1:y7moDoxYzMooFpT5aHgNgVOQDrS3qlkfiP9mDtGGK9c= +github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=