Skip to content

Commit

Permalink
Vault-2840 Add no-op check for HTTP listener validity (#12421)
Browse files Browse the repository at this point in the history
* fips tag and no-op code

* tls check

* change to error

* add tests

* add test file

* cleanup

* add changelog

* fix file difference

* remove changelog
  • Loading branch information
rculpepper committed Sep 7, 2021
1 parent ec04bac commit 71d1a29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions command/config/validate_listener.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package config

import "github.com/hashicorp/vault/internalshared/configutil"

func IsValidListener(listener *configutil.Listener) error {
return nil
}
6 changes: 6 additions & 0 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/hashicorp/go-secure-stdlib/mlock"
"github.com/hashicorp/go-secure-stdlib/reloadutil"
"github.com/hashicorp/vault/audit"
config2 "github.com/hashicorp/vault/command/config"
"github.com/hashicorp/vault/command/server"
"github.com/hashicorp/vault/helper/builtinplugins"
"github.com/hashicorp/vault/helper/metricsutil"
Expand Down Expand Up @@ -2623,6 +2624,11 @@ func startHttpServers(c *ServerCommand, core *vault.Core, config *server.Config,
if ln.Config == nil {
return fmt.Errorf("Found nil listener config after parsing")
}

if err := config2.IsValidListener(ln.Config); err != nil {
return err
}

handler := vaulthttp.Handler(&vault.HandlerProperties{
Core: core,
ListenerConfig: ln.Config,
Expand Down
2 changes: 1 addition & 1 deletion command/server_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !race,!hsm
// +build !race,!hsm,!fips_140_3

// NOTE: we can't use this with HSM. We can't set testing mode on and it's not
// safe to use env vars since that provides an attack vector in the real world.
Expand Down

0 comments on commit 71d1a29

Please sign in to comment.