Skip to content

Commit

Permalink
Merge branch 'main' into issuer-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kfox1111 authored Jan 13, 2025
2 parents 851dc3a + a49eaad commit dc97122
Show file tree
Hide file tree
Showing 71 changed files with 816 additions and 696 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
cosign-release: v2.2.3
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Build images
run: make images
- name: Log in to GHCR
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Download archived images
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Load cached deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
Expand Down Expand Up @@ -328,7 +328,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Load cached deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Download archived images
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Load cached deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Load cached deps
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
Expand Down Expand Up @@ -593,7 +593,7 @@ jobs:
with:
cosign-release: v2.2.3
- name: Install regctl
uses: regclient/actions/regctl-installer@b6614f5f56245066b533343a85f4109bdc38c8cc # main
uses: regclient/actions/regctl-installer@ce5fd131e371ffcdd7508b478cb223b3511a9183 # main
- name: Download archived images
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@ linters:
- bodyclose
- durationcheck
- errorlint
- gofmt
- goimports
- revive
- gosec
- misspell
- nakedret
- nilerr
- unconvert
- unparam
- intrange
- whitespace
- gocritic
- wastedassign
- nolintlint

linters-settings:
govet:
enable:
- nilness
- sortslice
- unusedwrite
revive:
# minimal confidence for issues, default is 0.8
confidence: 0.0
Expand Down
18 changes: 2 additions & 16 deletions cmd/spire-server/cli/bundle/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bundle

