• Stars
    star
    260
  • Rank 153,914 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Threatest is a CLI and Go framework for end-to-end testing threat detection rules.

Threatest

unit tests static analysis

Threatest

Threatest is a CLI and Go framework for testing threat detection end-to-end.

Threatest allows you to detonate an attack technique, and verify that the alert you expect was generated in your favorite security platform.

Read the announcement blog post: https://securitylabs.datadoghq.com/articles/threatest-end-to-end-testing-threat-detection/

Concepts

Detonators

A detonator describes how and where an attack technique is executed.

Supported detonators:

  • Local command execution
  • SSH command execution
  • Stratus Red Team
  • AWS CLI detonator
  • AWS detonator (programmatic only, does not work with the CLI)

Alert matchers

An alert matcher is a platform-specific integration that can check if an expected alert was triggered.

Supported alert matchers:

  • Datadog security signals

Detonation and alert correlation

Each detonation is assigned a UUID. This UUID is reflected in the detonation and used to ensure that the matched alert corresponds exactly to this detonation.

The way this is done depends on the detonator; for instance, Stratus Red Team and the AWS Detonator inject it in the user-agent; the SSH detonator uses a parent process containing the UUID.

Usage

Through the CLI

Threatest comes with a CLI that you can use to run test scenarios described as YAML, following a specific schema. You can configure this schema in your editor to benefit from in-IDE linting and autocompletion (see documentation for VSCode using the YAML extension).

Install the CLI by downloading a binary release or with Homebrew:

brew tap datadog/threatest https://github.com/datadog/threatest
brew install datadog/threatest/threatest

Sample usage:

$ threatest lint scenarios.threatest.yaml
All 6 scenarios are syntaxically valid

# Local detonation
$ threatest run local-scenarios.threatest.yaml

# Remote detonation over SSH
$ threatest run scenarios.threatest.yaml --ssh-host test-box --ssh-username vagrant

# Alternatively, specify SSH parameters from environment variables
$ export THREATEST_SSH_HOST=test-box
$ export THREATEST_SSH_USERNAME=vagrant
$ threatest run scenarios.threatest.yaml

Sample scenario definition files

  • Detonating over SSH
scenarios:
  # Remote detonation over SSH
  # Note: SSH configuration is provided using the --ssh-host, --ssh-username and --ssh-keyfile CLI arguments
  - name: curl metadata service
    detonate:
      remoteDetonator:
        commands: ["curl http://169.254.169.254 --connect-timeout 1"]
    expectations:
      - timeout: 1m
        datadogSecuritySignal:
          name: "Network utility accessed cloud metadata service"
          severity: medium
  • Detonating using Stratus Red Team
scenarios:
  # Stratus Red Team detonation
  # Note: You must be authenticated to the relevant cloud provider before running it
  # The example below is equivalent to manually running "stratus detonate aws.exfiltration.ec2-security-group-open-port-22-ingress"
  - name: opening a security group to the Internet
    detonate:
      stratusRedTeamDetonator:
        attackTechnique: aws.exfiltration.ec2-security-group-open-port-22-ingress
    expectations:
      - timeout: 15m
        datadogSecuritySignal:
          name: "Potential administrative port open to the world via AWS security group"
  • Detonating using AWS CLI commands
scenarios:
  # AWS CLI detonation
  # Note: You must be authenticated to AWS before running it and have the AWS CLI installed
  - name: opening a security group to the Internet
    detonate:
      awsCliDetonator:
        script: |
          set -e
          
          # Setup
          vpc=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text)
          sg=$(aws ec2 create-security-group --group-name sample-sg --description "Test security group" --vpc-id $vpc --query GroupId --output text)
          
          # Open security group
          aws ec2 authorize-security-group-ingress --group-id $sg --protocol tcp --port 22 --cidr 0.0.0.0/0
          
          # Cleanup
          aws ec2 delete-security-group --group-id $sg
          aws ec2 delete-vpc --vpc-id $vpc
    expectations:
      - timeout: 15m
        datadogSecuritySignal:
          name: "Potential administrative port open to the world via AWS security group"

