diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index ecb48e8..9ccc497 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -67,8 +67,8 @@ jobs: - alpine_3.10 - alpine_3.11 - alpine_3.12 - - centos_7 - - centos_8 + - rhel_7 + - rhel_8 - amazonlinux_2 - ubuntu_18.04 - ubuntu_20.04 diff --git a/Makefile b/Makefile index bafd55a..7366633 100644 --- a/Makefile +++ b/Makefile @@ -83,17 +83,3 @@ install-tools: ## Install all the dependencies under the tools module .PHONY: check-vanity-import check-vanity-import: @porto --skip-files "version.go" -l . - -.PHONY: install-libtraceable-downloader -install-libtraceable-downloader: - cd ./filter/traceable/cmd/libtraceable-downloader && \ - go build -o "${GOPATH}/bin/libtraceable-downloader" . - -.PHONY: pull-libtraceable-headers -pull-libtraceable-headers: install-libtraceable-downloader - ${GOPATH}/bin/libtraceable-downloader pull-library-headers "./filter/traceable" - -.PHONY: pull-libtraceable-libs -pull-libtraceable-libs: install-libtraceable-downloader - ${GOPATH}/bin/libtraceable-downloader pull-library-lib centos_7 "./filter/traceable/libs/linux_amd64" - ${GOPATH}/bin/libtraceable-downloader pull-library-lib alpine_3.9 "./filter/traceable/libs/linux_amd64-alpine" diff --git a/README.md b/README.md index c59ceed..71043cb 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,17 @@ Config values can be declared in config file, env variables or code. For further ### Traceable filter -By default, `goagent` includes the [Traceable filter](./filter/traceable) into server instrumentation (e.g. HTTP server or GRPC server) +By default, `goagent` includes the [Traceable filter](./filter/traceable) into the server instrumentation (e.g. HTTP server or GRPC server) based on the [configuration features](https://github.com/Traceableai/agent-config/blob/main/proto/ai/traceable/agent/config/v1/config.proto#L29). To run Traceable filter we need to: -Fist compile the binary using the build tag `traceable_filter`, for example: +First compile the binary using the build tag `traceable_filter`, for example: ```bash go build -tags 'traceable_filter' -o /path-to-app/myapp ``` -Then, copy the library in the same folder as the compiled binary: +Then, copy the library into the same folder as the compiled binary: ```bash curl -sSL https://raw.githubusercontent.com/Traceableai/goagent/main/filter/traceable/copy-library.sh | bash -s -- /path-to-app diff --git a/_examples/grpc-client/go.sum b/_examples/grpc-client/go.sum index 54138f8..1e0faee 100644 --- a/_examples/grpc-client/go.sum +++ b/_examples/grpc-client/go.sum @@ -8,8 +8,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -53,12 +53,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -108,10 +106,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_examples/grpc-server/go.sum b/_examples/grpc-server/go.sum index 54138f8..1e0faee 100644 --- a/_examples/grpc-server/go.sum +++ b/_examples/grpc-server/go.sum @@ -8,8 +8,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -53,12 +53,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -108,10 +106,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_examples/http-client/go.sum b/_examples/http-client/go.sum index 7e415da..001a15d 100644 --- a/_examples/http-client/go.sum +++ b/_examples/http-client/go.sum @@ -7,8 +7,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -53,12 +53,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -108,10 +106,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_examples/http-server/go.sum b/_examples/http-server/go.sum index dc42759..b452c5e 100644 --- a/_examples/http-server/go.sum +++ b/_examples/http-server/go.sum @@ -7,8 +7,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -53,12 +53,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -109,10 +107,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_examples/mux-server/go.sum b/_examples/mux-server/go.sum index dc42759..b452c5e 100644 --- a/_examples/mux-server/go.sum +++ b/_examples/mux-server/go.sum @@ -7,8 +7,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -53,12 +53,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -109,10 +107,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_tests/go.sum b/_tests/go.sum index 530f048..8bde33f 100644 --- a/_tests/go.sum +++ b/_tests/go.sum @@ -7,8 +7,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -52,12 +52,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -107,10 +105,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/_tests/main.go b/_tests/main.go index ee4ccc0..a9d8e22 100644 --- a/_tests/main.go +++ b/_tests/main.go @@ -30,7 +30,17 @@ func main() { _, s, ender := goagent.StartSpan(context.Background(), "test") defer ender() - _ = f.EvaluateBody(s, []byte("my_body"), map[string][]string{ + // This run time test does not block because there isn't OPA. For now, we + // must eyeball that the libtraceable debug output passes the right + // attributes to the respective calls: + // process_request_headers + // process_request_body + _ = f.EvaluateURLAndHeaders(s, "http://abc.com", map[string][]string{ + "x-forwarded-for": []string{"83.39.254.157"}, // arbitrary non local test IP + "http.request.headers.a": []string{"/usr/bin/perl"}, + }) + + _ = f.EvaluateBody(s, []byte("{\"bad_body\":\"/usr/bin/perl\""), map[string][]string{ "x-forwarded-for": []string{"83.39.254.157"}, // arbitrary non local test IP }) if !f.Stop() { diff --git a/config/defaults.go b/config/defaults.go index 44f5ed3..0ca8cc2 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -27,7 +27,8 @@ var defaultConfig = &AgentConfig{ Request: hyperconfig.Bool(true), Response: hyperconfig.Bool(true), }, - BodyMaxSizeBytes: hyperconfig.Int32(131072), + BodyMaxSizeBytes: hyperconfig.Int32(131072), + BodyMaxProcessingSizeBytes: hyperconfig.Int32(1048576), }, Reporting: &hyperconfig.Reporting{ Endpoint: hyperconfig.String("localhost:4317"), diff --git a/config/loaders_test.go b/config/loaders_test.go index 1aef071..635ec96 100644 --- a/config/loaders_test.go +++ b/config/loaders_test.go @@ -18,6 +18,8 @@ func TestLoadWithDefaults(t *testing.T) { assert.Equal(t, true, cfg.Tracing.DataCapture.HttpBody.Request.Value) assert.Equal(t, true, cfg.Tracing.DataCapture.HttpBody.Response.Value) + assert.Equal(t, int32(131072), cfg.Tracing.DataCapture.BodyMaxSizeBytes.Value) + assert.Equal(t, int32(1048576), cfg.Tracing.DataCapture.BodyMaxProcessingSizeBytes.Value) } func TestLoadFromFile(t *testing.T) { diff --git a/filter/traceable/blocking.h b/filter/traceable/blocking.h deleted file mode 100644 index d7eefef..0000000 --- a/filter/traceable/blocking.h +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - const char* key; - const char* value; -} traceable_attribute; - -typedef struct { - int count; - const traceable_attribute* attribute_array; -} traceable_attributes; - -typedef enum { TRACEABLE_LOG_NONE, TRACEABLE_LOG_STDOUT } TRACEABLE_LOG_MODE; - -typedef struct { - TRACEABLE_LOG_MODE mode; -} traceable_log_configuration; - -typedef struct { - const char* opa_server_url; - const char* logging_dir; - const char* logging_file_prefix; - const char* cert_file; - int log_to_console; - int skip_verify; - int min_delay; - int max_delay; - int debug_log; -} traceable_opa_config; - -typedef struct { - int enabled; -} traceable_modsecurity_config; - -typedef struct { - int enabled; -} traceable_rangeblocking_config; - -typedef struct { - int enabled; - const char* remote_endpoint; - int poll_period_sec; - const char* cert_file; -} traceable_remote_config; - -typedef struct { - traceable_log_configuration log_config; - traceable_opa_config opa_config; - traceable_modsecurity_config modsecurity_config; - traceable_rangeblocking_config rb_config; - traceable_remote_config remote_config; - int evaluate_body; - int skip_internal_request; -} traceable_blocking_config; - -typedef struct { - int block; - traceable_attributes attributes; -} traceable_block_result; - -typedef enum { TRACEABLE_SUCCESS, TRACEABLE_FAIL } TRACEABLE_RET; - -typedef void* traceable_blocking_engine; - -TRACEABLE_RET traceable_new_blocking_engine( - traceable_blocking_config blocking_config, - traceable_blocking_engine* out_blocking_engine); - -TRACEABLE_RET traceable_start_blocking_engine( - traceable_blocking_engine blocking_engine); - -TRACEABLE_RET traceable_block_request(traceable_blocking_engine blocking_engine, - traceable_attributes attributes, - traceable_block_result* out_block_result); - -TRACEABLE_RET traceable_block_request_headers( - traceable_blocking_engine blocking_engine, traceable_attributes attributes, - traceable_block_result* out_block_result); - -TRACEABLE_RET traceable_block_request_body( - traceable_blocking_engine blocking_engine, traceable_attributes attributes, - traceable_block_result* out_block_result); - -TRACEABLE_RET traceable_delete_block_result_data(traceable_block_result result); - -TRACEABLE_RET traceable_delete_blocking_engine( - traceable_blocking_engine blocking_engine); - -#ifdef __cplusplus -} -#endif diff --git a/filter/traceable/filter.go b/filter/traceable/filter.go index 53d2266..c6ef368 100644 --- a/filter/traceable/filter.go +++ b/filter/traceable/filter.go @@ -12,58 +12,73 @@ package traceable // import "github.com/Traceableai/goagent/filter/traceable" /* #cgo CFLAGS: -I./ #cgo LDFLAGS: -Wl,-rpath=\$ORIGIN -ldl -#include "blocking.h" +#include "libtraceable.h" #include #include -typedef TRACEABLE_RET (*traceable_new_blocking_engine_type)(traceable_blocking_config,traceable_blocking_engine*); +typedef TRACEABLE_RET (*traceable_new_libtraceable_type)(traceable_libtraceable_config, traceable_libtraceable*); -TRACEABLE_RET w_traceable_new_blocking_engine( +TRACEABLE_RET w_traceable_new_libtraceable( void* f, - traceable_blocking_config blocking_config, - traceable_blocking_engine* out_blocking_engine + traceable_libtraceable_config config, + traceable_libtraceable* out_libtraceable ) { - return ((traceable_new_blocking_engine_type) f)(blocking_config, out_blocking_engine); + return ((traceable_new_libtraceable_type) f)(config, out_libtraceable); } -typedef TRACEABLE_RET (*traceable_start_blocking_engine_type)(traceable_blocking_engine); +typedef TRACEABLE_RET (*traceable_start_libtraceable_type)(traceable_libtraceable); -TRACEABLE_RET w_traceable_start_blocking_engine ( - traceable_start_blocking_engine_type f, - traceable_blocking_engine blocking_engine +TRACEABLE_RET w_traceable_start_libtraceable ( + traceable_start_libtraceable_type f, + traceable_libtraceable libtraceable ) { - return f(blocking_engine); + return f(libtraceable); } -typedef TRACEABLE_RET (*traceable_delete_blocking_engine_type)(traceable_blocking_engine); +typedef TRACEABLE_RET (*traceable_delete_libtraceable_type)(traceable_libtraceable); -TRACEABLE_RET w_traceable_delete_blocking_engine ( - traceable_delete_blocking_engine_type f, - traceable_blocking_engine blocking_engine +TRACEABLE_RET w_traceable_delete_libtraceable ( + traceable_delete_libtraceable_type f, + traceable_libtraceable libtraceable ) { - return f(blocking_engine); + return f(libtraceable); } -typedef TRACEABLE_RET (*traceable_block_request_type)( - traceable_blocking_engine, +typedef TRACEABLE_RET (*traceable_process_request_headers_type)( + traceable_libtraceable, traceable_attributes, - traceable_block_result* + traceable_process_request_result* ); -TRACEABLE_RET w_traceable_block_request ( - traceable_block_request_type f, - traceable_blocking_engine blocking_engine, +TRACEABLE_RET w_traceable_process_request_headers ( + traceable_process_request_headers_type f, + traceable_libtraceable libtraceable, traceable_attributes attributes, - traceable_block_result* out_block_result + traceable_process_request_result* out_result ) { - return f(blocking_engine, attributes, out_block_result); + return f(libtraceable, attributes, out_result); } -typedef TRACEABLE_RET (*traceable_delete_block_result_data_type)(traceable_block_result); +typedef TRACEABLE_RET (*traceable_process_request_body_type)( + traceable_libtraceable, + traceable_attributes, + traceable_process_request_result* +); + +TRACEABLE_RET w_traceable_process_request_body ( + traceable_process_request_body_type f, + traceable_libtraceable libtraceable, + traceable_attributes attributes, + traceable_process_request_result* out_result +) { + return f(libtraceable, attributes, out_result); +} + +typedef TRACEABLE_RET (*traceable_delete_process_request_result_data_type)(traceable_process_request_result); -TRACEABLE_RET w_traceable_delete_block_result_data ( - traceable_delete_block_result_data_type f, - traceable_block_result result +TRACEABLE_RET w_traceable_delete_process_request_result_data ( + traceable_delete_process_request_result_data_type f, + traceable_process_request_result result ) { return f(result); } @@ -87,22 +102,23 @@ const defaultAgentManagerEndpoint = "localhost:5441" const defaultPollPeriodSec = 30 type Filter struct { - blockingEngine C.traceable_blocking_engine - blockingLib *blocking - started bool - logger *zap.Logger + libtraceableHandle C.traceable_libtraceable + libtraceable *libtraceableMethods + started bool + logger *zap.Logger } -type blocking struct { - startEngine C.traceable_start_blocking_engine_type - deleteEngine C.traceable_delete_blocking_engine_type - blockRequest C.traceable_block_request_type - deleteBlockResultData C.traceable_delete_block_result_data_type +type libtraceableMethods struct { + startEngine C.traceable_start_libtraceable_type + deleteEngine C.traceable_delete_libtraceable_type + processRequestHeaders C.traceable_process_request_headers_type + processRequestBody C.traceable_process_request_body_type + deleteProcessResultData C.traceable_delete_process_request_result_data_type } var _ filter.Filter = (*Filter)(nil) -// NewFilter creates libtraceable based blocking filter +// NewFilter creates libtraceable based filter func NewFilter(config *traceableconfig.AgentConfig, logger *zap.Logger) *Filter { blockingConfig := config.BlockingConfig @@ -120,7 +136,9 @@ func NewFilter(config *traceableconfig.AgentConfig, logger *zap.Logger) *Filter return &Filter{logger: logger} } - blockingLib := C.dlopen(C.CString(libPath), C.RTLD_NOW) + cStrLibPath := C.CString(libPath) + defer C.free(unsafe.Pointer(cStrLibPath)) + libHandle := C.dlopen(cStrLibPath, C.RTLD_NOW) if err := C.dlerror(); err != nil { logger.Warn( "Traceable filter is disabled because library can't be loaded", @@ -133,11 +151,13 @@ func NewFilter(config *traceableconfig.AgentConfig, logger *zap.Logger) *Filter libTraceableConfig := getLibTraceableConfig(config) defer freeLibTraceableConfig(libTraceableConfig) - var blockingFilter Filter - res := C.w_traceable_new_blocking_engine( - C.dlsym(blockingLib, C.CString("traceable_new_blocking_engine")), + var traceableFilter Filter + cStrNewLibtraceable := C.CString("traceable_new_libtraceable") + defer C.free(unsafe.Pointer(cStrNewLibtraceable)) + res := C.w_traceable_new_libtraceable( + C.dlsym(libHandle, cStrNewLibtraceable), libTraceableConfig, - &blockingFilter.blockingEngine, + &traceableFilter.libtraceableHandle, ) if res != C.TRACEABLE_SUCCESS { logger.Warn( @@ -147,8 +167,8 @@ func NewFilter(config *traceableconfig.AgentConfig, logger *zap.Logger) *Filter return &Filter{logger: logger} } - blockingFilter.logger = logger - blockingFilter.blockingLib, err = loadBlockingLibMethods(blockingLib) + traceableFilter.logger = logger + traceableFilter.libtraceable, err = loadLibtraceableMethods(libHandle) if err != nil { logger.Warn("Traceable filter is disabled.", zap.Error(err)) return &Filter{logger: logger} @@ -159,34 +179,50 @@ func NewFilter(config *traceableconfig.AgentConfig, logger *zap.Logger) *Filter zap.String("traceableai.goagent.lib_path", libPath), ) - return &blockingFilter + return &traceableFilter } -func loadBlockingLibMethods(blockingLib unsafe.Pointer) (*blocking, error) { - b := blocking{} +func loadLibtraceableMethods(libHandle unsafe.Pointer) (*libtraceableMethods, error) { + b := libtraceableMethods{} - if startEngine := C.dlsym(blockingLib, C.CString("traceable_start_blocking_engine")); startEngine == nil { - return nil, errors.New("failed to load traceable_start_blocking_engine") + cStrStartLibtraceable := C.CString("traceable_start_libtraceable") + defer C.free(unsafe.Pointer(cStrStartLibtraceable)) + if startEngine := C.dlsym(libHandle, cStrStartLibtraceable); startEngine == nil { + return nil, errors.New("failed to load traceable_start_libtraceable") } else { - b.startEngine = C.traceable_start_blocking_engine_type(startEngine) + b.startEngine = C.traceable_start_libtraceable_type(startEngine) } - if deleteEngine := C.dlsym(blockingLib, C.CString("traceable_delete_blocking_engine")); deleteEngine == nil { - return nil, errors.New("failed to load traceable_delete_blocking_engine") + cStrDeleteLibtraceable := C.CString("traceable_delete_libtraceable") + defer C.free(unsafe.Pointer(cStrDeleteLibtraceable)) + if deleteEngine := C.dlsym(libHandle, cStrDeleteLibtraceable); deleteEngine == nil { + return nil, errors.New("failed to load traceable_delete_libtraceable") } else { - b.deleteEngine = C.traceable_delete_blocking_engine_type(deleteEngine) + b.deleteEngine = C.traceable_delete_libtraceable_type(deleteEngine) } - if blockRequest := C.dlsym(blockingLib, C.CString("traceable_block_request")); blockRequest == nil { - return nil, errors.New("failed to load traceable_block_request") + cStrProcessRequestHeaders := C.CString("traceable_process_request_headers") + defer C.free(unsafe.Pointer(cStrProcessRequestHeaders)) + if processRequestHeaders := C.dlsym(libHandle, cStrProcessRequestHeaders); processRequestHeaders == nil { + return nil, errors.New("failed to load traceable_process_request_headers") } else { - b.blockRequest = C.traceable_block_request_type(blockRequest) + b.processRequestHeaders = C.traceable_process_request_headers_type(processRequestHeaders) } - if deleteBlockResultData := C.dlsym(blockingLib, C.CString("traceable_delete_block_result_data")); deleteBlockResultData == nil { - return nil, errors.New("failed to load traceable_delete_block_result_data") + cStrProcessRequestBody := C.CString("traceable_process_request_body") + defer C.free(unsafe.Pointer(cStrProcessRequestBody)) + if processRequestBody := C.dlsym(libHandle, cStrProcessRequestBody); processRequestBody == nil { + return nil, errors.New("failed to load traceable_process_request_body") } else { - b.deleteBlockResultData = C.traceable_delete_block_result_data_type(deleteBlockResultData) + b.processRequestBody = C.traceable_process_request_body_type(processRequestBody) + } + + cStrDeleteProcessRequestResultData := C.CString("traceable_delete_process_request_result_data") + defer C.free(unsafe.Pointer(cStrDeleteProcessRequestResultData)) + if deleteProcessResultData := C.dlsym(libHandle, cStrDeleteProcessRequestResultData); deleteProcessResultData == nil { + return nil, errors.New("failed to load traceable_delete_process_request_result_data") + } else { + b.deleteProcessResultData = C.traceable_delete_process_request_result_data_type(deleteProcessResultData) } return &b, nil @@ -194,30 +230,30 @@ func loadBlockingLibMethods(blockingLib unsafe.Pointer) (*blocking, error) { // Start() starts the threads to poll config func (f *Filter) Start() bool { - if f.blockingEngine != nil { - ret := C.w_traceable_start_blocking_engine(f.blockingLib.startEngine, f.blockingEngine) + if f.libtraceableHandle != nil { + ret := C.w_traceable_start_libtraceable(f.libtraceable.startEngine, f.libtraceableHandle) if ret == C.TRACEABLE_SUCCESS { f.started = true return true } - f.logger.Warn("Failed to start blocking engine") + f.logger.Warn("Failed to start libtraceable") return false } - f.logger.Debug("Filter started as NOOP because of null blocking engine") + f.logger.Debug("Filter started as NOOP because of null libtraceable") return true } func (f *Filter) Stop() bool { - if f.blockingEngine != nil { - ret := C.w_traceable_delete_blocking_engine(f.blockingLib.deleteEngine, f.blockingEngine) + if f.libtraceableHandle != nil { + ret := C.w_traceable_delete_libtraceable(f.libtraceable.deleteEngine, f.libtraceableHandle) if ret == C.TRACEABLE_SUCCESS { f.started = false return true } - f.logger.Warn("Failed to stop blocking engine") + f.logger.Warn("Failed to delete libtraceable") return false } @@ -290,25 +326,45 @@ func (f *Filter) EvaluateBody(span sdk.Span, body []byte, headers map[string][]s // evaluate is a common function that calls into libtraceable // and returns block result attributes to be added to span. +// true : block +// false : do not block func (f *Filter) evaluate(span sdk.Span, attributes map[string]string) bool { inputLibTraceableAttributes := createLibTraceableAttributes(attributes) defer freeLibTraceableAttributes(inputLibTraceableAttributes) - var blockResult C.traceable_block_result - ret := C.w_traceable_block_request(f.blockingLib.blockRequest, f.blockingEngine, inputLibTraceableAttributes, &blockResult) - defer C.w_traceable_delete_block_result_data(f.blockingLib.deleteBlockResultData, blockResult) + var processHeadersResult C.traceable_process_request_result + ret := C.w_traceable_process_request_headers(f.libtraceable.processRequestHeaders, f.libtraceableHandle, inputLibTraceableAttributes, &processHeadersResult) + defer C.w_traceable_delete_process_request_result_data(f.libtraceable.deleteProcessResultData, processHeadersResult) + // if call fails just return false + if ret != C.TRACEABLE_SUCCESS { + f.logger.Debug("Failed to evaluate header attributes") + return false + } + + outputAttributes := fromLibTraceableAttributes(processHeadersResult.attributes) + for k, v := range outputAttributes { + span.SetAttribute(k, v) + } + + if processHeadersResult.block != 0 { + return true + } + + var processBodyResult C.traceable_process_request_result + ret = C.w_traceable_process_request_body(f.libtraceable.processRequestBody, f.libtraceableHandle, inputLibTraceableAttributes, &processBodyResult) + defer C.w_traceable_delete_process_request_result_data(f.libtraceable.deleteProcessResultData, processBodyResult) // if call fails just return false if ret != C.TRACEABLE_SUCCESS { - f.logger.Debug("Failed to evaluate attributes") + f.logger.Debug("Failed to evaluate body attributes") return false } - outputAttributes := fromLibTraceableAttributes(blockResult.attributes) + outputAttributes = fromLibTraceableAttributes(processBodyResult.attributes) for k, v := range outputAttributes { span.SetAttribute(k, v) } - return blockResult.block != 0 + return processBodyResult.block != 0 } // createTraceableAttributes converts map of attributes into C.traceable_attributes @@ -353,7 +409,7 @@ func fromLibTraceableAttributes(attributes C.traceable_attributes) map[string]st return m } -func getLibTraceableConfig(config *traceableconfig.AgentConfig) C.traceable_blocking_config { +func getLibTraceableConfig(config *traceableconfig.AgentConfig) C.traceable_libtraceable_config { blocking, opa := config.BlockingConfig, config.Opa // debug log off by default @@ -368,6 +424,36 @@ func getLibTraceableConfig(config *traceableconfig.AgentConfig) C.traceable_bloc mode: libTraceableLogMode, } + remoteConfigEnabled := 1 + remoteConfigEndpoint := defaultAgentManagerEndpoint + remoteConfigPollPeriodSec := defaultPollPeriodSec + remoteConfigCertFile := "" + if blocking.GetRemoteConfig() != nil { + remoteConfig := blocking.GetRemoteConfig() + if remoteConfig.Enabled != nil && !remoteConfig.GetEnabled().GetValue() { + remoteConfigEnabled = 0 + remoteConfigEndpoint = "" + } else { + if remoteConfig.GetEndpoint().GetValue() != "" { + remoteConfigEndpoint = remoteConfig.GetEndpoint().GetValue() + } + if remoteConfig.GetPollPeriodSeconds() != nil && remoteConfig.GetPollPeriodSeconds().GetValue() != 0 { + remoteConfigPollPeriodSec = int(remoteConfig.GetPollPeriodSeconds().GetValue()) + } + if remoteConfig.GetCertFile() != nil { + remoteConfigCertFile = remoteConfig.GetCertFile().GetValue() + } + } + } + + remoteConfig := C.traceable_remote_config{ + enabled: C.int(remoteConfigEnabled), + remote_endpoint: C.CString(remoteConfigEndpoint), + poll_period_sec: C.int(remoteConfigPollPeriodSec), + cert_file: C.CString(remoteConfigCertFile), + } + + blockingEnabled := 1 opaCertFile := "" if opa.CertFile != nil { opaCertFile = opa.CertFile.Value @@ -409,35 +495,6 @@ func getLibTraceableConfig(config *traceableconfig.AgentConfig) C.traceable_bloc enabled: C.int(regionBlockingEnabled), } - blockingRemoteConfigEnabled := 1 - blockingRemoteConfigEndpoint := defaultAgentManagerEndpoint - blockingRemoteConfigPollPeriodSec := defaultPollPeriodSec - blockingRemoteConfigCertFile := "" - if blocking.GetRemoteConfig() != nil { - remoteConfig := blocking.GetRemoteConfig() - if remoteConfig.Enabled != nil && !remoteConfig.GetEnabled().GetValue() { - blockingRemoteConfigEnabled = 0 - blockingRemoteConfigEndpoint = "" - } else { - if remoteConfig.GetEndpoint().GetValue() != "" { - blockingRemoteConfigEndpoint = remoteConfig.GetEndpoint().GetValue() - } - if remoteConfig.GetPollPeriodSeconds() != nil && remoteConfig.GetPollPeriodSeconds().GetValue() != 0 { - blockingRemoteConfigPollPeriodSec = int(remoteConfig.GetPollPeriodSeconds().GetValue()) - } - if remoteConfig.GetCertFile() != nil { - blockingRemoteConfigCertFile = remoteConfig.GetCertFile().GetValue() - } - } - } - - blockingRemoteConfig := C.traceable_remote_config{ - enabled: C.int(blockingRemoteConfigEnabled), - remote_endpoint: C.CString(blockingRemoteConfigEndpoint), - poll_period_sec: C.int(blockingRemoteConfigPollPeriodSec), - cert_file: C.CString(blockingRemoteConfigCertFile), - } - evaluateBody := 1 if blocking.EvaluateBody != nil && !blocking.EvaluateBody.Value { evaluateBody = 0 @@ -448,22 +505,37 @@ func getLibTraceableConfig(config *traceableconfig.AgentConfig) C.traceable_bloc skipInternalRequest = 0 } - return C.traceable_blocking_config{ - log_config: logConfig, + blockingConfig := C.traceable_blocking_config{ + enabled: C.int(blockingEnabled), opa_config: opaConfig, modsecurity_config: modsecurityConfig, rb_config: regionBlockingConfig, evaluate_body: C.int(evaluateBody), - remote_config: blockingRemoteConfig, skip_internal_request: C.int(skipInternalRequest), } + + serviceName := "" + agentConfig := C.traceable_agent_config{ + service_name: C.CString(serviceName), + } + + return C.traceable_libtraceable_config{ + log_config: logConfig, + remote_config: remoteConfig, + blocking_config: blockingConfig, + agent_config: agentConfig, + } + } -func freeLibTraceableConfig(config C.traceable_blocking_config) { - C.free(unsafe.Pointer(config.opa_config.opa_server_url)) - C.free(unsafe.Pointer(config.opa_config.logging_dir)) - C.free(unsafe.Pointer(config.opa_config.logging_file_prefix)) +func freeLibTraceableConfig(config C.traceable_libtraceable_config) { C.free(unsafe.Pointer(config.remote_config.remote_endpoint)) + C.free(unsafe.Pointer(config.remote_config.cert_file)) + C.free(unsafe.Pointer(config.blocking_config.opa_config.opa_server_url)) + C.free(unsafe.Pointer(config.blocking_config.opa_config.logging_dir)) + C.free(unsafe.Pointer(config.blocking_config.opa_config.logging_file_prefix)) + C.free(unsafe.Pointer(config.blocking_config.opa_config.cert_file)) + C.free(unsafe.Pointer(config.agent_config.service_name)) } func getSliceFromCTraceableAttributes(attributes C.traceable_attributes) []C.traceable_attribute { diff --git a/filter/traceable/filter_test.go b/filter/traceable/filter_test.go index a081bad..d38175e 100644 --- a/filter/traceable/filter_test.go +++ b/filter/traceable/filter_test.go @@ -79,17 +79,17 @@ func TestGetLibTraceableConfig(t *testing.T) { }, ) - assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.opa_config.opa_server_url)) + assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.blocking_config.opa_config.opa_server_url)) assert.Equal(t, 0, int(libTraceableConfig.log_config.mode)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.min_delay)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.max_delay)) - assert.Equal(t, 1, int(libTraceableConfig.opa_config.log_to_console)) - assert.Equal(t, 0, int(libTraceableConfig.opa_config.debug_log)) - assert.Equal(t, 0, int(libTraceableConfig.opa_config.skip_verify)) - assert.Equal(t, 1, int(libTraceableConfig.modsecurity_config.enabled)) - assert.Equal(t, 1, int(libTraceableConfig.evaluate_body)) - assert.Equal(t, 1, int(libTraceableConfig.skip_internal_request)) - assert.Equal(t, 1, int(libTraceableConfig.rb_config.enabled)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.min_delay)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.max_delay)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.opa_config.log_to_console)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.opa_config.debug_log)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.opa_config.skip_verify)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.modsecurity_config.enabled)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.evaluate_body)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.skip_internal_request)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.rb_config.enabled)) assert.Equal(t, 1, int(libTraceableConfig.remote_config.enabled)) assert.Equal(t, "localhost:5441", getGoString(libTraceableConfig.remote_config.remote_endpoint)) assert.Equal(t, 30, int(libTraceableConfig.remote_config.poll_period_sec)) @@ -121,18 +121,18 @@ func TestGetLibTraceableConfig(t *testing.T) { }, ) - assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.opa_config.opa_server_url)) + assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.blocking_config.opa_config.opa_server_url)) assert.Equal(t, 1, int(libTraceableConfig.log_config.mode)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.min_delay)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.max_delay)) - assert.Equal(t, 1, int(libTraceableConfig.opa_config.log_to_console)) - assert.Equal(t, 1, int(libTraceableConfig.opa_config.debug_log)) - assert.Equal(t, 0, int(libTraceableConfig.opa_config.skip_verify)) - assert.Equal(t, "/conf/tls.crt", getGoString(libTraceableConfig.opa_config.cert_file)) - assert.Equal(t, 0, int(libTraceableConfig.modsecurity_config.enabled)) - assert.Equal(t, 0, int(libTraceableConfig.evaluate_body)) - assert.Equal(t, 0, int(libTraceableConfig.skip_internal_request)) - assert.Equal(t, 0, int(libTraceableConfig.rb_config.enabled)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.min_delay)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.max_delay)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.opa_config.log_to_console)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.opa_config.debug_log)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.opa_config.skip_verify)) + assert.Equal(t, "/conf/tls.crt", getGoString(libTraceableConfig.blocking_config.opa_config.cert_file)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.modsecurity_config.enabled)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.evaluate_body)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.skip_internal_request)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.rb_config.enabled)) assert.Equal(t, 0, int(libTraceableConfig.remote_config.enabled)) assert.Equal(t, "", getGoString(libTraceableConfig.remote_config.remote_endpoint)) assert.Equal(t, "", getGoString(libTraceableConfig.remote_config.cert_file)) @@ -154,17 +154,17 @@ func TestGetLibTraceableConfig(t *testing.T) { }, ) - assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.opa_config.opa_server_url)) + assert.Equal(t, "http://opa:8181", getGoString(libTraceableConfig.blocking_config.opa_config.opa_server_url)) assert.Equal(t, 0, int(libTraceableConfig.log_config.mode)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.min_delay)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.max_delay)) - assert.Equal(t, 1, int(libTraceableConfig.opa_config.log_to_console)) - assert.Equal(t, 0, int(libTraceableConfig.opa_config.debug_log)) - assert.Equal(t, 0, int(libTraceableConfig.opa_config.skip_verify)) - assert.Equal(t, 1, int(libTraceableConfig.modsecurity_config.enabled)) - assert.Equal(t, 1, int(libTraceableConfig.evaluate_body)) - assert.Equal(t, 1, int(libTraceableConfig.skip_internal_request)) - assert.Equal(t, 1, int(libTraceableConfig.rb_config.enabled)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.min_delay)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.max_delay)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.opa_config.log_to_console)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.opa_config.debug_log)) + assert.Equal(t, 0, int(libTraceableConfig.blocking_config.opa_config.skip_verify)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.modsecurity_config.enabled)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.evaluate_body)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.skip_internal_request)) + assert.Equal(t, 1, int(libTraceableConfig.blocking_config.rb_config.enabled)) assert.Equal(t, 1, int(libTraceableConfig.remote_config.enabled)) assert.Equal(t, "agent.traceableai:5441", getGoString(libTraceableConfig.remote_config.remote_endpoint)) assert.Equal(t, 10, int(libTraceableConfig.remote_config.poll_period_sec)) @@ -189,10 +189,10 @@ func TestGetLibTraceableConfig(t *testing.T) { }, ) - assert.Equal(t, "https://opa:8181", getGoString(libTraceableConfig.opa_config.opa_server_url)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.min_delay)) - assert.Equal(t, 10, int(libTraceableConfig.opa_config.max_delay)) - assert.Equal(t, "/conf/tls.crt", getGoString(libTraceableConfig.opa_config.cert_file)) + assert.Equal(t, "https://opa:8181", getGoString(libTraceableConfig.blocking_config.opa_config.opa_server_url)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.min_delay)) + assert.Equal(t, 10, int(libTraceableConfig.blocking_config.opa_config.max_delay)) + assert.Equal(t, "/conf/tls.crt", getGoString(libTraceableConfig.blocking_config.opa_config.cert_file)) assert.Equal(t, 1, int(libTraceableConfig.remote_config.enabled)) assert.Equal(t, "https:://agent:5441", getGoString(libTraceableConfig.remote_config.remote_endpoint)) assert.Equal(t, "/conf/tls.crt", getGoString(libTraceableConfig.remote_config.cert_file)) diff --git a/filter/traceable/libs/linux_amd64-alpine/libtraceable.so b/filter/traceable/libs/linux_amd64-alpine/libtraceable.so index 39b0673..371d2e5 100644 Binary files a/filter/traceable/libs/linux_amd64-alpine/libtraceable.so and b/filter/traceable/libs/linux_amd64-alpine/libtraceable.so differ diff --git a/filter/traceable/libs/linux_amd64/libtraceable.so b/filter/traceable/libs/linux_amd64/libtraceable.so index c474eca..9ca6ccb 100644 Binary files a/filter/traceable/libs/linux_amd64/libtraceable.so and b/filter/traceable/libs/linux_amd64/libtraceable.so differ diff --git a/filter/traceable/libtraceable.h b/filter/traceable/libtraceable.h new file mode 100644 index 0000000..ec020c7 --- /dev/null +++ b/filter/traceable/libtraceable.h @@ -0,0 +1,125 @@ +#ifndef LIBTRACEABLE_H +#define LIBTRACEABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Traceable input and output structures + */ + +typedef struct { + const char* key; + const char* value; +} traceable_attribute; + +typedef struct { + int count; + const traceable_attribute* attribute_array; +} traceable_attributes; + +typedef enum { TRACEABLE_LOG_NONE, TRACEABLE_LOG_STDOUT } TRACEABLE_LOG_MODE; + +typedef struct { + TRACEABLE_LOG_MODE mode; +} traceable_log_configuration; + +typedef struct { + const char* opa_server_url; + const char* logging_dir; + const char* logging_file_prefix; + const char* cert_file; + int log_to_console; + int skip_verify; + int min_delay; + int max_delay; + int debug_log; +} traceable_opa_config; + +typedef struct { + int enabled; +} traceable_modsecurity_config; + +typedef struct { + int enabled; +} traceable_rangeblocking_config; + +typedef struct { + int enabled; + const char* remote_endpoint; + int poll_period_sec; + const char* cert_file; +} traceable_remote_config; + +typedef struct { + int enabled; + traceable_opa_config opa_config; + traceable_modsecurity_config modsecurity_config; + traceable_rangeblocking_config rb_config; + int evaluate_body; + int skip_internal_request; +} traceable_blocking_config; + +typedef struct { + const char* service_name; +} traceable_agent_config; + +typedef struct { + int block; + int sample; + traceable_attributes attributes; +} traceable_process_request_result; + +typedef struct { + traceable_log_configuration log_config; + traceable_remote_config remote_config; + traceable_blocking_config blocking_config; + traceable_agent_config agent_config; +} traceable_libtraceable_config; + +typedef struct { + int sample; + traceable_attributes attributes; +} traceable_process_span_result; + +typedef enum { TRACEABLE_SUCCESS, TRACEABLE_FAIL } TRACEABLE_RET; + +typedef void* traceable_libtraceable; + +/* + * Traceable api functions + */ +TRACEABLE_RET traceable_new_libtraceable( + traceable_libtraceable_config libtraceable_config, + traceable_libtraceable* out_libtraceable); +TRACEABLE_RET traceable_start_libtraceable(traceable_libtraceable libtraceable); +TRACEABLE_RET traceable_delete_libtraceable( + traceable_libtraceable libtraceable); + +TRACEABLE_RET traceable_process_request_headers( + traceable_libtraceable libtraceable, traceable_attributes attributes, + traceable_process_request_result* out_process_result); +TRACEABLE_RET traceable_process_request_body( + traceable_libtraceable libtraceable, traceable_attributes attributes, + traceable_process_request_result* out_process_result); +TRACEABLE_RET traceable_delete_process_request_result_data( + traceable_process_request_result result); + +/* + * traceable_decode_protobuf decodes a raw protobuf buffer into a null + * terminated JSON string. The caller must free "out_string". depth controls + * the number of nested groups that are decoded. + */ +TRACEABLE_RET traceable_decode_protobuf(const char* blob, int length, int depth, + char** out_string); + +TRACEABLE_RET traceable_is_content_type_capturable( + const char* media_type, const char** supported_content_types, + int supported_content_types_size, int* out_should_capture); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/go.mod b/go.mod index 1be6758..8292327 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/Traceableai/goagent go 1.15 require ( - github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 + github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae github.com/gin-gonic/gin v1.7.2 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 - github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e - github.com/hypertrace/goagent v0.5.0 + github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 + github.com/hypertrace/goagent v0.5.1 github.com/pkg/errors v0.9.1 // indirect github.com/stretchr/testify v1.7.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0 diff --git a/go.sum b/go.sum index 5517837..8b1003a 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8 h1:DLAPdu0Qz8eGWecWDle0cKdyBBOKNc7ZVnSBucA6/lM= -github.com/Traceableai/agent-config/gen/go v0.0.0-20211024200733-966247a6fba8/go.mod h1:6QVyyi6IeqE3I4p5eKJDzZitZUcd+Fu7is8iRVaAcWM= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae h1:tTjZ3izWS5culkApVxNozMFKbZOEoEC4x1UJPA/Gifc= +github.com/Traceableai/agent-config/gen/go v0.0.0-20220209211231-51b2f4efb6ae/go.mod h1:B4yXrCocv0w+7Q4y0O8PHcib6eYSaiWq2ux/h/FnZMw= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -56,12 +56,10 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA= github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= @@ -116,10 +114,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e h1:RztUu5aZrCoOUP1+xmzvzTnq3fuhZ6AJUzAYOpT0/Eo= -github.com/hypertrace/agent-config/gen/go v0.0.0-20211201093046-a7ed863ff59e/go.mod h1:LjKDF0vbkemwirXM+v4aH+ARjX9y8EwVTIe3BDrqj0I= -github.com/hypertrace/goagent v0.5.0 h1:0v4NkHsW15QBao4afYuyKVhFh/coh9MI8XgXMxcZA9U= -github.com/hypertrace/goagent v0.5.0/go.mod h1:aKTnPHdaECx8QmjNvndfJqVXoRbFAFWIrp3X4dM9nC4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51 h1:be7Skj74loff4ogxQurGjhB/1jBFySN/wA8xSqDz2t4= +github.com/hypertrace/agent-config/gen/go v0.0.0-20220209183558-95cc7dcabb51/go.mod h1:mAjMCmZXb0eL7I20pNuPz0tTPx8Ow3IE1J5fHhnLyZs= +github.com/hypertrace/goagent v0.5.1 h1:8jVKRcJ2qHhOMT2AfxJ8KfG+JdUGc/2Igskki1nRrow= +github.com/hypertrace/goagent v0.5.1/go.mod h1:Ir/I83kaIUB5RFm61KvzkiYvTaqoL8t/aeqqDrhx9sE= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/version/version.go b/version/version.go index 3bdcb61..1307a79 100644 --- a/version/version.go +++ b/version/version.go @@ -2,4 +2,4 @@ package version -const Version = "0.3.0" +const Version = "0.3.1"