import (
"bytes"
"crypto"
"crypto/x509"
"encoding/json"
"encoding/pem"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/spiffe/go-spiffe/v2/spiffeid"
"github.com/spiffe/spire-api-sdk/proto/spire/api/types"
"github.com/spiffe/spire/cmd/spire-server/util"
"github.com/spiffe/spire/pkg/common/jwtutil"
"github.com/zeebo/errs"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func bundleFromProto(bundleProto *types.Bundle) (*spiffebundle.Bundle, error) {
if err != nil {
return nil, err
}
jwtAuthorities, err := jwtKeysFromProto(bundleProto.JwtAuthorities)
jwtAuthorities, err := jwtutil.JWTKeysFromProto(bundleProto.JwtAuthorities)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -132,20 +132,6 @@ func x509CertificatesFromProto(proto []*types.X509Certificate) ([]*x509.Certific
return certs, nil
}

// jwtKeysFromProto converts JWT keys from the given []*types.JWTKey to map[string]crypto.PublicKey.
// The key ID of the public key is used as the key in the returned map.
func jwtKeysFromProto(proto []*types.JWTKey) (map[string]crypto.PublicKey, error) {
keys := make(map[string]crypto.PublicKey)
for i, publicKey := range proto {
jwtSigningKey, err := x509.ParsePKIXPublicKey(publicKey.PublicKey)
if err != nil {
return nil, fmt.Errorf("unable to parse JWT signing key %d: %w", i, err)
}
keys[publicKey.KeyId] = jwtSigningKey
}
return keys, nil
}

func printBundleWithFormat(out io.Writer, bundle *types.Bundle, format string, header bool) error {
if bundle == nil {
return errors.New("no bundle provided")
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/entry/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func getEntries(count int) []*types.Entry {
}

e := []*types.Entry{}
for i := 0; i < count; i++ {
for i := range count {
e = append(e, entries[i])
}

Expand Down
22 changes: 2 additions & 20 deletions cmd/spire-server/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package util

import (
"context"
"crypto"
"crypto/x509"
"flag"
"fmt"
Expand All @@ -20,6 +19,7 @@ import (
trustdomainv1 "github.com/spiffe/spire-api-sdk/proto/spire/api/server/trustdomain/v1"
api_types "github.com/spiffe/spire-api-sdk/proto/spire/api/types"
common_cli "github.com/spiffe/spire/pkg/common/cli"
"github.com/spiffe/spire/pkg/common/jwtutil"
"github.com/spiffe/spire/pkg/common/pemutil"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -252,7 +252,7 @@ func protoFromSpiffeBundle(bundle *spiffebundle.Bundle) (*api_types.Bundle, erro
X509Authorities: protoFromX509Certificates(bundle.X509Authorities()),
}

jwtAuthorities, err := protoFromJWTKeys(bundle.JWTAuthorities())
jwtAuthorities, err := jwtutil.ProtoFromJWTKeys(bundle.JWTAuthorities())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -280,21 +280,3 @@ func protoFromX509Certificates(certs []*x509.Certificate) []*api_types.X509Certi

return resp
}

// protoFromJWTKeys converts JWT keys from the given map[string]crypto.PublicKey to []*types.JWTKey
func protoFromJWTKeys(keys map[string]crypto.PublicKey) ([]*api_types.JWTKey, error) {
var resp []*api_types.JWTKey

for kid, key := range keys {
pkixBytes, err := x509.MarshalPKIXPublicKey(key)
if err != nil {
return nil, err
}
resp = append(resp, &api_types.JWTKey{
PublicKey: pkixBytes,
KeyId: kid,
})
}

return resp, nil
}
30 changes: 15 additions & 15 deletions doc/telemetry/telemetry_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ You may use all, some, or none of the collectors. The following collectors suppo

## Telemetry configuration syntax

| Configuration | Type | Description | Default |
|-----------------------|---------------|---------------------------------------------------------------|--------------------------|
| `InMem` | `InMem` | In-memory configuration | running |
| `Prometheus` | `Prometheus` | Prometheus configuration | |
| `DogStatsd` | `[]DogStatsd` | List of DogStatsd configurations | |
| `Statsd` | `[]Statsd` | List of Statsd configurations | |
| `M3` | `[]M3` | List of M3 configurations | |
| `MetricPrefix` | `string` | Prefix to add to all emitted metrics | spire_server/spire_agent |
| `EnableHostnameLabel` | `bool` | Enable adding hostname to labels | true |
| `AllowedPrefixes` | `[]string` | A list of metric prefixes to allow, with '.' as the separator | |
| `AllowedPrefixes` | `[]string` | A list of metric prefixes to allow, with '.' as the separator | |
| `BlockedPrefixes` | `[]string` | A list of metric prefixes to block, with '.' as the separator | |
| `AllowedLabels` | `[]string` | A list of metric labels to allow, with '.' as the separator | |
| `BlockedLabels` | `[]string` | A list of metric labels to block, with '.' as the separator | |
| Configuration | Type | Description | Default |
|--------------------------|---------------|---------------------------------------------------------------|--------------------------|
| `InMem` | `InMem` | In-memory configuration | running |
| `Prometheus` | `Prometheus` | Prometheus configuration | |
| `DogStatsd` | `[]DogStatsd` | List of DogStatsd configurations | |
| `Statsd` | `[]Statsd` | List of Statsd configurations | |
| `M3` | `[]M3` | List of M3 configurations | |
| `MetricPrefix` | `string` | Prefix to add to all emitted metrics | spire_server/spire_agent |
| `EnableTrustDomainLabel` | `bool` | Enable optional trust domain label for all metrics | false |
| `EnableHostnameLabel` | `bool` | Enable adding hostname to labels | true |
| `AllowedPrefixes` | `[]string` | A list of metric prefixes to allow, with '.' as the separator | |
| `AllowedPrefixes` | `[]string` | A list of metric prefixes to allow, with '.' as the separator | |
| `BlockedPrefixes` | `[]string` | A list of metric prefixes to block, with '.' as the separator | |
| `AllowedLabels` | `[]string` | A list of metric labels to allow, with '.' as the separator | |
| `BlockedLabels` | `[]string` | A list of metric labels to block, with '.' as the separator | |

### `Prometheus`

Expand Down Expand Up @@ -79,7 +80,6 @@ telemetry {
]
InMem {}
AllowedLabels = []
BlockedLabels = []
AllowedPrefixes = []
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
cloud.google.com/go/secretmanager v1.14.2
cloud.google.com/go/security v1.18.2
cloud.google.com/go/storage v1.49.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys v0.10.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0
Expand All @@ -19,7 +19,7 @@ require (
github.com/Masterminds/sprig/v3 v3.3.0
github.com/Microsoft/go-winio v0.6.2
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129
github.com/aws/aws-sdk-go-v2 v1.32.6
github.com/aws/aws-sdk-go-v2 v1.32.7
github.com/aws/aws-sdk-go-v2/config v1.28.3
github.com/aws/aws-sdk-go-v2/credentials v1.17.44
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19
Expand All @@ -28,9 +28,9 @@ require (
github.com/aws/aws-sdk-go-v2/service/ec2 v1.198.0
github.com/aws/aws-sdk-go-v2/service/iam v1.38.1
github.com/aws/aws-sdk-go-v2/service/kms v1.37.5
github.com/aws/aws-sdk-go-v2/service/organizations v1.36.0
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0
github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.16.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.71.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.0
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1
github.com/aws/smithy-go v1.22.1
Expand Down Expand Up @@ -78,11 +78,11 @@ require (
github.com/uber-go/tally/v4 v4.1.16
github.com/valyala/fastjson v1.6.4
github.com/zeebo/errs v1.4.0
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/net v0.33.0
golang.org/x/net v0.34.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0
golang.org/x/sys v0.29.0
golang.org/x/time v0.8.0
google.golang.org/api v0.214.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576
Expand Down Expand Up @@ -120,16 +120,16 @@ require (
github.com/armon/go-radix v1.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/service/ecr v1.24.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.21.6 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.6 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.6 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.6 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -297,7 +297,7 @@ require (
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
Expand Down
Loading

0 comments on commit dc97122

Please sign in to comment.