You can output the test results to a JSON file:

$ threatest run scenarios.threatest.yaml --output test-results.json
$ cat test-results.json
[
  {
    "description": "change user password",
    "isSuccess": true,
    "errorMessage": "",
    "durationSeconds": 22.046627348,
    "timeDetonated": "2022-11-15T22:26:14.182844+01:00"
  },
  {
    "description": "adding an SSH key",
    "isSuccess": true,
    "errorMessage": "",
    "durationSeconds": 23.604699625,
    "timeDetonated": "2022-11-15T22:26:14.182832+01:00"
  },
  {
    "description": "change user password",
    "isSuccess": false,
    "errorMessage": "At least one scenario failed:\n\nchange user password returned: change user password: 1 assertions did not pass\n =\u003e Did not find Datadog security signal 'bar'\n",
    "durationSeconds": 3.505294235,
    "timeDetonated": "2022-11-15T22:26:36.229349+01:00"
  }
]

By default, scenarios are run with a maximum parallelism of 5. You can increase this setting using the --parallelism argument. Note that when using remote SSH detonators, each scenario running establishes a new SSH connection.

Using Threatest programmatically

See examples for complete programmatic usage example.

Testing Datadog Cloud SIEM signals triggered by Stratus Red Team

threatest := Threatest()

threatest.Scenario("AWS console login").
  WhenDetonating(StratusRedTeamTechnique("aws.initial-access.console-login-without-mfa")).
  Expect(DatadogSecuritySignal("AWS Console login without MFA").WithSeverity("medium")).
  WithTimeout(15 * time.Minute)

assert.NoError(t, threatest.Run())

Testing Datadog Cloud Workload Security signals triggered by running commands over SSH

ssh, _ := NewSSHCommandExecutor("test-box", "", "")

threatest := Threatest()

threatest.Scenario("curl to metadata service").
  WhenDetonating(NewCommandDetonator(ssh, "curl http://169.254.169.254 --connect-timeout 1")).
  Expect(DatadogSecuritySignal("EC2 Instance Metadata Service Accessed via Network Utility"))

assert.NoError(t, threatest.Run())

More Repositories

1

go-profiler-notes

felixge's notes on the various go profiling methods that are available.
Jupyter Notebook
3,255
star
2

glommio

Glommio is a thread-per-core crate that makes writing highly parallel asynchronous applications in a thread-per-core architecture easier for rustaceans.
Rust
2,907
star
3

datadog-agent

Main repository for Datadog Agent
Go
2,716
star
4

stratus-red-team

โ˜๏ธ โšก Granular, Actionable Adversary Emulation for the Cloud
Go
1,664
star
5

dd-agent

Datadog Agent Version 5
Python
1,291
star
6

integrations-core

Core integrations of the Datadog Agent
Python
878
star
7

zstd

Zstd wrapper for Go
C
724
star
8

the-monitor

Markdown files for Datadog's longform blog posts: https://www.datadoghq.com/blog/
Python
613
star
9

dd-trace-js

JavaScript APM Tracer
JavaScript
605
star
10

datadogpy

The Datadog Python library
Python
575
star
11

dd-trace-go

Datadog Go Library including APM tracing, profiling, and security monitoring.
Go
545
star
12

guarddog

๐Ÿ ๐Ÿ” GuardDog is a CLI tool to Identify malicious PyPI and npm packages
Python
530
star
13

dd-trace-py

Datadog Python APM Client
Python
502
star
14

dd-trace-java

Datadog APM client for Java
Java
500
star
15

yubikey

YubiKey at Datadog
Shell
493
star
16

kafka-kit

Kafka storage rebalancing, automated replication throttle, cluster API and more
Go
480
star
17

dd-trace-php

