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

agent: fix agent HTTP server audit event implementation access. #16076

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions command/agent/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

// Auditor describes the interface that must be implemented by an eventer.
type Auditor interface {
// Emit an event to the auditor
// Event emits an event to the auditor.
Event(ctx context.Context, eventType string, payload interface{}) error

// Specifies if the auditor is enabled or not
// Enabled details if the auditor is enabled or not.
Enabled() bool

// Reopen signals to auditor to reopen any files they have open.
Expand Down
38 changes: 23 additions & 15 deletions command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/client"
"github.com/hashicorp/nomad/command/agent/event"
"github.com/hashicorp/nomad/helper/noxssrw"
"github.com/hashicorp/nomad/helper/tlsutil"
"github.com/hashicorp/nomad/nomad"
Expand Down Expand Up @@ -88,7 +89,12 @@ type RPCer interface {

// HTTPServer is used to wrap an Agent and expose it over an HTTP interface
type HTTPServer struct {
agent RPCer
agent RPCer

// eventAuditor is the enterprise audit log feature which is needed by the
// HTTP server.
eventAuditor event.Auditor

mux *http.ServeMux
listener net.Listener
listenerCh chan struct{}
Expand Down Expand Up @@ -156,13 +162,14 @@ func NewHTTPServers(agent *Agent, config *Config) ([]*HTTPServer, error) {

// Create the server
srv := &HTTPServer{
agent: agent,
mux: http.NewServeMux(),
listener: ln,
listenerCh: make(chan struct{}),
logger: agent.httpLogger,
Addr: ln.Addr().String(),
wsUpgrader: wsUpgrader,
agent: agent,
eventAuditor: agent.auditor,
mux: http.NewServeMux(),
listener: ln,
listenerCh: make(chan struct{}),
logger: agent.httpLogger,
Addr: ln.Addr().String(),
wsUpgrader: wsUpgrader,
}
srv.registerHandlers(config.EnableDebug)

Expand All @@ -186,13 +193,14 @@ func NewHTTPServers(agent *Agent, config *Config) ([]*HTTPServer, error) {
// the builtinDialer and builtinListener will be nil.
if agent.builtinDialer != nil && agent.builtinListener != nil {
srv := &HTTPServer{
agent: agent,
mux: http.NewServeMux(),
listener: agent.builtinListener,
listenerCh: make(chan struct{}),
logger: agent.httpLogger,
Addr: "builtin",
wsUpgrader: wsUpgrader,
agent: agent,
eventAuditor: agent.auditor,
mux: http.NewServeMux(),
listener: agent.builtinListener,
listenerCh: make(chan struct{}),
logger: agent.httpLogger,
Addr: "builtin",
wsUpgrader: wsUpgrader,
}

srv.registerHandlers(config.EnableDebug)
Expand Down