Skip to content

Commit

Permalink
Get back to simpler mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Sep 9, 2024
1 parent 57bcc77 commit 43c760d
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 322 deletions.
1 change: 0 additions & 1 deletion utils/_context/_scenarios/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ def golang_library_factory():
# download the proper tracer version
COPY utils/build/docker/golang/install_ddtrace.sh binaries* /binaries/
COPY utils/build/docker/golang/parametric/system_tests_library_version.sh system_tests_library_version.sh
COPY utils/build/docker/golang/parametric/get_version/system_tests_library_version.go get_version/system_tests_library_version.go
RUN /binaries/install_ddtrace.sh
RUN go install
Expand Down
39 changes: 3 additions & 36 deletions utils/build/docker/golang/app/chi/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"runtime/debug"
"context"
"log"
"net/http"
Expand Down Expand Up @@ -38,45 +37,13 @@ func main() {
})

mux.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
var tracerVersion string
var libddwafVersion string

if bi, ok := debug.ReadBuildInfo(); ok {
for _, mod := range bi.Deps {
println(mod.Path, mod.Version)

if mod.Path == "gopkg.in/DataDog/dd-trace-go.v1" {
tracerVersion = mod.Version
} else if mod.Path == "github.com/DataDog/go-libddwaf/v3" {
libddwafVersion = mod.Version
}
}
}

if tracerVersion == "" {
http.Error(w, "Can't get dd-trace-go version", http.StatusInternalServerError)
return
}