Datadog PHP Clients
PHP
473
star
18

documentation

The source for Datadog's documentation site.
JavaScript
418
star
19

dd-trace-dotnet

.NET Client Library for Datadog APM
C#
412
star
20

security-labs-pocs

Proof of concept code for Datadog Security Labs referenced exploits.
Shell
355
star
21

go-python3

Go bindings to the CPython-3 API
Go
344
star
22

datadog-go

go dogstatsd client library for datadog
Go
332
star
23

terraform-provider-datadog

Terraform Datadog provider
Go
329
star
24

datadog-serverless-functions

Repo of AWS Lambda and Azure Functions functions that process streams and send data to Datadog
Python
326
star
25

helm-charts

Helm charts for Datadog products
Go
322
star
26

docker-dd-agent

Datadog Agent Dockerfile for Trusted Builds.
Roff
302
star
27

ansible-datadog

Ansible role for Datadog Agent
Jinja
294
star
28

datadog-operator

Datadog Agent Kubernetes Operator
Go
285
star
29

browser-sdk

Datadog Browser SDK
TypeScript
279
star
30

dd-trace-rb

Datadog Tracing Ruby Client
Ruby
261
star
31

integrations-extras

Community developed integrations and plugins for the Datadog Agent.
Python
243
star
32

watermarkpodautoscaler

Custom controller that extends the Horizontal Pod Autoscaler
Go
207
star
33

pupernetes

Spin up a full fledged Kubernetes environment designed for local development & CI
Go
200
star
34

Miscellany

Miscellaneous scripts and tools
Python
197
star
35

php-datadogstatsd

A PHP client for DogStatsd
PHP
185
star
36

dd-sdk-ios

Datadog SDK for iOS - Swift and Objective-C.
Swift
183
star
37

java-dogstatsd-client

Java statsd client library
Java
177
star
38

dogstatsd-ruby

A Ruby client for DogStatsd
Ruby
166
star
39

sketches-go

Go implementations of the distributed quantile sketch algorithm DDSketch
Go
142
star
40

chaos-controller

๐Ÿ’ ๐Ÿ”ฅ Datadog Failure Injection System for Kubernetes
C
142
star
41

dd-sdk-android

Datadog SDK for Android (Compatible with Kotlin and Java)
Kotlin
140
star
42

kvexpress

Go program to move data in and out of Consul's KV store.
Go
128
star
43

HASH

HASH (HTTP Agnostic Software Honeypot)
JavaScript
119
star
44

docker-compose-example

A working example of using Docker Compose with Datadog
Python
116
star
45

malicious-software-packages-dataset

An open-source dataset of malicious software packages found in the wild, 100% vetted by humans.
Python
116
star
46

ebpf-manager

This manager helps handle the life cycle of your eBPF programs
Go
114
star
47

trace-examples

trace sample apps
Python
113
star
48

sketches-java

DDSketch: A Fast and Fully-Mergeable Quantile Sketch with Relative-Error Guarantees.
Java
108
star
49

dd-sdk-reactnative

Datadog SDK for ReactNative
TypeScript
105
star
50

gohai

System information collector
Go
102
star
51

datadog-lambda-js

The Datadog AWS Lambda Library for Node
TypeScript
101
star
52

chef-datadog

Chef cookbook for Datadog Agent & Integrations
Ruby
97
star
53

piecewise

Functions for piecewise regression on time series data
Python
96
star
54

orchestrion

A tool for adding instrumentation to Go code
Go
96
star
55

jmxfetch

Export JMX metrics
Java
96
star
56

extendeddaemonset

Kubernetes Extended Daemonset controller
Go
95
star
57

datadog-api-client-go

Golang client for the Datadog API
Go
95
star
58

dogstatsd-csharp-client

A DogStatsD client for C#/.NET
C#
94
star
59

gostackparse

Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.
Go
94
star
60

ansible-datadog-callback

