Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.50.1
Choose a base ref
...
head repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.51.0
Choose a head ref

Commits on Apr 17, 2023

  1. Copy the full SHA
    7883f0e View commit details
  2. Copy the full SHA
    6408430 View commit details

Commits on Apr 18, 2023

  1. Copy the full SHA
    a48dc66 View commit details
  2. appsec: add blocking SDK body operation (#1901)

    #1901 adds the http sdk body blocking feature the feature is divided as follows:
    
    * Modifying the appsec api: adding appsec.MonitorParsedHTTPBody an error as return value
    * Adding a call to the WAF to check for security event synchronously with a call to appsec.MonitorParsedHTTPBody on the body passed as parameter
    * Removing the call to the WAF done on the body an the end of a request because we moved it.
    * Refactoring the waf addresses storage and access
    
    Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
    eliottness authored Apr 18, 2023
    Copy the full SHA
    3452a55 View commit details
  3. Copy the full SHA
    552a1ce View commit details
  4. Copy the full SHA
    361d193 View commit details
  5. internal/telemetry: track tracer init time metric (#1896)

    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    lievan and ajgajg1134 authored Apr 18, 2023
    Copy the full SHA
    58ba73d View commit details

Commits on Apr 19, 2023

  1. Copy the full SHA
    f727a69 View commit details
  2. Copy the full SHA
    c0fa284 View commit details
  3. Copy the full SHA
    5ccafe4 View commit details
  4. Copy the full SHA
    79647aa View commit details

Commits on Apr 20, 2023

  1. Copy the full SHA
    e5f54d7 View commit details
  2. Copy the full SHA
    17fb93d View commit details
  3. Copy the full SHA
    a00d7e5 View commit details

Commits on Apr 21, 2023

  1. Copy the full SHA
    4e28712 View commit details
  2. Copy the full SHA
    38016b0 View commit details

Commits on Apr 24, 2023

  1. Copy the full SHA
    b553a8a View commit details
  2. Copy the full SHA
    9ef1fd1 View commit details
  3. contrib/cassandra: use naming schema (#1911)

    Co-authored-by: Diana Shevchenko <40775148+dianashevchenko@users.noreply.github.com>
    rarguelloF and dianashevchenko authored Apr 24, 2023
    Copy the full SHA
    4895db6 View commit details
  4. contrib/redis: use naming schema (#1906)

    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    rarguelloF and ajgajg1134 authored Apr 24, 2023
    Copy the full SHA
    4e30ad7 View commit details

Commits on Apr 25, 2023

  1. Copy the full SHA
    d3d375c View commit details

Commits on Apr 27, 2023

  1. Copy the full SHA
    158fa4c View commit details

Commits on Apr 28, 2023

  1. contrib/redis/go-redis.v9: support v9 (#1730)

    Add support for new go-redis version v9.
    
    It does 2 things:
    Copy existing version 8 files to a new path, /redis/go-redis.v9.
    Make changes to support version 9.
    
    Fixes #1710
    taowata authored Apr 28, 2023
    Copy the full SHA
    2639a75 View commit details
  2. ddtrace/tracer: ensure access to trace tags is concurrency-safe (#1948)

    Spancontext marshaling was accessing tracer internal structures without a
    lock, resulting in a data race and panic.
    
    This commit adds a few methods to trace to allow safe access to the tags
    and propagatingTags members of trace to the marshaling code.
    
    Fixes #1944
    knusbaum authored Apr 28, 2023
    Copy the full SHA
    5deb295 View commit details

Commits on May 1, 2023

  1. ddtrace/tracer: mark context updated when SetUser is called (#1949)

    Fixes a minor logic mistake when setting a user on a span
    knusbaum authored May 1, 2023
    Copy the full SHA
    c19c747 View commit details

Commits on May 2, 2023

  1. Copy the full SHA
    e2c8230 View commit details

Commits on May 3, 2023

  1. go.mod: upgrade go-libddwaf to v1.2.0 (#1953)

    Co-authored-by: Julio Guerra <julio@datadog.com>
    Hellzy and Julio-Guerra authored May 3, 2023
    Copy the full SHA
    dead436 View commit details
  2. contrib/database/sql: fix bug where options were always overwritten b…

    …y register options (#1904)
    
    Co-authored-by: Diana Shevchenko <40775148+dianashevchenko@users.noreply.github.com>
    rarguelloF and dianashevchenko authored May 3, 2023
    Copy the full SHA
    773f8b8 View commit details
  3. Copy the full SHA
    81eb997 View commit details

Commits on May 4, 2023

  1. contrib/net/http: don't set empty string values as span tags (#1956)

    Do not set span fields when they are not configured so the tracer can put the defaults in.
    knusbaum authored May 4, 2023
    Copy the full SHA
    21e0089 View commit details

Commits on May 5, 2023

  1. Copy the full SHA
    b6486b2 View commit details
  2. Copy the full SHA
    7155f12 View commit details
  3. Copy the full SHA
    65026f8 View commit details
  4. Copy the full SHA
    043c641 View commit details
  5. Copy the full SHA
    63590ad View commit details

Commits on May 9, 2023

  1. Copy the full SHA
    242cc76 View commit details
  2. appsec: handle user custom rules through remote config (#1961)

    Co-authored-by: Julio Guerra <julio@datadog.com>
    Hellzy and Julio-Guerra authored May 9, 2023
    Copy the full SHA
    c9996a7 View commit details
  3. Copy the full SHA
    e4d62a7 View commit details

Commits on May 10, 2023

  1. ddtrace/trace: only tag fully-covered spans as execution traced (#1943)

    Only label spans as being covered by execution tracing if they are fully
    covered, i.e. they start and finish with execution tracing enabled.
    If we know that a span was partially covered, we can still label it, but
    with something different so it's clear there is missing information.
    nsrip-dd authored May 10, 2023
    Copy the full SHA
    d2e0f49 View commit details
  2. profiler: support reconfiguring execution tracing at runtime (#1978)

    Have the profiler check the execution tracing configuration environment
    variables at the beginning of each profiling cycle. That way, the
    environment variables can be updated at run-time. This will give initial
    users the flexibility to, for example, increase collection frequency
    during periods where they suspect a performance issue is happening,
    without requiring us to commit to a public interface for triggering or
    reconfiguring trace collection.
    nsrip-dd authored May 10, 2023
    Copy the full SHA
    3d9bf40 View commit details

Commits on May 11, 2023

  1. ddtrace/opentelemetry: parent start span options shouldn't be propaga…

    …ted and used during child span creation (#1958)
    dianashevchenko authored May 11, 2023
    Copy the full SHA
    10c4341 View commit details
  2. Copy the full SHA
    5e284e4 View commit details

Commits on May 12, 2023

  1. Copy the full SHA
    6f9dd8f View commit details
  2. contrib/aws/aws-sdk-go: add WithErrorCheck option (#1682)

    Co-authored-by: Diana Shevchenko <40775148+dianashevchenko@users.noreply.github.com>
    Co-authored-by: Zarir Hamza <zarir.hamza@datadoghq.com>
    3 people authored May 12, 2023
    Copy the full SHA
    aff2b5a View commit details
  3. contrib/go-redis/redis.v8: fix broken parsing of redis commands (#1783)

    Co-authored-by: Diana Shevchenko <40775148+dianashevchenko@users.noreply.github.com>
    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    3 people authored May 12, 2023
    Copy the full SHA
    3b1462c View commit details
  4. contrib: peer.service precursors for elasticsearch integrations (#1981

    )
    
    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    zarirhamza and ajgajg1134 authored May 12, 2023
    Copy the full SHA
    dc939eb View commit details
  5. contrib: peer.service precursors for confluentinc/segmentio integr…

    …ations (#1979)
    
    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    zarirhamza and ajgajg1134 authored May 12, 2023
    Copy the full SHA
    d1c023c View commit details
  6. Copy the full SHA
    8b09491 View commit details
  7. .github/workflows: allow checking out specific ref for system-tests (#…

    …1986)
    
    Co-authored-by: Julio Guerra <julio@datadog.com>
    Hellzy and Julio-Guerra authored May 12, 2023
    Copy the full SHA
    10c94ab View commit details
  8. contrib/gin-gonic: abort context if request is blocked by appsec (#1976)

    Co-authored-by: Julio Guerra <julio@datadog.com>
    Hellzy and Julio-Guerra authored May 12, 2023
    Copy the full SHA
    f00d6a6 View commit details
Showing with 6,568 additions and 1,354 deletions.
  1. +1 −1 .github/workflows/appsec.yml
  2. +3 −1 .github/workflows/smoke-tests.yml
  3. +57 −55 .github/workflows/system-tests.yml
  4. +4 −31 .github/workflows/unit-integration-tests.yml
  5. +1 −0 .golangci.yml
  6. +3 −0 CODEOWNERS
  7. +12 −6 appsec/appsec.go
  8. +6 −1 contrib/99designs/gqlgen/option.go
  9. +15 −8 contrib/99designs/gqlgen/tracer.go
  10. +64 −17 contrib/99designs/gqlgen/tracer_test.go
  11. +1 −8 contrib/Shopify/sarama/sarama_test.go
  12. +232 −9 contrib/aws/aws-sdk-go-v2/aws/aws.go
  13. +739 −3 contrib/aws/aws-sdk-go-v2/aws/aws_test.go
  14. +38 −25 contrib/aws/aws-sdk-go/aws/aws.go
  15. +171 −5 contrib/aws/aws-sdk-go/aws/aws_test.go
  16. +10 −0 contrib/aws/aws-sdk-go/aws/option.go
  17. +50 −0 contrib/aws/internal/awsnamingschema/awsnamingschema.go
  18. +21 −2 contrib/cloud.google.com/go/pubsub.v1/option.go
  19. +6 −6 contrib/cloud.google.com/go/pubsub.v1/pubsub.go
  20. +66 −23 contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go
  21. +56 −5 contrib/confluentinc/confluent-kafka-go/kafka/kafka.go
  22. +6 −11 contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go
  23. +16 −5 contrib/database/sql/option.go
  24. +0 −14 contrib/database/sql/sql.go
  25. +102 −22 contrib/database/sql/sql_test.go
  26. +21 −0 contrib/dimfeld/httptreemux.v5/httptreemux_test.go
  27. +6 −7 contrib/dimfeld/httptreemux.v5/option.go
  28. +1 −0 contrib/elastic/go-elasticsearch.v6/elastictrace.go
  29. +2 −0 contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go
  30. +2 −0 contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go
  31. +2 −0 contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go
  32. +9 −1 contrib/emicklei/go-restful/option.go
  33. +43 −3 contrib/emicklei/go-restful/restful_test.go
  34. +10 −1 contrib/garyburd/redigo/option.go
  35. +1 −1 contrib/garyburd/redigo/redigo.go
  36. +21 −0 contrib/garyburd/redigo/redigo_test.go
  37. +4 −2 contrib/gin-gonic/gin/appsec.go
  38. +7 −1 contrib/gin-gonic/gin/appsec_test.go
  39. +30 −0 contrib/gin-gonic/gin/gintrace_test.go
  40. +9 −9 contrib/gin-gonic/gin/option.go
  41. +2 −2 contrib/globalsign/mgo/mgo.go
  42. +28 −5 contrib/globalsign/mgo/mgo_test.go
  43. +11 −2 contrib/globalsign/mgo/option.go
  44. +32 −0 contrib/go-chi/chi.v5/chi_test.go
  45. +4 −4 contrib/go-chi/chi.v5/option.go
  46. +31 −0 contrib/go-chi/chi/chi_test.go
  47. +4 −4 contrib/go-chi/chi/option.go
  48. +10 −1 contrib/go-redis/redis.v7/option.go
  49. +1 −1 contrib/go-redis/redis.v7/redis.go
  50. +20 −0 contrib/go-redis/redis.v7/redis_test.go
  51. +10 −1 contrib/go-redis/redis.v8/option.go
  52. +10 −8 contrib/go-redis/redis.v8/redis.go
  53. +58 −11 contrib/go-redis/redis.v8/redis_test.go
  54. +10 −1 contrib/go-redis/redis/option.go
  55. +2 −2 contrib/go-redis/redis/redis.go
  56. +20 −0 contrib/go-redis/redis/redis_test.go
  57. +2 −2 contrib/go.mongodb.org/mongo-driver/mongo/mongo.go
  58. +29 −2 contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go
  59. +10 −1 contrib/go.mongodb.org/mongo-driver/mongo/option.go
  60. +2 −2 contrib/gocql/gocql/gocql.go
  61. +57 −6 contrib/gocql/gocql/gocql_test.go
  62. +17 −5 contrib/gocql/gocql/option.go
  63. +3 −3 contrib/gofiber/fiber.v2/fiber.go
  64. +42 −5 contrib/gofiber/fiber.v2/fiber_test.go
  65. +6 −4 contrib/gofiber/fiber.v2/option.go
  66. +10 −1 contrib/gomodule/redigo/option.go
  67. +3 −4 contrib/gomodule/redigo/redigo.go
  68. +44 −3 contrib/gomodule/redigo/redigo_test.go
  69. +10 −12 contrib/google.golang.org/grpc.v12/grpc.go
  70. +86 −9 contrib/google.golang.org/grpc.v12/grpc_test.go
  71. +26 −0 contrib/google.golang.org/grpc.v12/option.go
  72. +8 −14 contrib/google.golang.org/grpc/appsec.go
  73. +1 −1 contrib/google.golang.org/grpc/appsec_test.go
  74. +6 −6 contrib/google.golang.org/grpc/client.go
  75. +138 −50 contrib/google.golang.org/grpc/grpc_test.go
  76. +26 −19 contrib/google.golang.org/grpc/option.go
  77. +8 −8 contrib/google.golang.org/grpc/server.go
  78. +5 −4 contrib/google.golang.org/grpc/stats_client.go
  79. +12 −29 contrib/google.golang.org/grpc/stats_client_test.go
  80. +10 −5 contrib/google.golang.org/grpc/stats_server.go
  81. +13 −29 contrib/google.golang.org/grpc/stats_server_test.go
  82. +25 −0 contrib/gorilla/mux/mux_test.go
  83. +4 −4 contrib/gorilla/mux/option.go
  84. +1 −1 contrib/graph-gophers/graphql-go/graphql.go
  85. +71 −54 contrib/graph-gophers/graphql-go/graphql_test.go
  86. +9 −5 contrib/graph-gophers/graphql-go/option.go
  87. +5 −3 contrib/internal/httptrace/httptrace.go
  88. +9 −0 contrib/internal/lists/{combinations.go → lists.go}
  89. +5 −0 contrib/internal/lists/{combinations_test.go → lists_test.go}
  90. +36 −0 contrib/internal/namingschematest/cache.go
  91. +41 −0 contrib/internal/namingschematest/client_server.go
  92. +36 −0 contrib/internal/namingschematest/db.go
  93. +0 −30 contrib/internal/namingschematest/kafka.go
  94. +38 −0 contrib/internal/namingschematest/messaging.go
  95. +43 −26 contrib/internal/namingschematest/namingschematest.go
  96. +28 −0 contrib/internal/namingschematest/option.go
  97. +21 −0 contrib/julienschmidt/httprouter/httprouter_test.go
  98. +4 −4 contrib/julienschmidt/httprouter/option.go
  99. +7 −0 contrib/labstack/echo.v4/appsec_test.go
  100. +24 −0 contrib/labstack/echo.v4/echotrace_test.go
  101. +6 −3 contrib/labstack/echo.v4/option.go
  102. +3 −0 contrib/labstack/echo/echotrace.go
  103. +24 −0 contrib/labstack/echo/echotrace_test.go
  104. +4 −5 contrib/labstack/echo/option.go
  105. +6 −1 contrib/net/http/example_test.go
  106. +23 −2 contrib/net/http/http_test.go
  107. +11 −5 contrib/net/http/option.go
  108. +79 −17 contrib/net/http/roundtripper_test.go
  109. +10 −2 contrib/net/http/trace.go
  110. +29 −0 contrib/net/http/trace_test.go
  111. +1 −0 contrib/olivere/elastic/elastictrace.go
  112. +34 −25 contrib/olivere/elastic/elastictrace_test.go
  113. +59 −0 contrib/redis/go-redis.v9/example_test.go
  114. +79 −0 contrib/redis/go-redis.v9/option.go
  115. +205 −0 contrib/redis/go-redis.v9/redis.go
  116. +687 −0 contrib/redis/go-redis.v9/redis_test.go
  117. +19 −0 contrib/segmentio/kafka.go.v0/kafka.go
  118. +35 −9 contrib/segmentio/kafka.go.v0/kafka_test.go
  119. +1 −1 contrib/syndtr/goleveldb/leveldb/leveldb.go
  120. +41 −5 contrib/syndtr/goleveldb/leveldb/leveldb_test.go
  121. +11 −2 contrib/syndtr/goleveldb/leveldb/option.go
  122. +1 −1 contrib/tidwall/buntdb/buntdb.go
  123. +43 −3 contrib/tidwall/buntdb/buntdb_test.go
  124. +10 −1 contrib/tidwall/buntdb/option.go
  125. +21 −13 contrib/twitchtv/twirp/option.go
  126. +21 −18 contrib/twitchtv/twirp/twirp.go
  127. +73 −24 contrib/twitchtv/twirp/twirp_test.go
  128. +33 −0 contrib/urfave/negroni/negroni_test.go
  129. +4 −4 contrib/urfave/negroni/option.go
  130. +41 −1 contrib/zenazn/goji.v1/web/goji_test.go
  131. +8 −1 contrib/zenazn/goji.v1/web/option.go
  132. +2 −0 ddtrace/ext/cassandra.go
  133. +1 −0 ddtrace/ext/peer.go
  134. +10 −0 ddtrace/ext/tags.go
  135. +14 −3 ddtrace/opentelemetry/span_test.go
  136. +7 −1 ddtrace/opentelemetry/tracer.go
  137. +13 −0 ddtrace/opentelemetry/tracer_test.go
  138. +2 −0 ddtrace/opentracer/tracer.go
  139. +11 −0 ddtrace/opentracer/tracer_test.go
  140. +2 −1 ddtrace/tracer/log.go
  141. +68 −0 ddtrace/tracer/propagating_tags.go
  142. +21 −3 ddtrace/tracer/span.go
  143. +19 −0 ddtrace/tracer/span_test.go
  144. +8 −25 ddtrace/tracer/spancontext.go
  145. +8 −0 ddtrace/tracer/telemetry_test.go
  146. +71 −47 ddtrace/tracer/textmap.go
  147. +58 −4 ddtrace/tracer/textmap_test.go
  148. +3 −1 ddtrace/tracer/tracer.go
  149. +11 −2 ddtrace/tracer/tracer_test.go
  150. +4 −0 docker-compose.yaml
  151. +51 −31 go.mod
  152. +65 −25 go.sum
  153. +50 −0 internal/appsec/_testlib/mockspan.go
  154. +20 −0 internal/appsec/_testlib/require.go
  155. +11 −10 internal/appsec/dyngo/instrumentation/grpcsec/tags.go
  156. +25 −59 internal/appsec/dyngo/instrumentation/grpcsec/tags_test.go
  157. +64 −21 internal/appsec/dyngo/instrumentation/httpsec/http.go
  158. +26 −8 internal/appsec/dyngo/instrumentation/httpsec/tags.go
  159. +139 −0 internal/appsec/dyngo/instrumentation/httpsec/tags_test.go
  160. +2 −0 internal/appsec/remoteconfig.go
  161. +5 −5 internal/appsec/remoteconfig_test.go
  162. +2 −2 internal/appsec/rules.go
  163. +448 −121 internal/appsec/rules.json
  164. +18 −14 internal/appsec/{ruleset_builder.go → rules_manager.go}
  165. 0 internal/appsec/{ruleset_builder_test.go → rules_manager_test.go}
  166. +60 −0 internal/appsec/testdata/blocking.json
  167. +56 −0 internal/appsec/testdata/user_rules.json
  168. +63 −55 internal/appsec/waf.go
  169. +61 −1 internal/appsec/waf_test.go
  170. +8 −3 internal/httpmem/httpmem_test.go
  171. +5 −0 internal/namingschema/op_cache.go
  172. +9 −2 internal/namingschema/op_client_server.go
  173. +10 −0 internal/namingschema/op_db.go
  174. +12 −0 internal/namingschema/op_messaging.go
  175. +44 −4 internal/namingschema/op_test.go
  176. +7 −3 internal/remoteconfig/remoteconfig.go
  177. +66 −35 internal/telemetry/client.go
  178. +96 −26 internal/telemetry/client_test.go
  179. +33 −5 internal/telemetry/message.go
  180. +20 −1 internal/telemetry/telemetry.go
  181. +21 −4 internal/telemetry/telemetrytest/telemetrytest.go
  182. +1 −1 internal/version/version.go
  183. +30 −10 profiler/options.go
  184. +2 −1 profiler/profiler.go
  185. +1 −1 profiler/telemetry.go
2 changes: 1 addition & 1 deletion .github/workflows/appsec.yml
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ jobs:
native:
strategy:
matrix:
runs-on: [ macos-12, macos-11, macos-10.15, ubuntu-22.04, ubuntu-20.04, windows-latest ]
runs-on: [ macos-13, macos-12, macos-11, ubuntu-22.04, ubuntu-20.04, windows-latest ]
go-version: [ "1.20", "1.19", "1.18" ]
cgo_enabled: # test it compiles with and without cgo
- 0
4 changes: 3 additions & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -27,7 +27,9 @@ jobs:
go-version: 1.18
cache: true
- name: go get -u
run: go get -u $PACKAGES
run: |
go get -u $PACKAGES
go mod tidy
- name: Compile dd-trace-go
run: go build -tags appsec $PACKAGES
- name: Test dd-trace-go
112 changes: 57 additions & 55 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,13 @@ on:
branches:
- "**"
merge_group:
workflow_dispatch: {}
workflow_dispatch:
inputs:
ref:
description: 'System Tests ref/tag/branch'
required: true
default: main
type: string
schedule:
- cron: '00 04 * * 2-6'

@@ -21,22 +27,59 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
weblog-variant:
- net-http
- echo
- chi
- gin
scenario:
- DEFAULT
- APPSEC_DISABLED
- APPSEC_BLOCKING
- APPSEC_IP_BLOCKING
- APPSEC_REQUEST_BLOCKING
- APM_TRACING_E2E
- APM_TRACING_E2E_SINGLE_SPAN
include:
- library: golang
weblog-variant: net-http
- library: golang
weblog-variant: gorilla
- library: golang
weblog-variant: echo
- library: golang
weblog-variant: chi
- library: golang
weblog-variant: gin
- weblog-variant: net-http
scenario: REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES
- weblog-variant: net-http
scenario: REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES
- weblog-variant: net-http
scenario: REMOTE_CONFIG_MOCKED_BACKEND_ASM_DD
# AppSec scenarios that don't depend on the integrations, so we just run on the net/http variant
- weblog-variant: net-http
scenario: APPSEC_RATE_LIMITER
- weblog-variant: net-http
scenario: APPSEC_CUSTOM_RULES
- weblog-variant: net-http
scenario: APPSEC_MISSING_RULES
- weblog-variant: net-http
scenario: APPSEC_CORRUPTED_RULES
- weblog-variant: net-http
scenario: APPSEC_LOW_WAF_TIMEOUT
- weblog-variant: net-http
scenario: APPSEC_CUSTOM_OBFUSCATION
# APM scenarios requiring specific environment settings
- scenario: APM_TRACING_E2E
env:
DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY
DD_SITE="datadoghq.com"
- scenario: APM_TRACING_E2E_SINGLE_SPAN
env:
DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY
DD_SITE="datadoghq.com"

fail-fast: false
env:
TEST_LIBRARY: golang
WEBLOG_VARIANT: ${{ matrix.weblog-variant }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
SYSTEM_TESTS_E2E_DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
SYSTEM_TESTS_E2E_DD_APP_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
name: Test (${{ matrix.weblog-variant }}, ${{ matrix.scenario }})
steps:
- name: Setup python 3.9
uses: actions/setup-python@v4
@@ -47,6 +90,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: 'DataDog/system-tests'
ref: ${{ inputs.ref }}

- name: Checkout dd-trace-go
uses: actions/checkout@v2
@@ -57,49 +101,7 @@ jobs:
run: ./build.sh

- name: Run
run: ./run.sh

- name: Run APM E2E default tests
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh APM_TRACING_E2E

- name: Run APM E2E Single Span tests
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh APM_TRACING_E2E_SINGLE_SPAN

- name: Run ASM blocking scenario
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh APPSEC_BLOCKING

- name: Run ASM request blocking scenario
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh APPSEC_REQUEST_BLOCKING

- name: Run ASM_FEATURES remote configuration test
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES

- name: Run ASM_DD remote configuration test
env:
DD_API_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_API_KEY }}
DD_APPLICATION_KEY: ${{ secrets.SYSTEM_TESTS_E2E_DD_APP_KEY }}
DD_SITE: "datadoghq.com"
run: ./run.sh REMOTE_CONFIG_MOCKED_BACKEND_ASM_DD
run: env ${{ matrix.env }} ./run.sh ${{ matrix.scenario }}

- name: Compress artifact
if: ${{ always() }}
@@ -109,5 +111,5 @@ jobs:
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs_${{ matrix.weblog-variant }}
name: logs_${{ matrix.weblog-variant }}_${{ matrix.scenario }}
path: artifact.tar.gz
35 changes: 4 additions & 31 deletions .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -19,38 +19,7 @@ jobs:
run: |
go run checkcopyright.go
# Deprecated
# TODO remove this once the golangci-lint job is stable.
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: 'DataDog/dd-trace-go'
- name: gofmt
run: |
if [ "$(gofmt -e -l . | wc -l)" -gt 0 ]; then
gofmt -e -l .
exit 1
fi
- name: goimports
run: |
go install golang.org/x/tools/cmd/goimports
if [ "$(~/go/bin/goimports -e -l -local gopkg.in/DataDog/dd-trace-go.v1 . | wc -l)" -gt 0 ]; then
echo "Run 'goimports -w -local gopkg.in/DataDog/dd-trace-go.v1 .' to format code."
~/go/bin/goimports -d -local gopkg.in/DataDog/dd-trace-go.v1 .
exit 1
fi
- name: lint
run: |
go install golang.org/x/lint/golint@latest
curl https://raw.githubusercontent.com/alecthomas/gometalinter/master/scripts/install.sh | sh # https://github.com/alecthomas/gometalinter#binary-releases
./bin/gometalinter --disable-all --vendor --deadline=120s --enable=golint ./...
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
@@ -233,6 +202,10 @@ jobs:
KAFKA_BROKER_ID: 1
ports:
- 9092:9092
localstack:
image: localstack/localstack:latest
ports:
- 4566:4566
steps:
- name: Checkout
uses: actions/checkout@v2
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -9,3 +9,4 @@ linters:
- gofmt
- goimports
- revive
- bodyclose
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -19,3 +19,6 @@

# telemetry
/internal/telemetry @DataDog/apm-go

# linter rules
.golangci.yml @DataDog/tracing-go @DataDog/profiling-go @DataDog/appsec-go
18 changes: 12 additions & 6 deletions appsec/appsec.go
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ package appsec

import (
"context"
"sync"

"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
@@ -22,17 +23,22 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
)

var appsecDisabledLog sync.Once

// MonitorParsedHTTPBody runs the security monitoring rules on the given *parsed*
// HTTP request body. The given context must be the HTTP request context as returned
// HTTP request body and returns if the HTTP request is suspicious and configured to be blocked.
// The given context must be the HTTP request context as returned
// by the Context() method of an HTTP request. Calls to this function are ignored if
// AppSec is disabled or the given context is incorrect.
// Note that passing the raw bytes of the HTTP request body is not expected and would
// result in inaccurate attack detection.
func MonitorParsedHTTPBody(ctx context.Context, body interface{}) {
if appsec.Enabled() {
httpsec.MonitorParsedBody(ctx, body)
// This function always returns nil when appsec is disabled.
func MonitorParsedHTTPBody(ctx context.Context, body interface{}) error {
if !appsec.Enabled() {
appsecDisabledLog.Do(func() { log.Warn("appsec: not enabled. Body blocking checks won't be performed.") })
return nil
}
// bonus: use sync.Once to log a debug message once if AppSec is disabled
return httpsec.MonitorParsedBody(ctx, body)
}

// SetUser wraps tracer.SetUser() and extends it with user blocking.
@@ -51,7 +57,7 @@ func SetUser(ctx context.Context, id string, opts ...tracer.UserMonitoringOption
}
tracer.SetUser(s, id, opts...)
if !appsec.Enabled() {
log.Debug("appsec: not enabled. User blocking checks won't be performed.")
appsecDisabledLog.Do(func() { log.Warn("appsec: not enabled. User blocking checks won't be performed.") })
return nil
}
return sharedsec.MonitorUser(ctx, id)
7 changes: 6 additions & 1 deletion contrib/99designs/gqlgen/option.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"math"

"gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig"
"gopkg.in/DataDog/dd-trace-go.v1/internal/namingschema"
)

const defaultServiceName = "graphql"
@@ -22,7 +23,11 @@ type config struct {
type Option func(t *config)

func defaults(t *config) {
t.serviceName = defaultServiceName
t.serviceName = namingschema.NewServiceNameSchema(
"",
defaultServiceName,
namingschema.WithVersionOverride(namingschema.SchemaV0, defaultServiceName),
).GetName()
t.analyticsRate = globalconfig.AnalyticsRate()
}

23 changes: 15 additions & 8 deletions contrib/99designs/gqlgen/tracer.go
Original file line number Diff line number Diff line change
@@ -47,13 +47,14 @@ import (
"strings"
"time"

"github.com/99designs/gqlgen/graphql"
"github.com/vektah/gqlparser/v2/ast"

"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"gopkg.in/DataDog/dd-trace-go.v1/internal/namingschema"
"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"

"github.com/99designs/gqlgen/graphql"
"github.com/vektah/gqlparser/v2/ast"
)

const componentName = "99designs/gqlgen"
@@ -63,8 +64,6 @@ func init() {
}

const (
defaultGraphqlOperation = "graphql.request"

readOp = "graphql.read"
parsingOp = "graphql.parse"
validationOp = "graphql.validate"
@@ -106,7 +105,6 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response
var (
octx *graphql.OperationContext
)
name := defaultGraphqlOperation
if graphql.HasOperationContext(ctx) {
// Variables in the operation will be left out of the tags
// until obfuscation is implemented in the agent.
@@ -118,15 +116,14 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response
// Return early and do not create these spans.
return next(ctx)
}
name = fmt.Sprintf("%s.%s", ext.SpanTypeGraphQL, octx.Operation.Operation)
}
if octx.RawQuery != "" {
opts = append(opts, tracer.ResourceName(octx.RawQuery))
}
opts = append(opts, tracer.StartTime(octx.Stats.OperationStart))
}
var span ddtrace.Span
span, ctx = tracer.StartSpanFromContext(ctx, name, opts...)
span, ctx = tracer.StartSpanFromContext(ctx, serverSpanName(octx), opts...)
defer func() {
var errs []string
for _, err := range graphql.GetErrors(ctx) {
@@ -157,6 +154,16 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response
return next(ctx)
}

func serverSpanName(octx *graphql.OperationContext) string {
nameV0 := "graphql.request"
if octx != nil && octx.Operation != nil {
nameV0 = fmt.Sprintf("%s.%s", ext.SpanTypeGraphQL, octx.Operation.Operation)
}
return namingschema.NewGraphqlServerOp(
namingschema.WithVersionOverride(namingschema.SchemaV0, nameV0),
).GetName()
}

// Ensure all of these interfaces are implemented.
var _ interface {
graphql.HandlerExtension
Loading