appsec_rules_version, err := os.ReadFile("SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
healthCheck, err := common.GetHealtchCheck()
if err != nil {
http.Error(w, "Can't get SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION", http.StatusInternalServerError)
return
}

libray := map[string]interface{}{
"language": "golang",
"version": string(tracerVersion),
"appsec_event_rules_version": string(appsec_rules_version),
"libddwaf_version": libddwafVersion,
}

data := map[string]interface{}{
"status": "ok",
"library": libray,
http.Error(w, "Can't get JSON data", http.StatusInternalServerError)
}

jsonData, err := json.Marshal(data)
jsonData, err := json.Marshal(healthCheck)
if err != nil {
http.Error(w, "Can't build JSON data", http.StatusInternalServerError)
return
Expand Down
50 changes: 4 additions & 46 deletions utils/build/docker/golang/app/echo/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"runtime/debug"
"log"
"net/http"
"os"
Expand All @@ -18,18 +17,6 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

type HealtchCheckLibrary struct {
Language string `json:"language"`
Version string `json:"version"`
AppsecEventRulesVersion string `json:"appsec_event_rules_version"`
LibddwafVersion string `json:"libddwaf_version"`
}

type HealtchCheck struct {
Status string `json:"status"`
Library HealtchCheckLibrary `json:"library"`
}

func main() {
tracer.Start()
defer tracer.Stop()
Expand All @@ -43,42 +30,13 @@ func main() {
})

r.GET("/healthcheck", func(c echo.Context) error {
library := HealtchCheckLibrary{
Language: "golang",
Version: "",
AppsecEventRulesVersion: "",
LibddwafVersion: "",
}

result := HealtchCheck{
Status: "ok",
Library: library,
}

if bi, ok := debug.ReadBuildInfo(); ok {
for _, mod := range bi.Deps {
println(mod.Path, mod.Version)
healthCheck, err := common.GetHealtchCheck()

if mod.Path == "gopkg.in/DataDog/dd-trace-go.v1" {
library.Version = mod.Version
} else if mod.Path == "github.com/DataDog/go-libddwaf/v3" {
library.LibddwafVersion = mod.Version
}
}
if err != nil {
return c.JSON(http.StatusInternalServerError, err)
}

if library.Version == "" {
return c.JSON(http.StatusInternalServerError, "Can't get dd-trace-go version")
}

appsecEventRulesVersion, err := os.ReadFile("SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
if err != nil {
return c.JSON(http.StatusInternalServerError, "Can't get SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
}

library.AppsecEventRulesVersion = string(appsecEventRulesVersion)

return c.JSON(http.StatusOK, result)
return c.JSON(http.StatusOK, healthCheck)
})

r.Any("/*", func(c echo.Context) error {
Expand Down
50 changes: 4 additions & 46 deletions utils/build/docker/golang/app/gin/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"runtime/debug"
"log"
"net/http"
"os"
Expand All @@ -18,18 +17,6 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

type HealtchCheckLibrary struct {
Language string `json:"language"`
Version string `json:"version"`
AppsecEventRulesVersion string `json:"appsec_event_rules_version"`
LibddwafVersion string `json:"libddwaf_version"`
}

type HealtchCheck struct {
Status string `json:"status"`
Library HealtchCheckLibrary `json:"library"`
}

func main() {
tracer.Start()
defer tracer.Stop()
Expand All @@ -42,42 +29,13 @@ func main() {
})

r.GET("/healthcheck", func(ctx *gin.Context) {
library := HealtchCheckLibrary{
Language: "golang",
Version: "",
AppsecEventRulesVersion: "",
LibddwafVersion: "",
}

result := HealtchCheck{
Status: "ok",
Library: library,
}

if bi, ok := debug.ReadBuildInfo(); ok {
for _, mod := range bi.Deps {
println(mod.Path, mod.Version)
healthCheck, err := common.GetHealtchCheck()

if mod.Path == "gopkg.in/DataDog/dd-trace-go.v1" {
library.Version = mod.Version
} else if mod.Path == "github.com/DataDog/go-libddwaf/v3" {
library.LibddwafVersion = mod.Version
}
}
if err != nil {
c.JSON(http.StatusInternalServerError, err)
}

if library.Version == "" {
ctx.JSON(http.StatusInternalServerError, "Can't get dd-trace-go version")
}

appsecEventRulesVersion, err := os.ReadFile("SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
if err != nil {
ctx.JSON(http.StatusInternalServerError, "Can't get SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
}

library.AppsecEventRulesVersion = string(appsecEventRulesVersion)

ctx.JSON(http.StatusOK, result)
c.JSON(http.StatusOK, healthCheck)
})

r.Any("/waf", func(ctx *gin.Context) {
Expand Down
55 changes: 11 additions & 44 deletions utils/build/docker/golang/app/gqlgen/server.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"runtime/debug"
"net/http"
"os"
"encoding/json"
"weblog/gqlgen/graph"
"weblog/internal/common"
Expand Down Expand Up @@ -40,52 +38,21 @@ func main() {
})

mux.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
var tracerVersion string
var libddwafVersion string

if bi, ok := debug.ReadBuildInfo(); ok {
for _, mod := range bi.Deps {
println(mod.Path, mod.Version)

if mod.Path == "gopkg.in/DataDog/dd-trace-go.v1" {
tracerVersion = mod.Version
} else if mod.Path == "github.com/DataDog/go-libddwaf/v3" {
libddwafVersion = mod.Version
}
}
healthCheck, err := common.GetHealtchCheck()
if err != nil {
http.Error(w, "Can't get JSON data", http.StatusInternalServerError)
return
}

if tracerVersion == "" {
http.Error(w, "Can't get dd-trace-go version", http.StatusInternalServerError)
return
}

appsec_rules_version, err := os.ReadFile("SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
if err != nil {
http.Error(w, "Can't get SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION", http.StatusInternalServerError)
return
}

libray := map[string]interface{}{
"language": "golang",
"version": string(tracerVersion),
"appsec_event_rules_version": string(appsec_rules_version),
"libddwaf_version": libddwafVersion,
}

data := map[string]interface{}{
"status": "ok",
"library": libray,
}

jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "Can't build JSON data", http.StatusInternalServerError)
return
}
jsonData, err := json.Marshal(healthCheck)
if err != nil {
http.Error(w, "Can't build JSON data", http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
w.Write(jsonData)
w.Header().Set("Content-Type", "application/json")
w.Write(jsonData)
})

common.InitDatadog()
Expand Down
58 changes: 12 additions & 46 deletions utils/build/docker/golang/app/graph-gophers/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"runtime/debug"
"net/http"
"os"
"encoding/json"
"weblog/internal/common"

Expand Down Expand Up @@ -52,52 +50,20 @@ func main() {
})

mux.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
var tracerVersion string
var libddwafVersion string

if bi, ok := debug.ReadBuildInfo(); ok {
for _, mod := range bi.Deps {
println(mod.Path, mod.Version)

if mod.Path == "gopkg.in/DataDog/dd-trace-go.v1" {
tracerVersion = mod.Version
} else if mod.Path == "github.com/DataDog/go-libddwaf/v3" {
libddwafVersion = mod.Version
}
}

healthCheck, err := common.GetHealtchCheck()
if err != nil {
http.Error(w, "Can't get JSON data", http.StatusInternalServerError)
}

jsonData, err := json.Marshal(healthCheck)
if err != nil {
http.Error(w, "Can't build JSON data", http.StatusInternalServerError)
return
}

if tracerVersion == "" {
http.Error(w, "Can't get dd-trace-go version", http.StatusInternalServerError)
return
}

appsec_rules_version, err := os.ReadFile("SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION")
if err != nil {
http.Error(w, "Can't get SYSTEM_TESTS_APPSEC_EVENT_RULES_VERSION", http.StatusInternalServerError)
return
}

libray := map[string]interface{}{
"language": "golang",
"version": string(tracerVersion),
"appsec_event_rules_version": string(appsec_rules_version),
"libddwaf_version": libddwafVersion,
}

data := map[string]interface{}{
"status": "ok",
"library": libray,
}

jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "Can't build JSON data", http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
w.Write(jsonData)
w.Header().Set("Content-Type", "application/json")
w.Write(jsonData)
})

common.InitDatadog()
Expand Down
Loading

0 comments on commit 43c760d

Please sign in to comment.