Ansible callback to get stats & events directly into Datadog http://datadoghq.com
Python
93
star
61

dogapi-rb

Ruby client for Datadog's API
Ruby
92
star
62

redux-doghouse

Scoping helpers for building reusable components with Redux
JavaScript
90
star
63

build-plugin

Track your build performances like never before.
TypeScript
89
star
64

serverless-plugin-datadog

Serverless plugin to automagically instrument your Lambda functions with Datadog
TypeScript
87
star
65

ecommerce-workshop

Example eCommerce App for workshops and observability
Ruby
86
star
66

datadog-ci

Use Datadog from your CI.
TypeScript
85
star
67

ebpfbench

profile eBPF programs from Go
Go
83
star
68

datadog-lambda-python

The Datadog AWS Lambda Layer for Python
Python
80
star
69

sketches-py

Python implementations of the distributed quantile sketch algorithm DDSketch
Python
77
star
70

dirtypipe-container-breakout-poc

Container Excape PoC for CVE-2022-0847 "DirtyPipe"
77
star
71

datadog-api-client-typescript

Typescript client for the Datadog API
TypeScript
74
star
72

ddqa

Datadog's QA manager for releases of GitHub repositories
Python
73
star
73

datadog-trace-agent

Datadog Trace Agent archive (pre-6.10.0)
70
star
74

heroku-buildpack-datadog

Heroku Buildpack to run the Datadog Agent in a Dyno
Shell
69
star
75

datadog-api-client-python

Python client for the Datadog API
Python
68
star
76

datadog-static-analyzer

Datadog Static Analyzer
Rust
64
star
77

managed-kubernetes-auditing-toolkit

All-in-one auditing toolkit for identifying common security issues in managed Kubernetes environments. Currently supports AWS EKS.
Go
60
star
78

lading

A suite of data generation and load testing tools
Rust
60
star
79

datadog-lambda-extension

Rust
60
star
80

jsonapi

A marshaler/unmarshaler for JSON:API.
Go
59
star
81

datadog-cdk-constructs

CDK construct library to automagically instrument your Lambda functions with Datadog
TypeScript
58
star
82

datadog-lambda-go

The Datadog AWS Lambda package for Go
Go
57
star
83

datadog-api-client-java

Java client for the Datadog API
Java
54
star
84

serilog-sinks-datadog-logs

Serilog Sink that sends log events to Datadog https://www.datadoghq.com/
C#
53
star
85

puppet-datadog-agent

Puppet module to install the Datadog agent
Ruby
50
star
86

opencensus-go-exporter-datadog

Datadog exporter for OpenCensus metrics
Go
47
star
87

gello

:octocat: A self-hosted server for managing Trello cards based on GitHub webhook events
Python
45
star
88

datadog-cloudformation-resources

Python
44
star
89

effective-dashboards

A curated list of useful Datadog dashboards and Dashboard design best practices
44
star
90

ebpf-training

Go
44
star
91

jenkins-datadog-plugin

ARCHIVED: Current repository is now located https://github.com/jenkinsci/datadog-plugin
Java
42
star
92

dd-sdk-flutter

Flutter bindings and tools for utilizing Datadog Mobile SDKs
Dart
40
star
93

dd-opentracing-cpp

Datadog Opentracing C++ Client
C++
40
star
94

synthetics-ci-github-action

Use Browser and API tests in your CI/CD with Datadog Continuous Testing
TypeScript
40
star
95

rum-react-integration-examples

rum-react-integration
TypeScript
39
star
96

fluent-plugin-datadog

Fluentd output plugin for Datadog: https://www.datadog.com
Ruby
38
star
97

import-in-the-middle

Like `require-in-the-middle`, but for ESM import
JavaScript
38
star
98

ddprof

The Datadog Native Profiler for Linux
C++
35
star
99

datadog-sync-cli

Datadog cli tool to sync resources across organizations.
Python
33
star
100

apigentools

Generate API clients with ease
Python
32
star