GitHub - google/certificate-transparency-go: Auditing for TLS certificates (Go code) (original) (raw)

Go Report Card GoDoc CodeQL workflow

This repository holds Go code related toCertificate Transparency (CT). The repository requires Go version 1.24.

Support

Repository Structure

The main parts of the repository are:

Trillian CT Personality

The trillian/ subdirectory holds code and scripts for running a CT Log based on the Trillian general transparency Log, and is documented separately.

Working on the Code

Developers who want to make changes to the codebase need some additional dependencies and tools, described in the following sections.

Running Codebase Checks

The scripts/presubmit.sh script runs various tools and tests over the codebase; please ensure this script passes before sending pull requests for review.

Install golangci-lint

go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6

Run code generation, build, test and linters

./scripts/presubmit.sh

Run build, test and linters but skip code generation

./scripts/presubmit.sh --no-generate

Or just run the linters alone:

golangci-lint run

Rebuilding Generated Code

Some of the CT Go code is autogenerated from other files:

Re-generating mock or protobuffer files is only needed if you're changing the original files. The recommended way to do this is by using the Docker image used by the Cloud Build:

docker build -f ./integration/Dockerfile -t ctgo-builder . docker run -it --mount type=bind,src="$(pwd)",target=/src ctgo-builder /bin/bash -c "cd /src; ./scripts/install_deps.sh; go generate -x ./..."

These commands first create a docker image from the Dockerfile in this repo, and then launch a container based on this image with the local directory mounted. The correct versions of the tools are determined using the go.mod file in this repo, and these tools are installed. Finally, all of the generated files are regenerated and Docker exits.

Alternatively, you can install the prerequisites locally:

cd $(go list -f '{{ .Dir }}' github.com/google/certificate-transparency-go); \  
go install github.com/golang/mock/mockgen; \  
go install google.golang.org/protobuf/proto; \  
go install google.golang.org/protobuf/cmd/protoc-gen-go; \  
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc; \  
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc; \  
go install golang.org/x/tools/cmd/stringer  

and run the following:

go generate -x ./... # hunts for //go:generate comments and runs them