Skip to content

Commit

Permalink
Merge branch 'main' into fix_altdomain_dcname_overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
dhiaayachi authored Jun 12, 2023
2 parents 23f5d0e + 5e84674 commit 585c57f
Show file tree
Hide file tree
Showing 176 changed files with 9,118 additions and 633 deletions.
3 changes: 3 additions & 0 deletions .changelog/17546.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
connect: update supported envoy versions to 1.23.10, 1.24.8, 1.25.7, 1.26.2
```
3 changes: 3 additions & 0 deletions .changelog/17577.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
fix metric names in /docs/agent/telemetry
```
4 changes: 4 additions & 0 deletions .changelog/17609.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:bug
gateways: Fixed a bug in API gateways where binding a route that only targets a service imported from a peer results
in the programmed gateway having no routes.
```
3 changes: 3 additions & 0 deletions .changelog/17631.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
gateways: Fixed a bug where API gateways were not being taken into account in determining xDS rate limits.
```
3 changes: 3 additions & 0 deletions .changelog/_5669.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
audit-logging: **(Enterprise only)** enable error response and request body logging
```
3 changes: 3 additions & 0 deletions .changelog/_5740.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
api: (Enterprise only) Add `POST /v1/operator/audit-hash` endpoint to calculate the hash of the data used by the audit log hash function and salt.
```
3 changes: 3 additions & 0 deletions .changelog/_5750.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
cli: (Enterprise only) Add a new `consul operator audit hash` command to retrieve and compare the hash of the data used by the audit log hash function and salt.
```
3 changes: 3 additions & 0 deletions .changelog/_5805.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:security
audit-logging: **(Enterprise only)** limit `v1/operator/audit-hash` endpoint to ACL token with `operator:read` privileges.
```
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

name: Nightly Test 1.12.x
name: Nightly Test 1.16.x
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch: {}

env:
EMBER_PARTITION_TOTAL: 4 # Has to be changed in tandem with the matrix.partition
BRANCH: "release/1.12.x"
BRANCH_NAME: "release-1.12.x" # Used for naming artifacts
BRANCH: "release/1.16.x"
BRANCH_NAME: "release-1.16.x" # Used for naming artifacts

jobs:
frontend-test-workspace-node:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ jobs:
# this is further going to multiplied in envoy-integration tests by the
# other dimensions in the matrix. Currently TOTAL_RUNNERS would be
# multiplied by 8 based on these values:
# envoy-version: ["1.23.8", "1.24.6", "1.25.4", "1.26.0"]
# envoy-version: ["1.23.10", "1.24.8", "1.25.7", "1.26.2"]
# xds-target: ["server", "client"]
TOTAL_RUNNERS: 4
JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]'
Expand Down Expand Up @@ -273,7 +273,7 @@ jobs:
strategy:
fail-fast: false
matrix:
envoy-version: ["1.23.8", "1.24.6", "1.25.4", "1.26.0"]
envoy-version: ["1.23.10", "1.24.8", "1.25.7", "1.26.2"]
xds-target: ["server", "client"]
test-cases: ${{ fromJSON(needs.generate-envoy-job-matrices.outputs.envoy-matrix) }}
env:
Expand Down
11 changes: 11 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,18 @@ func (a *Agent) RPC(ctx context.Context, method string, args interface{}, reply
method = e + "." + p[1]
}
}

// audit log only on consul clients
_, ok := a.delegate.(*consul.Client)
if ok {
a.writeAuditRPCEvent(method, "OperationStart")
}

a.endpointsLock.RUnlock()

defer func() {
a.writeAuditRPCEvent(method, "OperationComplete")
}()
return a.delegate.RPC(ctx, method, args, reply)
}

