diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a8531f..f40641e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,10 @@ name: Test on: workflow_dispatch: # manually - schedule: # nightly - - cron: "0 0 * * *" - pull_request: # on pull requests touching appsec files + pull_request: # default behaviour opened, reopened, synchronize, edited, ready_for_review + merge_group: + branches: + - main push: # on push to the main branch branches: - main @@ -11,59 +12,69 @@ env: DD_APPSEC_WAF_TIMEOUT: 5s jobs: native: + name: Native ${{ matrix.runs-on }} (Go ${{ matrix.go-version }}, CGO_ENABLED=${{ matrix.cgo_enabled }}) strategy: matrix: - runs-on: [ macos-13, macos-12, macos-11, ubuntu-22.04, ubuntu-20.04, windows-latest ] - go-version: [ "1.21", "1.20", "1.19" ] - cgo_enabled: # test it compiles with and without cgo - - 0 - - 1 + runs-on: [ macos-15, macos-14, macos-13, ubuntu-24.04, ubuntu-22.04, windows-latest, arm-4core-linux ] + go-version: [ "1.24", "1.23" ] + cgo_enabled: [ "0", "1" ] # test it compiles with and without cgo fail-fast: false runs-on: ${{ matrix.runs-on }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Setup Go + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} cache: true - name: Go modules cache - uses: actions/cache@v3 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ~/go/pkg/mod key: go-pkg-mod-${{ hashFiles('**/go.sum') }} restore-keys: go-pkg-mod- + # Install build-essential on ARM linux runners if CGO is to be enabled + - name: Install build-essential (ARM linux) + if: matrix.runs-on == 'arm-4core-linux' && matrix.cgo_enabled == '1' + run: |- + sudo apt update + sudo apt install -y build-essential + - name: go test shell: bash run: | # Install gotestsum env GOBIN=$PWD go install gotest.tools/gotestsum@latest # Run the tests with gotestsum - env CGO_ENABLED=${{ matrix.cgo_enabled }} ./gotestsum -- -v ./... || true + ./gotestsum -- -v ${{ runner.os == 'Linux' && matrix.cgo_enabled == '1' && '-race' || '' }} ./... + env: + CGO_ENABLED: ${{ matrix.cgo_enabled }} # Same tests but on the official golang container for linux golang-linux-container: + name: Docker golang:${{ matrix.go-version }}-${{ matrix.distribution }} (CGO_ENABLED=${{ matrix.cgo_enabled }}) runs-on: ubuntu-latest container: image: golang:${{ matrix.go-version }}-${{ matrix.distribution }} strategy: matrix: - go-version: [ "1.21", "1.20", "1.19" ] - distribution: [ bookworm, bullseye, buster, alpine ] + go-version: [ "1.24", "1.23" ] + distribution: [ bookworm, bullseye, alpine ] cgo_enabled: [ "0", "1" ] # test it compiles with and without cgo - exclude: - - go-version: 1.21 - distribution: buster fail-fast: false steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # Install gcc and the libc headers on alpine images - - if: ${{ matrix.distribution == 'alpine' }} + - if: matrix.distribution == 'alpine' + name: Install necessary packages (Alpine) run: apk add gcc musl-dev libc6-compat git - name: Go modules cache - uses: actions/cache@v3 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ~/go/pkg/mod key: go-pkg-mod-${{ hashFiles('**/go.sum') }} @@ -74,27 +85,16 @@ jobs: # Install gotestsum env GOBIN=$PWD go install gotest.tools/gotestsum@latest # Run the tests with gotestsum - env CGO_ENABLED=${{ matrix.cgo_enabled }} ./gotestsum -- -v ./... || true + ./gotestsum -- -v ${{ matrix.cgo_enabled == '1' && '-race' || '' }} ./... + env: + CGO_ENABLED: ${{ matrix.cgo_enabled }} - linux-arm64: + everything: + name: All Tests + needs: + - native + - golang-linux-container runs-on: ubuntu-latest - strategy: - matrix: - cgo_enabled: # test it compiles with and without the cgo - - 0 - - 1 - fail-fast: false steps: - - uses: actions/checkout@v3 - - name: Go modules cache - uses: actions/cache@v3 - with: - path: ~/go/pkg/mod - key: go-pkg-mod-${{ hashFiles('**/go.sum') }} - restore-keys: go-pkg-mod- - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - run: docker run --platform=linux/arm64 -v $PWD:$PWD -w $PWD -eCGO_ENABLED=${{ matrix.cgo_enabled }} -eDD_APPSEC_WAF_TIMEOUT=$DD_APPSEC_WAF_TIMEOUT golang go test -v ./... - + - name: Completed + run: echo "All tests completed!" diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..2e4d479 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# default owner +* @DataDog/asm-go diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6d3c93 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# `github.com/DataDog/appsec-internal-go` + +This repository hosts a go module that provides shared implementations for +internal details of various DataDog libraries and agents. This module is not +intended to be used directly by end-users. + +## Updating embedded Rules + +Embedded rules (at `appsec/rules.json`) are updated by the +`_tools/rules-updater/update.sh` script. A GitHub Workflow named +`Update AppSec Rules` can be used to perform this task entirely from the GitHub +Web UI. + +The GitHub Workflow runs automatically on a weekly basis (relatively early on +Monday morning), so manual intervention (beyond reviewing and merging the PR +created by the scheduled execution) should not be needed unless rules need to be +updated without waiting for the next Monday. diff --git a/_tools/rules-updater/Dockerfile b/_tools/rules-updater/Dockerfile index 234126f..9655655 100644 --- a/_tools/rules-updater/Dockerfile +++ b/_tools/rules-updater/Dockerfile @@ -1,10 +1,30 @@ -FROM golang:1.21 as go-format -ARG version -ENV VERSION=$version -ADD https://raw.githubusercontent.com/DataDog/appsec-event-rules/$version/build/recommended.json /home/rules.json +# syntax=docker/dockerfile:1 +FROM golang:latest AS go-format + +RUN apt update && apt install -y jq curl COPY writer/ /home/ WORKDIR /home/ -RUN go run writer.go ${VERSION} > embed.go + +ARG version + +RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ + if [ "${version}" = "latest" ]; then \ + curl \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" \ + --header "X-Github-Api-Version: 2022-11-28" \ + -fSsL 'https://api.github.com/repos/DataDog/appsec-event-rules/releases/latest' \ + | jq -r '.tag_name' > .version; \ + else \ + echo "${version}" > .version; \ + fi + +RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ + curl \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" \ + --header "X-Github-Api-Version: 2022-11-28" \ + -fSsL "https://raw.githubusercontent.com/DataDog/appsec-event-rules/$(cat .version)/build/recommended.json" \ + -o /home/rules.json +RUN go run writer.go $(cat .version) > embed.go FROM scratch COPY --from=go-format /home/embed.go embed.go diff --git a/_tools/rules-updater/update.sh b/_tools/rules-updater/update.sh index 14a6b31..465c03d 100755 --- a/_tools/rules-updater/update.sh +++ b/_tools/rules-updater/update.sh @@ -10,11 +10,19 @@ # Usage: ./update.sh # Example: ./update.sh 1.2.5 # +# When the tag specified is "latest", the latest version of the rules file is +# determined using the GitHub API. set -eu [ $# -ne 1 ] && echo "Usage: $0 \"version\"" >&2 && exit 1 +if [ -z ${GITHUB_TOKEN:-} ]; then + echo "The GITHUB_TOKEN environmnent variable must be set to a valid GitHub" + echo "token with read access to the DataDog/appsec-event-rules repository." + exit 1 +fi + echo "================ Minifying ================" tmpDir="$(mktemp -d /tmp/rule-update-XXXXXXXXX)" @@ -24,8 +32,7 @@ destDir="$(readlink -f "$scriptDir/../../appsec/")" trap "rm -r $tmpDir" EXIT -DOCKER_BUILDKIT=1 docker build -o type=local,dest="$tmpDir" --build-arg version="$1" --no-cache "$scriptDir" +DOCKER_BUILDKIT=1 docker build -o type=local,dest="$tmpDir" --build-arg version="$1" --secret "id=GITHUB_TOKEN,env=GITHUB_TOKEN" --no-cache "$scriptDir" echo "================ Done ================" -cp -v $tmpDir/embed.go "$destDir" -cp -v $tmpDir/rules.json "$destDir" +cp -v $tmpDir/embed.go $tmpDir/rules.json "$destDir" echo "Output written to $destDir" diff --git a/_tools/rules-updater/writer/template.txt b/_tools/rules-updater/writer/template.txt index c0a02f5..652f904 100644 --- a/_tools/rules-updater/writer/template.txt +++ b/_tools/rules-updater/writer/template.txt @@ -5,16 +5,16 @@ package appsec -import _ "embed" // Blank import comment for golint compliance +import ( + _ "embed" // Blank import comment for golint compliance + "unsafe" +) -// StaticRecommendedRules holds the recommended AppSec security rules (v{{.Version}}) -// Source: https://github.com/DataDog/appsec-event-rules/blob/{{.Version}}/build/recommended.json -// -//go:embed rules.json -var StaticRecommendedRules string +var ( + //go:embed rules.json + staticRecommendedRules []byte -// StaticProcessors holds the default processors and scanners used for API Security -// Not part of the recommended security rules -// -//go:embed processors.json -var StaticProcessors string + // StaticRecommendedRules holds the recommended AppSec security rules (v{{.Version}}) + // Source: https://github.com/DataDog/appsec-event-rules/blob/{{.Version}}/build/recommended.json + StaticRecommendedRules = unsafe.String(&staticRecommendedRules[0], len(staticRecommendedRules)) +) diff --git a/apisec/internal/config/const.go b/apisec/internal/config/const.go new file mode 100644 index 0000000..6483f28 --- /dev/null +++ b/apisec/internal/config/const.go @@ -0,0 +1,11 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package config + +const ( + // MaxItemCount is the maximum amount of items to keep in a timed set. + MaxItemCount = 4_096 +) diff --git a/apisec/internal/timed/clock.go b/apisec/internal/timed/clock.go new file mode 100644 index 0000000..da0fa7f --- /dev/null +++ b/apisec/internal/timed/clock.go @@ -0,0 +1,42 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package timed + +import "time" + +type ( + ClockFunc = func() int64 + + // biasedClock is a specialized clock implementation used to ensure we can get + // 32-bit wide timestamps without having to worry about wraparound. + biasedClock struct { + // clock is the underlying clock, returning a timestamp in seconds. + clock ClockFunc + // bias is effectively the time at which the biasedClock was initialized. + bias int64 + } +) + +// newBiasedClock creates a new [biasedClock] with the given clock function and +// horizon. +func newBiasedClock(clock ClockFunc, horizon uint32) biasedClock { + return biasedClock{ + clock: clock, + bias: clock() - int64(horizon), + } +} + +// Now returns the current timestamp, relative to this [biasedClock]. +func (c *biasedClock) Now() uint32 { + // We clamp it to [0,) to be absolutely safe... + return uint32(max(0, c.clock()-c.bias)) +} + +// UnixTime is a [ClockFunc] that returns the current Unix time (seconds since +// the Unix epoch). +func UnixTime() int64 { + return time.Now().Unix() +} diff --git a/apisec/internal/timed/lru.go b/apisec/internal/timed/lru.go new file mode 100644 index 0000000..4a86f5d --- /dev/null +++ b/apisec/internal/timed/lru.go @@ -0,0 +1,211 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package timed + +import ( + "fmt" + "math" + "math/rand" + "sync/atomic" + "time" + + "github.com/DataDog/appsec-internal-go/apisec/internal/config" + "github.com/DataDog/appsec-internal-go/log" +) + +// capacity is the maximum number of items that may be temporarily present in a +// [LRU]. An eviction triggers once [config.MaxItemCount] is reached, however the +// implementation is based on Copy-Update-Replace semantics, so during a table +// rebuild, the old table may contrinue to receive items for a short while. +const capacity = 2 * config.MaxItemCount + +// LRU is a specialized open-addressing-hash-table-based implementation of a +// specialized LRU cache, using Copy-Update-Replace semantics to operate in a +// completely lock-less manner. +type LRU struct { + // table is the pointer to the current backing hash table + table atomic.Pointer[table] + // clock is used to determine the current timestamp when making + // changes + clock biasedClock + // intervalSeconds is the amount of time in seconds that an entry is + // considered live for. + intervalSeconds uint32 + // zeroKey is a key that is used to replace 0 in the set. This key and 0 are + // effectively the same item. This allows us to gracefully handle 0 in our + // use-case without having to half the hash-space (to 63 bits) so we can use + // one bit as an empty discriminator. The value is chosen at random when the + // set is created, so that different instances will merge 0 with a different + // key. + zeroKey uint64 + // rebuilding is a flag to indicate whether the table is being rebuilt as + // part of an eviction request. + rebuilding atomic.Bool +} + +// NewLRU initializes a new, empty [LRU] with the given interval and clock +// function. A warning will be logged if it is set below 1 second. Panics if +// the interval is more than [math.MaxUint32] seconds, as this value cannot be +// used internally. +// +// Note: timestamps are stored at second resolution, so the interval will be +// rounded down to the nearest second. +func NewLRU(interval time.Duration, clock ClockFunc) *LRU { + if interval < time.Second { + log.Warn("NewLRU: interval is less than one second; this should not be attempted in production (value: %s)", interval) + } + if interval > time.Second*math.MaxUint32 { + panic(fmt.Errorf("NewLRU: interval must be <= %s, but was %s", time.Second*math.MaxUint32, interval)) + } + + intervalSeconds := uint32(interval.Seconds()) + set := &LRU{ + clock: newBiasedClock(clock, intervalSeconds), + intervalSeconds: intervalSeconds, + zeroKey: rand.Uint64(), + } + + // That value cannot be zero... + for set.zeroKey == 0 { + set.zeroKey = rand.Uint64() + } + + set.table.Store(&table{}) + + return set +} + +// Hit determines whether the given key should be kept or dropped based on the +// last time it was sampled. If the table grows larger than [config.MaxItemCount], the +// [LRU.rebuild] method is called in a separate goroutine to begin the +// eviction process. Until this has completed, all updates to the [LRU] are +// effectively dropped, as they happen on the soon-to-be-replaced table. +// +// Note: in order to run completely lock-less, [LRU] cannot store the 0 key in +// the table, as a 0 key is used as a sentinel value to identify free entries. +// To avoid this pitfall, [LRU.zeroKey] is used as a substitute for 0, meaning +// 0 and [LRU.zeroKey] are treated as the same key. This is not an issue in +// common use, as given a uniform distribution of keys this only happens 1 in +// 2^64-1 times. +func (m *LRU) Hit(key uint64) bool { + if key == 0 { + // The 0 key is used as a way to imply a slot is empty; so we cannot store + // it in the table. To address this, when passed a 0 key, we will use the + // [Set.zeroKey] as a substitute. + key = m.zeroKey + } + + now := m.clock.Now() + threshold := now - m.intervalSeconds + + var ( + table = m.table.Load() + entry *entry + ) + for { + var exists bool + entry, exists = table.FindEntry(key) + if exists { + // The entry already exists, so we can proceed... + break + } + + // We're adding a new entry to the table, so we need to: + // 1. Ensure we have capacity (possibly trigger an eviction rebuild) + // 2. Claim the slot (or look for another slot if it's already claimed) + newCount := table.count.Add(1) + if newCount > config.MaxItemCount && m.rebuilding.CompareAndSwap(false, true) { + // We're already holding the maximium number of items, so we will rebuild + // in order to perform an eviction pass. Updates made in the meantime will + // be lost. + go m.rebuild(table, threshold) + } + if newCount > capacity { + // We don't have space to add any new item, so we'll ignore this and + // decide to DROP it (we may otherwise cause a surge of inconditional + // keep decisions, that is not desirable). This only happens in the most + // dire of circumstances (a table rebuild did not complete fast enough + // to make up free space). + table.count.Add(-1) + return false + } + + if entry.Key.CompareAndSwap(0, key) { + // We have successfully claimed the slot, so now we can proceed to set it + // up. If we fail to swap, another goroutine has sampled this slot just + // before this one, so we can DROP the sample. + return entry.Data.CompareAndSwap(0, newEntryData(now, now)) + } + + if entry.Key.Load() == key { + // Another goroutine has concurrently claimed this slot for this key, and + // since very little time has passed since then, so we can DROP this + // sample... This is extremely unlikely to happen (and nearly impossible + // to reliably cover in unit tests). + return false + } + + // Another goroutine has concurrently claimed this slot for another key... + // We will try to find another slot then... + table.count.Add(-1) + } + + // We have found an existing entry, so we can proceed to update it... + curData := entry.Data.Load() + if curData.SampleTime() <= threshold { + // We sampled this a while back (or this is the first time), so we may keep + // this sample! + + // Store the value ahead of the for loop so we don't have to do the bit + // shifts over and over again (even though they're cheap to do). + nowEntryData := newEntryData(now, now) + for !entry.Data.CompareAndSwap(curData, nowEntryData) { + // Another goroutine has already changed it... + curData = entry.Data.Load() + if curData.LastAccessKept() { + // The concurrent update was a KEEP (as is indicated by the fact its + // atime and stime are equal), so this one is necessarily a DROP. + return false + } + + if curData.SampleTime() >= now { + // The concurrent update was made in our future, and it somehow was not + // a KEEP, so we'll make a KEEP decision here, but avoid rolling back + // the [entryData.AccessTime] back. + return true + } + + // The concurrent update was a DROP, and our clock is ahead of theirs, so + // we'll try again... + } + + // We successfully swapped at this point, so we have our KEEP decision! + return true + } + + newData := curData.WithAccessTime(now) + for curData.AccessTime() < now { + if entry.Data.CompareAndSwap(curData, newData) { + // We are done here! + break + } + // Another goroutine has updated the access time... We'll try again... + curData = entry.Data.Load() + } + return false +} + +// rebuild runs in a separate goroutine, and creates a pruned copy of the +// provided [table] with old and expired entries removed. It will keep at most +// [config.MaxItemCount]*2/3 items in the new table. Once the rebuild is complete, it +// replaces the [LRU.table] with the copy. +func (m *LRU) rebuild(oldTable *table, threshold uint32) { + // Since Go has a GC, we can "just" replace the current [Set.table] with a + // trimmed down copy, and let the GC take care of reclaiming the old one, once + // it is no longer in use by any reader. + m.table.Store(oldTable.PrunedCopy(threshold)) + m.rebuilding.Store(false) +} diff --git a/apisec/internal/timed/lru_test.go b/apisec/internal/timed/lru_test.go new file mode 100644 index 0000000..c18ad49 --- /dev/null +++ b/apisec/internal/timed/lru_test.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package timed + +import ( + "context" + "math" + "runtime" + "sync" + "testing" + "time" + + "github.com/DataDog/appsec-internal-go/apisec/internal/config" + "github.com/DataDog/appsec-internal-go/apisec/internal/timed/testutil" + "github.com/stretchr/testify/require" +) + +func TestLRU(t *testing.T) { + t.Run("NewLRU", func(t *testing.T) { + require.PanicsWithError(t, "NewLRU: interval must be <= 1193046h28m15s, but was 1193046h28m16s", func() { NewLRU(time.Second*(math.MaxUint32+1), UnixTime) }) + }) + + t.Run("Hit", func(t *testing.T) { + fakeTime := time.Now().Unix() + fakeClock := func() int64 { return fakeTime } + + const sampleIntervalSeconds = 30 + subject := NewLRU(sampleIntervalSeconds*time.Second, fakeClock) + + require.True(t, subject.Hit(1337)) + for range sampleIntervalSeconds { + require.False(t, subject.Hit(1337)) + fakeTime++ + } + require.True(t, subject.Hit(1337)) + + t.Run("zero", func(t *testing.T) { + require.True(t, subject.Hit(0)) + + // Keys are slotted via [% capacity], so if we don't properly encode + // 0-values, the new slot will inherit the previously set sample time, and + // the assertion will fail as a result. + zeroSlot := uint64(capacity) + if zeroSlot == subject.zeroKey { + // There is a very small chance that the zero key has been set to + // [capacity], in which case we'll just double it to escape the + // collision and get a fresh new hit. + zeroSlot *= 2 + } + require.True(t, subject.Hit(zeroSlot)) + }) + }) + + t.Run("rebuild", func(t *testing.T) { + goCount := runtime.GOMAXPROCS(0) * 10 + ctx, cancel := context.WithCancel(context.Background()) + clock := testutil.NewFakeClock(ctx, t, goCount) + defer func() { + cancel() + clock.WaitUntilDone() + }() + + subject := NewLRU(30*time.Second, clock.Unix) + + var ( + startBarrier sync.WaitGroup + finishBarrier sync.WaitGroup + ) + startBarrier.Add(goCount + 1) + finishBarrier.Add(goCount) + for range goCount { + go func() { + defer finishBarrier.Done() + startBarrier.Done() + startBarrier.Wait() + + for key := range uint64(config.MaxItemCount * 4) { + _ = subject.Hit(key) + clock.WaitForTick() + } + }() + } + + startBarrier.Done() + finishBarrier.Wait() + + // Wiat for an in-progress rebuild to finish... + for subject.rebuilding.Load() { + runtime.Gosched() + } + + // Check the final table has a reasonable content... + table := subject.table.Load() + count := 0 + for i := range table.entries { + entry := &table.entries[i] + if entry.Key.Load() == 0 { + continue + } + // Since we ran through the keys sequentially, we should not have kept any + // of the first [config.MaxItemCount] keys in any case. + require.Less(t, uint64(config.MaxItemCount), entry.Key.Load()) + count++ + } + // We shoudl not have more than [maxItemCount] items left in the map... + require.LessOrEqual(t, count, config.MaxItemCount) + }) +} diff --git a/apisec/internal/timed/table.go b/apisec/internal/timed/table.go new file mode 100644 index 0000000..cfc1c4d --- /dev/null +++ b/apisec/internal/timed/table.go @@ -0,0 +1,181 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package timed + +import ( + "slices" + "sync/atomic" + + "github.com/DataDog/appsec-internal-go/apisec/internal/config" +) + +type ( + // table is a simple open-addressing hash table implementation that uses a + // fixed array of items. + table struct { + // entries is the set of items contained in the table. The last entry is + // reserved for cases where all slots are taken before a rebuild is + // complete (it saves us from having to write code to deal with the + // impossibility to find an empty slot, as we always have a slot to return. + // We could return a throw-away slot but this would incur a heap allocation, + // which we can spare by doing this). + entries [capacity + 1]entry + // count is the number of items currently stored in the table. + count atomic.Int32 + } + + // entry is a single item in the open-addressing hash table. + entry struct { + // Key is the Key of the entry. A zero Key indicates that the entry is + // currently free. + Key atomic.Uint64 + // Data is the Data associated with the entry. + Data atomicEntryData + } + + // atomicEntryData is an atomic version of [entryData]. + atomicEntryData atomic.Uint64 + // entryData is a 64-bit value that represents the last time an entry was + // accessed paired together with the last time this value was sampled. + entryData uint64 + + // copiableEntry is a copy-able version of entryData, which is used for + // sorting entries by recency using a heap when re-building the table. + copiableEntry struct { + // Key is the Key of the entry. + Key uint64 + // Data is the Data associated with the entry. + Data entryData + } +) + +// FindEntry locates the correct entry for use in the table. If an entry already +// exists for the given key, it is returned with true. If not, the first blank +// entry is returned with false. +func (t *table) FindEntry(key uint64) (*entry, bool) { + origIdx := key % capacity + idx := origIdx + + for { + entry := &t.entries[idx] + if curKey := entry.Key.Load(); curKey == 0 || curKey == key { + // This is either the entry we're looking for, or an empty slot we can + // claim for this key. + return entry, curKey == key + } + idx = (idx + 1) % capacity + if idx == origIdx { + // We are back at the original index, meaning the map is full. + break + } + } + // We have gone full circle without finding a blank slot, so we give up and + // return our last resort slot that is reserved for this situation. + return &t.entries[capacity], true +} + +// PrunedCopy creates a copy of this table with expired items removed, retaining +// up to the [config.MaxItemCount]*2/3 most recent items from the original. +func (t *table) PrunedCopy(threshold uint32) *table { + // Sort the existing entries (most recent at the top) + newEntries := make([]copiableEntry, 0, capacity) + for i := range capacity { + if t.entries[i].BlankOrExpired(threshold) { + continue + } + newEntries = append(newEntries, t.entries[i].Copyable()) + } + slices.SortFunc(newEntries, copiableEntry.Compare) + + // Insert up to [config.MaxItemCount]*2/3 items into the new table + t = new(table) + count := min(int32(config.MaxItemCount*2/3), int32(len(newEntries))) + for _, entry := range newEntries[:count] { + slot, _ := t.FindEntry(entry.Key) + slot.Key.Store(entry.Key) + slot.Data.Store(entry.Data) + } + t.count.Store(count) + + return t +} + +// BlankOrExpired returns true if the receiver is blank or has expired already. +func (e *entry) BlankOrExpired(threshold uint32) bool { + return e.Key.Load() == 0 || e.Data.Load().SampleTime() < threshold +} + +// Copyable returns a [copyableEntry] version of this entry. +func (e *entry) Copyable() copiableEntry { + return copiableEntry{ + Key: e.Key.Load(), + Data: e.Data.Load(), + } +} + +// Load returns the current value held by this atomic. +func (d *atomicEntryData) Load() entryData { + return entryData((*atomic.Uint64)(d).Load()) +} + +// CompareAndSwap atomically compares the current value held by this atomic with +// the old value, and if they match replaes it with the new value. Returns true +// if the swap happened. +func (d *atomicEntryData) CompareAndSwap(old entryData, new entryData) (swapped bool) { + return (*atomic.Uint64)(d).CompareAndSwap(uint64(old), uint64(new)) +} + +// Store atomically stores the given value in this atomic. +func (d *atomicEntryData) Store(new entryData) { + (*atomic.Uint64)(d).Store(uint64(new)) +} + +// newEntryData creates a new [entryData] value from the given access and sample +// times. +func newEntryData(atime uint32, stime uint32) entryData { + return entryData(uint64(atime)<<32 | uint64(stime)) +} + +// AccessTime is the access time part of the [entryData]. +func (d entryData) AccessTime() uint32 { + return uint32(d >> 32) +} + +// SampleTime is the sample time part of the [entryData]. +func (d entryData) SampleTime() uint32 { + return uint32(d) +} + +// LastAccessKept returns true if the last access to this entry resulted in a +// decision to keep the sample. This is true of the access time is not 0 and is +// equal to the sample time. +func (d entryData) LastAccessKept() bool { + return d.AccessTime() != 0 && d.AccessTime() == d.SampleTime() +} + +// WithAccessTime returns a new [entryData] by copying the receiver and +// replacing the access time portion with the specified value. +func (d entryData) WithAccessTime(atime uint32) entryData { + return (d & 0x00000000_FFFFFFFF) | (entryData(atime) << 32) +} + +// Compare performs a comparison between the receiver and another entry; such +// that most recently sampled entries come first. Two entries with the same +// sample time are considered equal. +func (e copiableEntry) Compare(other copiableEntry) int { + tst := e.Data.SampleTime() + ost := other.Data.SampleTime() + if tst < ost { + // Receiver was sampled more recently (sorts higher) + return 1 + } + if tst > ost { + // Receiver was sampled less recently (sorts lower) + return -1 + } + // Both have the same sample time, so we consider them equal. + return 0 +} diff --git a/apisec/internal/timed/table_test.go b/apisec/internal/timed/table_test.go new file mode 100644 index 0000000..abd9305 --- /dev/null +++ b/apisec/internal/timed/table_test.go @@ -0,0 +1,37 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package timed + +import ( + "math/rand/v2" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestEntryData(t *testing.T) { + t.Run("zero", func(t *testing.T) { + var subject entryData + + require.EqualValues(t, 0, subject.AccessTime()) + require.EqualValues(t, 0, subject.SampleTime()) + }) + + t.Run("newEntryData", func(t *testing.T) { + atime := rand.Uint32() + stime := rand.Uint32() + subject := newEntryData(atime, stime) + + require.Equal(t, atime, subject.AccessTime()) + require.Equal(t, stime, subject.SampleTime()) + + t.Run("WithAccessTime", func(t *testing.T) { + subject = subject.WithAccessTime(atime + 1) + require.Equal(t, atime+1, subject.AccessTime()) + require.Equal(t, stime, subject.SampleTime()) // Unchanged + }) + }) +} diff --git a/apisec/internal/timed/testutil/fakeclock.go b/apisec/internal/timed/testutil/fakeclock.go new file mode 100644 index 0000000..7d4fc0b --- /dev/null +++ b/apisec/internal/timed/testutil/fakeclock.go @@ -0,0 +1,80 @@ +package testutil + +import ( + "context" + "sync" + "sync/atomic" + "testing" + "time" +) + +type FakeClock struct { + t testing.TB + closed chan struct{} + goCount int + now int64 + needTick atomic.Bool + wg sync.WaitGroup + cnd sync.Cond +} + +func NewFakeClock(ctx context.Context, t testing.TB, goroutineCount int) *FakeClock { + res := &FakeClock{ + t: t, + closed: make(chan struct{}), + goCount: goroutineCount, + now: time.Now().Unix(), + cnd: *sync.NewCond(&sync.Mutex{}), + } + res.wg.Add(goroutineCount) + go res.tick(ctx) + return res +} + +func (c *FakeClock) Unix() int64 { + return c.now +} + +func (c *FakeClock) WaitForTick() { + c.cnd.L.Lock() + + c.needTick.CompareAndSwap(false, true) + curTime := c.now + + c.wg.Done() + for curTime == c.now && c.now > 0 { + c.cnd.Wait() + } + c.cnd.L.Unlock() +} + +func (c *FakeClock) WaitUntilDone() { + <-c.closed +} + +func (c *FakeClock) tick(ctx context.Context) { + c.t.Log("Start ticker!") + for { + select { + case <-ctx.Done(): + // Context is cancelled, stop the ticker... + c.cnd.L.Lock() + c.now = 0 + c.cnd.L.Unlock() + c.t.Log("Stop ticker!") + close(c.closed) + return + default: + if !c.needTick.Load() { + continue + } + c.wg.Wait() + c.cnd.L.Lock() + c.now++ + c.needTick.Store(false) + c.cnd.Broadcast() + c.wg.Add(c.goCount) + c.cnd.L.Unlock() + } + } +} diff --git a/apisec/sampler.go b/apisec/sampler.go new file mode 100644 index 0000000..76131f2 --- /dev/null +++ b/apisec/sampler.go @@ -0,0 +1,98 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package apisec + +import ( + "encoding/binary" + "hash/fnv" + "time" + + "github.com/DataDog/appsec-internal-go/apisec/internal/timed" + "github.com/DataDog/appsec-internal-go/limiter" +) + +type ( + Sampler interface { + DecisionFor(SamplingKey) bool + } + + timedSetSampler timed.LRU + + proxySampler struct { + limiter limiter.Limiter + } + + nullSampler struct{} + + SamplingKey struct { + // Method is the value of the http.method span tag + Method string + // Route is the value of the http.route span tag + Route string + // StatusCode is the value of the http.status_code span tag + StatusCode int + } + + clockFunc = func() int64 +) + +// NewProxySampler creates a new sampler suitable for proxy environments where the sampling decision +// is not based on the request's properties, but on a rate. +func NewProxySampler(rate int, interval time.Duration) Sampler { + if rate <= 0 { + return &nullSampler{} + } + r := int64(rate) + l := limiter.NewTokenTickerWithInterval(r, r, interval) + l.Start() + return &proxySampler{ + limiter: l, + } +} + +// NewSamplerWithInterval returns a new [*Sampler] with the specified interval. +func NewSamplerWithInterval(interval time.Duration) Sampler { + return newSampler(interval, timed.UnixTime) +} + +// newSampler allows creating a new [*Sampler] with custom clock function, +// which is useful for testing. +func newSampler(interval time.Duration, clock clockFunc) Sampler { + return (*timedSetSampler)(timed.NewLRU(interval, clock)) +} + +// DecisionFor makes a sampling decision for the provided [SamplingKey]. If it +// returns true, the request has been "sampled in" and the caller should proceed +// with the necessary actions. If it returns false, the request has been +// dropped, and the caller should short-circuit without extending further +// effort. +func (s *timedSetSampler) DecisionFor(key SamplingKey) bool { + keyHash := key.hash() + return (*timed.LRU)(s).Hit(keyHash) +} + +func (s *proxySampler) DecisionFor(_ SamplingKey) bool { + return s.limiter.Allow() +} + +func (s *nullSampler) DecisionFor(_ SamplingKey) bool { + return false +} + +// hash returns a hash of the key. Given the same seed, it always produces the +// same output. If the seed changes, the output is likely to change as well. +func (k SamplingKey) hash() uint64 { + fnv := fnv.New64() + + _, _ = fnv.Write([]byte(k.Method)) + _, _ = fnv.Write([]byte(k.Route)) + + var bytes [2]byte + binary.NativeEndian.PutUint16(bytes[:], uint16(k.StatusCode)) + _, _ = fnv.Write(bytes[:]) + + return fnv.Sum64() +} diff --git a/apisec/sampler_test.go b/apisec/sampler_test.go new file mode 100644 index 0000000..f502958 --- /dev/null +++ b/apisec/sampler_test.go @@ -0,0 +1,1324 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package apisec + +import ( + "context" + "fmt" + "math/rand" + "net/http" + "runtime" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/DataDog/appsec-internal-go/apisec/internal/config" + "github.com/DataDog/appsec-internal-go/apisec/internal/timed/testutil" + "github.com/stretchr/testify/assert" +) + +func TestSampler(t *testing.T) { + initTestVector() + + ctx := context.Background() + if deadline, ok := t.Deadline(); ok { + var cancel context.CancelFunc + ctx, cancel = context.WithDeadline(ctx, deadline) + defer cancel() + } + + const samplesToTake = config.MaxItemCount << 10 + + type testCase struct { + // KeySpace is the set of keys to randomly draw from when sampling. + KeySpace []SamplingKey + // SimulatedTPS is the number of samples per second to simulate. + SimulatedTPS int + // ExpectedKeepRate is the expected rate of samples being kept [0;1] + ExpectedKeepRate float64 + // AllowedDelta is the allowed delta for the keep rate. + AllowedDelta float64 + } + testCases := map[string]testCase{ + "small": { + KeySpace: testVector[:config.MaxItemCount/32], + SimulatedTPS: 10, + ExpectedKeepRate: .0415, + AllowedDelta: .0001, + }, + "medium": { + KeySpace: testVector[:config.MaxItemCount/16], + SimulatedTPS: 20, + ExpectedKeepRate: .0415, + AllowedDelta: .0001, + }, + "high": { + KeySpace: testVector[:config.MaxItemCount*2/3], + SimulatedTPS: 1000, + ExpectedKeepRate: .0091, + AllowedDelta: .0001, + }, + "large": { + KeySpace: testVector[:config.MaxItemCount], + SimulatedTPS: 1000, + ExpectedKeepRate: .01, + AllowedDelta: .005, // Small chance of collision here... so a bit more wiggle room... + }, + "extreme": { // Not actually realistic usage... Evictions galore! + KeySpace: testVector[:2*config.MaxItemCount], + SimulatedTPS: 10000, + ExpectedKeepRate: .21, + AllowedDelta: .05, // Very random evictions, so keep rate can be pretty off... + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + assert.Positive(t, tc.SimulatedTPS) + assert.GreaterOrEqual(t, tc.ExpectedKeepRate, 0.0) + assert.GreaterOrEqual(t, 1.0, tc.ExpectedKeepRate) + + const goroutineCount = 10 // Fixed to ensure consistent keep rate... + ctx, cancel := context.WithCancel(ctx) + clock := testutil.NewFakeClock(ctx, t, goroutineCount) + defer func() { + cancel() + clock.WaitForTick() + }() + + var ( + subject = newSampler(30*time.Second, clock.Unix) + sb sync.WaitGroup // Start barrier + wg sync.WaitGroup // Completion barrier + kept atomic.Uint64 + dropped atomic.Uint64 + ) + sb.Add(1 + goroutineCount) // All child goroutines + this one... + wg.Add(goroutineCount) + for range goroutineCount { + go func() { + defer wg.Done() + + sb.Done() // We're ready for business, signal to the start barrier... + sb.Wait() // Wait for all the goroutines to have started... + + for i := range samplesToTake { + if subject.DecisionFor(randomOne(tc.KeySpace)) { + kept.Add(1) + } else { + dropped.Add(1) + } + // The clock ticks every 10 samples (model a server processing 10 TPS) + if i%tc.SimulatedTPS == 0 { + clock.WaitForTick() + } + } + }() + } + + sb.Done() + wg.Wait() + + samplesTaken := kept.Load() + dropped.Load() + + keepRate := float64(kept.Load()) / float64(samplesTaken) + assert.InDelta(t, tc.ExpectedKeepRate, keepRate, tc.AllowedDelta, "expected keep rate around %.2f±%.2f%%, was %.2f%%", 100*tc.ExpectedKeepRate, 100*tc.AllowedDelta, 100*keepRate) + }) + } +} + +func TestSamplingKeyHash(t *testing.T) { + initTestVector() + + t.Run("collisions-are-infrequent", func(t *testing.T) { + hashes := make(map[uint64]struct{}, len(testVector)) + for _, key := range testVector { + hashes[key.hash()] = struct{}{} + } + + // Validates that the hash function results in less than 1% collisions. This + // is a little arbitrary, but should ensure the function as at least + // somewhat fit for purpose here. + assert.GreaterOrEqual(t, float64(len(hashes))/float64(len(testVector)), .99, + "the hash function should have less than 10% collisions") + }) + + t.Run("distribution-is-uniform-on-buckets", func(t *testing.T) { + buckets := make(map[int]struct{}, len(testVector)) + for _, key := range testVector { + buckets[int(key.hash()%config.MaxItemCount)] = struct{}{} + } + + // Validates that the hash function results in hitting at least 80% of the + // buckets. This is arbitrary, and may feel a little low, but our sample + // count is quite close to the bucket count, so this is actually solid. + assert.GreaterOrEqual(t, float64(len(buckets))/float64(config.MaxItemCount), .80, + "the hash function should slot into 50% of the buckets at least") + }) +} + +func BenchmarkSampler(b *testing.B) { + initTestVector() + + for _, keySpaceSize := range []int{config.MaxItemCount / 2, config.MaxItemCount * 2} { + keySpace := testVector[:keySpaceSize] + b.Run(fmt.Sprintf("keySpaceSize=%d", keySpaceSize), func(b *testing.B) { + for _, parallelism := range []int{1, 1000} { + b.Run(fmt.Sprintf("parallelism=%d/interval=1s", parallelism), func(b *testing.B) { + var ( + subject = NewSamplerWithInterval(time.Second) + kept atomic.Uint64 + dropped atomic.Uint64 + ) + + // We'll synchronize the start of all of our goroutines to ensure contention happens early. + b.StopTimer() + b.SetParallelism(parallelism) + var ( + wg sync.WaitGroup + barrier = make(chan struct{}) + ) + wg.Add(parallelism * runtime.GOMAXPROCS(0)) + + go func() { + wg.Wait() + b.StartTimer() + close(barrier) // Un-block all the goroutines; we're in business! + }() + + b.RunParallel(func(pb *testing.PB) { + wg.Done() + <-barrier + + for i := 0; pb.Next(); i = (i + 1) % keySpaceSize { + if subject.DecisionFor(keySpace[i]) { + kept.Add(1) + } else { + dropped.Add(1) + } + } + }) + + fkept := float64(kept.Load()) + b.ReportMetric(100*fkept/(fkept+float64(dropped.Load())), "keep%") + }) + } + }) + } +} + +func randomOne[T any](list []T) T { + return list[rand.Intn(len(list))] +} + +var ( + httpMethods = []string{ + http.MethodGet, + http.MethodHead, + http.MethodPost, + http.MethodPut, + http.MethodPatch, + http.MethodDelete, + http.MethodConnect, + http.MethodOptions, + http.MethodTrace, + } + httpStatusCodes = []int{ + http.StatusContinue, + http.StatusSwitchingProtocols, + http.StatusProcessing, + http.StatusEarlyHints, + http.StatusOK, + http.StatusCreated, + http.StatusAccepted, + http.StatusNonAuthoritativeInfo, + http.StatusNoContent, + http.StatusResetContent, + http.StatusPartialContent, + http.StatusMultiStatus, + http.StatusAlreadyReported, + http.StatusIMUsed, + http.StatusMultipleChoices, + http.StatusMovedPermanently, + http.StatusFound, + http.StatusSeeOther, + http.StatusNotModified, + http.StatusUseProxy, + http.StatusTemporaryRedirect, + http.StatusPermanentRedirect, + http.StatusBadRequest, + http.StatusUnauthorized, + http.StatusPaymentRequired, + http.StatusForbidden, + http.StatusNotFound, + http.StatusMethodNotAllowed, + http.StatusNotAcceptable, + http.StatusProxyAuthRequired, + http.StatusRequestTimeout, + http.StatusConflict, + http.StatusGone, + http.StatusLengthRequired, + http.StatusPreconditionFailed, + http.StatusRequestEntityTooLarge, + http.StatusRequestURITooLong, + http.StatusUnsupportedMediaType, + http.StatusRequestedRangeNotSatisfiable, + http.StatusExpectationFailed, + http.StatusTeapot, + http.StatusMisdirectedRequest, + http.StatusUnprocessableEntity, + http.StatusLocked, + http.StatusFailedDependency, + http.StatusTooEarly, + http.StatusUpgradeRequired, + http.StatusPreconditionRequired, + http.StatusTooManyRequests, + http.StatusRequestHeaderFieldsTooLarge, + http.StatusUnavailableForLegalReasons, + http.StatusInternalServerError, + http.StatusNotImplemented, + http.StatusBadGateway, + http.StatusServiceUnavailable, + http.StatusGatewayTimeout, + http.StatusHTTPVersionNotSupported, + http.StatusVariantAlsoNegotiates, + http.StatusInsufficientStorage, + http.StatusLoopDetected, + http.StatusNotExtended, + http.StatusNetworkAuthenticationRequired, + } + httpRoute = []string{ + "/{namespace}/{repository}/@{snapshot}/*", + "/api/ui/query/timeseries", + "/api/v1/synthetics/private-locations/tests", + "/api/ui/frontend_telemetry/metrics", + "/api/ui/query/rapid-scalar", + "/api/v1/validate", + "/config", + "/v8/artifacts/{id}", + "/api/ui/feature-flags/get-active-feature-flags", + "/api/v1/synthetics/private-locations/tests/{publicID}/results", + "/api/v1/distribution_points", + "/api//logs-analytics/", + "/internal/snapshot/pull", + "/*", + "/api/unstable/apm/entities", + "/v2/", + "/dashboard/shared_widget_update/{id}/{widget_id}", + "/authn", + "/api/v1/synthetics/tests/updates/", + "/authz", + "/v3/elements/search", + "/api/ui/event-platform/logs/facets", + "/vault/agent/", + "/internal/snapshot/push", + "/api/v2/dashboard/presence/{resourceId}", + "/api/v1/snapshot", + "/api/v1/query", + "/api/v1/series", + "/v8/artifacts/events", + "/api/v1/monitor/", + "/series/batch_query", + "/orgs/{orgId}/analytics/requests", + "/api/v0.1/status", + "/api/v1/synthetics/private-locations/tests//results", + "/api/ui/error-tracking/issues/searches", + "/api/intake/ci/custom_spans", + "/internal/error-tracking/search", + "/v2/{name:(?:(?:(?:[a-zA-Z0-9]", + "/api/v0.1/configurations", + "/api/v2/apm/service_inference", + "/api/v2/git/repository/search_commits", + "/jobs/", + "/api/v2/libraries/tests/services/setting", + "/api/ui/data_streams/map", + "/readiness", + "/api/ui/apm/latency_breakdowns", + "/api/v2/discussions/dashboard/{dashboardID}", + "^dump-request$", + "/api/v2/watchdog/insights/search/", + "/api/ui/apm/versions", + "/probe", + "/api/v2/watchdog/insights/search", + "/api/ui/orchestration/facets/v2", + "/account/login", + "/-/readiness", + "/api/ui/apm/resources", + "/-/liveness", + "/monitor/evaluation_graph", + "/{namespace}/{repository}/@{snapshot}/simple/{project}", + "/watchdoginsights/outliers_query", + "/health/readiness", + "/health/liveness", + "/api/v2/on-prem-management-service/workflow-tasks/dequeue", + "/api/v2/users", + "/api/ui/slack-app/event", + "/token", + "/v2/{name:(?:(?:(?:[a-zA-Z0-9]", + "/watchdoginsights/outliers_resume", + "/_health", + "/api/unstable/coscreen", + "/internal/v0/3rd-party-software-info/query", + "/api/v2/org_configs/", + "/health", + "/watchdoginsights/watchdog_stories_query", + "/api//logs-analytics//", + "/api/intake/llm-obs/v1/trace/spans", + "/internal/ciem/enablementRequirements/{orgId}", + "/api/v2/ddsql/table", + "/monitor/search", + "/api/v2/cases/count", + "/api/ui/apm/live-search", + "/api/ui/orchestration/entities", + "/api/ui/experiments/get-all-experiments", + "/api/ui/event-platform/trace/facets", + "/api/v1/settings/favorite/list", + "/api/ui/team", + "/api/v1/dashboard/", + "/api/v2/query/timeseries", + "/api//watchdog/stories", + "/orgs/{orgId}/analytics/requests/{requestId}", + "/api/v2/team", + "/api/unstable/apm/entities/graph", + "/api/v2/incidents/search", + "/api/ui/support/authenticate", + "/dequeue_job", + "/api/ui/apm/breakdown", + "/static/*", + "/api/unstable/change-stories", + "/v2/{name:(?:(?:(?:[a-zA-Z0-9]", + "/api/v1/logs/views", + "/api/v2/ci/libraries/tests", + "/api/v2/notebook/presence/{resourceId}", + "/api/unstable/restriction_policy/relations/bulk", + "/orgs/{orgId}/scopes", + "/api/v1/security_analytics/activation", + "/api/v2/cases", + "/api/ui/api-monitoring/endpoint", + "/watchdoginsights/log_anomalies_query", + "/api/v1/slo//history", + "/api/ui/api-monitoring/endpoints", + "/api/v1/logs/indexes", + "/orgs/{orgId}/security_analytics/activation", + "/lock", + "/v2/{repo:(?:(?:(?:[a-zA-Z0-9]", + "/api/ui/apm/web/metadata", + "/metric/hosts_and_tags", + "/api/v1/monitor", + "/api/ui/event-platform/rum/facets", + "/favicon.ico", + "/api/ui/event-platform/feed/facets", + "/api/v2/workflows/{workflowId}/instances", + "/watchdoginsights/profiling_query", + "/api/v2/case/presence/{resourceId}", + "/api/v1/metrics/", + "/api//watchdog/story_facets", + "/v1/applications/{appId}", + "/snapshot/view////", + "/fabric-proxy-healthcheck", + "/api/v2/users/", + "/api/v2/current_user/user_team_fave", + "/dashboard/*", + "/api/v1/monitor//validate", + "/api/ui/query/scalar", + "/api/v2/static-analysis/rulesets/{RulesetName}", + "/api/ui/data_streams/info", + "/api/v2/event-platform/profile/activity", + "/metric/flat_tags_for_metric", + "/api/v2/services/definitions/", + "/api/unstable/databases/hosts", + "^$", + "api/usage/v1/hourly-usage.{ext}", + "/internal/api/v2/devflow/run-workflow", + "/api/ui/apm/host_groups", + "/api/v2/ci/tests/skippable", + "/api/v2/restriction_policy/", + "/status/index", + "/api/v1/logs/default-views", + "/api/v2/cases/aggregate", + "/dash/set_preference", + "/internal/catalog/v1/namespaces/*", + "/computeMetadata/v1/instance/service-accounts/{serviceAccount:[^/]+}/token", + "/metric/metric_metadata", + "/orgs/{orgId}/security_analytics/activation/{product}/pricing_model", + "/api/unstable/databases/recommendations/aggregated", + "/api/ui/event-platform/audit/facets", + "/api/v1/restriction_policy/{resourceID}", + "/api/ui/event-platform/query/field", + "/api/v1/monitor/validate", + "/metric/contexts_for_metrics", + "/graphql", + "/{version}/meta-data/iam/security-credentials/{role:.+}", + "/orgs/{orgId}/indexes", + "/api/v2/workflows//instances/", + "/api/v1/monitor//search_groups", + "/v1/applications/{appId}/streaming", + "/check//contexts", + "/api/v2/process/summary", + "/{version}/meta-data/iam/security-credentials/", + "/api/ui/flows/scalar", + "/api/v2/catalog/entity", + "/api/ui/integration/jira/webhook/{org_uuid}", + "/api/v1/apps/:app/inputs", + "/internal/dashboards/search/_index", + "/api/v1/apps/:app/inputs/:inputId", + "/api/v2/services/definitions", + "/api/v2/embed_query/timeseries", + "/api/ui/orchestration/manifest_history", + "/api/ui/monitor/search_all_counts", + "/api/ui/apm/latest_deployments", + "/", + "/internal/compliance/frameworks/{orgId}", + "/api/v2/ci/pipeline/tags", + "/api/unstable/public_dashboard_widget_query", + "/api/v2/logs/events/search", + "/api/unstable/datasets", + "/internal/event-platform/query/composite", + "/api/ui/trace/{traceID}", + "/api/unstable/accupath/entities/graph/{entityType}/*", + "^click$", + "/api/v1/monitor/groups/search", + "/api/v2/static-analysis/config/client", + "/api/v2/incidents-incident/presence/{resourceId}", + "/api/v2/metrics//volumes", + "/api/v1/dashboard_search", + "/api//hosts", + "/v2/{repo:(?:(?:(?:[a-zA-Z0-9]", + "/api/v2/roles", + "/api/ui/event-platform/{track}/standard-attributes/rules", + "/api/v2/ci/pipeline/metrics", + "/api/v2/host_map/nodes_by_group", + "/api//databases/hosts", + "/api/ui/apm/widget_stats_histogram", + "/api//logs-queries/list", + "/api/ui/dashboards//payload_version_history", + "/api/unstable/on-call/teams", + "/api/v1/tags/hosts/", + "/api/ui/security/asm/services", + "/api/v2/synthetics/tests//results", + "/api/ui/data_streams/alerts", + "/api/v2/workflows/{workflowId}/instances/{instanceId}", + "/api/v2/incident/presence/{resourceId}", + "/mail/sendgrid_incoming", + "/v2/{name:(?:(?:(?:[a-zA-Z0-9]", + "/api/v1/legacy_current_user", + "/unauthenticated_probe", + "/api/ui/services/catalog", + "/v3/elements/update", + "/api/unstable/obs-pipelines/quotas/{pipelineId}/buckets", + "/api/v2/services/catalog/product_areas", + "/computeMetadata/v1/instance/service-accounts/{serviceAccount:[^/]+}/", + "/api/v2/apm/services/stats", + "/api/v1/intake_monitoring", + "/series/proc_key_query", + "/api/v2/incidents-timeline/presence/{resourceId}", + "/lock/", + "/api/ui/apm/service/graph_real_time", + "/api/ui/error-tracking/issues/field-translations", + "/internal/security-graph/shards/{orgID}", + "/api//events/", + "/autoscaling/recommendation", + "/api/ui/event-platform/databasequery/facets", + "/api/unstable/databases/monitors", + "/api/unstable/apm/entities/ranked_entity_id_tags", + "/api/unstable/cost/tags", + "/api/intake/aws/securitylake", + "/tile/validate", + "/api/unstable/datasets/", + "/api/ui/monitor/search_all", + "/api/v1/synthetics/tests/uptimes", + "/api/ui/metric/search", + "/api/v2/notebook/multiplayer/{resourceId}", + "/api/v2/ci/pipeline", + "/api/v1/notebooks/", + "/api/v2/host_map/filters_and_groups", + "/monitor/validate_text", + "/api/ui/apm/has_traces", + "/api/ui/apm/dependency_stats_tree", + "/api/v1/rum/projects", + "/api/unstable/databases/recommendations", + "/api/v1/check_run", + "/api/v2/scorecard/grouped-outcomes", + "/integration/slack/inbound-event", + "/api/v2/intake_monitoring", + "/api/unstable/on-call/pages", + "/api/ui/event-platform/{track}/livetail/token", + "/api/ui/app_installations", + "/internal/event-platform/query/composite/resume", + "/api/v2/services/integrations/pagerduty", + "/api/v1/monitor/search", + "/v1/applications", + "/api/ui/api-monitoring/endpoints/count", + "/liveness", + "/dashboard/template-variables/values", + "/v1/version", + "/api/v2/workflows", + "/api/v1/notebooks", + "/metric/tag_keys_for_metric", + "/api/unstable/security/appsec/vm/activation", + "/computeMetadata/v1/project/project-id", + "/api/v1/synthetics/tests//locations", + "/api/ui/slo/correction_windows", + "/files/{ref}/{filename}", + "/api/unstable/datasets/{datasetUUID}", + "/api/v1/integration/webhooks/configuration/webhooks/", + "/process/tags/v2", + "/api/v2/monitor//downtime_matches", + "/apm/*", + "/api/v2/security_monitoring/rules", + `/sb/{string_1:[^/?()[\]]+}`, + "^basic-auth$", + "/v3/elements", + "/utils/healthcheck", + "/api/v2/scorecard/outcomes/batch", + "/metadata/identity/oauth2/token", + "/api/ui/apm/web/metadata/{serviceName}", + "/api/v1/synthetics/tests/search", + "/api/v1/logs/rate_limited_indexes", + "/api//node_map/nodes_by_group", + "/api/unstable/symdb-api/scopes/search", + "/api/v2/catalog/relation", + "/monitor/search_counts", + "/api/unstable/stegadography/cache", + "/query", + "/api/ui/event-platform/signal/facets", + "/api/beta/sketches", + "^simple-variable$", + "/internal/api/repository/{owner}/{repository}/history", + "/api/v2/current_user", + "/connectors/{connector}/status", + "/v1/health", + "/api/ui/error-tracking/issues/field-values", + "/api/unstable/symdb-api/services/metadata", + "/api/ui/span_links/{traceID}", + "/internal/domains/{DomainName}/routegroups/{RouteGroupName}", + "/v1/orgs/{orgId}/logs-queries/list", + "/api/v2/permissions", + "/api/v2/workflows//instances", + "/api/ui/watchdog/explains/influential-tags/ff", + "/apm/home", + "/cost/tags/pod/{namespace}/{pod_name}", + "/api/v2/integration/salesforce_marketing_cloud/event", + "/api/ui/cost/settings", + "^click-trap$", + "/api/v2/watchdog-story/presence/{resourceId}", + "/api/v2/reporting/schedule//", + "/api/v2/static-analysis/default-rulesets/{Language}", + "/indicators", + "/api/ui/cost/multisource", + "/internal/api/v2/spark_jobs/{spark_job_id}", + "/api/v2/scorecard/rules", + "/api/v2/roles/{roleUuid}", + "/internal/ci/gitlab/pipeline/*", + "/api/v2/security_monitoring/configuration/notification_rules", + "/api/ui/event-platform/query/field-value", + "/api/v2/synthetics/private-locations/config", + "/api/v2/test/libraries/test-management/tests", + "/api/v1/slo", + "/cluster_configuration/", + "/api/v1/slo/search", + "/api/ui/error-tracking/config", + "/api/ui/event-platform/profile/facets", + "/internal/api/v2/concurrency_locks", + "/api/v2/rum/funnel", + "/api/v0/synthetics/tests//status", + "/catalog/v1/namespaces", + "/api/unstable/restriction_policy/principal/", + "/api/v2/services/integrations/pagerduty/oncalls", + "/api/v1/synthetics/tests", + "/api/v1/monitor/tags", + "/internal/notebooks/search/_index", + "/orgs/{orgId}/cloud_security_management/resource_filters", + "/api/v1/integration", + "^cors-protected-resource$", + "/connectors/{connector}", + "/api/unstable/ui/trace/{traceID}", + "/alert/query_value/", + "/api/v2/query/scalar", + "/metric/histogram", + "/api/ui/resource_catalog/list", + "/v2/orgs/{orgId}/{trackType}/events/search", + "/api/ui/remote_config/*", + "/api/v2/security_monitoring/rules/{ruleId}", + "/api/v2/api_keys/", + "^status$", + "/api/v2/source-code-integration/enrich-stack-trace", + "/monitor/validate_param", + "/orgs/{orgId}/v2/security_analytics/rules", + "/api/v2/on-prem-management-service/runner/health-check", + "/api/v2/security_monitoring/signals/", + "/event/distrib", + "/internal/ciem/enabledIntegrations/{orgId}", + "/jobs", + "/internal/core/v2/prefixes/{id}", + "/api/v2/apicatalog/endpoints", + "/v2/orgs/{orgId}/vm", + "^sigv4$", + "/oauth2/v1/token", + "/api/v1/synthetics/tests/browser/", + "/api/v1/dashboard/public/", + "^simple-iframe$", + "/api//host_map/node_values", + "/api/v2/services/integrations/pagerduty/incidents", + "/v2/orgs/{orgId}/security_monitoring/configuration/notification_rules", + "/internal/intake/developer-telemetry/count", + "/api/v2/org_connections", + "/api/v1/synthetics/browser/tests//results//steps//screenshot", + "/api/ui/security_monitoring/content_packs", + "/api/unstable/on-call/escalation-policies/{policyUUID}/steps/{policyStepUUID}/escalations", + "/orgs/{orgId}/security_analytics/signals/get_metadata", + "/api/ui/container_images/facets", + "/api/ui/on-call/shifts", + "/api/v2/services/integrations/opsgenie", + "/monitors/*", + "/api/v2/services/integrations/opsgenie/incidents", + "/api//logs/analytics/aggregate", + "/orgs/{orgId}/analytics/requests/validate-search", + "/.well-known/jwks.json", + "/api/v2/events", + "/api/v1/slo/", + "/api/v1/monitor//unmute", + "/*id", + "/api/v1/rum/replay/sessions//views//segments", + "/api/v2/infrastructure/devices", + "/probe_smart_edge", + "/api/ui/event-platform/profilemetrics/facets", + "/api/ui/data_streams/apm_streaming_services", + "/api/v2/ucap/annotations/search-by-file", + "/api/v2/processes", + "/healthz/liveness", + "/api/v2/reporting/schedule/list", + "/catalog/v1/namespaces/{namespace}/tables/{table}/metrics", + "/watchdoginsights/synthetics_search_tests", + "/v2/models/{model_name}/versions/{model_version}/ready", + "/security/*", + "/v1/task/{taskId}", + "/api/v0.1/org", + "/clusters", + "/watchdoginsights/outliers_cancel", + "/logs", + "/api/v1/dashboard/lists", + "/v3/elements/aggregate", + "/api/v1/notebook//comments", + "/api/unstable/apm/tracer_agent_latest_versions", + "/api/ui/event-platform/{track}/org/state", + "/orgs/{orgId}/facets-with-reserved-fields", + "/event/icon/", + "/profiling/api/v1/aggregate", + "/api/ui/event-platform/netflow/facets", + "/api/v2/ci/my-commits", + "/v2/orgs/{orgId}/{trackType}/analytics/aggregate", + "/api/v1/synthetics/tests/", + "/api/v1/synthetics/ci/batch/", + "/api/v1/security_analytics/rules/facet_info", + "/orgs/{orgId}/state", + "/api/ui/apm/live-search/keys", + "/api/v1/events", + "/api/v1/synthetics/tests/poll_results", + "/api/v2/monitor/recommended", + "/api/v2/ucap/annotations/search", + "/api/v2/scorecard/outcomes", + "/internal/csm/onboarding/steps", + "/api/unstable/obs-pipelines/quotas/batch", + "/api/v2/incidents//relationships/integrations", + "/api/ui/notebooks//payload_version_history", + "/api/v2/team//memberships", + "/api/v2/security_monitoring/configuration/security_filters", + "/api/v2/internal/*", + "/api/ui/remote_config/products/live_debugging/probes", + "/series/embed_batch_query", + "/api/ui/error-tracking/issues/facets", + "/api/v2/services/definitions/{service:.*}", + "/api/v1/integrations/tiles/list", + "/api/v2/services/catalog", + "/healthz", + "/api/v1/metadata", + "/api/v2/logs/events", + "/api/v2/bits-ai-investigation/presence/{resourceId}", + "/status", + "/-/health", + "/api/v2/api_keys", + "/api/v2/metrics", + "/api/v1/synthetics/settings", + "/internal/api/ui/prr-survey-relay/surveys/{ServiceName}", + "/v1/info/state", + "/internal/disruptioncrons", + "/internal/hypothesis", + "/api/ui/error-tracking/issues/{issueID}", + "/series/proc_container_query", + "/api/v2/slo/{sloID}/status", + "/v3/entities", + "/account/change_subdomain/", + "^headers$", + "/rum/*", + "/api/:version/jobs/request", + "/api//apm/config/retention-filters", + "/api/v2/monitor/policy", + "/api/v1/role/{roleUuid}/user/{userHandle}", + "/api/ui/billing/vat_required", + "/api/ui/apm/resource", + "/api/v0/synthetics/tests/", + "/api/v2/product_trial_summary", + "/account/oauth2", + "/api/v1/restriction_policy/principal/{principalID}", + "/proc/query", + "/api/v1/insights", + "/intake", + "/profiling/api/v1/profiles//breakdown", + "/api/ui/error-tracking/issues/searches/{searchID}", + "/eee-intake/prod/gitlab", + "/internal/reporting/job/dequeue", + "/api/v2/incidents/", + "/api/v2/users//permissions", + "/api/unstable/security_monitoring/csm_features", + "/api/v2/bits-ai/config/global", + "/api/v2/powerpacks", + "/api/v1/lineage", + "/api/ui/public_dashboard/", + "/account/plan/plan_details", + "/v1/memory", + "/api/v2/incidents//timeline", + "/api/v2/metrics//all-tags", + "/api/unstable/on-call/pages/{pageIdentifier}", + "/v1/task/{taskId}/status", + "/monitor/notifications", + "/api/v2/workflow_instance_sources//instances", + "/account/integration", + "/api/ui/usage/billable/overall", + "/catalog/v1/config", + "/api/v2/security_monitoring/livetail", + "/api//events", + "/api//node_map/node_values", + "/api/v2/application_keys", + "/api/unstable/slo/search/group_by_tag", + "/api/ui/event-platform/appsecspan/facets", + "/api/ui/monitor//evaluation_graph", + "/api/v2/rum/analytics/aggregate", + "/api/v2/rum/applications", + "/api//node_map/filters_and_groups", + "/api/v2/static-analysis-sca/dependencies", + "/api/v1/hosts/totals", + "/api/ui/notebooks/lfg", + "/metrics", + "api/usage/v1/status", + "/api/v2/workflow_instance_sources/{id}/instances", + "/api/ui/ms-teams-app/bot/activity", + "/api/v0.2/stats", + "/internal/api/v2/spark_jobs", + "^scroll$", + "/api/v1/audit/config", + "/api/ui/flows/timeseries", + "/v1/status", + "/healthcheck", + "/monitors/manage", + "/api/unstable/catalog/definition", + "/orgs/{orgId}/security_analytics/rules/{ruleId}", + "/internal/dashboards/search/_bulkindex", + "/api/ui/trace/related_dashboards", + "/api/v2/source-code-integration/code-snippet", + "/synthetics/*", + "/agent_stats/report_failure", + "/api/v1/synthetics/_multilocator/updates", + "/account/saml/assertion", + "/api/v2/notebooks/search", + "/v1/task/{taskId}/results/{bufferId}/{token}", + "/api/v2/rum/resource", + "/api/v2/rum/events", + "/api/v2/events/search", + "/api/ui/event-platform/citest/facets", + "/api/ui/cost/aws_accounts", + "/api/v2/incidents", + "/api/ui/debugger/probe-statuses", + "/api/ui/event-platform/cipipeline/facets", + "/api/v2/synthetics/tests//results/", + "/api/v1/security_analytics/rules/facets", + "/screen/setup_notify_change", + "/api/v2/metrics/{metricName}/assets", + "/orgs/{orgId}/security_analytics/rules/facet_info", + "^assert-element-content$", + "^user-agent$", + "/api/v2/saml_configurations/", + "/signup/process", + "/api/ui/metrics/summary/list", + "/api/v2/integration/gcp/accounts", + "/api/v2/logs/config/custom-destinations/", + "/api/v2/embed_query/scalar", + "/api/v2/dora/settings", + "/api/v2/apicatalog/tags", + "/api/v1/logs/views/", + "/api/v2/host_map/node_names", + "/v1/announcement/{node_id}", + "/api/unstable/llm-obs/v2/clusters", + "/v1/service/{type}/{pool}", + "^input$", + "/internal/intake/developer-telemetry/distribution", + "/api/v2/dora/deployment", + "/api/unstable/monitor/on_missing_data_default_details", + "/api/v2/rum/replay/sessions/{sessionID}/watchers", + "^authenticated$", + "/functions", + "^assert-text-nowhere$", + "^iframeception$", + "^small-device$", + "/api/v2/{trackType}", + "/v2/_scanning/", + "^assert-text-present$", + "^iframe-in-popup$", + "/api/v1/synthetics/config", + "^prototype$", + "^cors$", + "/api/v1/security_analytics/rules/{ruleId}", + "/api/v1/synthetics/tests/api/", + "/gomod/{ref}/*", + "^hover$", + "^redirect-auth$", + "/api/v1/synthetics/variables", + "/v2/_scanning/{name:(?:(?:(?:[a-zA-Z0-9]", + "/v2/orgs/{orgId}/security_monitoring/configuration/security_filters", + "/process/get_token", + "/v1/statement/executing/{queryId}/{slug}/{token}", + "^select-option$", + "/api/v2/pets/{petID}", + "/monitors/{int_1:[0-9]+}/edit", + "/api/unstable/ddsql/custom_output", + "/api/v2/spreadsheets/{spreadsheetID}", + "/*repository_path/git-upload-pack", + "/notebook/*", + "/api/unstable/trace/{traceID}", + "/api/ui/app_listings", + "/api/ui/remote_config/management/org_config", + "/api/v1/security_analytics/rules/tags", + "/api/v1/rum/projects/", + "/account/saml/assertion/id/", + "/api/unstable/on-call/teams/{teamUUID}/on-call", + "/api/v2/apm/services", + "/internal/core/v2/routetables/{id}", + "/api/ui/container_images", + "/api/ui/security/appsec/flaggedips/{from}/{to}", + "/api/v2/incidents/config/rules", + "/orgs/{orgId}/facets", + "/api/v2/flamegraph", + "/api/v2/oauth2/.well-known/sites", + "/orgs/{orgId}/v2/security_analytics/livetail", + "/api//logs/config/archives/", + "/internal/security-graph/shards/mappings", + "/api/ui/team-list", + "fakecdnoutage", + "/api/:version/jobs/:id", + "/api/ui/cost/lite", + "/api/v2/internal/admin/org_access_request_meta/", + "/api/unstable/integration/aws/accounts", + "/internal/core/v2/pools/{id}/summary", + "/api/v2/metrics//tags", + "/monitor/bulk_delete", + "/orgs/{orgId}/security_analytics/rules", + "/v1/task/{taskId}/results/{bufferId}/{token}/acknowledge", + "^upload-file$", + "/api/ui/event-platform/cpfinding/facets", + "/account/forgot_password", + "/api/v2/rum/replay/playlists/{playlistID}", + "/internal/catalog/v1/namespaces", + "/integration/github/private-apps/hostnames", + "/api/v2/rum/resource/token", + "/api/v1/synthetics/tests/browser//results", + "/api/v1/synthetics/tests//results", + `/orchestration/{string_1:[^/?()[\]]+}/{string_2:[^/?()[\]]+}`, + "/api//observability_pipelines/v2/graphql", + "/api/v1/monitor//related_dashboards", + `/monitors/create/{string_1:[^/?()[\]]+}`, + "/xds/validate-config", + "/api/ui/data_streams/clusters", + "/v2/orgs/{orgId}/logs/config/custom-destination/{customDestinationId}", + "/api/ui/remote_config/products/asm/waf/exclusion_filters", + "/api/v2/py/pets/{pet_id}", + "/api/v2/security_monitoring/configuration/suppressions/{suppressionId}", + "/api/v2/rum/events/search", + "/api/unstable/smoke-test-go-classic-http/five", + "/api/unstable/smoke-test-go-classic-http/gzip", + "/api/unstable/smoke-test-go-classic-http/vault/secret", + "/api/unstable/smoke-test-go-classic-http/consul/value", + "/api/unstable/smoke-test-go-classic-http/experiment/status", + "/api/unstable/smoke-test-go-classic-http/panic", + "/metric/explorer", + "/api/unstable/smoke-test-go-classic-http/four", + "/api/unstable/smoke-test-go-classic-http/tap", + "/api/v1/security_analytics/resource_type_mapping", + "/api/ui/flows/list", + "/orgs/{orgId}/security_analytics/activation/{product}/enabled_log_sources", + "/api/v2/rum/replay/sessions//retention", + "/api/ui/resource_catalog/facet_resources", + "/v2/orgs/{orgId}/security_monitoring/cloud_workload_security/agent_rules/csm_features", + "/api/v1/notebooks//cells/", + "/api//tag_keys", + "/api/v2/apm/primary_tags/list", + "/api/ui/billing/accessible_features", + "/api/ui/ip-lookup/get-info", + "/api/v2/rum/replay/sessions/{sessionID}/watches", + "/api/v2/spans/events", + "/api/v2/app-builder/apps/{appId}", + "/error-tracking", + "/api/v2/team/{team_id}/memberships", + "/api/v2/ci/pipelines/events/search", + "/locks", + "/api/v1/org", + "/api/v2/connection/connections", + "/orgs/{orgId}/security_analytics/rules/tags", + "/api/v2/ddsql/user/table", + "/api/v1/integration/azure", + "/api/ui/event-platform/llmobs/facets", + "/logs/", + "/api/ui/remote_config/products/live_debugging/probes/log/{probeID}", + "/api/v1/check_github", + "/security/appsec/*", + "/api/ui/metrics/summary/facet_info", + "/api/v2/internal/admin/get_support_org_list", + "/api/ui/event-platform/ccm/facets", + "/api/v1/org/", + "/api/v1/widget/share", + "/v1/statement/queued/{queryId}/{slug}/{token}", + "/api/ui/remote_config/products/fleet/agents/count", + "/api/ui/resource-catalog-api/resources", + "/api/v2/reference-tables/{TableName}/rows", + "/api/v1/monitor/can_delete", + "/api/v2/spreadsheets", + "/debug/vars", + "/api/:version/jobs/:id/artifacts", + "/api/v2/infrastructure/facets", + "/api//event-platform//processors/samples", + "/api/v1/downtime", + "/api/v1/integration/gcp", + "/api/v1/slo/correction/", + "/profiling/api/v1/profiles//timeline", + "/api/ui/flows/map", + "/api/v1/service_dependencies/*", + "/api/v1/timeline", + "/api/unstable/error-tracking-codegen/*", + "/api/v2/git/repository/packfile", + "/api/v2/actions-datastores/{datastoreId}/items", + "/api/v2/integration/aws/accounts/{aws_account_config_id}", + "/oauth2/v1/keys", + "/api/ui/error-tracking/issues/field-values/{fieldValuesID}", + "/api/ui/remote_config/products/asm/waf/policies", + "/api/v2/agentless_scanning/accounts/azure", + "/api/ui/security_monitoring/rules/dependents", + "/api//node_map/node_names", + "/account/saml/metadata.xml", + "/metric/distribution/summary_aggr", + "/api/v2/current_user/application_keys", + "/api/v1/synthetics/private-locations/tests/files", + "/api/ui/usage/relevant-summary", + "/api/ui/error-tracking/issues/{issueID}/suspect-commit", + "/api/v2/incidents/config/user-defined-roles", + "/api/v2/incidents/{IncidentUUID}/rule-execution-states", + "/java-bazel/{ref}/{name}/{filename}", + "/api/v2/saml_configurations", + "/intake/", + "/account/saml/config//sp_metadata.xml", + "/api/ui/usage/ddm-summary", + "/api/v2/ide/product-availability", + "/api/v2/logs/historical_indexes", + "/api/unstable/on-call/schedules/{scheduleUUID}/on-call", + "/api/v1/integration/pagerduty/configuration/services/", + "api/usage/v1/relevant-usage.json", + "/api/ui/usage/relevant-trends", + "/api/ui/usage/summary", + "/api/ui/usage/trends", + "/api/v2/users//memberships", + "/orgs/{orgId}/security_analytics/rules/dependents", + "/api/ui/error-tracking/issues/{issueID}/activity-timeline", + "/oauth2/v1/.well-known/openid-configuration", + "/api/v2/org", + "/api/:version/jobs/:id/trace", + "/api/unstable/sensitive-data-scanner/groups", + "/api/v2/saml_configurations/idp_metadata", + "/api/unstable/cost/tag_keys", + "/v2/orgs/{orgId}/external-archives", + "/api/unstable/metric//tag_cardinalities", + "/internal/api/v2/concurrency_locks/{concurrency_lock_definition_id}/{workflow_id}", + "/api/ui/monitor/evaluation_preview", + "/api/v1/synthetics/private-locations", + "/api/v2/static-analysis/analysis/diff-aware", + "/api/unstable/error-tracking-codegen/ai-suggestions", + "/api/ui/app_listings/", + "/api/v1/breakdown", + "/api/ui/remote_config/products/live_debugging/probes/log", + "/api/v1/dashboard", + "/api/v2/incidents/config/types", + "/graph/embed", + "/orgs/{orgId}/security_analytics/rules/facets", + "/api/ui/orchestration/manifest_content", + "/api/v2/consul/value", + "/api/v2/ide/services/search", + "/api/v2/vault/secret", + "/account/login/by_email", + "/api/ui/usage/ddm-trends", + "/api/v2/exception", + "/api/unstable/remote_config/products/asm/activation", + "/api/v2/experiment/status", + "/v2/_dd/operations/replicate", + "/api/v1/correlations/", + "/internal/trino-ui/{cluster}/cluster_details_json", + "/api/unstable/profiles/list", + "/api/v2/app-builder/apps", + "/api/v2/agentless_scanning/setup_feedback/accounts/aws", + "/api/v2/identity_providers", + "/api/v2/cloud_security_management/resource_filters", + "/api/ui/event-platform/synthetics/facets", + "/api/v2/hamr", + "/api/v2/agentless_scanning/accounts/aws", + "/api/ui/event-platform/query/composite-list", + "/api/v2/users//orgs", + "/api/ui/security_monitoring/configuration/suppressions/rules/{ruleId}", + "/internal/api/v2/spark_jobs/{spark_job_id}/{retry_attempt}/state", + "/api/v2/quality-gates/evaluate", + "/source/list", + "/api/ui/siem-historical-detections/jobs/facet_info", + "/api/v1/trial", + "/overview/system_tiles", + "/api/v1/screen/integration/", + "/api/v1/downtime/search", + "/security", + "/internal/error-tracking/incoming", + "/v2/orgs/{orgId}/logs/config/archives/{externalId}", + "/api/unstable/team", + "/api/v2/internal/admin/switch_handle_post", + "/notebook", + "/v3/orgs/{orgId}/{trackType}/pipelines", + "/api/ui/data_streams/schemas", + "/integration/slack/configuration", + "/api/ui/security/appsec/responses/entities", + "/metric/distribution/list_summaries", + "/api/v1/downtime/cancel/by_scope", + "/api/unstable/stegadography/cache/{id}", + "/account/login/id/", + "/api/v1/health", + "/api/v2/spreadsheets/{spreadsheetID}/table-sheets/{sheetID}", + "/api/v2/static-analysis/repositories/counts/analysis", + "/api/v2/reference-tables", + "/api/v2/roles/{roleUuid}/permissions", + "/api/v1/synthetics/browser/tests/", + "/api/v2/incidents/config/org/settings/", + "/api/v2/roles/{roleUuid}/users", + "/api/v2/downtime", + "/api/v2/rum/replay/playlists", + "/api/v2/incidents/config/user-defined-fields", + "/api/v2/incidents//responders", + "/api/ui/twilio/voice/events", + "api/usage/v1/active-usage-types.json", + "/api/v2/audit/events", + "/api/v2/identity_providers//users", + "/api/v1/graph/embed", + "/api/v2/incidents/config/integrations//workflows", + "/api/v2/logs/views/mark-as-viewed", + "/api/ui/billing/last-updated", + "/signup_corp", + "/integration/github/private-apps/enrich-link", + "None", + "/api/v2/connection/integrations", + "/internal/doggo/search", + "/api/v2/source-code-integration/repositories-v2", + "/api/ui/billing/org/is-super", + "/api/v2/cases/projects", + "/api/v2/source-code-integration/code-owners", + "/api/v2/spans/events/search", + "/.well-known/apollo/server-health", + "/api/v2/on_prem_runners", + "/get_org_billing_data", + "/api/ui/product-catalog/be/ddm/product", + "/api/ui/product-catalog/bp/billing-dimension", + "/api/ui/product-catalog/rq/usage_attribution", + "/api/ui/product-catalog/be/billing-dimension", + "/api/ui/product-catalog/be/category", + "/api/ui/product-catalog/bp/percent-based", + "/api/v1/synthetics/browser/subtests//parents", + "/api/v2/authn_mappings/", + "/api/v2/on-call/presence/{resourceId}", + "/locks/delete", + "/api/v2/metrics//estimate", + "/api/v1/dashboard/recommendations_load_event//", + "/api/:version/runners/verify", + "/api/ui/integration/aws/integrationissues/account", + "/api/unstable/csm/onboarding/agents/count", + "/api/unstable/csm/onboarding/agents", + "/api/unstable/csm/onboarding/agents/facets", + "/api/v1/synthetics/browser/tests//results//artifacts", + "/api/v2/workflow_actions", + "/api/v2/apicatalog/facet/{facet}", + "/api/ui/csm/onboarding/agents/count", + "/api/ui/resource-catalog-api/distinct", + "/organization-settings/*", + "/api/v2/rum/replay/sessions//metadata", + "/api/ui/spans/custom-metrics", + "/services", + "/api/ui/obs-pipelines/pipelines/{pipelineId}", + "/api/v1/compliance_monitoring/findings/rule_based_view", + "/api/v2/static-analysis/repositories/products-enabled", + "/internal/cit/pr-comment", + "/v1/statement", + "/api/ui/integration/aws/integrationissues/status", + "/api/v2/py/pets", + "/process/agent_hosts", + "/api/unstable/smoke-test-go-classic-http/smoketest/grpc", + "/-/healthy", + "/api/unstable/smoke-test-go-classic-http-dest/smoketest/grpc", + "/api/unstable/smoke-test-go-classic-http/paginated/number-size", + "/api/unstable/smoke-test-go-classic-http/paginated/cursor", + "/internal/slack/event", + "/startup", + "/api/ui/data_streams/lag_metrics", + "/api/unstable/smoke-test-go-classic-http/paginated/offset-limit", + "/api/v1/synthetics/settings/default_locations", + "/api/v2/pets", + "/v2/orgs/{orgId}/security_monitoring/configuration/suppressions/rules/{ruleId}", + "/api/v2/actions-datastores/{datastoreId}", + "/api/unstable/on-prem-management-service/workflow-tasks/dequeue", + "/api/v1/search", + "/api/:version/job", + "/reports/v2/agents", + "/api/ui/ide/profiles/analytics", + "/api/ui/metrics/summary/export", + "/api/v2/paginated/cursor_limit", + "/api/v2/paginated/offset_limit", + "/api/ui/obs-pipelines/pipelines/{pipelineId}/relationships/draft", + "/api/v2/cloud_security_management/iac_remediation/code_location/finding", + "/api/v2/response_test/five", + "/api/v1/metrics", + "/api/v2/response_test/four", + "/api/v1/slo//corrections", + "/api/v2/paginated/number_size", + "/api/unstable/databases/recommendations/tags", + "/api/v2/services/integrations/opsgenie/oncalls", + "/api/v2/integration/aws/accounts", + "/u", + "/api/ui/security/appsec/responses/integrations", + "/api/v1/synthetics/tests/trigger/ci", + "/internal/reporting/job/heartbeat", + "/api/v1/integration/aws", + "/api/v2/incidents/incident_roles/reserved_roles", + "/downtime/monitors/match", + "/-/ready", + "/api/v1/security_analytics/rules", + "/v1/bundles/general", + "/api/ui/integrations//accounts", + "/api/ui/slo/summary_widget_query", + "/api/ui/workflows/", + "/api/unstable/data_security/summary", + "/api/v2/change-tracking/service_edges", + "/internal/v1/events", + "/api/ui/event-platform/secruntime/facets", + "/ticino/agent/", + "/api/unstable/cost/tag_keys/", + "/api/ui/apm/default_env_setting", + "/api/ui/security/appsec/responses/safeguards", + "/internal/gitlab/*", + "/api/intake/llm-obs/v1/eval-metric", + "/api/ui/remote_config/products/asm/waf/rules", + "/api/v2/workflow_actions/", + "^email_ses$", + "/api/v1/notebooks//cells", + "/api/v1/slo/saved_view/search", + "/jobs/spark_config", + "/api/ui/csm/onboarding/agents/heartbeats", + "/api/ui/remote_config/products/fleet/agents", + "/gateway/backend/all", + "/v1/task/{taskId}/results/{bufferId}", + "/api//apm/pipelines", + "/api/v2/rum/sankey", + "/api/unstable/cost/tag_groups", + "/api/v2/users/{user_id}/memberships", + "/api/v2/logs/config/custom-destinations", + "/api/v1/settings/favorite", + "/api/v2/event-correlation/rules", + "/api/v1/graph/snapshot", + "/api/v2/ddsql/user/csv", + "/api/v2/source-code-integration/get-file-link", + "/api/unstable/on-call/pages/facets", + "/api/ui/ide/profiles/flamegraph", + "/api/v2/metrics//active-configurations", + "/api/ui/data_streams/service_summary", + "/api/v1/inventories/taxonomy", + "/_internal/health", + "/api/v2/containers", + "/ready", + "/api/ui/apm/operation_names", + "/api/v1/logs/configuration/indexes", + "/orgs/{orgId}/integrations", + "/v1/issuer/sycamore/token", + "/api/v2/notifications/handles", + "/api/v2/workflow_templates", + "/api/v1/slo/preview_history", + "/event/explorer", + "/api/v1/service_dependencies", + "/infrastructure", + "/api/v2/static-analysis/secrets/rules", + "/v2/_scanning/{name:(?:(?:(?:[a-zA-Z0-9]", + "/orgs/{orgId}/security_analytics/default_rules", + "/api/ui/apm/host_group_keys", + "/api/ui/resource_catalog/list/group", + "/api/v1/downtime/", + "/api/v2/audit/events/search", + "/internal/v2/telemetry-archive/api/orgs/{orgID}/analytics/requests", + "/api/v1/dash/integration/", + "/gateway", + "/account/not_my_account", + "/api/v2/source-code-integration/repo-ids/search", + "/api/v2/tags/enrichment/{rulesetId}", + "/api//watchdog/stories/", + "/api/ui/integration/aws/metric_streams_config/{aws_account_config_id}", + "/api/ui/apps/categories", + "/api/ui/slo/search/tag_keys", + "/api/ui/workflows/{workflowId}", + "/api/unstable/data_security/resources/csv", + "/account/login/recaptcha", + "/api/ui/signup/event", + "/api/unstable/data_security/resources", + "/api/unstable/query-prediction/predict", + "/api/v1/synthetics/tests/fast", + "/api/v2/series", + "/process", + "/api//usage/hourly-attribution", + "/api/unstable/databases/datamodels/query", + "/kubernetes_jobs/", + "/v2/orgs/{orgId}/historical-indexes", + "/api/:version/projects/:id", + "/api/v2/security_monitoring/signals/search", + "/api/v1/logs/filters", + "/internal/csm/onboarding/capabilities", + "^create-element-with-user-provided-id$", + "/api/ui/reporting/recurrence/list", + "/specs//trigger", + } +) + +var ( + once sync.Once + testVector []SamplingKey +) + +func initTestVector() { + once.Do(func() { + testVector = make([]SamplingKey, len(httpMethods)*len(httpRoute)*len(httpStatusCodes)) + var mi, ri, si int + for i := range testVector { + testVector[i] = SamplingKey{ + Method: httpMethods[mi], + Route: httpRoute[ri], + StatusCode: httpStatusCodes[si], + } + if si = (si + 1) % len(httpStatusCodes); si == 0 { + if ri = (ri + 1) % len(httpRoute); ri == 0 { + mi++ + } + } + } + + // Shuffle the order of the key space so it's random, but use a constant-seed RNG so that all + // runs are equal (useful in benchmarks). + rand := rand.New(rand.NewSource(1337)) + rand.Shuffle(len(testVector), func(i int, j int) { testVector[i], testVector[j] = testVector[j], testVector[i] }) + }) +} diff --git a/appsec/config.go b/appsec/config.go index 7248e60..54cc54f 100644 --- a/appsec/config.go +++ b/appsec/config.go @@ -13,34 +13,65 @@ import ( "unicode" "unicode/utf8" + "github.com/DataDog/appsec-internal-go/apisec" "github.com/DataDog/appsec-internal-go/log" ) // Configuration environment variables const ( - envAPISecEnabled = "DD_EXPERIMENTAL_API_SECURITY_ENABLED" - envAPISecSampleRate = "DD_API_SECURITY_REQUEST_SAMPLE_RATE" - envObfuscatorKey = "DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP" - envObfuscatorValue = "DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP" - envWafTimeout = "DD_APPSEC_WAF_TIMEOUT" - envTraceRateLimit = "DD_APPSEC_TRACE_RATE_LIMIT" - envRules = "DD_APPSEC_RULES" + // EnvAPISecEnabled is the env var used to enable API Security + EnvAPISecEnabled = "DD_API_SECURITY_ENABLED" + // EnvAPISecSampleRate is the env var used to set the sampling rate of API Security schema extraction. + // Deprecated: a new [APISecConfig.Sampler] is now used instead of this. + EnvAPISecSampleRate = "DD_API_SECURITY_REQUEST_SAMPLE_RATE" + // EnvAPISecProxySampleRate is the env var used to set the sampling rate of API Security schema extraction for proxies. + // The value represents the number of schemas extracted per minute (samples per minute). + EnvAPISecProxySampleRate = "DD_API_SECURITY_PROXY_SAMPLE_RATE" + // EnvObfuscatorKey is the env var used to provide the WAF key obfuscation regexp + EnvObfuscatorKey = "DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP" + // EnvObfuscatorValue is the env var used to provide the WAF value obfuscation regexp + EnvObfuscatorValue = "DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP" + // EnvWAFTimeout is the env var used to specify the timeout value for a WAF run + EnvWAFTimeout = "DD_APPSEC_WAF_TIMEOUT" + // EnvTraceRateLimit is the env var used to set the ASM trace limiting rate + EnvTraceRateLimit = "DD_APPSEC_TRACE_RATE_LIMIT" + // EnvRules is the env var used to provide a path to a local security rule file + EnvRules = "DD_APPSEC_RULES" + // EnvRASPEnabled is the env var used to enable/disable RASP functionalities for ASM + EnvRASPEnabled = "DD_APPSEC_RASP_ENABLED" + + // envAPISecSampleDelay is the env var used to set the delay for the API Security sampler in system tests. + // It is not indended to be set by users. + envAPISecSampleDelay = "DD_API_SECURITY_SAMPLE_DELAY" ) // Configuration constants and default values const ( - defaultAPISecSampleRate = .1 - defaultObfuscatorKeyRegex = `(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?)key)|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization` - defaultObfuscatorValueRegex = `(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\s*=[^;]|"\s*:\s*"[^"]+")|bearer\s+[a-z0-9\._\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\w=-]+\.ey[I-L][\w=-]+(?:\.[\w.+\/=-]+)?|[\-]{5}BEGIN[a-z\s]+PRIVATE\sKEY[\-]{5}[^\-]+[\-]{5}END[a-z\s]+PRIVATE\sKEY|ssh-rsa\s*[a-z0-9\/\.+]{100,}` - defaultWAFTimeout = 4 * time.Millisecond - defaultTraceRate uint = 100 // up to 100 appsec traces/s + // DefaultAPISecSampleRate is the default rate at which API Security schemas are extracted from requests + DefaultAPISecSampleRate = .1 + // DefaultAPISecSampleInterval is the default interval between two samples being taken. + DefaultAPISecSampleInterval = 30 * time.Second + // DefaultAPISecProxySampleRate is the default rate (schemas per minute) at which API Security schemas are extracted from requests + DefaultAPISecProxySampleRate = 300 + // DefaultAPISecProxySampleInterval is the default time window for the API Security proxy sampler rate limiter. + DefaultAPISecProxySampleInterval = time.Minute + // DefaultObfuscatorKeyRegex is the default regexp used to obfuscate keys + DefaultObfuscatorKeyRegex = `(?i)pass|pw(?:or)?d|secret|(?:api|private|public|access)[_-]?key|token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization|jsessionid|phpsessid|asp\.net[_-]sessionid|sid|jwt` + // DefaultObfuscatorValueRegex is the default regexp used to obfuscate values + DefaultObfuscatorValueRegex = `(?i)(?:p(?:ass)?w(?:or)?d|pass(?:[_-]?phrase)?|secret(?:[_-]?key)?|(?:(?:api|private|public|access)[_-]?)key(?:[_-]?id)?|(?:(?:auth|access|id|refresh)[_-]?)?token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?|jsessionid|phpsessid|asp\.net(?:[_-]|-)sessionid|sid|jwt)(?:\s*=([^;&]+)|"\s*:\s*("[^"]+"|\d+))|bearer\s+([a-z0-9\._\-]+)|token\s*:\s*([a-z0-9]{13})|gh[opsu]_([0-9a-zA-Z]{36})|ey[I-L][\w=-]+\.(ey[I-L][\w=-]+(?:\.[\w.+\/=-]+)?)|[\-]{5}BEGIN[a-z\s]+PRIVATE\sKEY[\-]{5}([^\-]+)[\-]{5}END[a-z\s]+PRIVATE\sKEY|ssh-rsa\s*([a-z0-9\/\.+]{100,})` + // DefaultWAFTimeout is the default time limit past which a WAF run will timeout + DefaultWAFTimeout = time.Millisecond + // DefaultTraceRate is the default limit (trace/sec) past which ASM traces are sampled out + DefaultTraceRate uint = 100 // up to 100 appsec traces/s ) -// APISecConfig holds the configuration for API Security schemas reporting -// It is used to enabled/disable the feature as well as to configure the rate -// at which schemas get reported, +// APISecConfig holds the configuration for API Security schemas reporting. +// It is used to enabled/disable the feature. type APISecConfig struct { - Enabled bool + Sampler apisec.Sampler + Enabled bool + IsProxy bool + // Deprecated: use the new [APISecConfig.Sampler] instead. SampleRate float64 } @@ -50,25 +81,42 @@ type ObfuscatorConfig struct { ValueRegex string } +type APISecOption func(*APISecConfig) + // NewAPISecConfig creates and returns a new API Security configuration by reading the env -func NewAPISecConfig() APISecConfig { - return APISecConfig{ - Enabled: apiSecurityEnabled(), +func NewAPISecConfig(opts ...APISecOption) APISecConfig { + cfg := APISecConfig{ + Enabled: boolEnv(EnvAPISecEnabled, true), SampleRate: readAPISecuritySampleRate(), } -} + for _, opt := range opts { + opt(&cfg) + } -func apiSecurityEnabled() bool { - enabled, _ := strconv.ParseBool(os.Getenv(envAPISecEnabled)) - return enabled + if cfg.Sampler != nil { + return cfg + } + + if cfg.IsProxy { + rate := intEnv(EnvAPISecProxySampleRate, DefaultAPISecProxySampleRate) + cfg.Sampler = apisec.NewProxySampler(rate, DefaultAPISecProxySampleInterval) + } else { + cfg.Sampler = apisec.NewSamplerWithInterval(durationEnv(envAPISecSampleDelay, "s", DefaultAPISecSampleInterval)) + } + + return cfg } func readAPISecuritySampleRate() float64 { - value := os.Getenv(envAPISecSampleRate) + value := os.Getenv(EnvAPISecSampleRate) + if value == "" { + return DefaultAPISecSampleRate + } + rate, err := strconv.ParseFloat(value, 64) if err != nil { - logEnvVarParsingError(envAPISecSampleRate, value, err, defaultAPISecSampleRate) - return defaultAPISecSampleRate + logEnvVarParsingError(EnvAPISecSampleRate, value, err, DefaultAPISecSampleRate) + return DefaultAPISecSampleRate } // Clamp the value so that 0.0 <= rate <= 1.0 if rate < 0. { @@ -79,10 +127,31 @@ func readAPISecuritySampleRate() float64 { return rate } +// WithAPISecSampler sets the sampler for the API Security configuration. This is useful for testing +// purposes. +func WithAPISecSampler(sampler apisec.Sampler) APISecOption { + return func(c *APISecConfig) { + c.Sampler = sampler + } +} + +// WithProxy configures API Security for a proxy environment. +func WithProxy() APISecOption { + return func(c *APISecConfig) { + c.IsProxy = true + } +} + +// RASPEnabled returns true if RASP functionalities are enabled through the env, or if DD_APPSEC_RASP_ENABLED +// is not set +func RASPEnabled() bool { + return boolEnv(EnvRASPEnabled, true) +} + // NewObfuscatorConfig creates and returns a new WAF obfuscator configuration by reading the env func NewObfuscatorConfig() ObfuscatorConfig { - keyRE := readObfuscatorConfigRegexp(envObfuscatorKey, defaultObfuscatorKeyRegex) - valueRE := readObfuscatorConfigRegexp(envObfuscatorValue, defaultObfuscatorValueRegex) + keyRE := readObfuscatorConfigRegexp(EnvObfuscatorKey, DefaultObfuscatorKeyRegex) + valueRE := readObfuscatorConfigRegexp(EnvObfuscatorValue, DefaultObfuscatorValueRegex) return ObfuscatorConfig{KeyRegex: keyRE, ValueRegex: valueRE} } @@ -101,10 +170,10 @@ func readObfuscatorConfigRegexp(name, defaultValue string) string { } // WAFTimeoutFromEnv reads and parses the WAF timeout value set through the env -// If not set, it defaults to `defaultWAFTimeout` +// If not set, it defaults to `DefaultWAFTimeout` func WAFTimeoutFromEnv() (timeout time.Duration) { - timeout = defaultWAFTimeout - value := os.Getenv(envWafTimeout) + timeout = DefaultWAFTimeout + value := os.Getenv(EnvWAFTimeout) if value == "" { return } @@ -118,31 +187,31 @@ func WAFTimeoutFromEnv() (timeout time.Duration) { parsed, err := time.ParseDuration(value) if err != nil { - logEnvVarParsingError(envWafTimeout, value, err, timeout) + logEnvVarParsingError(EnvWAFTimeout, value, err, timeout) return } if parsed <= 0 { - logUnexpectedEnvVarValue(envWafTimeout, parsed, "expecting a strictly positive duration", timeout) + logUnexpectedEnvVarValue(EnvWAFTimeout, parsed, "expecting a strictly positive duration", timeout) return } return parsed } // RateLimitFromEnv reads and parses the trace rate limit set through the env -// If not set, it defaults to `defaultTraceRate` +// If not set, it defaults to `DefaultTraceRate` func RateLimitFromEnv() (rate uint) { - rate = defaultTraceRate - value := os.Getenv(envTraceRateLimit) + rate = DefaultTraceRate + value := os.Getenv(EnvTraceRateLimit) if value == "" { return rate } parsed, err := strconv.ParseUint(value, 10, 0) if err != nil { - logEnvVarParsingError(envTraceRateLimit, value, err, rate) + logEnvVarParsingError(EnvTraceRateLimit, value, err, rate) return } if parsed == 0 { - logUnexpectedEnvVarValue(envTraceRateLimit, parsed, "expecting a value strictly greater than 0", rate) + logUnexpectedEnvVarValue(EnvTraceRateLimit, parsed, "expecting a value strictly greater than 0", rate) return } return uint(parsed) @@ -151,7 +220,7 @@ func RateLimitFromEnv() (rate uint) { // RulesFromEnv returns the security rules provided through the environment // If the env var is not set, the default recommended rules are returned instead func RulesFromEnv() ([]byte, error) { - filepath := os.Getenv(envRules) + filepath := os.Getenv(EnvRules) if filepath == "" { log.Debug("appsec: using the default built-in recommended security rules") return DefaultRuleset() @@ -174,3 +243,42 @@ func logEnvVarParsingError(name, value string, err error, defaultValue any) { func logUnexpectedEnvVarValue(name string, value any, reason string, defaultValue any) { log.Debug("appsec: unexpected configuration value of %s=%v: %s. Using default value %v.", name, value, reason, defaultValue) } + +func boolEnv(key string, def bool) bool { + strVal, ok := os.LookupEnv(key) + if !ok { + return def + } + v, err := strconv.ParseBool(strVal) + if err != nil { + logEnvVarParsingError(key, strVal, err, def) + return def + } + return v +} + +func durationEnv(key string, unit string, def time.Duration) time.Duration { + strVal, ok := os.LookupEnv(key) + if !ok { + return def + } + val, err := time.ParseDuration(strVal + unit) + if err != nil { + logEnvVarParsingError(key, strVal, err, def) + return def + } + return val +} + +func intEnv(key string, def int) int { + strVal, ok := os.LookupEnv(key) + if !ok { + return def + } + val, err := strconv.Atoi(strVal) + if err != nil { + logEnvVarParsingError(key, strVal, err, def) + return def + } + return val +} diff --git a/appsec/config_test.go b/appsec/config_test.go index 7df561a..c6cc762 100644 --- a/appsec/config_test.go +++ b/appsec/config_test.go @@ -15,96 +15,69 @@ import ( func TestAPISecConfig(t *testing.T) { for _, tc := range []struct { - name string - enabledVar string - sampleRateVar string - enabled bool - sampleRate float64 + name string + enabledVar string + enabled bool }{ - { - name: "disabled", - sampleRate: defaultAPISecSampleRate, - }, { name: "disabled", enabledVar: "false", - sampleRate: defaultAPISecSampleRate, }, { name: "disabled", enabledVar: "0", - sampleRate: defaultAPISecSampleRate, }, { - name: "disabled", - enabledVar: "weirdvalue", - sampleRate: defaultAPISecSampleRate, + name: "enabled", + enabled: true, }, { name: "enabled", enabledVar: "true", enabled: true, - sampleRate: defaultAPISecSampleRate, }, { name: "enabled", enabledVar: "1", enabled: true, - sampleRate: defaultAPISecSampleRate, }, { - name: "sampleRate 1.0", - enabledVar: "true", - sampleRateVar: "1.0", - enabled: true, - sampleRate: 1., - }, - { - name: "sampleRate 50.0", - enabledVar: "true", - sampleRateVar: "50.0", - enabled: true, - sampleRate: 1., - }, - { - name: "sampleRate -50.0", - enabledVar: "true", - sampleRateVar: "-50.0", - enabled: true, - sampleRate: 0., + name: "enabled", + enabledVar: "weirdvalue", + enabled: true, }, } { t.Run(tc.name, func(t *testing.T) { - t.Setenv(envAPISecEnabled, tc.enabledVar) - t.Setenv(envAPISecSampleRate, tc.sampleRateVar) + if len(tc.enabledVar) > 0 { + t.Setenv(EnvAPISecEnabled, tc.enabledVar) + } cfg := NewAPISecConfig() require.Equal(t, tc.enabled, cfg.Enabled) - require.Equal(t, tc.sampleRate, cfg.SampleRate) }) } } func TestObfuscatorConfig(t *testing.T) { defaultConfig := ObfuscatorConfig{ - KeyRegex: defaultObfuscatorKeyRegex, - ValueRegex: defaultObfuscatorValueRegex, + KeyRegex: DefaultObfuscatorKeyRegex, + ValueRegex: DefaultObfuscatorValueRegex, } t.Run("key/env-var-normal", func(t *testing.T) { expCfg := defaultConfig expCfg.KeyRegex = "test" - t.Setenv(envObfuscatorKey, "test") + t.Setenv(EnvObfuscatorKey, "test") cfg := NewObfuscatorConfig() require.Equal(t, expCfg, cfg) }) t.Run("key/env-var-empty", func(t *testing.T) { expCfg := defaultConfig expCfg.KeyRegex = "" - t.Setenv(envObfuscatorKey, "") + t.Setenv(EnvObfuscatorKey, "") cfg := NewObfuscatorConfig() require.Equal(t, expCfg, cfg) }) t.Run("key/compile-error", func(t *testing.T) { - t.Setenv(envObfuscatorKey, "+") + t.Setenv(EnvObfuscatorKey, "+") cfg := NewObfuscatorConfig() require.Equal(t, defaultConfig, cfg) }) @@ -112,19 +85,19 @@ func TestObfuscatorConfig(t *testing.T) { t.Run("value/env-var-normal", func(t *testing.T) { expCfg := defaultConfig expCfg.ValueRegex = "test" - t.Setenv(envObfuscatorValue, "test") + t.Setenv(EnvObfuscatorValue, "test") cfg := NewObfuscatorConfig() require.Equal(t, expCfg, cfg) }) t.Run("value/env-var-empty", func(t *testing.T) { expCfg := defaultConfig expCfg.ValueRegex = "" - t.Setenv(envObfuscatorValue, "") + t.Setenv(EnvObfuscatorValue, "") cfg := NewObfuscatorConfig() require.Equal(t, expCfg, cfg) }) t.Run("value/compile-error", func(t *testing.T) { - t.Setenv(envObfuscatorValue, "+") + t.Setenv(EnvObfuscatorValue, "+") cfg := NewObfuscatorConfig() require.Equal(t, defaultConfig, cfg) }) @@ -144,26 +117,26 @@ func TestTraceRateLimit(t *testing.T) { { name: "not-parsable", env: "not a uint", - expected: defaultTraceRate, + expected: DefaultTraceRate, }, { name: "negative", env: "-1", - expected: defaultTraceRate, + expected: DefaultTraceRate, }, { name: "zero", env: "0", - expected: defaultTraceRate, + expected: DefaultTraceRate, }, { name: "empty-string", env: "", - expected: defaultTraceRate, + expected: DefaultTraceRate, }, } { t.Run(tc.name, func(t *testing.T) { - t.Setenv(envTraceRateLimit, tc.env) + t.Setenv(EnvTraceRateLimit, tc.env) require.Equal(t, tc.expected, RateLimitFromEnv()) }) } @@ -188,26 +161,26 @@ func TestWAFTimeout(t *testing.T) { { name: "not-parsable", env: "not a duration string", - expected: defaultWAFTimeout, + expected: DefaultWAFTimeout, }, { name: "negative", env: "-1s", - expected: defaultWAFTimeout, + expected: DefaultWAFTimeout, }, { name: "zero", env: "0", - expected: defaultWAFTimeout, + expected: DefaultWAFTimeout, }, { name: "empty-string", env: "", - expected: defaultWAFTimeout, + expected: DefaultWAFTimeout, }, } { t.Run(tc.name, func(t *testing.T) { - t.Setenv(envWafTimeout, tc.env) + t.Setenv(EnvWAFTimeout, tc.env) require.Equal(t, tc.expected, WAFTimeoutFromEnv()) }) @@ -218,14 +191,14 @@ func TestRules(t *testing.T) { t.Run("empty-string", func(t *testing.T) { defaultRules, err := DefaultRuleset() require.NoError(t, err) - t.Setenv(envRules, "") + t.Setenv(EnvRules, "") rules, err := RulesFromEnv() require.NoError(t, err) require.Equal(t, defaultRules, rules) }) t.Run("file-not-found", func(t *testing.T) { - t.Setenv(envRules, "i do not exist") + t.Setenv(EnvRules, "i do not exist") rules, err := RulesFromEnv() require.Error(t, err) require.Nil(t, rules) @@ -240,9 +213,62 @@ func TestRules(t *testing.T) { }() _, err = file.WriteString(StaticRecommendedRules) require.NoError(t, err) - t.Setenv(envRules, file.Name()) + t.Setenv(EnvRules, file.Name()) rules, err := RulesFromEnv() require.NoError(t, err) require.Equal(t, StaticRecommendedRules, string(rules)) }) } + +func TestRASPEnablement(t *testing.T) { + t.Run("enabled", func(t *testing.T) { + t.Setenv(EnvRASPEnabled, "true") + require.True(t, RASPEnabled()) + }) + + t.Run("disabled", func(t *testing.T) { + t.Setenv(EnvRASPEnabled, "false") + require.False(t, RASPEnabled()) + }) + + t.Run("unset", func(t *testing.T) { + // t.Setenv first to restore the original value at the end of the test + t.Setenv(EnvRASPEnabled, "") + os.Unsetenv(EnvRASPEnabled) + require.True(t, RASPEnabled()) + }) +} + +func TestDurationEnv(t *testing.T) { + const varName = "DD_TEST_VARIABLE_DURATION" + + type testCase struct { + EnvVal string + EnvUnit string + Expected time.Duration + } + testCases := map[string]testCase{ + "blank": { + EnvVal: "", + EnvUnit: "s", + Expected: 1337, + }, + "1m": { + EnvVal: "1", + EnvUnit: "m", + Expected: time.Minute, + }, + "invalid": { + EnvVal: "invalid", + EnvUnit: "s", + Expected: 1337, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + t.Setenv(varName, tc.EnvVal) + require.Equal(t, tc.Expected, durationEnv(varName, tc.EnvUnit, 1337)) + }) + } +} diff --git a/appsec/embed.go b/appsec/embed.go index 2262840..125f298 100644 --- a/appsec/embed.go +++ b/appsec/embed.go @@ -5,16 +5,16 @@ package appsec -import _ "embed" // Blank import comment for golint compliance +import ( + _ "embed" // Blank import comment for golint compliance + "unsafe" +) -// StaticRecommendedRules holds the recommended AppSec security rules (v1.8.0) -// Source: https://github.com/DataDog/appsec-event-rules/blob/1.8.0/build/recommended.json -// -//go:embed rules.json -var StaticRecommendedRules string +var ( + //go:embed rules.json + staticRecommendedRules []byte -// StaticProcessors holds the default processors and scanners used for API Security -// Not part of the recommended security rules -// -//go:embed processors.json -var StaticProcessors string + // StaticRecommendedRules holds the recommended AppSec security rules (v1.15.1) + // Source: https://github.com/DataDog/appsec-event-rules/blob/1.15.1/build/recommended.json + StaticRecommendedRules = unsafe.String(&staticRecommendedRules[0], len(staticRecommendedRules)) +) diff --git a/appsec/processors.json b/appsec/processors.json deleted file mode 100644 index 968c53d..0000000 --- a/appsec/processors.json +++ /dev/null @@ -1,208 +0,0 @@ -{ - "processors": [ - { - "id": "processor-001", - "generator": "extract_schema", - "conditions": [ - { - "operator": "equals", - "parameters": { - "inputs": [ - { - "address": "waf.context.processor", - "key_path": [ - "extract-schema" - ] - } - ], - "type": "boolean", - "value": true - } - } - ], - "parameters": { - "mappings": [ - { - "inputs": [ - { - "address": "server.request.body" - } - ], - "output": "_dd.appsec.s.req.body" - }, - { - "inputs": [ - { - "address": "server.request.headers.no_cookies" - } - ], - "output": "_dd.appsec.s.req.headers" - }, - { - "inputs": [ - { - "address": "server.request.query" - } - ], - "output": "_dd.appsec.s.req.query" - }, - { - "inputs": [ - { - "address": "server.request.path_params" - } - ], - "output": "_dd.appsec.s.req.params" - }, - { - "inputs": [ - { - "address": "server.request.cookies" - } - ], - "output": "_dd.appsec.s.req.cookies" - }, - { - "inputs": [ - { - "address": "server.response.headers.no_cookies" - } - ], - "output": "_dd.appsec.s.res.headers" - }, - { - "inputs": [ - { - "address": "server.response.body" - } - ], - "output": "_dd.appsec.s.res.body" - } - ], - "scanners": [ - { - "tags": { - "category": "pii" - } - } - ] - }, - "evaluate": false, - "output": true - } - ], - "scanners": [ - { - "id": "d962f7ddb3f55041e39195a60ff79d4814a7c331", - "name": "US Passport Scanner", - "key": { - "operator": "match_regex", - "parameters": { - "regex": "passport", - "options": { - "case_sensitive": false, - "min_length": 8 - } - } - }, - "value": { - "operator": "match_regex", - "parameters": { - "regex": "\\b[0-9A-Z]{9}\\b|\\b[0-9]{6}[A-Z][0-9]{2}\\b", - "options": { - "case_sensitive": false, - "min_length": 8 - } - } - }, - "tags": { - "type": "passport_number", - "category": "pii" - } - }, - { - "id": "ac6d683cbac77f6e399a14990793dd8fd0fca333", - "name": "US Vehicle Identification Number Scanner", - "key": { - "operator": "match_regex", - "parameters": { - "regex": "vehicle[_\\s-]*identification[_\\s-]*number|vin", - "options": { - "case_sensitive": false, - "min_length": 3 - } - } - }, - "value": { - "operator": "match_regex", - "parameters": { - "regex": "\\b[A-HJ-NPR-Z0-9]{17}\\b", - "options": { - "case_sensitive": false, - "min_length": 17 - } - } - }, - "tags": { - "type": "vin", - "category": "pii" - } - }, - { - "id": "de0899e0cbaaa812bb624cf04c912071012f616d", - "name": "UK National Insurance Number Scanner", - "key": { - "operator": "match_regex", - "parameters": { - "regex": "national[\\s_]?(?:insurance(?:\\s+number)?)?|NIN|NI[\\s_]?number|insurance[\\s_]?number", - "options": { - "case_sensitive": false, - "min_length": 3 - } - } - }, - "value": { - "operator": "match_regex", - "parameters": { - "regex": "\\b[A-Z]{2}\\d{6}[A-Z]?\\b", - "options": { - "case_sensitive": false, - "min_length": 8 - } - } - }, - "tags": { - "type": "uk_nin", - "category": "pii" - } - }, - { - "id": "450239afc250a19799b6c03dc0e16fd6a4b2a1af", - "name": "Canadian Social Insurance Number Scanner", - "key": { - "operator": "match_regex", - "parameters": { - "regex": "social[\\s_]?(?:insurance(?:\\s+number)?)?|SIN|Canadian[\\s_]?(?:social[\\s_]?(?:insurance)?|insurance[\\s_]?number)?", - "options": { - "case_sensitive": false, - "min_length": 3 - } - } - }, - "value": { - "operator": "match_regex", - "parameters": { - "regex": "\\b\\d{3}-\\d{3}-\\d{3}\\b", - "options": { - "case_sensitive": false, - "min_length": 11 - } - } - }, - "tags": { - "type": "canadian_sin", - "category": "pii" - } - } - ] -} \ No newline at end of file diff --git a/appsec/rules.go b/appsec/rules.go index d2d672a..50bc023 100644 --- a/appsec/rules.go +++ b/appsec/rules.go @@ -2,32 +2,22 @@ // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2023-present Datadog, Inc. + package appsec import "encoding/json" // DefaultRuleset returns the marshaled default recommended security rules for AppSec func DefaultRuleset() ([]byte, error) { - rules, err := DefaultRulesetMap() - if err != nil { - return nil, err - } - return json.Marshal(rules) + return staticRecommendedRules, nil } // DefaultRulesetMap returns the unmarshaled default recommended security rules for AppSec func DefaultRulesetMap() (map[string]any, error) { var rules map[string]any - var processors map[string]any - if err := json.Unmarshal([]byte(StaticRecommendedRules), &rules); err != nil { + if err := json.Unmarshal(staticRecommendedRules, &rules); err != nil { return nil, err } - if err := json.Unmarshal([]byte(StaticProcessors), &processors); err != nil { - return nil, err - } - for k, v := range processors { - rules[k] = v - } return rules, nil } diff --git a/appsec/rules.json b/appsec/rules.json index 172558f..b39992a 100644 --- a/appsec/rules.json +++ b/appsec/rules.json @@ -1,7 +1,7 @@ { "version": "2.2", "metadata": { - "rules_version": "1.9.0" + "rules_version": "1.15.1" }, "rules": [ { @@ -9,7 +9,8 @@ "name": "Block IP Addresses", "tags": { "type": "block_ip", - "category": "security_response" + "category": "security_response", + "module": "network-acl" }, "conditions": [ { @@ -34,7 +35,8 @@ "name": "Block User Addresses", "tags": { "type": "block_user", - "category": "security_response" + "category": "security_response", + "module": "authentication-acl" }, "conditions": [ { @@ -64,7 +66,8 @@ "tool_name": "Acunetix", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -98,7 +101,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -118,6 +122,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "list": [ @@ -138,7 +145,10 @@ "appscan_fingerprint", "w00tw00t.at.isc.sans.dfind", "w00tw00t.at.blackhats.romanian.anti-sec" - ] + ], + "options": { + "enforce_word_boundary": true + } }, "operator": "phrase_match" } @@ -156,7 +166,8 @@ "category": "attack_attempt", "cwe": "176", "capec": "1000/255/153/267/71", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -185,7 +196,8 @@ "crs_id": "921110", "category": "attack_attempt", "cwe": "444", - "capec": "1000/210/272/220/33" + "capec": "1000/210/272/220/33", + "module": "waf" }, "conditions": [ { @@ -222,7 +234,8 @@ "crs_id": "921160", "category": "attack_attempt", "cwe": "113", - "capec": "1000/210/272/220/105" + "capec": "1000/210/272/220/105", + "module": "waf" }, "conditions": [ { @@ -257,7 +270,8 @@ "category": "attack_attempt", "cwe": "22", "capec": "1000/255/153/126", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -291,7 +305,8 @@ "category": "attack_attempt", "cwe": "22", "capec": "1000/255/153/126", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -346,6 +361,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "list": [ @@ -1772,7 +1790,10 @@ "windows\\win.ini", "default\\ntuser.dat", "/var/run/secrets/kubernetes.io/serviceaccount" - ] + ], + "options": { + "enforce_word_boundary": true + } }, "operator": "phrase_match" } @@ -1791,7 +1812,8 @@ "category": "attack_attempt", "cwe": "98", "capec": "1000/152/175/253/193", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -1819,7 +1841,8 @@ "crs_id": "931120", "category": "attack_attempt", "cwe": "98", - "capec": "1000/152/175/253/193" + "capec": "1000/152/175/253/193", + "module": "waf" }, "conditions": [ { @@ -1839,6 +1862,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "^(?i:file|ftps?)://.*?\\?+$", @@ -1861,7 +1887,8 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -1881,8 +1908,14 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], + "options": { + "enforce_word_boundary": true + }, "list": [ "${cdpath}", "${dirstack}", @@ -1900,7 +1933,6 @@ "$ifs", "$oldpwd", "$ostype", - "$path", "$pwd", "dev/fd/", "dev/null", @@ -2368,7 +2400,8 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2391,6 +2424,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "^\\(\\s*\\)\\s+{", @@ -2413,7 +2449,8 @@ "category": "attack_attempt", "cwe": "706", "capec": "1000/225/122/17/177", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2456,7 +2493,10 @@ "settings.local.php", "local.xml", ".env" - ] + ], + "options": { + "enforce_word_boundary": true + } }, "operator": "phrase_match" } @@ -2474,7 +2514,8 @@ "category": "attack_attempt", "cwe": "434", "capec": "1000/225/122/17/650", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2527,7 +2568,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2547,8 +2589,14 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], + "options": { + "enforce_word_boundary": true + }, "list": [ "$globals", "$_cookie", @@ -2588,7 +2636,8 @@ "crs_id": "933131", "category": "attack_attempt", "cwe": "94", - "capec": "1000/225/122/17/650" + "capec": "1000/225/122/17/650", + "module": "waf" }, "conditions": [ { @@ -2608,6 +2657,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:HTTP_(?:ACCEPT(?:_(?:ENCODING|LANGUAGE|CHARSET))?|(?:X_FORWARDED_FO|REFERE)R|(?:USER_AGEN|HOS)T|CONNECTION|KEEP_ALIVE)|PATH_(?:TRANSLATED|INFO)|ORIG_PATH_INFO|QUERY_STRING|REQUEST_URI|AUTH_TYPE)", @@ -2630,7 +2682,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2650,6 +2703,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "php://(?:std(?:in|out|err)|(?:in|out)put|fd|memory|temp|filter)", @@ -2671,7 +2727,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2691,6 +2748,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "list": [ @@ -2738,7 +2798,10 @@ "wp_safe_remote_post", "wp_safe_remote_request", "zlib_decode" - ] + ], + "options": { + "enforce_word_boundary": true + } }, "operator": "phrase_match" } @@ -2755,7 +2818,8 @@ "crs_id": "933160", "category": "attack_attempt", "cwe": "94", - "capec": "1000/225/122/17/650" + "capec": "1000/225/122/17/650", + "module": "waf" }, "conditions": [ { @@ -2775,9 +2839,12 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], - "regex": "\\b(?:s(?:e(?:t(?:_(?:e(?:xception|rror)_handler|magic_quotes_runtime|include_path)|defaultstub)|ssion_s(?:et_save_handler|tart))|qlite_(?:(?:(?:unbuffered|single|array)_)?query|create_(?:aggregate|function)|p?open|exec)|tr(?:eam_(?:context_create|socket_client)|ipc?slashes|rev)|implexml_load_(?:string|file)|ocket_c(?:onnect|reate)|h(?:ow_sourc|a1_fil)e|pl_autoload_register|ystem)|p(?:r(?:eg_(?:replace(?:_callback(?:_array)?)?|match(?:_all)?|split)|oc_(?:(?:terminat|clos|nic)e|get_status|open)|int_r)|o(?:six_(?:get(?:(?:e[gu]|g)id|login|pwnam)|mk(?:fifo|nod)|ttyname|kill)|pen)|hp(?:_(?:strip_whitespac|unam)e|version|info)|g_(?:(?:execut|prepar)e|connect|query)|a(?:rse_(?:ini_file|str)|ssthru)|utenv)|r(?:unkit_(?:function_(?:re(?:defin|nam)e|copy|add)|method_(?:re(?:defin|nam)e|copy|add)|constant_(?:redefine|add))|e(?:(?:gister_(?:shutdown|tick)|name)_function|ad(?:(?:gz)?file|_exif_data|dir))|awurl(?:de|en)code)|i(?:mage(?:createfrom(?:(?:jpe|pn)g|x[bp]m|wbmp|gif)|(?:jpe|pn)g|g(?:d2?|if)|2?wbmp|xbm)|s_(?:(?:(?:execut|write?|read)ab|fi)le|dir)|ni_(?:get(?:_all)?|set)|terator_apply|ptcembed)|g(?:et(?:_(?:c(?:urrent_use|fg_va)r|meta_tags)|my(?:[gpu]id|inode)|(?:lastmo|cw)d|imagesize|env)|z(?:(?:(?:defla|wri)t|encod|fil)e|compress|open|read)|lob)|a(?:rray_(?:u(?:intersect(?:_u?assoc)?|diff(?:_u?assoc)?)|intersect_u(?:assoc|key)|diff_u(?:assoc|key)|filter|reduce|map)|ssert(?:_options)?|tob)|h(?:tml(?:specialchars(?:_decode)?|_entity_decode|entities)|(?:ash(?:_(?:update|hmac))?|ighlight)_file|e(?:ader_register_callback|x2bin))|f(?:i(?:le(?:(?:[acm]tim|inod)e|(?:_exist|perm)s|group)?|nfo_open)|tp_(?:nb_(?:ge|pu)|connec|ge|pu)t|(?:unction_exis|pu)ts|write|open)|o(?:b_(?:get_(?:c(?:ontents|lean)|flush)|end_(?:clean|flush)|clean|flush|start)|dbc_(?:result(?:_all)?|exec(?:ute)?|connect)|pendir)|m(?:b_(?:ereg(?:_(?:replace(?:_callback)?|match)|i(?:_replace)?)?|parse_str)|(?:ove_uploaded|d5)_file|ethod_exists|ysql_query|kdir)|e(?:x(?:if_(?:t(?:humbnail|agname)|imagetype|read_data)|ec)|scapeshell(?:arg|cmd)|rror_reporting|val)|c(?:url_(?:file_create|exec|init)|onvert_uuencode|reate_function|hr)|u(?:n(?:serialize|pack)|rl(?:de|en)code|[ak]?sort)|b(?:(?:son_(?:de|en)|ase64_en)code|zopen|toa)|(?:json_(?:de|en)cod|debug_backtrac|tmpfil)e|var_dump)(?:\\s|/\\*.*\\*/|//.*|#.*|\\\"|')*\\((?:(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:\\$\\w+|[A-Z\\d]\\w*|\\w+\\(.*\\)|\\\\?\"(?:[^\"]|\\\\\"|\"\"|\"\\+\")*\\\\?\"|\\\\?'(?:[^']|''|'\\+')*\\\\?')(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:(?:::|\\.|->)(?:\\s|/\\*.*\\*/|//.*|#.*)*\\w+(?:\\(.*\\))?)?,)*(?:(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:\\$\\w+|[A-Z\\d]\\w*|\\w+\\(.*\\)|\\\\?\"(?:[^\"]|\\\\\"|\"\"|\"\\+\")*\\\\?\"|\\\\?'(?:[^']|''|'\\+')*\\\\?')(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:(?:::|\\.|->)(?:\\s|/\\*.*\\*/|//.*|#.*)*\\w+(?:\\(.*\\))?)?)?\\)", + "regex": "\\b(?:s(?:e(?:t(?:_(?:e(?:xception|rror)_handler|magic_quotes_runtime|include_path)|defaultstub)|ssion_s(?:et_save_handler|tart))|qlite_(?:(?:(?:unbuffered|single|array)_)?query|create_(?:aggregate|function)|p?open|exec)|tr(?:eam_(?:context_create|socket_client)|ipc?slashes|rev)|implexml_load_(?:string|file)|ocket_c(?:onnect|reate)|h(?:ow_sourc|a1_fil)e|pl_autoload_register|ystem)|p(?:r(?:eg_(?:replace(?:_callback(?:_array)?)?|match(?:_all)?|split)|oc_(?:(?:terminat|clos|nic)e|get_status|open)|int_r)|o(?:six_(?:get(?:(?:e[gu]|g)id|login|pwnam)|mk(?:fifo|nod)|ttyname|kill)|pen)|hp(?:_(?:strip_whitespac|unam)e|version|info)|g_(?:(?:execut|prepar)e|connect|query)|a(?:rse_(?:ini_file|str)|ssthru)|utenv)|r(?:unkit_(?:function_(?:re(?:defin|nam)e|copy|add)|method_(?:re(?:defin|nam)e|copy|add)|constant_(?:redefine|add))|e(?:(?:gister_(?:shutdown|tick)|name)_function|ad(?:(?:gz)?file|_exif_data|dir))|awurl(?:de|en)code)|i(?:mage(?:createfrom(?:(?:jpe|pn)g|x[bp]m|wbmp|gif)|(?:jpe|pn)g|g(?:d2?|if)|2?wbmp|xbm)|s_(?:(?:(?:execut|write?|read)ab|fi)le|dir)|ni_(?:get(?:_all)?|set)|terator_apply|ptcembed)|g(?:et(?:_(?:c(?:urrent_use|fg_va)r|meta_tags)|my(?:[gpu]id|inode)|(?:lastmo|cw)d|imagesize|env)|z(?:(?:(?:defla|wri)t|encod|fil)e|compress|open|read)|lob)|a(?:rray_(?:u(?:intersect(?:_u?assoc)?|diff(?:_u?assoc)?)|intersect_u(?:assoc|key)|diff_u(?:assoc|key)|filter|reduce|map)|ssert(?:_options)?|tob)|h(?:tml(?:specialchars(?:_decode)?|_entity_decode|entities)|(?:ash(?:_(?:update|hmac))?|ighlight)_file|e(?:ader_register_callback|x2bin))|f(?:i(?:le(?:(?:[acm]tim|inod)e|(?:_exist|perm)s|group)?|nfo_open)|tp_(?:nb_(?:ge|pu)|connec|ge|pu)t|(?:unction_exis|pu)ts|write|open)|o(?:b_(?:get_(?:c(?:ontents|lean)|flush)|end_(?:clean|flush)|clean|flush|start)|dbc_(?:result(?:_all)?|exec(?:ute)?|connect)|pendir)|m(?:b_(?:ereg(?:_(?:replace(?:_callback)?|match)|i(?:_replace)?)?|parse_str)|(?:ove_uploaded|d5)_file|ethod_exists|ysql_query|kdir)|e(?:x(?:if_(?:t(?:humbnail|agname)|imagetype|read_data)|ec)|scapeshell(?:arg|cmd)|rror_reporting|val)|c(?:url_(?:file_create|exec|init)|onvert_uuencode|reate_function|hr)|u(?:n(?:serialize|pack)|rl(?:de|en)code|[ak]?sort)|b(?:(?:son_(?:de|en)|ase64_en)code|zopen|toa)|(?:json_(?:de|en)cod|debug_backtrac|tmpfil)e|var_dump)(?:\\s|/\\*.*\\*/|//.*|#.*|\\\"|')*\\((?:(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:\\$\\w+|[A-Z\\d]\\w*|\\w+\\(.*\\)|\\\\?\"(?:[^\"]|\\\\\"|\"\"|\"\\+\")*\\\\?\"|\\\\?'(?:[^']|''|'\\+')*\\\\?')(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:(?:::|\\.|->)(?:\\s|/\\*.*\\*/|//.*|#.*)*\\w+(?:\\(.*\\))?)?,)*(?:(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:\\$\\w+|[A-Z\\d]\\w*|\\w+\\(.*\\)|\\\\?\"(?:[^\"]|\\\\\"|\"\"|\"\\+\")*\\\\?\"|\\\\?'(?:[^']|''|'\\+')*\\\\?')(?:\\s|/\\*.*\\*/|//.*|#.*)*(?:(?:::|\\.|->)(?:\\s|/\\*.*\\*/|//.*|#.*)*\\w+(?:\\(.*\\))?)?)?\\)\\s*(?:[;\\.)}\\]|\\\\]|\\?>|%>|$)", "options": { "case_sensitive": true, "min_length": 5 @@ -2797,7 +2864,8 @@ "category": "attack_attempt", "cwe": "502", "capec": "1000/152/586", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2820,6 +2888,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "[oOcC]:\\d+:\\\".+?\\\":\\d+:{[\\W\\w]*}", @@ -2841,7 +2912,8 @@ "crs_id": "933200", "category": "attack_attempt", "cwe": "502", - "capec": "1000/152/586" + "capec": "1000/152/586", + "module": "waf" }, "conditions": [ { @@ -2861,6 +2933,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:(?:bzip|ssh)2|z(?:lib|ip)|(?:ph|r)ar|expect|glob|ogg)://", @@ -2884,7 +2959,8 @@ "crs_id": "934100", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -2904,9 +2980,12 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], - "regex": "\\b(?:(?:l(?:(?:utimes|chmod)(?:Sync)?|(?:stat|ink)Sync)|w(?:rite(?:(?:File|v)(?:Sync)?|Sync)|atchFile)|u(?:n(?:watchFile|linkSync)|times(?:Sync)?)|s(?:(?:ymlink|tat)Sync|pawn(?:File|Sync))|ex(?:ec(?:File(?:Sync)?|Sync)|istsSync)|a(?:ppendFile|ccess)(?:Sync)?|(?:Caveat|Inode)s|open(?:dir)?Sync|new\\s+Function|Availability|\\beval)\\s*\\(|m(?:ain(?:Module\\s*(?:\\W*\\s*(?:constructor|require)|\\[)|\\s*(?:\\W*\\s*(?:constructor|require)|\\[))|kd(?:temp(?:Sync)?|irSync)\\s*\\(|odule\\.exports\\s*=)|c(?:(?:(?:h(?:mod|own)|lose)Sync|reate(?:Write|Read)Stream|p(?:Sync)?)\\s*\\(|o(?:nstructor\\s*(?:\\W*\\s*_load|\\[)|pyFile(?:Sync)?\\s*\\())|f(?:(?:(?:s(?:(?:yncS)?|tatS)|datas(?:yncS)?)ync|ch(?:mod|own)(?:Sync)?)\\s*\\(|u(?:nction\\s*\\(\\s*\\)\\s*{|times(?:Sync)?\\s*\\())|r(?:e(?:(?:ad(?:(?:File|link|dir)?Sync|v(?:Sync)?)|nameSync)\\s*\\(|quire\\s*(?:\\W*\\s*main|\\[))|m(?:Sync)?\\s*\\()|process\\s*(?:\\W*\\s*(?:mainModule|binding)|\\[)|t(?:his\\.constructor|runcateSync\\s*\\()|_(?:\\$\\$ND_FUNC\\$\\$_|_js_function)|global\\s*(?:\\W*\\s*process|\\[)|String\\s*\\.\\s*fromCharCode|binding\\s*\\[)", + "regex": "\\b(?:(?:l(?:(?:utimes|chmod)(?:Sync)?|(?:stat|ink)Sync)|w(?:rite(?:(?:File|v)(?:Sync)?|Sync)|atchFile)|u(?:n(?:watchFile|linkSync)|times(?:Sync)?)|s(?:(?:ymlink|tat)Sync|pawn(?:File|Sync))|ex(?:ec(?:File(?:Sync)?|Sync)|istsSync)|a(?:ppendFile|ccess)(?:Sync)?|(?:Caveat|Inode)s|open(?:dir)?Sync|new\\s+Function|Availability|\\beval)\\s*\\(|m(?:ain(?:Module\\s*(?:\\W*\\s*(?:constructor|require)|\\[)|\\s*(?:\\W*\\s*(?:constructor|require)|\\[))|kd(?:temp(?:Sync)?|irSync)\\s*\\(|odule\\.exports\\s*=)|c(?:(?:(?:h(?:mod|own)|lose)Sync|reate(?:Write|Read)Stream|p(?:Sync)?)\\s*\\(|o(?:nstructor\\s*(?:\\W*\\s*_load|\\[)|pyFile(?:Sync)?\\s*\\())|f(?:(?:(?:s(?:(?:yncS)?|tatS)|datas(?:yncS)?)ync|ch(?:mod|own)(?:Sync)?)\\s*\\(|u(?:nction\\s*\\(\\s*\\)\\s*{|times(?:Sync)?\\s*\\())|r(?:e(?:(?:ad(?:(?:File|link|dir)?Sync|v(?:Sync)?)|nameSync)\\s*\\(|quire\\s*(?:\\W*\\s*main\\b|\\[))|m(?:Sync)?\\s*\\()|process\\s*(?:\\W*\\s*(?:mainModule|binding)|\\[)|t(?:his\\.constructor|runcateSync\\s*\\()|_(?:\\$\\$ND_FUNC\\$\\$_|_js_function)|global\\s*(?:\\W*\\s*process|\\[)|String\\s*\\.\\s*fromCharCode|binding\\s*\\[)", "options": { "case_sensitive": true, "min_length": 3 @@ -2926,7 +3005,8 @@ "category": "attack_attempt", "confidence": "1", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -2942,10 +3022,10 @@ "address": "server.request.path_params" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" } ], "regex": "\\b(?:w(?:atch|rite)|(?:spaw|ope)n|exists|close|fork|read)\\s*\\(", @@ -2968,7 +3048,8 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -2996,10 +3077,10 @@ "address": "server.request.path_params" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" } ], "regex": "]*>[\\s\\S]*?", @@ -3025,7 +3106,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3057,6 +3139,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bon(?:d(?:r(?:ag(?:en(?:ter|d)|leave|start|over)?|op)|urationchange|blclick)|s(?:e(?:ek(?:ing|ed)|arch|lect)|u(?:spend|bmit)|talled|croll|how)|m(?:ouse(?:(?:lea|mo)ve|o(?:ver|ut)|enter|down|up)|essage)|p(?:a(?:ge(?:hide|show)|(?:st|us)e)|lay(?:ing)?|rogress|aste|ointer(?:cancel|down|enter|leave|move|out|over|rawupdate|up))|c(?:anplay(?:through)?|o(?:ntextmenu|py)|hange|lick|ut)|a(?:nimation(?:iteration|start|end)|(?:fterprin|bor)t|uxclick|fterscriptexecute)|t(?:o(?:uch(?:cancel|start|move|end)|ggle)|imeupdate)|f(?:ullscreen(?:change|error)|ocus(?:out|in)?|inish)|(?:(?:volume|hash)chang|o(?:ff|n)lin)e|b(?:efore(?:unload|print)|lur)|load(?:ed(?:meta)?data|start|end)?|r(?:es(?:ize|et)|atechange)|key(?:press|down|up)|w(?:aiting|heel)|in(?:valid|put)|e(?:nded|rror)|unload)[\\s\\x0B\\x09\\x0C\\x3B\\x2C\\x28\\x3B]*?=[^=]", @@ -3081,7 +3166,8 @@ "category": "attack_attempt", "cwe": "84", "capec": "1000/152/242/63/591/244", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3113,6 +3199,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "[a-z]+=(?:[^:=]+:.+;)*?[^:=]+:url\\(javascript", @@ -3137,7 +3226,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3169,6 +3259,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:\\W|^)(?:javascript:(?:[\\s\\S]+[=\\x5c\\(\\[\\.<]|[\\s\\S]*?(?:\\bname\\b|\\x5c[ux]\\d)))|@\\W*?i\\W*?m\\W*?p\\W*?o\\W*?r\\W*?t\\W*?(?:/\\*[\\s\\S]*?)?(?:[\\\"']|\\W*?u\\W*?r\\W*?l[\\s\\S]*?\\()|[^-]*?-\\W*?m\\W*?o\\W*?z\\W*?-\\W*?b\\W*?i\\W*?n\\W*?d\\W*?i\\W*?n\\W*?g[^:]*?:\\W*?u\\W*?r\\W*?l[\\s\\S]*?\\(", @@ -3192,7 +3285,8 @@ "crs_id": "941180", "category": "attack_attempt", "cwe": "79", - "capec": "1000/152/242/63/591" + "capec": "1000/152/242/63/591", + "module": "waf" }, "conditions": [ { @@ -3212,8 +3306,14 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], + "options": { + "enforce_word_boundary": true + }, "list": [ "document.cookie", "document.write", @@ -3240,7 +3340,8 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3260,6 +3361,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:<.*[:]?vmlframe.*?[\\s/+]*?src[\\s/+]*=)", @@ -3284,7 +3388,8 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3304,6 +3409,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:(?:j|&#x?0*(?:74|4A|106|6A);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:a|&#x?0*(?:65|41|97|61);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:v|&#x?0*(?:86|56|118|76);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:a|&#x?0*(?:65|41|97|61);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:s|&#x?0*(?:83|53|115|73);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:c|&#x?0*(?:67|43|99|63);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:r|&#x?0*(?:82|52|114|72);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:i|&#x?0*(?:73|49|105|69);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:p|&#x?0*(?:80|50|112|70);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:t|&#x?0*(?:84|54|116|74);?)(?:\\t|\\n|\\r|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?::|&(?:#x?0*(?:58|3A);?|colon;)).)", @@ -3328,7 +3436,8 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3348,6 +3457,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:(?:v|&#x?0*(?:86|56|118|76);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:b|&#x?0*(?:66|42|98|62);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:s|&#x?0*(?:83|53|115|73);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:c|&#x?0*(?:67|43|99|63);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:r|&#x?0*(?:82|52|114|72);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:i|&#x?0*(?:73|49|105|69);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:p|&#x?0*(?:80|50|112|70);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:t|&#x?0*(?:84|54|116|74);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?::|&(?:#x?0*(?:58|3A);?|colon;)).)", @@ -3372,7 +3484,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3392,6 +3505,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "]", @@ -3588,7 +3717,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3608,6 +3738,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": ")|<.*\\+AD4-", @@ -3672,7 +3809,8 @@ "crs_id": "941360", "category": "attack_attempt", "cwe": "87", - "capec": "1000/152/242/63/591/199" + "capec": "1000/152/242/63/591/199", + "module": "waf" }, "conditions": [ { @@ -3692,6 +3830,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "![!+ ]\\[\\]", @@ -3714,7 +3855,8 @@ "category": "attack_attempt", "confidence": "1", "cwe": "79", - "capec": "1000/152/242/63/591" + "capec": "1000/152/242/63/591", + "module": "waf" }, "conditions": [ { @@ -3734,6 +3876,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?i:eval|settimeout|setinterval|new\\s+Function|alert|prompt)[\\s+]*\\([^\\)]", @@ -3755,7 +3900,8 @@ "crs_id": "942100", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66" + "capec": "1000/152/248/66", + "module": "waf" }, "conditions": [ { @@ -3771,10 +3917,10 @@ "address": "server.request.path_params" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" } ] }, @@ -3794,7 +3940,8 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3814,6 +3961,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:sleep\\(\\s*?\\d*?\\s*?\\)|benchmark\\(.*?\\,.*?\\))", @@ -3836,7 +3986,8 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3856,6 +4007,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:[\\\"'`](?:;*?\\s*?waitfor\\s+(?:delay|time)\\s+[\\\"'`]|;.*?:\\s*?goto)|alter\\s*?\\w+.*?cha(?:racte)?r\\s+set\\s+\\w+)", @@ -3876,7 +4030,8 @@ "crs_id": "942250", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66" + "capec": "1000/152/248/66", + "module": "waf" }, "conditions": [ { @@ -3896,6 +4051,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:merge.*?using\\s*?\\(|execute\\s*?immediate\\s*?[\\\"'`]|match\\s*?[\\w(?:),+-]+\\s*?against\\s*?\\()", @@ -3917,7 +4075,8 @@ "crs_id": "942270", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66" + "capec": "1000/152/248/66", + "module": "waf" }, "conditions": [ { @@ -3937,6 +4096,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "union.*?select.*?from", @@ -3958,7 +4120,8 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -3978,6 +4141,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:;\\s*?shutdown\\s*?(?:[#;{]|\\/\\*|--)|waitfor\\s*?delay\\s?[\\\"'`]+\\s?\\d|select\\s*?pg_sleep)", @@ -3998,7 +4164,8 @@ "crs_id": "942290", "category": "attack_attempt", "cwe": "943", - "capec": "1000/152/248/676" + "capec": "1000/152/248/676", + "module": "waf" }, "conditions": [ { @@ -4018,6 +4185,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:(?:\\[?\\$(?:(?:s(?:lic|iz)|wher)e|e(?:lemMatch|xists|q)|n(?:o[rt]|in?|e)|l(?:ike|te?)|t(?:ext|ype)|a(?:ll|nd)|jsonSchema|between|regex|x?or|div|mod)\\]?)\\b)", @@ -4041,7 +4211,8 @@ "crs_id": "942360", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66/470" + "capec": "1000/152/248/66/470", + "module": "waf" }, "conditions": [ { @@ -4061,6 +4232,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:^[\\W\\d]+\\s*?(?:alter\\s*(?:a(?:(?:pplication\\s*rol|ggregat)e|s(?:ymmetric\\s*ke|sembl)y|u(?:thorization|dit)|vailability\\s*group)|c(?:r(?:yptographic\\s*provider|edential)|o(?:l(?:latio|um)|nversio)n|ertificate|luster)|s(?:e(?:rv(?:ice|er)|curity|quence|ssion|arch)|y(?:mmetric\\s*key|nonym)|togroup|chema)|m(?:a(?:s(?:ter\\s*key|k)|terialized)|e(?:ssage\\s*type|thod)|odule)|l(?:o(?:g(?:file\\s*group|in)|ckdown)|a(?:ngua|r)ge|ibrary)|t(?:(?:abl(?:espac)?|yp)e|r(?:igger|usted)|hreshold|ext)|p(?:a(?:rtition|ckage)|ro(?:cedur|fil)e|ermission)|d(?:i(?:mension|skgroup)|atabase|efault|omain)|r(?:o(?:l(?:lback|e)|ute)|e(?:sourc|mot)e)|f(?:u(?:lltext|nction)|lashback|oreign)|e(?:xte(?:nsion|rnal)|(?:ndpoi|ve)nt)|in(?:dex(?:type)?|memory|stance)|b(?:roker\\s*priority|ufferpool)|x(?:ml\\s*schema|srobject)|w(?:ork(?:load)?|rapper)|hi(?:erarchy|stogram)|o(?:perator|utline)|(?:nicknam|queu)e|us(?:age|er)|group|java|view)|union\\s*(?:(?:distin|sele)ct|all))\\b|\\b(?:(?:(?:trunc|cre|upd)at|renam)e|(?:inser|selec)t|de(?:lete|sc)|alter|load)\\s+(?:group_concat|load_file|char)\\b\\s*\\(?|[\\s(]load_file\\s*?\\(|[\\\"'`]\\s+regexp\\W)", @@ -4081,7 +4255,8 @@ "crs_id": "942500", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66" + "capec": "1000/152/248/66", + "module": "waf" }, "conditions": [ { @@ -4101,6 +4276,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:/\\*[!+](?:[\\w\\s=_\\-(?:)]+)?\\*/)", @@ -4123,7 +4301,8 @@ "category": "attack_attempt", "cwe": "384", "capec": "1000/225/21/593/61", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4143,6 +4322,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i:\\.cookie\\b.*?;\\W*?(?:expires|domain)\\W*?=|\\bhttp-equiv\\W+set-cookie\\b)", @@ -4165,7 +4347,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4188,6 +4371,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "java\\.lang\\.(?:runtime|processbuilder)", @@ -4210,7 +4396,8 @@ "type": "java_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -4233,6 +4420,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:unmarshaller|base64data|java\\.).*(?:runtime|processbuilder)", @@ -4254,7 +4444,8 @@ "crs_id": "944130", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -4277,6 +4468,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "list": [ @@ -4312,6 +4506,7 @@ "java.lang.object", "java.lang.process", "java.lang.reflect", + "java.lang.runtime", "java.lang.string", "java.lang.stringbuilder", "java.lang.system", @@ -4321,7 +4516,10 @@ "org.apache.struts2", "org.omg.corba", "java.beans.xmldecode" - ] + ], + "options": { + "enforce_word_boundary": true + } }, "operator": "phrase_match" } @@ -4362,6 +4560,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:class\\.module\\.classLoader\\.resources\\.context\\.parent\\.pipeline|springframework\\.context\\.support\\.FileSystemXmlApplicationContext)", @@ -4382,7 +4583,8 @@ "type": "nosql_injection", "category": "attack_attempt", "cwe": "943", - "capec": "1000/152/248/676" + "capec": "1000/152/248/676", + "module": "waf" }, "conditions": [ { @@ -4403,6 +4605,9 @@ { "address": "graphql.server.all_resolvers" }, + { + "address": "graphql.server.resolver" + }, { "address": "server.request.headers.no_cookies" } @@ -4423,7 +4628,8 @@ "type": "java_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -4443,10 +4649,10 @@ "address": "server.request.path_params" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" }, { "address": "server.request.headers.no_cookies" @@ -4469,7 +4675,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4493,6 +4700,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "[@#]ognl", @@ -4542,7 +4752,8 @@ "category": "attack_attempt", "cwe": "1321", "capec": "1000/152/242", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4572,7 +4783,8 @@ "category": "attack_attempt", "cwe": "1321", "capec": "1000/152/242", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4616,7 +4828,8 @@ "category": "attack_attempt", "cwe": "1336", "capec": "1000/152/242/19", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4639,6 +4852,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "#(?:set|foreach|macro|parse|if)\\(.*\\)|<#assign.*>" @@ -4648,6 +4864,36 @@ ], "transformers": [] }, + { + "id": "ua0-600-68x", + "name": "xorbot", + "tags": { + "type": "attack_tool", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "xorbot", + "confidence": "0", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + ], + "regex": "\\bmasjesu\\b" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, { "id": "dog-913-001", "name": "BurpCollaborator OOB domain", @@ -4657,7 +4903,8 @@ "tool_name": "BurpCollaborator", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4680,6 +4927,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?:burpcollaborator\\.net|oastify\\.com)\\b" @@ -4698,7 +4948,8 @@ "tool_name": "Qualys", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -4721,6 +4972,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bqualysperiscope\\.com\\b|\\.oscomm\\." @@ -4739,7 +4993,8 @@ "tool_name": "Probely", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -4762,6 +5017,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bprbly\\.win\\b" @@ -4779,7 +5037,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4802,6 +5061,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?:webhook\\.site|\\.canarytokens\\.com|vii\\.one|act1on3\\.ru|gdsburp\\.com|arcticwolf\\.net|oob\\.li|htbiw\\.com|h4\\.vc|mochan\\.cloud|imshopping\\.com|bootstrapnodejs\\.com|mooo-ng\\.com|securitytrails\\.com|canyouhackit\\.io|7bae\\.xyz)\\b" @@ -4819,7 +5081,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -4842,6 +5105,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?:\\.ngrok\\.io|requestbin\\.com|requestbin\\.net)\\b" @@ -4860,7 +5126,8 @@ "tool_name": "Rapid7", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -4883,6 +5150,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bappspidered\\.rapid7\\." @@ -4901,7 +5171,8 @@ "tool_name": "interact.sh", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -4924,6 +5195,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?:interact\\.sh|oast\\.(?:pro|live|site|online|fun|me)|indusfacefinder\\.in|where\\.land|syhunt\\.net|tssrt\\.de|boardofcyber\\.io|assetnote-callback\\.com|praetorianlabs\\.dev|netspi\\.sh)\\b" @@ -4942,7 +5216,8 @@ "tool_name": "Netsparker", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -4965,6 +5240,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b(?:\\.|(?:\\\\|&#)(?:0*46|x0*2e);)?r87(?:\\.|(?:\\\\|&#)(?:0*46|x0*2e);)(?:me|com)\\b", @@ -4987,7 +5265,8 @@ "tool_name": "WhiteHatSecurity", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -5010,6 +5289,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bwhsec(?:\\.|(?:\\\\|&#)(?:0*46|x0*2e);)us\\b", @@ -5032,7 +5314,8 @@ "tool_name": "Nessus", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -5055,6 +5338,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\b\\.nessus\\.org\\b", @@ -5077,7 +5363,8 @@ "tool_name": "Watchtowr", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -5100,6 +5387,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bwatchtowr\\.com\\b", @@ -5122,7 +5412,8 @@ "tool_name": "AppCheckNG", "cwe": "200", "capec": "1000/118/169", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -5145,6 +5436,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "\\bptst\\.io\\b", @@ -5158,6 +5452,118 @@ ], "transformers": [] }, + { + "id": "dog-913-013", + "name": "Public PoC for CVE-2025-24813", + "tags": { + "type": "attack_tool", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "confidence": "1", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "/iSee857/session", + "options": { + "case_sensitive": false, + "min_length": 16 + } + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, + { + "id": "dog-913-014", + "name": "Exploit attempt for Next.js Middleware Exploit (CVE-2025-29927)", + "tags": { + "type": "security_scanner", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "confidence": "0", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "x-middleware-subrequest" + ] + } + ], + "regex": ".*", + "options": { + "min_length": 1 + } + }, + "operator": "match_regex" + }, + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "x-middleware-subrequest" + ] + } + ], + "regex": "[0-9a-fA-F]{40}|\\[\\w+\\]" + }, + "operator": "!match_regex" + } + ], + "transformers": [] + }, + { + "id": "dog-920-001", + "name": "JWT authentication bypass", + "tags": { + "type": "http_protocol_violation", + "category": "attack_attempt", + "cwe": "287", + "capec": "1000/225/115", + "confidence": "0", + "module": "waf" + }, + "max_version": "1.24.9", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.cookies" + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "authorization" + ] + } + ], + "regex": "^(?:Bearer )?ey[A-Za-z0-9+_\\-/]*([QY][UW]x[Hn]Ij([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[\\x2b\\x2f-9A-Za-z]ICJ[Ou][Tb][02]5[Fl]|[QY][UW]x[Hn]I([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[048AEIMQUYcgkosw]gOiAi[Tb][km]9[Ou][RZ][Q-Za-f]|[QY][UW]x[Hn]Ij([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[048AEIMQUYcgkosw]gI[km]5[Pv][Tb][km][U-X]|[\\x2b\\x2f-9A-Za-z]{2}[159BFJNRVZdhlptx][Bh][Tb][EG]ci([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[048AEIMQUYcgkosw]gO([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[CSiy]Ai[Tb][km]9[Ou][RZ][Q-Za-f]|[QY][UW]x[Hn]I([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[048AEIMQUYcgkosw]gO([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*ICJ[Ou][Tb][02]5[Fl]|[\\x2b\\x2f-9A-Za-z][02EGUWkm]F[Ms][RZ]y([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*[CSiy]A6([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z]I)*ICJ[Ou][Tb][02]5[Fl]|[QY][UW]x[Hn]I([048ACEIMQSUYcgikoswy]|[\\x2b\\x2f-9A-Za-z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+ } + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, { "id": "dog-931-001", "name": "RFI: URL Payload to well known RFI target", @@ -5166,7 +5572,8 @@ "category": "attack_attempt", "cwe": "98", "capec": "1000/152/175/253/193", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5186,6 +5593,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "^(?i:file|ftps?|https?).*/rfiinc\\.txt\\?+$", @@ -5207,7 +5617,8 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -5230,6 +5641,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:(?:['\"\\x60({|;&]|(?:^|['\"\\x60({|;&])(?:cmd(?:\\.exe)?\\s+(?:/\\w(?::\\w+)?\\s+)*))(?:ping|curl|wget|telnet)|\\bnslookup)[\\s,]", @@ -5243,6 +5657,52 @@ ], "transformers": [] }, + { + "id": "dog-932-110", + "name": "Python: Subprocess-based command injection", + "tags": { + "type": "command_injection", + "category": "attack_attempt", + "confidence": "0", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ], + "regex": "(?s)\\bsubprocess\\b.*\\b(?:check_output|run|Popen|call|check_call)\\b", + "options": { + "case_sensitive": true, + "min_length": 14 + } + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, { "id": "dog-934-001", "name": "XXE - XML file loads external entity", @@ -5251,7 +5711,8 @@ "category": "attack_attempt", "cwe": "91", "capec": "1000/152/248/250", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5265,6 +5726,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?:<\\?xml[^>]*>.*)]+SYSTEM\\s+[^>]+>", @@ -5286,7 +5750,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5318,6 +5783,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "<(?:iframe|esi:include)(?:(?:\\s|/)*\\w+=[\"'\\w]+)*(?:\\s|/)*src(?:doc)?=[\"']?(?:data:|javascript:|http:|dns:|//)[^\\s'\"]+['\"]?", @@ -5341,7 +5809,8 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5364,6 +5833,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "https?:\\/\\/(?:.*\\.)?(?:bxss\\.(?:in|me)|xss\\.ht|js\\.rip)", @@ -5404,6 +5876,9 @@ { "operator": "phrase_match", "parameters": { + "options": { + "enforce_word_boundary": true + }, "inputs": [ { "address": "server.request.uri.raw" @@ -5604,7 +6079,8 @@ "/website.php", "/stats.php", "/assets/plugins/mp3_id/mp3_id.php", - "/siteminderagent/forms/smpwservices.fcc" + "/siteminderagent/forms/smpwservices.fcc", + "/eval-stdin.php" ] } } @@ -5621,7 +6097,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5663,7 +6140,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5705,7 +6183,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5747,7 +6226,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5789,7 +6269,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5814,7 +6295,7 @@ "address": "server.request.uri.raw" } ], - "regex": "\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)", + "regex": "\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([?#&/]|$)", "options": { "case_sensitive": false } @@ -5831,7 +6312,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5873,7 +6355,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5915,7 +6398,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5949,6 +6433,308 @@ ], "transformers": [] }, + { + "id": "nfd-000-010", + "name": "Detect failed attempts to find API documentation", + "tags": { + "type": "security_scanner", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "confidence": "0", + "module": "waf" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "(?:^|/)(?:swagger|api[-/]?docs?|openapi)\\b", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "rasp-930-100", + "name": "Local file inclusion exploit", + "tags": { + "type": "lfi", + "category": "vulnerability_trigger", + "cwe": "22", + "capec": "1000/255/153/126", + "confidence": "1", + "module": "rasp" + }, + "conditions": [ + { + "parameters": { + "resource": [ + { + "address": "server.io.fs.file" + } + ], + "params": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ] + }, + "operator": "lfi_detector@v2" + } + ], + "transformers": [], + "on_match": [ + "stack_trace" + ] + }, + { + "id": "rasp-932-100", + "name": "Shell command injection exploit", + "tags": { + "type": "command_injection", + "category": "vulnerability_trigger", + "cwe": "77", + "capec": "1000/152/248/88", + "confidence": "1", + "module": "rasp" + }, + "conditions": [ + { + "parameters": { + "resource": [ + { + "address": "server.sys.shell.cmd" + } + ], + "params": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ] + }, + "operator": "shi_detector" + } + ], + "transformers": [], + "on_match": [ + "stack_trace" + ] + }, + { + "id": "rasp-932-110", + "name": "OS command injection exploit", + "tags": { + "type": "command_injection", + "category": "vulnerability_trigger", + "cwe": "77", + "capec": "1000/152/248/88", + "confidence": "1", + "module": "rasp" + }, + "conditions": [ + { + "parameters": { + "resource": [ + { + "address": "server.sys.exec.cmd" + } + ], + "params": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ] + }, + "operator": "cmdi_detector" + } + ], + "transformers": [], + "on_match": [ + "stack_trace" + ] + }, + { + "id": "rasp-934-100", + "name": "Server-side request forgery exploit", + "tags": { + "type": "ssrf", + "category": "vulnerability_trigger", + "cwe": "918", + "capec": "1000/225/115/664", + "confidence": "0", + "module": "rasp" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.io.net.url" + } + ], + "regex": "^(jar:)?https?:\\/\\/\\W*([0-9oq]{1,5}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|[0-9]{1,10}|(\\[)?[:0-9a-f\\.x]{2,}(\\])?|metadata\\.google\\.internal|(?:[a-z0-9:@\\.\\-]*\\.)?(?:burpcollaborator\\.net|localtest\\.me|mail\\.ebc\\.apple\\.com|bugbounty\\.dod\\.network|.*\\.[nx]ip\\.io|oastify\\.com|oast\\.(?:pro|live|site|online|fun|me)|sslip\\.io|requestbin\\.com|requestbin\\.net|hookbin\\.com|webhook\\.site|canarytokens\\.com|interact\\.sh|ngrok\\.io|bugbounty\\.click|prbly\\.win|qualysperiscope\\.com|vii\\.one|act1on3\\.ru|ifconfig\\.pro|dnslog\\.\\w+))(:[0-9]{1,5})?(\\/[^:@]*)?$", + "options": { + "case_sensitive": false + } + }, + "operator": "match_regex" + }, + { + "parameters": { + "resource": [ + { + "address": "server.io.net.url" + } + ], + "params": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ], + "options": { + "path-inspection": true + } + }, + "operator": "ssrf_detector" + } + ], + "transformers": [], + "on_match": [ + "stack_trace" + ] + }, + { + "id": "rasp-942-100", + "name": "SQL injection exploit", + "tags": { + "type": "sql_injection", + "category": "vulnerability_trigger", + "cwe": "89", + "capec": "1000/152/248/66", + "confidence": "1", + "module": "rasp" + }, + "conditions": [ + { + "parameters": { + "resource": [ + { + "address": "server.db.statement" + } + ], + "params": [ + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" + } + ], + "db_type": [ + { + "address": "server.db.system" + } + ] + }, + "operator": "sqli_detector@v2" + } + ], + "transformers": [], + "on_match": [ + "stack_trace" + ] + }, { "id": "sqr-000-001", "name": "SSRF: Try to access the credential manager of the main cloud services", @@ -5957,7 +6743,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -5977,6 +6764,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i)^\\W*((http|ftp)s?://)?\\W*((::f{4}:)?(169|(0x)?0*a9|0+251)\\.?(254|(0x)?0*fe|0+376)[0-9a-fx\\.:]+|metadata\\.google\\.internal|metadata\\.goog)\\W*/", @@ -5998,7 +6788,8 @@ "type": "js_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242" + "capec": "1000/152/242", + "module": "waf" }, "conditions": [ { @@ -6018,6 +6809,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "require\\(['\"][\\w\\.]+['\"]\\)|process\\.\\w+\\([\\w\\.]*\\)|\\.toString\\(\\)", @@ -6040,7 +6834,8 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6063,6 +6858,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i)[&|]\\s*type\\s+%\\w+%\\\\+\\w+\\.ini\\s*[&|]" @@ -6080,7 +6878,8 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6103,6 +6902,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i)[&|]\\s*cat\\s*\\/etc\\/[\\w\\.\\/]*passwd\\s*[&|]" @@ -6122,7 +6924,8 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6145,6 +6948,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "(?i)[&|]\\s*timeout\\s+/t\\s+\\d+\\s*[&|]" @@ -6162,7 +6968,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6182,6 +6989,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "http(s?):\\/\\/([A-Za-z0-9\\.\\-\\_]+|\\[[A-Fa-f0-9\\:]+\\]|):5986\\/wsman", @@ -6202,7 +7012,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6222,6 +7033,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "^(jar:)?(http|https):\\/\\/([0-9oq]{1,5}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|[0-9]{1,10})(:[0-9]{1,5})?(\\/[^:@]*)?$" @@ -6241,7 +7055,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6261,6 +7076,9 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], "regex": "^(jar:)?(http|https):\\/\\/((\\[)?[:0-9a-f\\.x]{2,}(\\])?)(:[0-9]{1,5})?(\\/[^:@]*)?$" @@ -6280,7 +7098,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6303,9 +7122,12 @@ }, { "address": "graphql.server.all_resolvers" + }, + { + "address": "graphql.server.resolver" } ], - "regex": "(http|https):\\/\\/(?:.*\\.)?(?:burpcollaborator\\.net|localtest\\.me|mail\\.ebc\\.apple\\.com|bugbounty\\.dod\\.network|.*\\.[nx]ip\\.io|oastify\\.com|oast\\.(?:pro|live|site|online|fun|me)|sslip\\.io|requestbin\\.com|requestbin\\.net|hookbin\\.com|webhook\\.site|canarytokens\\.com|interact\\.sh|ngrok\\.io|bugbounty\\.click|prbly\\.win|qualysperiscope\\.com|vii\\.one|act1on3\\.ru)" + "regex": "(http|https):\\/\\/(?:.*\\.)?(?:burpcollaborator\\.net|localtest\\.me|mail\\.ebc\\.apple\\.com|bugbounty\\.dod\\.network|.*\\.[nx]ip\\.io|oastify\\.com|oast\\.(?:pro|live|site|online|fun|me)|sslip\\.io|requestbin\\.com|requestbin\\.net|hookbin\\.com|webhook\\.site|canarytokens\\.com|interact\\.sh|ngrok\\.io|bugbounty\\.click|prbly\\.win|qualysperiscope\\.com|vii\\.one|act1on3\\.ru|dnslog\\.\\w+)" }, "operator": "match_regex" } @@ -6320,7 +7142,8 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6339,10 +7162,10 @@ "address": "server.request.headers.no_cookies" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" } ], "regex": "^(jar:)?((file|netdoc):\\/\\/[\\\\\\/]+|(dict|gopher|ldap|sftp|tftp):\\/\\/.*:[0-9]{1,5})" @@ -6362,7 +7185,8 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6384,10 +7208,10 @@ "address": "server.request.headers.no_cookies" }, { - "address": "grpc.server.request.message" + "address": "graphql.server.all_resolvers" }, { - "address": "graphql.server.all_resolvers" + "address": "graphql.server.resolver" } ], "regex": "\\${[^j]*j[^n]*n[^d]*d[^i]*i[^:]*:[^}]*}" @@ -6408,7 +7232,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Joomla exploitation tool", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6437,7 +7262,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nessus", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6466,7 +7292,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Arachni", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6495,7 +7322,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Jorgee", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6524,7 +7352,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Probely", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6553,7 +7382,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Metis", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6582,7 +7412,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLPowerInjector", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6611,7 +7442,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "N-Stealth", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6640,7 +7472,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Brutus", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6668,7 +7501,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6697,7 +7531,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Netsparker", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6726,7 +7561,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "JAASCois", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6755,7 +7591,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nsauditor", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6784,7 +7621,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Paros", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6813,7 +7651,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "DirBuster", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6842,7 +7681,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Pangolin", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6871,7 +7711,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Qualys", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -6900,7 +7741,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLNinja", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6929,7 +7771,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nikto", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6958,7 +7801,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "BlackWidow", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -6987,7 +7831,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Grendel-Scan", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7016,7 +7861,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Havij", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7045,7 +7891,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "w3af", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7074,7 +7921,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nmap", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7087,7 +7935,7 @@ ] } ], - "regex": "nmap (nse|scripting engine)" + "regex": "nmap (nse|scripting engine|icap-client/)" }, "operator": "match_regex" } @@ -7103,7 +7951,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nessus", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7132,7 +7981,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "EvilScanner", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7161,7 +8011,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "WebFuck", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7190,7 +8041,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "OpenVAS", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7219,7 +8071,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Spider-Pig", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7248,7 +8101,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Zgrab", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7277,7 +8131,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Zmeu", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7306,7 +8161,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "GoogleSecurityScanner", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -7335,7 +8191,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Commix", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7364,7 +8221,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Gobuster", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7393,7 +8251,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "CGIchk", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7422,7 +8281,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "FFUF", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7451,7 +8311,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nuclei", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7480,7 +8341,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Tsunami", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7509,7 +8371,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nimbostratus", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7538,7 +8401,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Datadog Canary Test", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7573,7 +8437,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Datadog Canary Test", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7611,7 +8476,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "AlertLogic", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -7640,7 +8506,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "wfuzz", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7669,7 +8536,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Detectify", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -7698,7 +8566,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "BSQLBF", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7727,7 +8596,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "masscan", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7756,7 +8626,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "WPScan", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7785,7 +8656,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Aon", - "confidence": "0" + "confidence": "0", + "module": "waf" }, "conditions": [ { @@ -7814,7 +8686,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "feroxbuster", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7834,6 +8707,126 @@ ], "transformers": [] }, + { + "id": "ua0-600-64x", + "name": "ddg_win", + "tags": { + "type": "attack_tool", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "ddg_win", + "confidence": "1", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + ], + "regex": "\\bddg_win\\b" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, + { + "id": "ua0-600-65x", + "name": "ISS", + "tags": { + "type": "commercial_scanner", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "iss", + "confidence": "0", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + ], + "regex": "\\bisscyberriskcrawler/\\d\\.\\d" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, + { + "id": "ua0-600-66x", + "name": "BountyBot", + "tags": { + "type": "attack_tool", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "bountybot", + "confidence": "1", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + ], + "regex": "\\bbountybot\\b" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, + { + "id": "ua0-600-67x", + "name": "ZumBot", + "tags": { + "type": "attack_tool", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "zumbot", + "confidence": "1", + "module": "waf" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + ], + "regex": "\\bzumbot\\b" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, { "id": "ua0-600-6xx", "name": "Stealthy scanner", @@ -7842,7 +8835,8 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7874,7 +8868,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLmap", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7903,7 +8898,8 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Skipfish", - "confidence": "1" + "confidence": "1", + "module": "waf" }, "conditions": [ { @@ -7923,5 +8919,1586 @@ ], "transformers": [] } + ], + "rules_compat": [ + { + "id": "api-001-100", + "name": "JWT: No expiry is present", + "tags": { + "type": "jwt", + "category": "api_security", + "confidence": "0", + "module": "business-logic" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.jwt", + "key_path": [ + "payload", + "exp" + ] + } + ] + }, + "operator": "!exists" + } + ], + "transformers": [], + "output": { + "event": false, + "keep": false, + "attributes": { + "_dd.appsec.api.jwt.no_expiry": { + "value": 1 + } + } + } + }, + { + "id": "api-001-110", + "name": "JWT: Collect algorithm used", + "tags": { + "type": "jwt", + "category": "api_security", + "confidence": "0", + "module": "business-logic" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.jwt", + "key_path": [ + "header", + "alg" + ] + } + ] + }, + "operator": "exists" + } + ], + "transformers": [], + "output": { + "event": false, + "keep": false, + "attributes": { + "_dd.appsec.api.jwt_alg": { + "address": "server.request.jwt", + "key_path": [ + "header", + "alg" + ] + } + } + } + }, + { + "id": "api-001-120", + "name": "JWT: No audience is specified", + "tags": { + "type": "jwt", + "category": "api_security", + "confidence": "0", + "module": "business-logic" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.jwt", + "key_path": [ + "payload", + "aud" + ] + } + ] + }, + "operator": "!exists" + } + ], + "transformers": [], + "output": { + "event": false, + "keep": false, + "attributes": { + "_dd.appsec.api.jwt.no_audience": { + "value": 1 + } + } + } + }, + { + "id": "api-001-130", + "name": "JWT: None algorithm used", + "tags": { + "type": "jwt", + "category": "api_security", + "confidence": "0", + "module": "business-logic" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.jwt", + "key_path": [ + "header", + "alg" + ] + } + ], + "list": [ + "none", + "nonE", + "noNe", + "noNE", + "nOne", + "nOnE", + "nONe", + "nONE", + "None", + "NonE", + "NoNe", + "NoNE", + "NOne", + "NOnE", + "NONe", + "NONE" + ] + }, + "operator": "exact_match" + } + ], + "transformers": [], + "output": { + "event": false, + "keep": true, + "attributes": { + "_dd.appsec.api.jwt.none_alg": { + "value": 1 + } + } + } + }, + { + "id": "ua0-600-551", + "name": "Datadog test scanner - scalar trace-tagging version: user-agent", + "tags": { + "type": "security_scanner", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "Datadog Canary Test", + "confidence": "1", + "module": "waf" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + }, + { + "address": "grpc.server.request.metadata", + "key_path": [ + "dd-canary" + ] + } + ], + "regex": "^dd-test-scanner-tag-scalar(?:$|/|\\s)" + }, + "operator": "match_regex" + } + ], + "transformers": [], + "output": { + "event": false, + "attributes": { + "_dd.appsec.test.scanner.scalar": { + "value": 1 + } + } + } + }, + { + "id": "ua0-600-552", + "name": "Datadog test scanner - reference trace-tagging version: user-agent", + "tags": { + "type": "security_scanner", + "category": "attack_attempt", + "cwe": "200", + "capec": "1000/118/169", + "tool_name": "Datadog Canary Test", + "confidence": "1", + "module": "waf" + }, + "min_version": "1.25.0", + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + }, + { + "address": "grpc.server.request.metadata", + "key_path": [ + "dd-canary" + ] + } + ], + "regex": "^dd-test-scanner-tag-ref(?:$|/|\\s)" + }, + "operator": "match_regex" + } + ], + "transformers": [], + "output": { + "event": false, + "attributes": { + "_dd.appsec.test.scanner.reference": { + "address": "server.request.headers.no_cookies", + "key_path": [ + "user-agent" + ] + } + } + } + } + ], + "processors": [ + { + "id": "http-endpoint-fingerprint", + "generator": "http_endpoint_fingerprint", + "conditions": [], + "parameters": { + "mappings": [ + { + "method": [ + { + "address": "server.request.method" + } + ], + "uri_raw": [ + { + "address": "server.request.uri.raw" + } + ], + "body": [ + { + "address": "server.request.body" + } + ], + "query": [ + { + "address": "server.request.query" + } + ], + "output": "_dd.appsec.fp.http.endpoint" + } + ] + }, + "evaluate": true, + "output": true + }, + { + "id": "extract-content", + "generator": "extract_schema", + "conditions": [ + { + "operator": "equals", + "parameters": { + "inputs": [ + { + "address": "waf.context.processor", + "key_path": [ + "extract-schema" + ] + } + ], + "type": "boolean", + "value": true + } + } + ], + "parameters": { + "mappings": [ + { + "inputs": [ + { + "address": "server.request.body" + } + ], + "output": "_dd.appsec.s.req.body" + }, + { + "inputs": [ + { + "address": "server.request.cookies" + } + ], + "output": "_dd.appsec.s.req.cookies" + }, + { + "inputs": [ + { + "address": "server.request.query" + } + ], + "output": "_dd.appsec.s.req.query" + }, + { + "inputs": [ + { + "address": "server.request.path_params" + } + ], + "output": "_dd.appsec.s.req.params" + }, + { + "inputs": [ + { + "address": "server.response.body" + } + ], + "output": "_dd.appsec.s.res.body" + }, + { + "inputs": [ + { + "address": "graphql.server.all_resolvers" + } + ], + "output": "_dd.appsec.s.graphql.all_resolvers" + }, + { + "inputs": [ + { + "address": "graphql.server.resolver" + } + ], + "output": "_dd.appsec.s.graphql.resolver" + } + ], + "scanners": [ + { + "tags": { + "category": "payment" + } + }, + { + "tags": { + "category": "pii" + } + } + ] + }, + "evaluate": false, + "output": true + }, + { + "id": "extract-headers", + "generator": "extract_schema", + "conditions": [ + { + "operator": "equals", + "parameters": { + "inputs": [ + { + "address": "waf.context.processor", + "key_path": [ + "extract-schema" + ] + } + ], + "type": "boolean", + "value": true + } + } + ], + "parameters": { + "mappings": [ + { + "inputs": [ + { + "address": "server.request.headers.no_cookies" + } + ], + "output": "_dd.appsec.s.req.headers" + }, + { + "inputs": [ + { + "address": "server.response.headers.no_cookies" + } + ], + "output": "_dd.appsec.s.res.headers" + } + ], + "scanners": [ + { + "tags": { + "category": "credentials" + } + }, + { + "tags": { + "category": "pii" + } + } + ] + }, + "evaluate": false, + "output": true + }, + { + "id": "http-header-fingerprint", + "generator": "http_header_fingerprint", + "conditions": [], + "parameters": { + "mappings": [ + { + "headers": [ + { + "address": "server.request.headers.no_cookies" + } + ], + "output": "_dd.appsec.fp.http.header" + } + ] + }, + "evaluate": true, + "output": true + }, + { + "id": "decode-auth-jwt", + "generator": "jwt_decode", + "min_version": "1.25.0", + "parameters": { + "mappings": [ + { + "inputs": [ + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "authorization" + ] + } + ], + "output": "server.request.jwt" + } + ] + }, + "evaluate": true, + "output": false + }, + { + "id": "http-network-fingerprint", + "generator": "http_network_fingerprint", + "conditions": [], + "parameters": { + "mappings": [ + { + "headers": [ + { + "address": "server.request.headers.no_cookies" + } + ], + "output": "_dd.appsec.fp.http.network" + } + ] + }, + "evaluate": true, + "output": true + }, + { + "id": "session-fingerprint", + "generator": "session_fingerprint", + "conditions": [], + "parameters": { + "mappings": [ + { + "cookies": [ + { + "address": "server.request.cookies" + } + ], + "session_id": [ + { + "address": "usr.session_id" + } + ], + "user_id": [ + { + "address": "usr.id" + } + ], + "output": "_dd.appsec.fp.session" + } + ] + }, + "evaluate": true, + "output": true + } + ], + "scanners": [ + { + "id": "406f8606-52c4-4663-8db9-df70f9e8766c", + "name": "ZIP Code", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:zip|postal)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "^[0-9]{5}(?:-[0-9]{4})?$", + "options": { + "case_sensitive": true, + "min_length": 5 + } + } + }, + "tags": { + "type": "zipcode", + "category": "address" + } + }, + { + "id": "JU1sRk3mSzqSUJn6GrVn7g", + "name": "American Express Card Scanner (4+4+4+3 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b3[47]\\d{2}(?:(?:\\s\\d{4}\\s\\d{4}\\s\\d{3})|(?:\\,\\d{4}\\,\\d{4}\\,\\d{3})|(?:-\\d{4}-\\d{4}-\\d{3})|(?:\\.\\d{4}\\.\\d{4}\\.\\d{3}))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "amex", + "category": "payment" + } + }, + { + "id": "edmH513UTQWcRiQ9UnzHlw-mod", + "name": "American Express Card Scanner (4+6|5+5|6 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b3[47]\\d{2}(?:(?:\\s\\d{5,6}\\s\\d{5,6})|(?:\\.\\d{5,6}\\.\\d{5,6})|(?:-\\d{5,6}-\\d{5,6})|(?:,\\d{5,6},\\d{5,6}))\\b", + "options": { + "case_sensitive": false, + "min_length": 17 + } + } + }, + "tags": { + "type": "card", + "card_type": "amex", + "category": "payment" + } + }, + { + "id": "e6K4h_7qTLaMiAbaNXoSZA", + "name": "American Express Card Scanner (8+7 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b3[47]\\d{6}(?:(?:\\s\\d{7})|(?:\\,\\d{7})|(?:-\\d{7})|(?:\\.\\d{7}))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "amex", + "category": "payment" + } + }, + { + "id": "K2rZflWzRhGM9HiTc6whyQ", + "name": "American Express Card Scanner (1x15 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b3[47]\\d{13}\\b", + "options": { + "case_sensitive": false, + "min_length": 15 + } + } + }, + "tags": { + "type": "card", + "card_type": "amex", + "category": "payment" + } + }, + { + "id": "9d7756e343cefa22a5c098e1092590f806eb5446", + "name": "Basic Authentication Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bauthorization\\b", + "options": { + "case_sensitive": false, + "min_length": 13 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "^basic\\s+[A-Za-z0-9+/=]+", + "options": { + "case_sensitive": false, + "min_length": 7 + } + } + }, + "tags": { + "type": "basic_auth", + "category": "credentials" + } + }, + { + "id": "mZy8XjZLReC9smpERXWnnw", + "name": "Bearer Authentication Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bauthorization\\b", + "options": { + "case_sensitive": false, + "min_length": 13 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "^bearer\\s+[-a-z0-9._~+/]{4,}", + "options": { + "case_sensitive": false, + "min_length": 11 + } + } + }, + "tags": { + "type": "bearer_token", + "category": "credentials" + } + }, + { + "id": "450239afc250a19799b6c03dc0e16fd6a4b2a1af", + "name": "Canadian Social Insurance Number Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:social[\\s_]?(?:insurance(?:\\s+number)?)?|SIN|Canadian[\\s_]?(?:social[\\s_]?(?:insurance)?|insurance[\\s_]?number)?)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b\\d{3}-\\d{3}-\\d{3}\\b", + "options": { + "case_sensitive": false, + "min_length": 11 + } + } + }, + "tags": { + "type": "canadian_sin", + "category": "pii" + } + }, + { + "id": "87a879ff33693b46c8a614d8211f5a2c289beca0", + "name": "Digest Authentication Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bauthorization\\b", + "options": { + "case_sensitive": false, + "min_length": 13 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "^digest\\s+", + "options": { + "case_sensitive": false, + "min_length": 7 + } + } + }, + "tags": { + "type": "digest_auth", + "category": "credentials" + } + }, + { + "id": "qWumeP1GQUa_E4ffAnT-Yg", + "name": "American Express Card Scanner (1x14 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "(?:30[0-59]\\d|3[689]\\d{2})(?:\\d{10})", + "options": { + "case_sensitive": false, + "min_length": 14 + } + } + }, + "tags": { + "type": "card", + "card_type": "diners", + "category": "payment" + } + }, + { + "id": "NlTWWM5LS6W0GSqBLuvtRw", + "name": "Diners Card Scanner (4+4+4+2 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:30[0-59]\\d|3[689]\\d{2})(?:(?:\\s\\d{4}\\s\\d{4}\\s\\d{2})|(?:\\,\\d{4}\\,\\d{4}\\,\\d{2})|(?:-\\d{4}-\\d{4}-\\d{2})|(?:\\.\\d{4}\\.\\d{4}\\.\\d{2}))\\b", + "options": { + "case_sensitive": false, + "min_length": 17 + } + } + }, + "tags": { + "type": "card", + "card_type": "diners", + "category": "payment" + } + }, + { + "id": "Xr5VdbQSTXitYGGiTfxBpw", + "name": "Diners Card Scanner (4+6+4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:30[0-59]\\d|3[689]\\d{2})(?:(?:\\s\\d{6}\\s\\d{4})|(?:\\.\\d{6}\\.\\d{4})|(?:-\\d{6}-\\d{4})|(?:,\\d{6},\\d{4}))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "diners", + "category": "payment" + } + }, + { + "id": "gAbunN_WQNytxu54DjcbAA-mod", + "name": "Diners Card Scanner (8+6 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:30[0-59]\\d{5}|3[689]\\d{6})\\s?(?:(?:\\s\\d{6})|(?:\\,\\d{6})|(?:-\\d{6})|(?:\\.\\d{6}))\\b", + "options": { + "case_sensitive": false, + "min_length": 14 + } + } + }, + "tags": { + "type": "card", + "card_type": "diners", + "category": "payment" + } + }, + { + "id": "9cs4qCfEQBeX17U7AepOvQ", + "name": "MasterCard Scanner (2x8 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:6221(?:2[6-9]|[3-9][0-9])\\d{2}(?:,\\d{8}|\\s\\d{8}|-\\d{8}|\\.\\d{8})|6229(?:[01][0-9]|2[0-5])\\d{2}(?:,\\d{8}|\\s\\d{8}|-\\d{8}|\\.\\d{8})|(?:6011|65\\d{2}|64[4-9]\\d|622[2-8])\\d{4}(?:,\\d{8}|\\s\\d{8}|-\\d{8}|\\.\\d{8}))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "discover", + "category": "payment" + } + }, + { + "id": "YBIDWJIvQWW_TFOyU0CGJg", + "name": "Discover Card Scanner (4x4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:(?:(?:6221(?:2[6-9]|[3-9][0-9])\\d{2}(?:,\\d{4}){2})|(?:6221\\s(?:2[6-9]|[3-9][0-9])\\d{2}(?:\\s\\d{4}){2})|(?:6221\\.(?:2[6-9]|[3-9][0-9])\\d{2}(?:\\.\\d{4}){2})|(?:6221-(?:2[6-9]|[3-9][0-9])\\d{2}(?:-\\d{4}){2}))|(?:(?:6229(?:[01][0-9]|2[0-5])\\d{2}(?:,\\d{4}){2})|(?:6229\\s(?:[01][0-9]|2[0-5])\\d{2}(?:\\s\\d{4}){2})|(?:6229\\.(?:[01][0-9]|2[0-5])\\d{2}(?:\\.\\d{4}){2})|(?:6229-(?:[01][0-9]|2[0-5])\\d{2}(?:-\\d{4}){2}))|(?:(?:6011|65\\d{2}|64[4-9]\\d|622[2-8])(?:(?:\\s\\d{4}){3}|(?:\\.\\d{4}){3}|(?:-\\d{4}){3}|(?:,\\d{4}){3})))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "discover", + "category": "payment" + } + }, + { + "id": "12cpbjtVTMaMutFhh9sojQ", + "name": "Discover Card Scanner (1x16 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:6221(?:2[6-9]|[3-9][0-9])\\d{10}|6229(?:[01][0-9]|2[0-5])\\d{10}|(?:6011|65\\d{2}|64[4-9]\\d|622[2-8])\\d{12})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "discover", + "category": "payment" + } + }, + { + "id": "PuXiVTCkTHOtj0Yad1ppsw", + "name": "Standard E-mail Address", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:(?:e[-\\s]?)?mail|address|sender|\\bto\\b|from|recipient)\\b", + "options": { + "case_sensitive": false, + "min_length": 2 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*(%40|@)(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}\\b", + "options": { + "case_sensitive": false, + "min_length": 5 + } + } + }, + "tags": { + "type": "email", + "category": "pii" + } + }, + { + "id": "8VS2RKxzR8a_95L5fuwaXQ", + "name": "IBAN", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:iban|account|sender|receiver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(?:[ \\-]?[A-Z0-9]{5}){4}|(?:AL|CY)\\d{2}(?:[ \\-]?\\d{4}){2}(?:[ \\-]?[A-Z0-9]{4}){4}|(?:HU|PL)\\d{2}(?:[ \\-]?\\d{4}){6}|QA\\d{2}[ \\-]?[A-Z]{4}(?:[ \\-]?[A-Z0-9]{4}){5}[ \\-]?[A-Z0-9]|PS\\d{2}[ \\-]?[A-Z0-9]{4}(?:[ \\-]?\\d{4}){5}[ \\-]?\\d|UA\\d{2}[ \\-]?\\d{4}[ \\-]?\\d{2}[A-Z0-9]{2}(?:[ \\-]?[A-Z0-9]{4}){4}[ \\-]?[A-Z0-9]|BR\\d{2}(?:[ \\-]?\\d{4}){5}[ \\-]?\\d{3}[A-Z0-9][ \\-]?[A-Z0-9]|EG\\d{2}(?:[ \\-]?\\d{4}){6}\\d|MU\\d{2}[ \\-]?[A-Z]{4}(?:[ \\-]?\\d{4}){4}\\d{3}[A-Z][ \\-]?[A-Z]{2}|(?:KW|JO)\\d{2}[ \\-]?[A-Z]{4}(?:[ \\-]?[A-Z0-9]{4}){5}[ \\-]?[A-Z0-9]{2}|MT\\d{2}[ \\-]?[A-Z]{4}[ \\-]?\\d{4}[ \\-]?\\d[A-Z0-9]{3}(?:[ \\-]?[A-Z0-9]{3}){4}[ \\-]?[A-Z0-9]{3}|SC\\d{2}[ \\-]?[A-Z]{4}(?:[ \\-]?\\d{4}){5}[ \\-]?[A-Z]{3}|LC\\d{2}[ \\-]?[A-Z]{4}(?:[ \\-]?[A-Z0-9]{4}){6})\\b", + "options": { + "case_sensitive": false, + "min_length": 15 + } + } + }, + "tags": { + "type": "iban", + "category": "payment" + } + }, + { + "id": "h6WJcecQTwqvN9KeEtwDvg", + "name": "JCB Card Scanner (1x16 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b35(?:2[89]|[3-9][0-9])(?:\\d{12})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "jcb", + "category": "payment" + } + }, + { + "id": "gcEaMu_VSJ2-bGCEkgyC0w", + "name": "JCB Card Scanner (2x8 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b35(?:2[89]|[3-9][0-9])\\d{4}(?:(?:,\\d{8})|(?:-\\d{8})|(?:\\s\\d{8})|(?:\\.\\d{8}))\\b", + "options": { + "case_sensitive": false, + "min_length": 17 + } + } + }, + "tags": { + "type": "card", + "card_type": "jcb", + "category": "payment" + } + }, + { + "id": "imTliuhXT5GAeRNhqChXQQ", + "name": "JCB Card Scanner (4x4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b35(?:2[89]|[3-9][0-9])(?:(?:\\s\\d{4}){3}|(?:\\.\\d{4}){3}|(?:-\\d{4}){3}|(?:,\\d{4}){3})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "jcb", + "category": "payment" + } + }, + { + "id": "9osY3xc9Q7ONAV0zw9Uz4A", + "name": "JSON Web Token", + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\bey[I-L][\\w=-]+\\.ey[I-L][\\w=-]+(\\.[\\w.+\\/=-]+)?\\b", + "options": { + "case_sensitive": false, + "min_length": 20 + } + } + }, + "tags": { + "type": "json_web_token", + "category": "credentials" + } + }, + { + "id": "d1Q9D3YMRxuVKf6CZInJPw", + "name": "Maestro Card Scanner (1x16 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:5[06-9]\\d{2}|6\\d{3})(?:\\d{12})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "maestro", + "category": "payment" + } + }, + { + "id": "M3YIQKKjRVmoeQuM3pjzrw", + "name": "Maestro Card Scanner (2x8 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:5[06-9]\\d{6}|6\\d{7})(?:\\s\\d{8}|\\.\\d{8}|-\\d{8}|,\\d{8})\\b", + "options": { + "case_sensitive": false, + "min_length": 17 + } + } + }, + "tags": { + "type": "card", + "card_type": "maestro", + "category": "payment" + } + }, + { + "id": "hRxiQBlSSVKcjh5U7LZYLA", + "name": "Maestro Card Scanner (4x4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:5[06-9]\\d{2}|6\\d{3})(?:(?:\\s\\d{4}){3}|(?:\\.\\d{4}){3}|(?:-\\d{4}){3}|(?:,\\d{4}){3})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "maestro", + "category": "payment" + } + }, + { + "id": "NwhIYNS4STqZys37WlaIKA", + "name": "MasterCard Scanner (2x8 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:(?:5[1-5]\\d{2})|(?:222[1-9])|(?:22[3-9]\\d)|(?:2[3-6]\\d{2})|(?:27[0-1]\\d)|(?:2720))(?:(?:\\d{4}(?:(?:,\\d{8})|(?:-\\d{8})|(?:\\s\\d{8})|(?:\\.\\d{8}))))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "mastercard", + "category": "payment" + } + }, + { + "id": "axxJkyjhRTOuhjwlsA35Vw", + "name": "MasterCard Scanner (4x4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:(?:5[1-5]\\d{2})|(?:222[1-9])|(?:22[3-9]\\d)|(?:2[3-6]\\d{2})|(?:27[0-1]\\d)|(?:2720))(?:(?:\\s\\d{4}){3}|(?:\\.\\d{4}){3}|(?:-\\d{4}){3}|(?:,\\d{4}){3})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "mastercard", + "category": "payment" + } + }, + { + "id": "76EhmoK3TPqJcpM-fK0pLw", + "name": "MasterCard Scanner (1x16 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:(?:5[1-5]\\d{2})|(?:222[1-9])|(?:22[3-9]\\d)|(?:2[3-6]\\d{2})|(?:27[0-1]\\d)|(?:2720))(?:\\d{12})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "mastercard", + "category": "payment" + } + }, + { + "id": "c542c147-3883-43d6-a067-178e4a7bd65d", + "name": "Password", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bpass(?:[_-]?word|wd)?\\b|\\bpwd\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "tags": { + "type": "password", + "category": "credentials" + } + }, + { + "id": "18b608bd7a764bff5b2344c0", + "name": "Phone number", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bphone|number|mobile\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "^(?:\\(\\+\\d{1,3}\\)|\\+\\d{1,3}|00\\d{1,3})?[-\\s\\.]?(?:\\(\\d{3}\\)[-\\s\\.]?)?(?:\\d[-\\s\\.]?){6,10}$", + "options": { + "case_sensitive": false, + "min_length": 6 + } + } + }, + "tags": { + "type": "phone", + "category": "pii" + } + }, + { + "id": "de0899e0cbaaa812bb624cf04c912071012f616d-mod", + "name": "UK National Insurance Number Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "^nin$|\\binsurance\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b[A-Z]{2}[\\s-]?\\d{6}[\\s-]?[A-Z]?\\b", + "options": { + "case_sensitive": false, + "min_length": 8 + } + } + }, + "tags": { + "type": "uk_nin", + "category": "pii" + } + }, + { + "id": "d962f7ddb3f55041e39195a60ff79d4814a7c331", + "name": "US Passport Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\bpassport\\b", + "options": { + "case_sensitive": false, + "min_length": 8 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b[0-9A-Z]{9}\\b|\\b[0-9]{6}[A-Z][0-9]{2}\\b", + "options": { + "case_sensitive": false, + "min_length": 8 + } + } + }, + "tags": { + "type": "passport_number", + "category": "pii" + } + }, + { + "id": "7771fc3b-b205-4b93-bcef-28608c5c1b54", + "name": "United States Social Security Number Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:SSN|(?:(?:social)?[\\s_]?(?:security)?[\\s_]?(?:number)?)?)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b\\d{3}[-\\s\\.]{1}\\d{2}[-\\s\\.]{1}\\d{4}\\b", + "options": { + "case_sensitive": false, + "min_length": 11 + } + } + }, + "tags": { + "type": "us_ssn", + "category": "pii" + } + }, + { + "id": "ac6d683cbac77f6e399a14990793dd8fd0fca333", + "name": "US Vehicle Identification Number Scanner", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:vehicle[_\\s-]*identification[_\\s-]*number|vin)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b[A-HJ-NPR-Z0-9]{17}\\b", + "options": { + "case_sensitive": false, + "min_length": 17 + } + } + }, + "tags": { + "type": "vin", + "category": "pii" + } + }, + { + "id": "wJIgOygRQhKkR69b_9XbRQ", + "name": "Visa Card Scanner (2x8 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b4\\d{3}(?:(?:\\d{4}(?:(?:,\\d{8})|(?:-\\d{8})|(?:\\s\\d{8})|(?:\\.\\d{8}))))\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "visa", + "category": "payment" + } + }, + { + "id": "0o71SJxXQNK7Q6gMbBesFQ", + "name": "Visa Card Scanner (4x4 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "\\b4\\d{3}(?:(?:,\\d{4}){3}|(?:\\s\\d{4}){3}|(?:\\.\\d{4}){3}|(?:-\\d{4}){3})\\b", + "options": { + "case_sensitive": false, + "min_length": 16 + } + } + }, + "tags": { + "type": "card", + "card_type": "visa", + "category": "payment" + } + }, + { + "id": "QrHD6AfgQm6z-j0wStxTvA", + "name": "Visa Card Scanner (1x15 & 1x16 & 1x19 digits)", + "key": { + "operator": "match_regex", + "parameters": { + "regex": "\\b(?:card|cc|credit|debit|payment|amex|visa|mastercard|maestro|discover|jcb|diner)\\b", + "options": { + "case_sensitive": false, + "min_length": 3 + } + } + }, + "value": { + "operator": "match_regex", + "parameters": { + "regex": "4[0-9]{12}(?:[0-9]{3})?", + "options": { + "case_sensitive": false, + "min_length": 13 + } + } + }, + "tags": { + "type": "card", + "card_type": "visa", + "category": "payment" + } + } ] -} \ No newline at end of file +} diff --git a/appsec/rules_test.go b/appsec/rules_test.go new file mode 100644 index 0000000..f03545b --- /dev/null +++ b/appsec/rules_test.go @@ -0,0 +1,24 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package appsec + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDefaultRuleset(t *testing.T) { + rules, err := DefaultRuleset() + require.NoError(t, err) + require.NotEmpty(t, rules) +} + +func TestDefaultRulesetMap(t *testing.T) { + rules, err := DefaultRulesetMap() + require.NoError(t, err) + require.NotEmpty(t, rules) +} diff --git a/go.mod b/go.mod index 9d34c29..9aa23ba 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module github.com/DataDog/appsec-internal-go -go 1.18 +go 1.23.0 require ( - github.com/stretchr/testify v1.8.4 - go.uber.org/atomic v1.11.0 - inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a + github.com/stretchr/testify v1.10.0 + go.uber.org/goleak v1.3.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect - go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +retract v1.10.0 // This version includes unintended breaking changes. diff --git a/go.sum b/go.sum index 1a031ca..7dbe38a 100644 --- a/go.sum +++ b/go.sum @@ -1,44 +1,18 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA= -go4.org/intern v0.0.0-20230525184215-6c62f75575cb h1:ae7kzL5Cfdmcecbh22ll7lYP3iuUdnfnhiPcSaDgH/8= -go4.org/intern v0.0.0-20230525184215-6c62f75575cb/go.mod h1:Ycrt6raEcnF5FTsLiLKkhBTO6DPX3RCUCUVnks3gFJU= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 h1:lGdhQUN/cnWdSH3291CUuxSEqc+AsGTiDxPP3r2J0l4= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM= -inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo= diff --git a/limiter/limiter.go b/limiter/limiter.go index c14f772..fbe4f3e 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -3,12 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2022-present Datadog, Inc. +// Package limiter provides simple rate limiting primitives, and an implementation of a token bucket rate limiter. package limiter import ( "time" - "go.uber.org/atomic" + "sync/atomic" ) // Limiter is used to abstract the rate limiter implementation to only expose the needed function for rate limiting. @@ -25,35 +26,50 @@ type Limiter interface { // TokenTicker.Allow() and TokenTicker.Stop() *must* be called once done using. Note that calling TokenTicker.Allow() // before TokenTicker.Start() is valid, but it means the bucket won't be refilling until the call to TokenTicker.Start() is made type TokenTicker struct { - tokens atomic.Int64 - maxTokens int64 - ticker *time.Ticker - stopChan chan struct{} + tokens atomic.Int64 // The amount of tokens currently available + maxTokens int64 // The maximum amount of tokens the bucket can hold + interval time.Duration // The interval at which the tokens are refilled + ticker *time.Ticker // The ticker used to update the bucket (nil if not started yet) + stopChan chan struct{} // The channel to stop the ticker updater (nil if not started yet) } // NewTokenTicker is a utility function that allocates a token ticker, initializes necessary fields and returns it func NewTokenTicker(tokens, maxTokens int64) *TokenTicker { - return &TokenTicker{ - tokens: *atomic.NewInt64(tokens), + return NewTokenTickerWithInterval(tokens, maxTokens, time.Second) +} + +// NewTokenTickerWithInterval is a utility function that allocates a token ticker with a custom interval +func NewTokenTickerWithInterval(tokens, maxTokens int64, interval time.Duration) *TokenTicker { + t := &TokenTicker{ maxTokens: maxTokens, + interval: interval, } + t.tokens.Store(tokens) + return t } // updateBucket performs a select loop to update the token amount in the bucket. // Used in a goroutine by the rate limiter. -func (t *TokenTicker) updateBucket(ticksChan <-chan time.Time, startTime time.Time, syncChan chan struct{}) { - nsPerToken := time.Second.Nanoseconds() / t.maxTokens +func (t *TokenTicker) updateBucket(startTime time.Time, ticksChan <-chan time.Time, stopChan <-chan struct{}, syncChan chan<- struct{}) { + nsPerToken := t.interval.Nanoseconds() / t.maxTokens elapsedNs := int64(0) prevStamp := startTime for { select { - case <-t.stopChan: + case <-stopChan: if syncChan != nil { close(syncChan) } return - case stamp := <-ticksChan: + case stamp, ok := <-ticksChan: + if !ok { + // The ticker has been closed, stamp is a zero-value, we ignore that. We nil-out the + // ticksChan so we don't get stuck endlessly reading from this closed channel again. + ticksChan = nil + continue + } + // Compute the time in nanoseconds that passed between the previous timestamp and this one // This will be used to know how many tokens can be added into the bucket depending on the limiter rate elapsedNs += stamp.Sub(prevStamp).Nanoseconds() @@ -96,22 +112,17 @@ func (t *TokenTicker) updateBucket(ticksChan <-chan time.Time, startTime time.Ti func (t *TokenTicker) Start() { timeNow := time.Now() t.ticker = time.NewTicker(500 * time.Microsecond) - t.start(t.ticker.C, timeNow, false) + t.start(timeNow, t.ticker.C, nil) } // start is used for internal testing. Controlling the ticker means being able to test per-tick -// rather than per-duration, which is more reliable if the app is under a lot of stress. -// sync is used to decide whether the limiter should create a channel for synchronization with the testing app after a -// bucket update. The limiter is in charge of closing the channel in this case. -func (t *TokenTicker) start(ticksChan <-chan time.Time, startTime time.Time, sync bool) <-chan struct{} { +// rather than per-duration, which is more reliable if the app is under a lot of stress. The +// syncChan, if non-nil, will receive one message after each tick from the ticksChan has been +// processed, providing a strong synchronization primitive. The limiter will close the syncChan when +// it is stopped, signaling that no further ticks will be processed. +func (t *TokenTicker) start(startTime time.Time, ticksChan <-chan time.Time, syncChan chan<- struct{}) { t.stopChan = make(chan struct{}) - var syncChan chan struct{} - - if sync { - syncChan = make(chan struct{}) - } - go t.updateBucket(ticksChan, startTime, syncChan) - return syncChan + go t.updateBucket(startTime, ticksChan, t.stopChan, syncChan) } // Stop shuts down the rate limiter, taking care stopping the ticker and closing all channels @@ -119,11 +130,13 @@ func (t *TokenTicker) Stop() { // Stop the ticker only if it has been instantiated (not the case when testing by calling start() directly) if t.ticker != nil { t.ticker.Stop() + t.ticker = nil // Ensure stop can be called multiple times idempotently. } // Close the stop channel only if it has been created. This covers the case where Stop() is called without any prior // call to Start() if t.stopChan != nil { close(t.stopChan) + t.stopChan = nil // Ensure stop can be called multiple times idempotently. } } diff --git a/limiter/limiter_test.go b/limiter/limiter_test.go index 18f1a03..7d0467c 100644 --- a/limiter/limiter_test.go +++ b/limiter/limiter_test.go @@ -9,18 +9,22 @@ import ( "fmt" "math" "sync" + "sync/atomic" "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/atomic" + "go.uber.org/goleak" ) func TestLimiterUnit(t *testing.T) { startTime := time.Now() t.Run("no-ticks-1", func(t *testing.T) { - l := NewTestTicker(1, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(1, 100) l.start(startTime) defer l.stop() // No ticks between the requests @@ -29,7 +33,9 @@ func TestLimiterUnit(t *testing.T) { }) t.Run("no-ticks-2", func(t *testing.T) { - l := NewTestTicker(100, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() // No ticks between the requests @@ -40,89 +46,102 @@ func TestLimiterUnit(t *testing.T) { }) t.Run("10ms-ticks", func(t *testing.T) { - l := NewTestTicker(1, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(1, 100) l.start(startTime) defer l.stop() require.True(t, l.Allow(), "First call to limiter.Allow() should return True") require.False(t, l.Allow(), "Second call to limiter.Allow() should return false") - l.tick(startTime.Add(10 * time.Millisecond)) + l.tick(10 * time.Millisecond) require.True(t, l.Allow(), "Third call to limiter.Allow() after 10ms should return True") }) t.Run("9ms-ticks", func(t *testing.T) { - l := NewTestTicker(1, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(1, 100) l.start(startTime) defer l.stop() require.True(t, l.Allow(), "First call to limiter.Allow() should return True") - l.tick(startTime.Add(9 * time.Millisecond)) + l.tick(9 * time.Millisecond) require.False(t, l.Allow(), "Second call to limiter.Allow() after 9ms should return False") - l.tick(startTime.Add(10 * time.Millisecond)) + l.tick(10 * time.Millisecond) require.True(t, l.Allow(), "Third call to limiter.Allow() after 10ms should return True") }) t.Run("1s-rate", func(t *testing.T) { - l := NewTestTicker(1, 1) + defer goleak.VerifyNone(t) + + l := newTestTicker(1, 1) l.start(startTime) defer l.stop() require.True(t, l.Allow(), "First call to limiter.Allow() should return True with 1s per token") - l.tick(startTime.Add(500 * time.Millisecond)) + l.tick(500 * time.Millisecond) require.False(t, l.Allow(), "Second call to limiter.Allow() should return False with 1s per Token") - l.tick(startTime.Add(1000 * time.Millisecond)) + l.tick(1000 * time.Millisecond) require.True(t, l.Allow(), "Third call to limiter.Allow() should return True with 1s per Token") }) t.Run("100-requests-burst", func(t *testing.T) { - l := NewTestTicker(100, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() for i := 0; i < 100; i++ { require.Truef(t, l.Allow(), "Burst call %d to limiter.Allow() should return True with 100 initial tokens", i) - startTime = startTime.Add(50 * time.Microsecond) - l.tick(startTime) + l.tick(50 * time.Millisecond) } }) t.Run("101-requests-burst", func(t *testing.T) { - l := NewTestTicker(100, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() for i := 0; i < 100; i++ { require.Truef(t, l.Allow(), "Burst call %d to limiter.Allow() should return True with 100 initial tokens", i) startTime = startTime.Add(50 * time.Microsecond) - l.tick(startTime) + l.tick(0) } require.False(t, l.Allow(), "Burst call 101 to limiter.Allow() should return False with 100 initial tokens") }) t.Run("bucket-refill-short", func(t *testing.T) { - l := NewTestTicker(100, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() for i := 0; i < 1000; i++ { - startTime = startTime.Add(time.Millisecond) - l.tick(startTime) + l.tick(time.Millisecond) require.Equalf(t, int64(100), l.t.tokens.Load(), "Bucket should have exactly 100 tokens") } }) t.Run("bucket-refill-long", func(t *testing.T) { - l := NewTestTicker(100, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() for i := 0; i < 1000; i++ { - startTime = startTime.Add(3 * time.Second) - l.tick(startTime) + l.tick(3 * time.Second) } require.Equalf(t, int64(100), l.t.tokens.Load(), "Bucket should have exactly 100 tokens") }) t.Run("allow-after-stop", func(t *testing.T) { - l := NewTestTicker(3, 3) + defer goleak.VerifyNone(t) + + l := newTestTicker(3, 3) l.start(startTime) require.True(t, l.Allow()) l.stop() @@ -133,7 +152,9 @@ func TestLimiterUnit(t *testing.T) { }) t.Run("allow-before-start", func(t *testing.T) { - l := NewTestTicker(2, 100) + defer goleak.VerifyNone(t) + + l := newTestTicker(2, 100) // The limiter keeps allowing until there's no more tokens require.True(t, l.Allow()) require.True(t, l.Allow()) @@ -141,7 +162,7 @@ func TestLimiterUnit(t *testing.T) { l.start(startTime) // The limiter has used all its tokens and the bucket is not getting refilled yet require.False(t, l.Allow()) - l.tick(startTime.Add(10 * time.Millisecond)) + l.tick(10 * time.Millisecond) // The limiter has started refilling its tokens require.True(t, l.Allow()) l.stop() @@ -154,6 +175,8 @@ func TestLimiter(t *testing.T) { // Each goroutine will continuously call the rate limiter for 1 second for nbUsers := 1; nbUsers <= 10; nbUsers *= 10 { t.Run(fmt.Sprintf("continuous-requests-%d-users", nbUsers), func(t *testing.T) { + defer goleak.VerifyNone(t) + var startBarrier, stopBarrier sync.WaitGroup // Create a start barrier to synchronize every goroutine's launch and // increase the chances of parallel accesses @@ -170,9 +193,9 @@ func TestLimiter(t *testing.T) { for tStart := time.Now(); time.Since(tStart) < 1*time.Second; { if !l.Allow() { - skipped.Inc() + skipped.Add(1) } else { - kept.Inc() + kept.Add(1) } } }(l, &kept, &skipped) @@ -197,9 +220,11 @@ func TestLimiter(t *testing.T) { // Simulate sporadic bursts during up to 1 minute for burstAmount := 1; burstAmount <= 10; burstAmount++ { t.Run(fmt.Sprintf("requests-bursts-%d-iterations", burstAmount), func(t *testing.T) { + defer goleak.VerifyNone(t) + skipped := 0 kept := 0 - l := NewTestTicker(100, 100) + l := newTestTicker(100, 100) l.start(startTime) defer l.stop() @@ -212,8 +237,7 @@ func TestLimiter(t *testing.T) { } } // Schedule next burst 1sec later - startTime = startTime.Add(burstFreq) - l.tick(startTime) + l.tick(burstFreq) } expectedSkipped := (burstSize - 100) * burstAmount @@ -230,12 +254,16 @@ func TestLimiter(t *testing.T) { } func BenchmarkLimiter(b *testing.B) { + defer goleak.VerifyNone(b, goleak.IgnoreCurrent()) + for nbUsers := 1; nbUsers <= 1000; nbUsers *= 10 { b.Run(fmt.Sprintf("%d-users", nbUsers), func(b *testing.B) { var skipped, kept atomic.Uint64 limiter := NewTokenTicker(0, 100) limiter.Start() defer limiter.Stop() + + b.StopTimer() b.ResetTimer() for n := 0; n < b.N; n++ { @@ -251,18 +279,25 @@ func BenchmarkLimiter(b *testing.B) { startBarrier.Wait() // Sync the starts of the goroutines defer stopBarrier.Done() // Signal we are done when returning + b.StartTimer() // Ensure the timer is started now... + for i := 0; i < 100; i++ { if !l.Allow() { - skipped.Inc() + skipped.Add(1) } else { - kept.Inc() + kept.Add(1) } } }(limiter, &kept, &skipped) } + startBarrier.Done() // Unblock the user goroutines stopBarrier.Wait() // Wait for the user goroutines to be done + b.StopTimer() } + + assert.NotEqual(b, 0, kept.Load(), "expected to have accepted at least 1") + assert.NotEqual(b, 0, skipped.Load(), "expected to have skipped at least 1") }) } } @@ -270,33 +305,91 @@ func BenchmarkLimiter(b *testing.B) { // TestTicker is a utility struct used to send hand-crafted ticks to the rate limiter for controlled testing // It also makes sure to give time to the bucket update goroutine by using the optional sync channel type TestTicker struct { - C chan time.Time - syncChan <-chan struct{} - t *TokenTicker + C chan time.Time + syncChan <-chan struct{} + t *TokenTicker + timestamp time.Time } -func NewTestTicker(tokens, maxTokens int64) *TestTicker { +func newTestTicker(tokens, maxTokens int64) *TestTicker { return &TestTicker{ C: make(chan time.Time), t: NewTokenTicker(tokens, maxTokens), } } -func (t *TestTicker) start(timeStamp time.Time) { - t.syncChan = t.t.start(t.C, timeStamp, true) +func (t *TestTicker) start(timestamp time.Time) { + syncChan := make(chan struct{}, 1) + t.syncChan = syncChan + t.timestamp = timestamp + t.t.start(timestamp, t.C, syncChan) } func (t *TestTicker) stop() { t.t.Stop() close(t.C) - // syncChan is closed by the token ticker when sure that nothing else will be sent on it + // syncChan is closed by the token ticker when sure that nothing else will be sent on it. + for _, ok := <-t.syncChan; ok; _, ok = <-t.syncChan { + // Drain the channel. + } + t.syncChan = nil + t.timestamp = time.Time{} } -func (t *TestTicker) tick(timeStamp time.Time) { - t.C <- timeStamp +// tick advances the `TestTicker`'s internal clock by the provided duration, and sends a tick to the +// underlying `TokenTicker`. It then waits for the `TokenTicker` to be done processing that tick, so +// the caller can assume the tocken bucket has been appropriately updated. +func (t *TestTicker) tick(delta time.Duration) { + t.timestamp = t.timestamp.Add(delta) + + t.C <- t.timestamp <-t.syncChan } func (t *TestTicker) Allow() bool { return t.t.Allow() } + +func newTestTickerWithInterval(tokens, maxTokens int64, interval time.Duration) *TestTicker { + return &TestTicker{ + C: make(chan time.Time), + t: NewTokenTickerWithInterval(tokens, maxTokens, interval), + } +} + +func TestLimiterWithInterval(t *testing.T) { + startTime := time.Now() + t.Run("60-per-minute-rate", func(t *testing.T) { + defer goleak.VerifyNone(t) + + l := newTestTickerWithInterval(1, 60, time.Minute) // 60 tokens per minute, so 1 per second + l.start(startTime) + defer l.stop() + require.True(t, l.Allow(), "First call should be allowed") + require.False(t, l.Allow(), "Second call should be disallowed") + + l.tick(500 * time.Millisecond) + require.False(t, l.Allow(), "A call after 0.5s should be disallowed") + + l.tick(500 * time.Millisecond) // Total 1 second passed + require.True(t, l.Allow(), "A call after 1s should be allowed") + require.False(t, l.Allow(), "Another call should be disallowed") + }) + + t.Run("1-per-100ms-rate", func(t *testing.T) { + defer goleak.VerifyNone(t) + + l := newTestTickerWithInterval(1, 1, 100*time.Millisecond) // 1 token per 100ms + l.start(startTime) + defer l.stop() + require.True(t, l.Allow(), "First call should be allowed") + require.False(t, l.Allow(), "Second call should be disallowed") + + l.tick(50 * time.Millisecond) + require.False(t, l.Allow(), "A call after 50ms should be disallowed") + + l.tick(50 * time.Millisecond) // Total 100ms passed + require.True(t, l.Allow(), "A call after 100ms should be allowed") + require.False(t, l.Allow(), "Another call should be disallowed") + }) +} diff --git a/netip/ip_go119.go b/netip/ip.go similarity index 96% rename from netip/ip_go119.go rename to netip/ip.go index 2c185de..99e1e62 100644 --- a/netip/ip_go119.go +++ b/netip/ip.go @@ -3,9 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2022 Datadog, Inc. -//go:build go1.19 -// +build go1.19 - package netip import "net/netip" diff --git a/netip/ip_default.go b/netip/ip_default.go deleted file mode 100644 index f2906a0..0000000 --- a/netip/ip_default.go +++ /dev/null @@ -1,32 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2022 Datadog, Inc. - -//go:build !go1.19 -// +build !go1.19 - -package netip - -import "inet.af/netaddr" - -// Addr wraps an netaddr.IP value -type Addr = netaddr.IP - -// Prefix wraps an netaddr.IPPrefix value -type Prefix = netaddr.IPPrefix - -var ( - // ParseAddr wraps the netaddr.ParseIP function - ParseAddr = netaddr.ParseIP - // ParsePrefix wraps the netaddr.ParseIPPrefix function - ParsePrefix = netaddr.ParseIPPrefix - // MustParsePrefix wraps the netaddr.MustParseIPPrefix function - MustParsePrefix = netaddr.MustParseIPPrefix - // MustParseAddr wraps the netaddr.MustParseIP function - MustParseAddr = netaddr.MustParseIP - // IPv4 wraps the netaddr.IPv4 function - IPv4 = netaddr.IPv4 - // AddrFrom16 wraps the netaddr.IPv6Raw function - AddrFrom16 = netaddr.IPv6Raw -)