Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cmd/devguard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ import (
_ "github.com/lib/pq"
)

var release string // Will be filled at build time

// @title DevGuard API
// @version v1
// @description DevGuard Backend. Secure your Software Supply Chain. Attestation-based compliance as Code, manage your CVEs seamlessly, Integrate your Vulnerability Scanners, Security Framework Documentation made easy. OWASP Incubating Project
Expand Down Expand Up @@ -196,7 +194,7 @@ func main() {
}

func apiVersion() string {
return telemetry.RuntimeVersion(config.Version, release)
return telemetry.RuntimeVersion(config.Version)
}
Comment on lines 196 to 198

type fxErrorLogger struct{}
Expand Down Expand Up @@ -351,7 +349,7 @@ func initSentry() {
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("ERROR_TRACKING_DSN"),
Environment: environment,
Release: release,
Release: config.Version,

Comment thread
5byuri marked this conversation as resolved.
// Configures whether SDK should generate and attach stack traces to pure
// capture message calls.
Expand Down
15 changes: 4 additions & 11 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os"
"runtime"
"runtime/debug"
"strconv"
"strings"
"time"

Expand All @@ -40,7 +41,7 @@ const (

EventName = "devguard-instance-start"
TelemetryEndpoint = "https://umami.l3montree.com/api/send"
WebsiteID = "2ab9fe36-42ec-485d-a592-b0f6e78dd1ad"
WebsiteID = "19cc127d-774c-4fb0-981d-26d110074a14"
DefaultTimeout = 30 * time.Second
UserAgent = "DevguardTelemetry"
SchemaVersion = 1
Expand Down Expand Up @@ -100,8 +101,9 @@ type umamiPayload struct {
}

func ConfigFromEnv() Config {
disabled, _ := strconv.ParseBool(os.Getenv(EnvDisabled))
return Config{
Disabled: isTruthyEnv(os.Getenv(EnvDisabled)),
Disabled: disabled,
}
}
Comment thread
5byuri marked this conversation as resolved.

Expand Down Expand Up @@ -281,15 +283,6 @@ func HashParts(parts ...string) string {
return hex.EncodeToString(hash.Sum(nil))[:instanceIDLength]
}

func isTruthyEnv(value string) bool {
switch strings.ToLower(strings.TrimSpace(value)) {
case "1", "true", "yes", "on":
return true
default:
return false
}
}

func RuntimeVersion(values ...string) string {
for _, value := range values {
if version := normalizeBuildVersion(value); version != "" {
Expand Down
2 changes: 1 addition & 1 deletion telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestScannerStartupPayloadDoesNotIncludeSensitiveRuntimeInputs(t *testing.T)
}

func TestConfigFromEnvDisabledValues(t *testing.T) {
for _, value := range []string{"true", "TRUE", "1", "yes", "on"} {
for _, value := range []string{"true", "TRUE", "True", "1", "t", "T"} {
Comment thread
5byuri marked this conversation as resolved.
t.Run(value, func(t *testing.T) {
t.Setenv(EnvDisabled, value)

Expand Down
Loading