Expand Down
10 changes: 4 additions & 6 deletions agent/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ import (
"strings"
"time"

"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-memdb"
"github.com/mitchellh/hashstructure"

"github.com/hashicorp/consul/envoyextensions/xdscommon"
"github.com/hashicorp/consul/version"

"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/serf/coordinate"
"github.com/hashicorp/serf/serf"
"github.com/mitchellh/hashstructure"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"

Expand All @@ -31,11 +27,13 @@ import (
"github.com/hashicorp/consul/agent/structs"
token_store "github.com/hashicorp/consul/agent/token"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/envoyextensions/xdscommon"
"github.com/hashicorp/consul/ipaddr"
"github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/logging"
"github.com/hashicorp/consul/logging/monitor"
"github.com/hashicorp/consul/types"
"github.com/hashicorp/consul/version"
)

type Self struct {
Expand Down
62 changes: 30 additions & 32 deletions agent/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import (
"time"

"github.com/armon/go-metrics"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/version"

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/serf/serf"
Expand All @@ -44,12 +40,14 @@ import (
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/agent/token"
tokenStore "github.com/hashicorp/consul/agent/token"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/envoyextensions/xdscommon"
"github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/hashicorp/consul/sdk/testutil/retry"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/types"
"github.com/hashicorp/consul/version"
)

func createACLTokenWithAgentReadPolicy(t *testing.T, srv *HTTPHandlers) string {
Expand Down Expand Up @@ -1822,7 +1820,7 @@ func TestAgent_ReloadDoesNotTriggerWatch(t *testing.T) {
for i := 1; i < 7; i++ {
contents, err := os.ReadFile(tmpFile)
if err != nil {
t.Fatalf("should be able to read file, but had: %#v", err)
r.Fatalf("should be able to read file, but had: %#v", err)
}
contentsStr = string(contents)
if contentsStr != "" {
Expand Down Expand Up @@ -1909,14 +1907,14 @@ func TestAgent_ReloadDoesNotTriggerWatch(t *testing.T) {
ensureNothingCritical(r, "red-is-dead")

if err := a.reloadConfigInternal(cfg2); err != nil {
t.Fatalf("got error %v want nil", err)
r.Fatalf("got error %v want nil", err)
}

// We check that reload does not go to critical
ensureNothingCritical(r, "red-is-dead")
ensureNothingCritical(r, "testing-agent-reload-001")

require.NoError(t, a.updateTTLCheck(checkID, api.HealthPassing, "testing-agent-reload-002"))
require.NoError(r, a.updateTTLCheck(checkID, api.HealthPassing, "testing-agent-reload-002"))

ensureNothingCritical(r, "red-is-dead")
})
Expand Down Expand Up @@ -2926,7 +2924,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/check/register", jsonReader(nodeCheck))
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusForbidden, resp.Code)
require.Equal(r, http.StatusForbidden, resp.Code)
})
})

Expand All @@ -2936,7 +2934,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req.Header.Add("X-Consul-Token", svcToken.SecretID)
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusForbidden, resp.Code)
require.Equal(r, http.StatusForbidden, resp.Code)
})
})

Expand All @@ -2946,7 +2944,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req.Header.Add("X-Consul-Token", nodeToken.SecretID)
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusOK, resp.Code)
require.Equal(r, http.StatusOK, resp.Code)
})
})

Expand All @@ -2955,7 +2953,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/check/register", jsonReader(svcCheck))
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusForbidden, resp.Code)
require.Equal(r, http.StatusForbidden, resp.Code)
})
})

Expand All @@ -2965,7 +2963,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req.Header.Add("X-Consul-Token", nodeToken.SecretID)
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusForbidden, resp.Code)
require.Equal(r, http.StatusForbidden, resp.Code)
})
})

