From ef7fba89a415ba2afed5a0ddf059ae974a499ee9 Mon Sep 17 00:00:00 2001 From: Tymur Khrushchov Date: Mon, 28 Oct 2024 15:36:55 +0100 Subject: [PATCH] name field && lint fixes --- .golangci.yaml | 7 ++-- adapters/database/service.go | 8 +++-- adapters/database/service_test.go | 35 ------------------ adapters/secrets/service.go | 3 +- application/config_test.go | 3 +- application/config_utils.go | 3 +- application/service.go | 6 ++-- domain/measurements-jq.json | 1 - domain/measurements.json | 1 - domain/types.go | 12 +++---- domain/types_test.go | 60 ------------------------------- httpserver/handler.go | 41 --------------------- httpserver/vars.go | 5 --- metrics/server.go | 3 +- ports/http_handler.go | 27 +++++++------- ports/types.go | 28 ++++++++------- staticcheck.conf | 2 +- 17 files changed, 55 insertions(+), 190 deletions(-) delete mode 100644 domain/measurements-jq.json delete mode 100644 domain/measurements.json delete mode 100644 domain/types_test.go diff --git a/.golangci.yaml b/.golangci.yaml index fc4d5cf..2dd2c60 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,3 +1,5 @@ +run: + tests: false linters: enable-all: true disable: @@ -11,7 +13,6 @@ linters: - godot - godox - gomnd - - mnd - lll - nestif - nilnil @@ -27,7 +28,9 @@ linters: - wsl - exhaustruct - depguard - - err113 + - prealloc + - whitespace + - musttag # # Disabled because of generics: diff --git a/adapters/database/service.go b/adapters/database/service.go index 0c92fd8..ccfdfa4 100644 --- a/adapters/database/service.go +++ b/adapters/database/service.go @@ -1,3 +1,4 @@ +// Package database provides a database adapter for postgres package database import ( @@ -36,7 +37,6 @@ func (s *Service) Close() error { return s.DB.Close() } -// GetMeasurementByTypeAndHash retrieves a measurement by OID and hash func (s *Service) GetActiveMeasurementsByType(ctx context.Context, attestationType string) ([]domain.Measurement, error) { var measurements []Measurement err := s.DB.SelectContext(ctx, &measurements, `SELECT * FROM measurements_whitelist WHERE is_active=true AND attestation_type=$1`, attestationType) @@ -90,13 +90,15 @@ func (s *Service) GetActiveMeasurements(ctx context.Context) ([]domain.Measureme // RegisterCredentialsForBuilder registers new credentials for a builder, deprecating all previous credentials // It uses hash and attestation_type to fetch the corresponding measurement_id via a subquery. -func (s *Service) RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName string, attestationType string) error { +func (s *Service) RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName, attestationType string) error { // Start a transaction tx, err := s.DB.BeginTx(ctx, nil) if err != nil { return err } - defer tx.Rollback() // Rollback the transaction if it's not committed + defer func() { + _ = tx.Rollback() + }() // Rollback the transaction if it's not committed // Deprecate all previous credentials for this builder and service _, err = tx.Exec(` diff --git a/adapters/database/service_test.go b/adapters/database/service_test.go index 4df95f0..7acca77 100644 --- a/adapters/database/service_test.go +++ b/adapters/database/service_test.go @@ -12,40 +12,6 @@ func TestGetBuilder(t *testing.T) { if err != nil { t.Errorf("NewDatabaseService() = %v; want nil", err) } - //t.Run("GetBuilder", func(t *testing.T) { - // _, err = db.Exec("create temporary table t (id serial primary key, ip inet not null);") - // if err != nil { - // log.Fatal(err) - // } - // - // var paramIP pgtype.Inet - // err = paramIP.Set("10.0.0.0/16") - // if err != nil { - // log.Fatal(err) - // } - // - // _, err = db.Exec("insert into t (ip) values ($1);", paramIP) - // if err != nil { - // log.Fatal(err) - // } - // - // var resultIP pgtype.Inet - // err = db.QueryRow("select ip from t").Scan(&resultIP) - // if err != nil { - // log.Fatal(err) - // } - // - // fmt.Println(resultIP.IPNet) - //}) - //t.Run("GetBuilder", func(t *testing.T) { - // t.Run("should return a builder", func(t *testing.T) { - // builder, err := serv.GetBuilderByIP(net.ParseIP("192.168.1.100")) - // if err != nil { - // t.Errorf("GetBuilder() = %v; want nil", err) - // } - // fmt.Println(builder) - // }) - //}) t.Run("GetBuilder2", func(t *testing.T) { t.Run("should return a builder", func(t *testing.T) { whitelist, err := serv.GetBuilderByIP(net.ParseIP("192.168.1.1")) @@ -69,5 +35,4 @@ func TestGetBuilder(t *testing.T) { fmt.Println(whitelist) }) }) - } diff --git a/adapters/secrets/service.go b/adapters/secrets/service.go index 3e9821c..2bd0eb5 100644 --- a/adapters/secrets/service.go +++ b/adapters/secrets/service.go @@ -1,3 +1,4 @@ +// Package secrets contains logic for adapter to aws secrets manager package secrets import ( @@ -60,7 +61,7 @@ func (s *Service) GetSecretValues(builderName string) (map[string]string, error) return MergeSecrets(defaultSecrets, builderSecrets), nil } -func MergeSecrets(defaultSecrets map[string]string, secrets map[string]string) map[string]string { +func MergeSecrets(defaultSecrets, secrets map[string]string) map[string]string { // merge secrets res := make(map[string]string) for k, v := range defaultSecrets { diff --git a/application/config_test.go b/application/config_test.go index 0bb1295..271ee31 100644 --- a/application/config_test.go +++ b/application/config_test.go @@ -184,5 +184,6 @@ func TestMerge(t *testing.T) { cfg := ExampleConfig{} err = json.Unmarshal(newC, &cfg) - require.Equal(t, cfg.OrderflowProxy.FlashbotsOfSigningKey, "test_value_1") + require.NoError(t, err) + require.Equal(t, "test_value_1", cfg.OrderflowProxy.FlashbotsOfSigningKey) } diff --git a/application/config_utils.go b/application/config_utils.go index 134ad4c..0629667 100644 --- a/application/config_utils.go +++ b/application/config_utils.go @@ -1,3 +1,4 @@ +// Package application contains application logic for the builder-hub package application import ( @@ -9,7 +10,7 @@ import ( func MergeConfigSecrets(config json.RawMessage, secrets map[string]string) (json.RawMessage, error) { // merge config and secrets - var bts = []byte(config) + bts := []byte(config) var err error for k, v := range secrets { tV := "\"" + v + "\"" diff --git a/application/service.go b/application/service.go index 311637a..1c2f147 100644 --- a/application/service.go +++ b/application/service.go @@ -15,7 +15,7 @@ type BuilderDataAccessor interface { GetActiveMeasurementsByType(ctx context.Context, attestationType string) ([]domain.Measurement, error) GetBuilderByIP(ip net.IP) (*domain.Builder, error) GetActiveConfigForBuilder(ctx context.Context, builderName string) (json.RawMessage, error) - RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName string, attestationType string) error + RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName, attestationType string) error } type SecretAccessor interface { @@ -39,7 +39,7 @@ func (b *BuilderHub) GetActiveBuilders(ctx context.Context) ([]domain.BuilderWit return b.dataAccessor.GetActiveBuildersWithServiceCredentials(ctx) } -func (b *BuilderHub) RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName string, attestationType string) error { +func (b *BuilderHub) RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName, attestationType string) error { return b.dataAccessor.RegisterCredentialsForBuilder(ctx, builderName, service, tlsCert, ecdsaPubKey, measurementName, attestationType) } @@ -59,7 +59,7 @@ func (b *BuilderHub) GetConfigWithSecrets(ctx context.Context, builderName strin return res, nil } -func (b *BuilderHub) VerifyIpAndMeasurements(ctx context.Context, ip net.IP, measurement map[string]string, attestationType string) (*domain.Builder, string, error) { +func (b *BuilderHub) VerifyIPAndMeasurements(ctx context.Context, ip net.IP, measurement map[string]string, attestationType string) (*domain.Builder, string, error) { measurements, err := b.dataAccessor.GetActiveMeasurementsByType(ctx, attestationType) if err != nil { return nil, "", fmt.Errorf("failing to fetch corresponding measurement data %s %w", attestationType, err) diff --git a/domain/measurements-jq.json b/domain/measurements-jq.json deleted file mode 100644 index f04c61c..0000000 --- a/domain/measurements-jq.json +++ /dev/null @@ -1 +0,0 @@ -{"key1":"value1","key2":"value2"} diff --git a/domain/measurements.json b/domain/measurements.json deleted file mode 100644 index 2e51740..0000000 --- a/domain/measurements.json +++ /dev/null @@ -1 +0,0 @@ -{"1":"2214214214214","3":"217429174987412","2": "2124214"} \ No newline at end of file diff --git a/domain/types.go b/domain/types.go index e58c2f6..de773b9 100644 --- a/domain/types.go +++ b/domain/types.go @@ -1,14 +1,15 @@ +// Package domain contains domain area types/functions for builder hub package domain import ( - "fmt" + "errors" "net" ) var ( - ErrNotFound = fmt.Errorf("not found") - ErrIncorrectBuilder = fmt.Errorf("incorrect builder") - ErrInvalidMeasurement = fmt.Errorf("no such active measurement found") + ErrNotFound = errors.New("not found") + ErrIncorrectBuilder = errors.New("incorrect builder") + ErrInvalidMeasurement = errors.New("no such active measurement found") ) type Measurement struct { @@ -45,6 +46,3 @@ type BuilderServices struct { ECDSAPubKey []byte Service string } - -type BuilderConfig struct { -} diff --git a/domain/types_test.go b/domain/types_test.go deleted file mode 100644 index 4904874..0000000 --- a/domain/types_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package domain - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestCalculateHash(t *testing.T) { - t.Run("simple", func(t *testing.T) { - measurements := map[string]SingleMeasurement{ - "key1": {"value1"}, - "key2": {"value2"}, - } - hash := CalculateHash(measurements) - require.Equal(t, fmt.Sprintf("%x", hash), "f0605189145d385e22a5dcba5f850d6fcafe83dde8586bc79b8f2dc3450ae849") - }) - t.Run("unordered", func(t *testing.T) { - measurements := map[string]SingleMeasurement{ - "1": {"2214214214214"}, - "3": {"217429174987412"}, - "2": {"2124214"}, - } - hash := CalculateHash(measurements) - require.Equal(t, fmt.Sprintf("%x", hash), "2a4d79238e4876617c64eb3d5a46f8e851399d0f91311b8d74e2b499fd2b576d") - }) - t.Run("attestation-td", func(t *testing.T) { - measuremnt := make(map[string]SingleMeasurement) - s := `{ - "11": { - "expected": "0000000000000000000000000000000000000000000000000000000000000000" - }, - "12": { - "expected": "f1a142c53586e7e2223ec74e5f4d1a4942956b1fd9ac78fafcdf85117aa345da" - }, - "13": { - "expected": "0000000000000000000000000000000000000000000000000000000000000000" - }, - "15": { - "expected": "0000000000000000000000000000000000000000000000000000000000000000" - }, - "4": { - "expected": "98ba2c602b62e67b8e0bd6c6676f12ade320a763e5e4564f62fd875a502dd651" - }, - "8": { - "expected": "0000000000000000000000000000000000000000000000000000000000000000" - }, - "9": { - "expected": "e77938394412d83a8d4de52cdaf97df82a4d4059e1e7c4fc3c73581816cea496" - } -}` - err := json.Unmarshal([]byte(s), &measuremnt) - require.NoError(t, err) - hash := CalculateHash(measuremnt) - require.Equal(t, fmt.Sprintf("%x", hash), "538c7595f3570c9dab335a0232c84a7e7a352acd4c84f78cd2b5e70429acf30b") - }) - -} diff --git a/httpserver/handler.go b/httpserver/handler.go index 1c73295..b92d1cc 100644 --- a/httpserver/handler.go +++ b/httpserver/handler.go @@ -1,12 +1,8 @@ package httpserver import ( - "fmt" - "io" "net/http" "time" - - "github.com/go-chi/chi/v5" ) func (srv *Server) handleLivenessCheck(w http.ResponseWriter, r *http.Request) { @@ -47,40 +43,3 @@ func (srv *Server) handleTestPanic(w http.ResponseWriter, r *http.Request) { // // BuilderConfigHub API: https://www.notion.so/flashbots/BuilderConfigHub-1076b4a0d8768074bcdcd1c06c26ec87?pvs=4#10a6b4a0d87680fd81e0cad9bac3b8c5 // - -func (srv *Server) handleGetConfiguration(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, srv.mockGetConfigResponse) - w.WriteHeader(http.StatusOK) -} - -func (srv *Server) handleGetBuilders(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, srv.mockGetBuildersResponse) - w.WriteHeader(http.StatusOK) -} - -func (srv *Server) handleGetMeasurements(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, srv.mockGetMeasurementsResponse) - w.WriteHeader(http.StatusOK) -} - -func (srv *Server) handleRegisterCredentials(w http.ResponseWriter, r *http.Request) { - // get service name from URL - service := chi.URLParam(r, "service") - if !allowedServices[service] { - srv.log.Error("Invalid service name", "service", service) - w.WriteHeader(http.StatusBadRequest) - return - } - - // read request body - body, err := io.ReadAll(r.Body) - if err != nil { - srv.log.Error("Failed to read request body", "err", err) - w.WriteHeader(http.StatusInternalServerError) - return - } - defer r.Body.Close() - - srv.log.Info("Register credentials", "service", service, "body", string(body)) - w.WriteHeader(http.StatusOK) -} diff --git a/httpserver/vars.go b/httpserver/vars.go index 965a4b7..b482627 100644 --- a/httpserver/vars.go +++ b/httpserver/vars.go @@ -1,6 +1 @@ package httpserver - -var allowedServices = map[string]bool{ - "of-proxy": true, - "rbuilder": true, -} diff --git a/metrics/server.go b/metrics/server.go index b131f50..18cbb2e 100644 --- a/metrics/server.go +++ b/metrics/server.go @@ -2,6 +2,7 @@ package metrics import ( "context" + "errors" "net/http" "time" @@ -32,7 +33,7 @@ func (srv *MetricsServer) Start() error { ReadHeaderTimeout: 5 * time.Second, } - if err := srv.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err := srv.srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { return err } return nil diff --git a/ports/http_handler.go b/ports/http_handler.go index 2a4f704..606eee6 100644 --- a/ports/http_handler.go +++ b/ports/http_handler.go @@ -19,9 +19,9 @@ import ( type BuilderHubService interface { GetAllowedMeasurements(ctx context.Context) ([]domain.Measurement, error) GetActiveBuilders(ctx context.Context) ([]domain.BuilderWithServices, error) - VerifyIpAndMeasurements(ctx context.Context, ip net.IP, measurement map[string]string, attestationType string) (*domain.Builder, string, error) + VerifyIPAndMeasurements(ctx context.Context, ip net.IP, measurement map[string]string, attestationType string) (*domain.Builder, string, error) GetConfigWithSecrets(ctx context.Context, builderName string) ([]byte, error) - RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName string, attestationType string) error + RegisterCredentialsForBuilder(ctx context.Context, builderName, service, tlsCert string, ecdsaPubKey []byte, measurementName, attestationType string) error } type BuilderHubHandler struct { builderHubService BuilderHubService @@ -53,7 +53,7 @@ func (bhs *BuilderHubHandler) getAuthData(r *http.Request) (*AuthData, error) { if len(ipHeaders) == 0 { return nil, fmt.Errorf("ip header is empty %w", ErrInvalidAuthData) } - //NOTE: we need this quite awkward logic since header comes not in the canonical format, with space. + // NOTE: we need this quite awkward logic since header comes not in the canonical format, with space. ipHeader := ipHeaders[len(ipHeaders)-1] ipHeaders = strings.Split(ipHeader, ",") ipHeader = ipHeaders[len(ipHeaders)-1] @@ -70,6 +70,7 @@ func (bhs *BuilderHubHandler) getAuthData(r *http.Request) (*AuthData, error) { IP: ip, }, nil } + func (bhs *BuilderHubHandler) GetAllowedMeasurements(w http.ResponseWriter, r *http.Request) { _, err := io.ReadAll(r.Body) if err != nil { @@ -85,7 +86,7 @@ func (bhs *BuilderHubHandler) GetAllowedMeasurements(w http.ResponseWriter, r *h } var pMeasurements []Measurement for _, m := range measurements { - pMeasurements = append(pMeasurements, fromDomainMeasurement(&m)) + pMeasurements = append(pMeasurements, fromDomainMeasurement(m)) } btsM, err := json.Marshal(pMeasurements) @@ -101,14 +102,13 @@ func (bhs *BuilderHubHandler) GetAllowedMeasurements(w http.ResponseWriter, r *h } func (bhs *BuilderHubHandler) GetActiveBuilders(w http.ResponseWriter, r *http.Request) { - //r.Header.Get("Authorization") authData, err := bhs.getAuthData(r) if err != nil { bhs.log.Warn("malformed auth data", "error", err) w.WriteHeader(http.StatusForbidden) return } - _, _, err = bhs.builderHubService.VerifyIpAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) + _, _, err = bhs.builderHubService.VerifyIPAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) if errors.Is(err, domain.ErrNotFound) { bhs.log.Warn("invalid auth data", "error", err) w.WriteHeader(http.StatusForbidden) @@ -128,7 +128,7 @@ func (bhs *BuilderHubHandler) GetActiveBuilders(w http.ResponseWriter, r *http.R } var pBuilders []BuilderWithServiceCreds for _, b := range builders { - pBuilders = append(pBuilders, fromDomainBuilderWithServices(&b)) + pBuilders = append(pBuilders, fromDomainBuilderWithServices(b)) } bts, err := json.Marshal(pBuilders) if err != nil { @@ -143,7 +143,6 @@ func (bhs *BuilderHubHandler) GetActiveBuilders(w http.ResponseWriter, r *http.R } func (bhs *BuilderHubHandler) GetActiveBuildersNoAuth(w http.ResponseWriter, r *http.Request) { - //bhs.builderHubService builders, err := bhs.builderHubService.GetActiveBuilders(r.Context()) if err != nil { bhs.log.Error("failed to fetch active builders from db", "error", err) @@ -152,7 +151,7 @@ func (bhs *BuilderHubHandler) GetActiveBuildersNoAuth(w http.ResponseWriter, r * } var pBuilders []BuilderWithServiceCreds for _, b := range builders { - pBuilders = append(pBuilders, fromDomainBuilderWithServices(&b)) + pBuilders = append(pBuilders, fromDomainBuilderWithServices(b)) } bts, err := json.Marshal(pBuilders) if err != nil { @@ -173,7 +172,7 @@ func (bhs *BuilderHubHandler) GetConfigSecrets(w http.ResponseWriter, r *http.Re w.WriteHeader(http.StatusForbidden) return } - builder, _, err := bhs.builderHubService.VerifyIpAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) + builder, _, err := bhs.builderHubService.VerifyIPAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) if errors.Is(err, domain.ErrNotFound) { bhs.log.Warn("invalid auth data", "error", err) w.WriteHeader(http.StatusForbidden) @@ -198,7 +197,7 @@ func (bhs *BuilderHubHandler) RegisterCredentials(w http.ResponseWriter, r *http w.WriteHeader(http.StatusForbidden) return } - builder, measurementName, err := bhs.builderHubService.VerifyIpAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) + builder, measurementName, err := bhs.builderHubService.VerifyIPAndMeasurements(r.Context(), authData.IP, authData.MeasurementData, authData.AttestationType) if errors.Is(err, domain.ErrNotFound) { bhs.log.Warn("invalid auth data", "error", err) w.WriteHeader(http.StatusForbidden) @@ -211,7 +210,7 @@ func (bhs *BuilderHubHandler) RegisterCredentials(w http.ResponseWriter, r *http } service := chi.URLParam(r, "service") - //TODO: validate service + // TODO: validate service if service == "" { bhs.log.Warn("service is empty") w.WriteHeader(http.StatusBadRequest) @@ -232,13 +231,13 @@ func (bhs *BuilderHubHandler) RegisterCredentials(w http.ResponseWriter, r *http w.WriteHeader(http.StatusBadRequest) return } - ecdsaBytes, err := hex.DecodeString(sc.EcdsaPubkey) + ecdsaBytes, err := hex.DecodeString(sc.ECDSAPubkey) if err != nil { bhs.log.Error("Failed to decode ecdsa public key", "err", err) w.WriteHeader(http.StatusBadRequest) return } - err = bhs.builderHubService.RegisterCredentialsForBuilder(r.Context(), builder.Name, service, sc.TlsCert, ecdsaBytes, measurementName, authData.AttestationType) + err = bhs.builderHubService.RegisterCredentialsForBuilder(r.Context(), builder.Name, service, sc.TLSCert, ecdsaBytes, measurementName, authData.AttestationType) if err != nil { bhs.log.Error("Failed to register credentials", "err", err) w.WriteHeader(http.StatusInternalServerError) diff --git a/ports/types.go b/ports/types.go index ac2e294..b5d6f8f 100644 --- a/ports/types.go +++ b/ports/types.go @@ -1,3 +1,4 @@ +// Package ports contains entry-point related logic for builder-hub. As of now only way to access builder-hub functionality is via http package ports import ( @@ -14,18 +15,17 @@ const ( ForwardedHeader string = "X-Forwarded-For" ) -var ( - ErrInvalidAuthData = errors.New("invalid auth data") -) +var ErrInvalidAuthData = errors.New("invalid auth data") type BuilderWithServiceCreds struct { - Ip string + IP string + Name string ServiceCreds map[string]ServiceCred } type ServiceCred struct { - TlsCert string `json:"tls_cert,omitempty"` - EcdsaPubkey string `json:"ecdsa_pubkey,omitempty"` + TLSCert string `json:"tls_cert,omitempty"` + ECDSAPubkey string `json:"ecdsa_pubkey,omitempty"` } // MarshalJSON is a custom json marshaller. Unfortunately, there seems to be no way to inline map[string]Service when marshalling @@ -34,8 +34,9 @@ func (b BuilderWithServiceCreds) MarshalJSON() ([]byte, error) { // Create a map to hold all fields m := make(map[string]interface{}) - // Add the Ip field - m["ip"] = b.Ip + // Add the IP field + m["ip"] = b.IP + m["name"] = b.Name // Add all services for k, v := range b.ServiceCreds { @@ -46,15 +47,16 @@ func (b BuilderWithServiceCreds) MarshalJSON() ([]byte, error) { return json.Marshal(m) } -func fromDomainBuilderWithServices(builder *domain.BuilderWithServices) BuilderWithServiceCreds { +func fromDomainBuilderWithServices(builder domain.BuilderWithServices) BuilderWithServiceCreds { b := BuilderWithServiceCreds{} - b.Ip = builder.Builder.IPAddress.String() + b.IP = builder.Builder.IPAddress.String() + b.Name = builder.Builder.Name b.ServiceCreds = make(map[string]ServiceCred) for _, v := range builder.Services { b.ServiceCreds[v.Service] = ServiceCred{ - TlsCert: v.TLSCert, - EcdsaPubkey: hex.EncodeToString(v.ECDSAPubKey), + TLSCert: v.TLSCert, + ECDSAPubkey: hex.EncodeToString(v.ECDSAPubKey), } } @@ -67,7 +69,7 @@ type Measurement struct { Measurement map[string]domain.SingleMeasurement `json:"measurement"` } -func fromDomainMeasurement(measurement *domain.Measurement) Measurement { +func fromDomainMeasurement(measurement domain.Measurement) Measurement { m := Measurement{ Name: measurement.Name, AttestationType: measurement.AttestationType, diff --git a/staticcheck.conf b/staticcheck.conf index 5df9d3d..de640c6 100644 --- a/staticcheck.conf +++ b/staticcheck.conf @@ -1,4 +1,4 @@ -checks = ["all"] +checks = ["all", "-ST1003"] # checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023"] initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] dot_import_whitelist = ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"]