Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to go 1.17 #12868

Merged
merged 15 commits into from Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
494 changes: 247 additions & 247 deletions .circleci/config.yml

Large diffs are not rendered by default.

474 changes: 237 additions & 237 deletions .circleci/config/@build-release.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .circleci/config/commands/go_test.yml
Expand Up @@ -14,7 +14,7 @@ parameters:
default: false
go_image:
type: string
default: "docker.mirror.hashicorp.services/circleci/golang:1.16.7-buster"
default: "docker.mirror.hashicorp.services/circleci/golang:1.17.2-buster"
use_docker:
type: boolean
default: false
Expand Down
8 changes: 4 additions & 4 deletions .circleci/config/executors/@executors.yml
Expand Up @@ -3,7 +3,7 @@ go-machine:
shell: /usr/bin/env bash -euo pipefail -c
environment:
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
GO_VERSION: 1.16.7 # Pin Go to patch version (ex: 1.2.3)
GO_VERSION: 1.17.2 # Pin Go to patch version (ex: 1.2.3)
GOTESTSUM_VERSION: 0.5.2 # Pin gotestsum to patch version (ex: 1.2.3)
GO_TAGS: ""
working_directory: /go/src/github.com/hashicorp/vault
Expand All @@ -25,23 +25,23 @@ alpine:
docker-env-go-test-remote-docker:
resource_class: medium
docker:
- image: "docker.mirror.hashicorp.services/circleci/golang:1.16.7-buster"
- image: "docker.mirror.hashicorp.services/circleci/golang:1.17.2-buster"
environment:
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
GO_TAGS: ""
working_directory: /go/src/github.com/hashicorp/vault
docker-env-go-test:
resource_class: large
docker:
- image: "docker.mirror.hashicorp.services/circleci/golang:1.16.7-buster"
- image: "docker.mirror.hashicorp.services/circleci/golang:1.17.2-buster"
environment:
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
GO_TAGS: ""
working_directory: /go/src/github.com/hashicorp/vault
docker-env-go-test-race:
resource_class: xlarge
docker:
- image: "docker.mirror.hashicorp.services/circleci/golang:1.16.7-buster"
- image: "docker.mirror.hashicorp.services/circleci/golang:1.17.2-buster"
environment:
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
GO_TAGS: ""
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -15,7 +15,7 @@ EXTERNAL_TOOLS=\
GOFMT_FILES?=$$(find . -name '*.go' | grep -v pb.go | grep -v vendor)


GO_VERSION_MIN=1.16.7
GO_VERSION_MIN=1.17.2
GO_CMD?=go
CGO_ENABLED?=0
ifneq ($(FDB_ENABLED), )
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -72,7 +72,7 @@ Developing Vault

If you wish to work on Vault itself or any of its built-in systems, you'll
first need [Go](https://www.golang.org) installed on your machine. Go version
1.16.7+ is *required*.
1.17.2+ is *required*.

For local dev first make sure Go is properly installed, including setting up a
[GOPATH](https://golang.org/doc/code.html#GOPATH). Ensure that `$GOPATH/bin` is in
Expand Down
5 changes: 5 additions & 0 deletions builtin/credential/approle/path_role.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/go-secure-stdlib/strutil"
uuid "github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/helper/parseip"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/helper/cidrutil"
"github.com/hashicorp/vault/sdk/helper/consts"
Expand Down Expand Up @@ -818,6 +819,10 @@ func (b *backend) roleEntry(ctx context.Context, s logical.Storage, roleName str
needsUpgrade = true
}

for i, cidr := range role.SecretIDBoundCIDRs {
role.SecretIDBoundCIDRs[i] = parseip.TrimLeadingZeroesCIDR(cidr)
}

if role.TokenPeriod == 0 && role.Period > 0 {
role.TokenPeriod = role.Period
}
Expand Down
28 changes: 24 additions & 4 deletions builtin/credential/approle/validation.go
Expand Up @@ -9,6 +9,7 @@ import (
"time"

uuid "github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/helper/parseip"
"github.com/hashicorp/vault/sdk/helper/cidrutil"
"github.com/hashicorp/vault/sdk/helper/locksutil"
"github.com/hashicorp/vault/sdk/logical"
Expand Down Expand Up @@ -110,6 +111,25 @@ func (b *backend) secretIDAccessorLock(secretIDAccessor string) *locksutil.LockE
return locksutil.LockForKey(b.secretIDAccessorLocks, secretIDAccessor)
}

func decodeSecretIDStorageEntry(entry *logical.StorageEntry) (*secretIDStorageEntry, error) {
result := secretIDStorageEntry{}
if err := entry.DecodeJSON(&result); err != nil {
return nil, err
}

cleanup := func(in []string) []string {
var out []string
swayne275 marked this conversation as resolved.
Show resolved Hide resolved
for _, s := range in {
out = append(out, parseip.TrimLeadingZeroesCIDR(s))
}
return out
}

result.CIDRList = cleanup(result.CIDRList)
result.TokenBoundCIDRs = cleanup(result.TokenBoundCIDRs)
return &result, nil
}

// nonLockedSecretIDStorageEntry fetches the secret ID properties from physical
// storage. The entry will be indexed based on the given HMACs of both role
// name and the secret ID. This method will not acquire secret ID lock to fetch
Expand All @@ -134,8 +154,8 @@ func (b *backend) nonLockedSecretIDStorageEntry(ctx context.Context, s logical.S
return nil, nil
}

result := secretIDStorageEntry{}
if err := entry.DecodeJSON(&result); err != nil {
result, err := decodeSecretIDStorageEntry(entry)
if err != nil {
return nil, err
}

Expand All @@ -154,12 +174,12 @@ func (b *backend) nonLockedSecretIDStorageEntry(ctx context.Context, s logical.S
}

if persistNeeded {
if err := b.nonLockedSetSecretIDStorageEntry(ctx, s, roleSecretIDPrefix, roleNameHMAC, secretIDHMAC, &result); err != nil {
if err := b.nonLockedSetSecretIDStorageEntry(ctx, s, roleSecretIDPrefix, roleNameHMAC, secretIDHMAC, result); err != nil {
return nil, fmt.Errorf("failed to upgrade role storage entry %w", err)
}
}

return &result, nil
return result, nil
}

// nonLockedSetSecretIDStorageEntry creates or updates a secret ID entry at the
Expand Down
3 changes: 1 addition & 2 deletions builtin/logical/ssh/util.go
Expand Up @@ -13,10 +13,9 @@ import (
"strings"
"time"

log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/vault/sdk/logical"

log "github.com/hashicorp/go-hclog"
"golang.org/x/crypto/ssh"
)

Expand Down
3 changes: 3 additions & 0 deletions changelog/12868.txt
@@ -0,0 +1,3 @@
```release-note:improvement
core: build with Go 1.17, and mitigate a breaking change they made that could impact how approle and ssh interpret IPs/CIDRs
```