appsec_disabled.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Unless explicitly stated otherwise all files in this repository are licensed
  2. // under the Apache License Version 2.0.
  3. // This product includes software developed at Datadog (https://www.datadoghq.com/).
  4. // Copyright 2016 Datadog, Inc.
  5. //go:build !appsec
  6. // +build !appsec
  7. package appsec
  8. import "gopkg.in/DataDog/dd-trace-go.v1/internal/log"
  9. // Enabled returns true when AppSec is up and running. Meaning that the appsec build tag is enabled, the env var
  10. // DD_APPSEC_ENABLED is set to true, and the tracer is started.
  11. func Enabled() bool {
  12. return false
  13. }
  14. // Start AppSec when enabled by both using the appsec build tag and
  15. // setting the environment variable DD_APPSEC_ENABLED to true.
  16. func Start(...StartOption) {
  17. if enabled, _, err := isEnabled(); err != nil {
  18. // Something went wrong while checking the DD_APPSEC_ENABLED configuration
  19. log.Error("appsec: error while checking if appsec is enabled: %v", err)
  20. } else if enabled {
  21. // The user is willing to enable appsec but didn't use the build tag
  22. log.Info("appsec: enabled by the configuration but has not been activated during the compilation: please add the go build tag `appsec` to your build options to enable it")
  23. } else {
  24. // The user is not willing to start appsec, a simple debug log is enough
  25. log.Debug("appsec: not been not enabled during the compilation: please add the go build tag `appsec` to your build options to enable it")
  26. }
  27. }
  28. // Stop AppSec.
  29. func Stop() {}
  30. // Static rule stubs when disabled.
  31. const staticRecommendedRules = ""