Expand All @@ -2975,7 +2973,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
req.Header.Add("X-Consul-Token", svcToken.SecretID)
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusOK, resp.Code)
require.Equal(r, http.StatusOK, resp.Code)
})
})
}
Expand Down Expand Up @@ -5976,17 +5974,17 @@ func TestAgent_Monitor(t *testing.T) {
res := httptest.NewRecorder()
a.srv.h.ServeHTTP(res, registerReq)
if http.StatusOK != res.Code {
t.Fatalf("expected 200 but got %v", res.Code)
r.Fatalf("expected 200 but got %v", res.Code)
}

// Wait until we have received some type of logging output
require.Eventually(t, func() bool {
require.Eventually(r, func() bool {
return len(resp.Body.Bytes()) > 0
}, 3*time.Second, 100*time.Millisecond)

cancelFunc()
code := <-codeCh
require.Equal(t, http.StatusOK, code)
require.Equal(r, http.StatusOK, code)
got := resp.Body.String()

// Only check a substring that we are highly confident in finding
Expand Down Expand Up @@ -6026,11 +6024,11 @@ func TestAgent_Monitor(t *testing.T) {
res := httptest.NewRecorder()
a.srv.h.ServeHTTP(res, registerReq)
if http.StatusOK != res.Code {
t.Fatalf("expected 200 but got %v", res.Code)
r.Fatalf("expected 200 but got %v", res.Code)
}

// Wait until we have received some type of logging output
require.Eventually(t, func() bool {
require.Eventually(r, func() bool {
return len(resp.Body.Bytes()) > 0
}, 3*time.Second, 100*time.Millisecond)
cancelFunc()
Expand Down Expand Up @@ -6063,24 +6061,24 @@ func TestAgent_Monitor(t *testing.T) {
res := httptest.NewRecorder()
a.srv.h.ServeHTTP(res, registerReq)
if http.StatusOK != res.Code {
t.Fatalf("expected 200 but got %v", res.Code)
r.Fatalf("expected 200 but got %v", res.Code)
}

// Wait until we have received some type of logging output
require.Eventually(t, func() bool {
require.Eventually(r, func() bool {
return len(resp.Body.Bytes()) > 0
}, 3*time.Second, 100*time.Millisecond)

cancelFunc()
code := <-codeCh
require.Equal(t, http.StatusOK, code)
require.Equal(r, http.StatusOK, code)

// Each line is output as a separate JSON object, we grab the first and
// make sure it can be unmarshalled.
firstLine := bytes.Split(resp.Body.Bytes(), []byte("\n"))[0]
var output map[string]interface{}
if err := json.Unmarshal(firstLine, &output); err != nil {
t.Fatalf("err: %v", err)
r.Fatalf("err: %v", err)
}
})
})
Expand Down Expand Up @@ -6672,7 +6670,7 @@ func TestAgentConnectCARoots_list(t *testing.T) {

dec := json.NewDecoder(resp.Body)
value := &structs.IndexedCARoots{}
require.NoError(t, dec.Decode(value))
require.NoError(r, dec.Decode(value))
if ca.ID != value.ActiveRootID {
r.Fatalf("%s != %s", ca.ID, value.ActiveRootID)
}
Expand Down Expand Up @@ -7080,7 +7078,7 @@ func TestAgentConnectCALeafCert_goodNotLocal(t *testing.T) {

dec := json.NewDecoder(resp.Body)
issued2 := &structs.IssuedCert{}
require.NoError(t, dec.Decode(issued2))
require.NoError(r, dec.Decode(issued2))
if issued.CertPEM == issued2.CertPEM {
r.Fatalf("leaf has not updated")
}
Expand All @@ -7092,9 +7090,9 @@ func TestAgentConnectCALeafCert_goodNotLocal(t *testing.T) {
}

// Verify that the cert is signed by the new CA
requireLeafValidUnderCA(t, issued2, ca)
requireLeafValidUnderCA(r, issued2, ca)

require.NotEqual(t, issued, issued2)
require.NotEqual(r, issued, issued2)
})
}
}
Expand Down Expand Up @@ -7471,11 +7469,11 @@ func TestAgentConnectCALeafCert_secondaryDC_good(t *testing.T) {
// Try and sign again (note no index/wait arg since cache should update in
// background even if we aren't actively blocking)
a2.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusOK, resp.Code)
require.Equal(r, http.StatusOK, resp.Code)

dec := json.NewDecoder(resp.Body)
issued2 := &structs.IssuedCert{}
require.NoError(t, dec.Decode(issued2))
require.NoError(r, dec.Decode(issued2))
if issued.CertPEM == issued2.CertPEM {
r.Fatalf("leaf has not updated")
}
Expand All @@ -7487,9 +7485,9 @@ func TestAgentConnectCALeafCert_secondaryDC_good(t *testing.T) {
}

// Verify that the cert is signed by the new CA
requireLeafValidUnderCA(t, issued2, dc1_ca2)
requireLeafValidUnderCA(r, issued2, dc1_ca2)

require.NotEqual(t, issued, issued2)
require.NotEqual(r, issued, issued2)
})
}

Expand All @@ -7499,12 +7497,12 @@ func waitForActiveCARoot(t *testing.T, srv *HTTPHandlers, expect *structs.CARoot
resp := httptest.NewRecorder()
srv.h.ServeHTTP(resp, req)
if http.StatusOK != resp.Code {
t.Fatalf("expected 200 but got %v", resp.Code)
r.Fatalf("expected 200 but got %v", resp.Code)
}

dec := json.NewDecoder(resp.Body)
roots := &structs.IndexedCARoots{}
require.NoError(t, dec.Decode(roots))
require.NoError(r, dec.Decode(roots))

var root *structs.CARoot
for _, r := range roots.Roots {
Expand Down
4 changes: 4 additions & 0 deletions agent/agent_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ func (a *Agent) AgentEnterpriseMeta() *acl.EnterpriseMeta {
func (a *Agent) registerEntCache() {}

func (*Agent) fillEnterpriseProxyDataSources(*proxycfg.DataSources) {}

func (a *Agent) writeAuditRPCEvent(_ string, _ string) interface{} {
return nil
}
5 changes: 3 additions & 2 deletions agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,9 @@ type ConfigEntries struct {

// Audit allows us to enable and define destinations for auditing
type Audit struct {
Enabled *bool `mapstructure:"enabled"`
Sinks map[string]AuditSink `mapstructure:"sink"`
Enabled *bool `mapstructure:"enabled"`
Sinks map[string]AuditSink `mapstructure:"sink"`
RPCEnabled *bool `mapstructure:"rpc_enabled"`
}

// AuditSink can be provided multiple times to define pipelines for auditing
Expand Down
Loading

0 comments on commit 585c57f

Please sign in to comment.