Skip to content

Commit

Permalink
Avoid slicing errors due to incorrect serial numbers (#222)
Browse files Browse the repository at this point in the history
* Docker workflow fix

* chore(deps): bump google.golang.org/protobuf from 1.29.0 to 1.29.1

Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.29.0 to 1.29.1.
- [Release notes](https://github.com/protocolbuffers/protobuf-go/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash)
- [Commits](protocolbuffers/protobuf-go@v1.29.0...v1.29.1)

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Avoid slicing errors due to incorrect serial numbers

* Update go.mod

* add nil check in serialnumber

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pbuff07 <2323217463@qq.com>
Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
  • Loading branch information
6 people committed Mar 26, 2023
1 parent d24550d commit 586245c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM golang:1.18.2-alpine3.14 AS build-env
# Base
FROM golang:1.20.1-alpine AS builder
RUN apk add --no-cache build-base
RUN go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest
WORKDIR /app
COPY . /app
RUN go mod download
RUN go build ./cmd/tlsx

# Release
FROM alpine:3.17.2
RUN apk add --no-cache bind-tools ca-certificates
COPY --from=build-env /go/bin/tlsx /usr/local/bin/tlsx
ENTRYPOINT ["tlsx"]
RUN apk -U upgrade --no-cache \
&& apk add --no-cache bind-tools ca-certificates
COPY --from=builder /app/tlsx /usr/local/bin/

ENTRYPOINT ["tlsx"]
3 changes: 3 additions & 0 deletions pkg/tlsx/clients/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func GetConn(ctx context.Context, hostname, ip, port string, inputOpts *Options)
// FormatToSerialNumber converts big.Int to colon seperated hex string
// Example: 17034156255497985825694118641198758684 -> 0C:D0:A8:BE:C6:32:CF:E6:45:EC:A0:A9:B0:84:FB:1C
func FormatToSerialNumber(serialNumber *big.Int) string {
if serialNumber == nil || serialNumber.Cmp(big.NewInt(0)) == 0 {
return ""
}
b := serialNumber.Bytes()
buf := make([]byte, 0, 3*len(b))
x := buf[1*len(b) : 3*len(b)]
Expand Down

0 comments on commit 586245c

Please sign in to comment.