diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f40641e..5765215 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,9 @@ name: Test on: workflow_dispatch: # manually - pull_request: # default behaviour opened, reopened, synchronize, edited, ready_for_review + schedule: # nightly + - cron: "0 0 * * *" + pull_request: {} merge_group: branches: - main @@ -15,43 +17,32 @@ jobs: name: Native ${{ matrix.runs-on }} (Go ${{ matrix.go-version }}, CGO_ENABLED=${{ matrix.cgo_enabled }}) strategy: matrix: - 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" ] + 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: [ "0", "1" ] # test it compiles with and without cgo fail-fast: false runs-on: ${{ matrix.runs-on }} steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} cache: true - name: Go modules cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@v3 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 - ./gotestsum -- -v ${{ runner.os == 'Linux' && matrix.cgo_enabled == '1' && '-race' || '' }} ./... - env: - CGO_ENABLED: ${{ matrix.cgo_enabled }} + env CGO_ENABLED=${{ matrix.cgo_enabled }} ./gotestsum -- -v ./... || true # Same tests but on the official golang container for linux golang-linux-container: @@ -61,20 +52,21 @@ jobs: image: golang:${{ matrix.go-version }}-${{ matrix.distribution }} strategy: matrix: - go-version: [ "1.24", "1.23" ] - distribution: [ bookworm, bullseye, alpine ] + go-version: [ "1.21", "1.20", "1.19" ] + distribution: [ bookworm, bullseye, buster, alpine ] cgo_enabled: [ "0", "1" ] # test it compiles with and without cgo + exclude: + - go-version: 1.21 + distribution: buster fail-fast: false steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/checkout@v3 # Install gcc and the libc headers on alpine images - - if: matrix.distribution == 'alpine' - name: Install necessary packages (Alpine) + - if: ${{ matrix.distribution == 'alpine' }} run: apk add gcc musl-dev libc6-compat git - name: Go modules cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: go-pkg-mod-${{ hashFiles('**/go.sum') }} @@ -85,15 +77,35 @@ jobs: # Install gotestsum env GOBIN=$PWD go install gotest.tools/gotestsum@latest # Run the tests with gotestsum - ./gotestsum -- -v ${{ matrix.cgo_enabled == '1' && '-race' || '' }} ./... - env: - CGO_ENABLED: ${{ matrix.cgo_enabled }} + env CGO_ENABLED=${{ matrix.cgo_enabled }} ./gotestsum -- -v ./... || true + + linux-arm64: + name: Linux ARM64 (CGO_ENABLED=${{ matrix.cgo_enabled }}) + runs-on: ubuntu-latest + strategy: + matrix: + cgo_enabled: [ "0", "1" ] # test it compiles with and without the cgo + 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 ./... everything: name: All Tests needs: - native - golang-linux-container + - linux-arm64 runs-on: ubuntu-latest steps: - name: Completed diff --git a/.github/workflows/update-rules.yml b/.github/workflows/update-rules.yml new file mode 100644 index 0000000..9ea3917 --- /dev/null +++ b/.github/workflows/update-rules.yml @@ -0,0 +1,65 @@ +name: Update AppSec Rules +on: + workflow_dispatch: # manually + schedule: + - cron: "0 6 * * 1" # every Monday at 06:00 UTC + +jobs: + update: + runs-on: ubuntu-latest + outputs: + mutation_happened: ${{ steps.detect.outputs.mutation_happened }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + - name: Upgrade AppSec Rules + run: ./_tools/rules-updater/update.sh latest + env: + GITHUB_TOKEN: ${{ secrets.UPDATE_RULES_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + - name: Detect Updated Code + id: detect + run: |- + git add . + git diff --staged --patch --exit-code > ${{ runner.temp }}/repo.patch || echo "mutation_happened=true" >> $GITHUB_OUTPUT + - name: Upload Patch + if: steps.detect.outputs.mutation_happened + uses: actions/upload-artifact@v3 + with: + name: repo.patch + path: ${{ runner.temp }}/repo.patch + + create-pr: + needs: update + runs-on: ubuntu-latest + permissions: + contents: write + if: needs.update.outputs.mutation_happened + steps: + - uses: actions/checkout@v3 + - name: Download Patch + uses: actions/download-artifact@v3 + with: + name: repo.patch + path: ${{ runner.temp }} + - name: Apply Patch + id: apply + run: |- + git apply ${{ runner.temp }}/repo.patch + echo "version=$(jq -r '.metadata.rules_version' < ./appsec/rules.json)" >> $GITHUB_OUTPUT + - name: Configure git identity + run: |- + git config user.name "github-actions[bot] on behalf of ${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + - name: Push Changes + run: |- + git add . + git commit -m "Update embedded AppSec Rules" + git push --force-with-lease origin HEAD:automation/update-appsec-rules + - name: Create Pull Request + run: |- + gh pr create --title "Update embedded AppSec Rules to ${{ steps.apply.outputs.version }}" \ + --body "Automatically created by [GitHub Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." \ + --base "main" --head "automation/update-appsec-rules" \ + --reviewer "@DataDog/asm-go" + env: + GITHUB_TOKEN: ${{ secrets.MUTATOR_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/_tools/rules-updater/Dockerfile b/_tools/rules-updater/Dockerfile index 9655655..43f7e14 100644 --- a/_tools/rules-updater/Dockerfile +++ b/_tools/rules-updater/Dockerfile @@ -1,14 +1,13 @@ -# syntax=docker/dockerfile:1 -FROM golang:latest AS go-format +FROM golang:1.21 as go-format RUN apt update && apt install -y jq curl COPY writer/ /home/ WORKDIR /home/ ARG version +ARG GITHUB_TOKEN -RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ - if [ "${version}" = "latest" ]; then \ +RUN if [ "${version}" = "latest" ]; then \ curl \ --header "Authorization: Bearer ${GITHUB_TOKEN}" \ --header "X-Github-Api-Version: 2022-11-28" \ @@ -18,8 +17,7 @@ RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ echo "${version}" > .version; \ fi -RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ - curl \ +RUN 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" \ diff --git a/_tools/rules-updater/update.sh b/_tools/rules-updater/update.sh index 465c03d..34701b2 100755 --- a/_tools/rules-updater/update.sh +++ b/_tools/rules-updater/update.sh @@ -32,7 +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" --secret "id=GITHUB_TOKEN,env=GITHUB_TOKEN" --no-cache "$scriptDir" +DOCKER_BUILDKIT=1 docker build -o type=local,dest="$tmpDir" --build-arg version="$1" --build-arg GITHUB_TOKEN="${GITHUB_TOKEN}" --no-cache "$scriptDir" echo "================ Done ================" 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 652f904..c0a02f5 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 - "unsafe" -) +import _ "embed" // Blank import comment for golint compliance -var ( - //go:embed rules.json - staticRecommendedRules []byte +// 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 - // 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)) -) +// 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 diff --git a/apisec/internal/config/const.go b/apisec/internal/config/const.go deleted file mode 100644 index 6483f28..0000000 --- a/apisec/internal/config/const.go +++ /dev/null @@ -1,11 +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 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 deleted file mode 100644 index da0fa7f..0000000 --- a/apisec/internal/timed/clock.go +++ /dev/null @@ -1,42 +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 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 deleted file mode 100644 index 4a86f5d..0000000 --- a/apisec/internal/timed/lru.go +++ /dev/null @@ -1,211 +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 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 deleted file mode 100644 index c18ad49..0000000 --- a/apisec/internal/timed/lru_test.go +++ /dev/null @@ -1,111 +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 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 deleted file mode 100644 index cfc1c4d..0000000 --- a/apisec/internal/timed/table.go +++ /dev/null @@ -1,181 +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 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 deleted file mode 100644 index abd9305..0000000 --- a/apisec/internal/timed/table_test.go +++ /dev/null @@ -1,37 +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 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 deleted file mode 100644 index 7d4fc0b..0000000 --- a/apisec/internal/timed/testutil/fakeclock.go +++ /dev/null @@ -1,80 +0,0 @@ -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 deleted file mode 100644 index 76131f2..0000000 --- a/apisec/sampler.go +++ /dev/null @@ -1,98 +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 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 deleted file mode 100644 index f502958..0000000 --- a/apisec/sampler_test.go +++ /dev/null @@ -1,1324 +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 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 54cc54f..74a4739 100644 --- a/appsec/config.go +++ b/appsec/config.go @@ -13,7 +13,6 @@ import ( "unicode" "unicode/utf8" - "github.com/DataDog/appsec-internal-go/apisec" "github.com/DataDog/appsec-internal-go/log" ) @@ -21,12 +20,8 @@ import ( const ( // 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 is the env var used to set the sampling rate of API Security schema extraction 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 @@ -39,39 +34,27 @@ const ( 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 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` + 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 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,})` + 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 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. +// 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, type APISecConfig struct { - Sampler apisec.Sampler - Enabled bool - IsProxy bool - // Deprecated: use the new [APISecConfig.Sampler] instead. + Enabled bool SampleRate float64 } @@ -81,38 +64,15 @@ type ObfuscatorConfig struct { ValueRegex string } -type APISecOption func(*APISecConfig) - // NewAPISecConfig creates and returns a new API Security configuration by reading the env -func NewAPISecConfig(opts ...APISecOption) APISecConfig { - cfg := APISecConfig{ +func NewAPISecConfig() APISecConfig { + return APISecConfig{ Enabled: boolEnv(EnvAPISecEnabled, true), SampleRate: readAPISecuritySampleRate(), } - for _, opt := range opts { - opt(&cfg) - } - - 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) - if value == "" { - return DefaultAPISecSampleRate - } - rate, err := strconv.ParseFloat(value, 64) if err != nil { logEnvVarParsingError(EnvAPISecSampleRate, value, err, DefaultAPISecSampleRate) @@ -127,21 +87,6 @@ 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 { @@ -256,29 +201,3 @@ func boolEnv(key string, def bool) bool { } 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 c6cc762..c3c56c0 100644 --- a/appsec/config_test.go +++ b/appsec/config_test.go @@ -15,44 +15,71 @@ import ( func TestAPISecConfig(t *testing.T) { for _, tc := range []struct { - name string - enabledVar string - enabled bool + name string + enabledVar string + sampleRateVar string + enabled bool + sampleRate float64 }{ { name: "disabled", enabledVar: "false", + sampleRate: DefaultAPISecSampleRate, }, { name: "disabled", enabledVar: "0", + sampleRate: DefaultAPISecSampleRate, }, { - name: "enabled", - enabled: true, + name: "disabled", + enabledVar: "weirdvalue", + sampleRate: DefaultAPISecSampleRate, + }, + { + name: "enabled", + enabled: true, + sampleRate: DefaultAPISecSampleRate, }, { name: "enabled", enabledVar: "true", enabled: true, + sampleRate: DefaultAPISecSampleRate, }, { name: "enabled", enabledVar: "1", enabled: true, + sampleRate: DefaultAPISecSampleRate, }, { - name: "enabled", - enabledVar: "weirdvalue", - enabled: true, + name: "sampleRate 1.0", + sampleRateVar: "1.0", + enabled: true, + sampleRate: 1., + }, + { + name: "sampleRate 50.0", + sampleRateVar: "50.0", + enabled: true, + sampleRate: 1., + }, + { + name: "sampleRate -50.0", + sampleRateVar: "-50.0", + enabled: true, + sampleRate: 0., }, } { t.Run(tc.name, func(t *testing.T) { if len(tc.enabledVar) > 0 { t.Setenv(EnvAPISecEnabled, tc.enabledVar) } + t.Setenv(EnvAPISecSampleRate, tc.sampleRateVar) cfg := NewAPISecConfig() require.Equal(t, tc.enabled, cfg.Enabled) + require.Equal(t, tc.sampleRate, cfg.SampleRate) }) } } @@ -238,37 +265,3 @@ func TestRASPEnablement(t *testing.T) { 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 125f298..9617fb3 100644 --- a/appsec/embed.go +++ b/appsec/embed.go @@ -5,16 +5,16 @@ package appsec -import ( - _ "embed" // Blank import comment for golint compliance - "unsafe" -) +import _ "embed" // Blank import comment for golint compliance -var ( - //go:embed rules.json - staticRecommendedRules []byte +// StaticRecommendedRules holds the recommended AppSec security rules (v1.11.0) +// Source: https://github.com/DataDog/appsec-event-rules/blob/1.11.0/build/recommended.json +// +//go:embed rules.json +var StaticRecommendedRules 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)) -) +// 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 diff --git a/appsec/processors.json b/appsec/processors.json new file mode 100644 index 0000000..968c53d --- /dev/null +++ b/appsec/processors.json @@ -0,0 +1,208 @@ +{ + "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 50bc023..d2d672a 100644 --- a/appsec/rules.go +++ b/appsec/rules.go @@ -2,22 +2,32 @@ // 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) { - return staticRecommendedRules, nil + rules, err := DefaultRulesetMap() + if err != nil { + return nil, err + } + return json.Marshal(rules) } // DefaultRulesetMap returns the unmarshaled default recommended security rules for AppSec func DefaultRulesetMap() (map[string]any, error) { var rules map[string]any - if err := json.Unmarshal(staticRecommendedRules, &rules); err != nil { + var processors map[string]any + if err := json.Unmarshal([]byte(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 b39992a..7912743 100644 --- a/appsec/rules.json +++ b/appsec/rules.json @@ -1,7 +1,7 @@ { "version": "2.2", "metadata": { - "rules_version": "1.15.1" + "rules_version": "1.11.0" }, "rules": [ { @@ -9,8 +9,7 @@ "name": "Block IP Addresses", "tags": { "type": "block_ip", - "category": "security_response", - "module": "network-acl" + "category": "security_response" }, "conditions": [ { @@ -35,8 +34,7 @@ "name": "Block User Addresses", "tags": { "type": "block_user", - "category": "security_response", - "module": "authentication-acl" + "category": "security_response" }, "conditions": [ { @@ -66,8 +64,7 @@ "tool_name": "Acunetix", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -101,8 +98,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -166,8 +162,7 @@ "category": "attack_attempt", "cwe": "176", "capec": "1000/255/153/267/71", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -196,8 +191,7 @@ "crs_id": "921110", "category": "attack_attempt", "cwe": "444", - "capec": "1000/210/272/220/33", - "module": "waf" + "capec": "1000/210/272/220/33" }, "conditions": [ { @@ -234,8 +228,7 @@ "crs_id": "921160", "category": "attack_attempt", "cwe": "113", - "capec": "1000/210/272/220/105", - "module": "waf" + "capec": "1000/210/272/220/105" }, "conditions": [ { @@ -270,8 +263,7 @@ "category": "attack_attempt", "cwe": "22", "capec": "1000/255/153/126", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -305,8 +297,7 @@ "category": "attack_attempt", "cwe": "22", "capec": "1000/255/153/126", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -1812,8 +1803,7 @@ "category": "attack_attempt", "cwe": "98", "capec": "1000/152/175/253/193", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -1841,8 +1831,7 @@ "crs_id": "931120", "category": "attack_attempt", "cwe": "98", - "capec": "1000/152/175/253/193", - "module": "waf" + "capec": "1000/152/175/253/193" }, "conditions": [ { @@ -1887,8 +1876,7 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -1933,6 +1921,7 @@ "$ifs", "$oldpwd", "$ostype", + "$path", "$pwd", "dev/fd/", "dev/null", @@ -2400,8 +2389,7 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2449,8 +2437,7 @@ "category": "attack_attempt", "cwe": "706", "capec": "1000/225/122/17/177", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2514,8 +2501,7 @@ "category": "attack_attempt", "cwe": "434", "capec": "1000/225/122/17/650", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2568,8 +2554,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2636,8 +2621,7 @@ "crs_id": "933131", "category": "attack_attempt", "cwe": "94", - "capec": "1000/225/122/17/650", - "module": "waf" + "capec": "1000/225/122/17/650" }, "conditions": [ { @@ -2682,8 +2666,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2727,8 +2710,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/225/122/17/650", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2818,8 +2800,7 @@ "crs_id": "933160", "category": "attack_attempt", "cwe": "94", - "capec": "1000/225/122/17/650", - "module": "waf" + "capec": "1000/225/122/17/650" }, "conditions": [ { @@ -2844,7 +2825,7 @@ "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+(?:\\(.*\\))?)?)?\\)\\s*(?:[;\\.)}\\]|\\\\]|\\?>|%>|$)", + "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+(?:\\(.*\\))?)?)?\\)", "options": { "case_sensitive": true, "min_length": 5 @@ -2864,8 +2845,7 @@ "category": "attack_attempt", "cwe": "502", "capec": "1000/152/586", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -2912,8 +2892,7 @@ "crs_id": "933200", "category": "attack_attempt", "cwe": "502", - "capec": "1000/152/586", - "module": "waf" + "capec": "1000/152/586" }, "conditions": [ { @@ -2959,8 +2938,7 @@ "crs_id": "934100", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -2985,7 +2963,7 @@ "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\\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*\\[)", + "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*\\[)", "options": { "case_sensitive": true, "min_length": 3 @@ -3005,8 +2983,7 @@ "category": "attack_attempt", "confidence": "1", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -3048,8 +3025,7 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3106,8 +3082,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3166,8 +3141,7 @@ "category": "attack_attempt", "cwe": "84", "capec": "1000/152/242/63/591/244", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3226,8 +3200,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3285,8 +3258,7 @@ "crs_id": "941180", "category": "attack_attempt", "cwe": "79", - "capec": "1000/152/242/63/591", - "module": "waf" + "capec": "1000/152/242/63/591" }, "conditions": [ { @@ -3340,8 +3312,7 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3388,8 +3359,7 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3436,8 +3406,7 @@ "category": "attack_attempt", "cwe": "80", "capec": "1000/152/242/63/591", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3484,8 +3453,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3531,8 +3499,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3579,8 +3546,7 @@ "crs_id": "941270", "category": "attack_attempt", "cwe": "83", - "capec": "1000/152/242/63/591/243", - "module": "waf" + "capec": "1000/152/242/63/591/243" }, "conditions": [ { @@ -3623,8 +3589,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3670,8 +3635,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3717,8 +3681,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3764,8 +3727,7 @@ "category": "attack_attempt", "cwe": "87", "capec": "1000/152/242/63/591/199", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3809,8 +3771,7 @@ "crs_id": "941360", "category": "attack_attempt", "cwe": "87", - "capec": "1000/152/242/63/591/199", - "module": "waf" + "capec": "1000/152/242/63/591/199" }, "conditions": [ { @@ -3855,8 +3816,7 @@ "category": "attack_attempt", "confidence": "1", "cwe": "79", - "capec": "1000/152/242/63/591", - "module": "waf" + "capec": "1000/152/242/63/591" }, "conditions": [ { @@ -3900,8 +3860,7 @@ "crs_id": "942100", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66", - "module": "waf" + "capec": "1000/152/248/66" }, "conditions": [ { @@ -3940,8 +3899,7 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -3986,8 +3944,7 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4030,8 +3987,7 @@ "crs_id": "942250", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66", - "module": "waf" + "capec": "1000/152/248/66" }, "conditions": [ { @@ -4075,8 +4031,7 @@ "crs_id": "942270", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66", - "module": "waf" + "capec": "1000/152/248/66" }, "conditions": [ { @@ -4120,8 +4075,7 @@ "category": "attack_attempt", "cwe": "89", "capec": "1000/152/248/66/7", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4164,8 +4118,7 @@ "crs_id": "942290", "category": "attack_attempt", "cwe": "943", - "capec": "1000/152/248/676", - "module": "waf" + "capec": "1000/152/248/676" }, "conditions": [ { @@ -4211,8 +4164,7 @@ "crs_id": "942360", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66/470", - "module": "waf" + "capec": "1000/152/248/66/470" }, "conditions": [ { @@ -4255,8 +4207,7 @@ "crs_id": "942500", "category": "attack_attempt", "cwe": "89", - "capec": "1000/152/248/66", - "module": "waf" + "capec": "1000/152/248/66" }, "conditions": [ { @@ -4301,8 +4252,7 @@ "category": "attack_attempt", "cwe": "384", "capec": "1000/225/21/593/61", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4347,8 +4297,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4396,8 +4345,7 @@ "type": "java_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -4444,8 +4392,7 @@ "crs_id": "944130", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -4583,8 +4530,7 @@ "type": "nosql_injection", "category": "attack_attempt", "cwe": "943", - "capec": "1000/152/248/676", - "module": "waf" + "capec": "1000/152/248/676" }, "conditions": [ { @@ -4628,8 +4574,7 @@ "type": "java_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -4675,8 +4620,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4752,8 +4696,7 @@ "category": "attack_attempt", "cwe": "1321", "capec": "1000/152/242", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4783,8 +4726,7 @@ "category": "attack_attempt", "cwe": "1321", "capec": "1000/152/242", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4828,8 +4770,7 @@ "category": "attack_attempt", "cwe": "1336", "capec": "1000/152/242/19", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4864,36 +4805,6 @@ ], "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", @@ -4903,8 +4814,7 @@ "tool_name": "BurpCollaborator", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -4948,8 +4858,7 @@ "tool_name": "Qualys", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -4993,8 +4902,7 @@ "tool_name": "Probely", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5037,8 +4945,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -5081,8 +4988,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5126,8 +5032,7 @@ "tool_name": "Rapid7", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5171,8 +5076,7 @@ "tool_name": "interact.sh", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -5216,8 +5120,7 @@ "tool_name": "Netsparker", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5265,8 +5168,7 @@ "tool_name": "WhiteHatSecurity", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5314,8 +5216,7 @@ "tool_name": "Nessus", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5363,8 +5264,7 @@ "tool_name": "Watchtowr", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5412,8 +5312,7 @@ "tool_name": "AppCheckNG", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5452,82 +5351,6 @@ ], "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", @@ -5536,10 +5359,8 @@ "category": "attack_attempt", "cwe": "287", "capec": "1000/225/115", - "confidence": "0", - "module": "waf" + "confidence": "0" }, - "max_version": "1.24.9", "conditions": [ { "parameters": { @@ -5572,8 +5393,7 @@ "category": "attack_attempt", "cwe": "98", "capec": "1000/152/175/253/193", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -5617,8 +5437,7 @@ "category": "attack_attempt", "cwe": "77", "capec": "1000/152/248/88", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -5657,52 +5476,6 @@ ], "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", @@ -5711,8 +5484,7 @@ "category": "attack_attempt", "cwe": "91", "capec": "1000/152/248/250", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -5750,8 +5522,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -5809,8 +5580,7 @@ "category": "attack_attempt", "cwe": "83", "capec": "1000/152/242/63/591/243", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6079,8 +5849,7 @@ "/website.php", "/stats.php", "/assets/plugins/mp3_id/mp3_id.php", - "/siteminderagent/forms/smpwservices.fcc", - "/eval-stdin.php" + "/siteminderagent/forms/smpwservices.fcc" ] } } @@ -6097,8 +5866,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6140,8 +5908,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6183,8 +5950,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6226,8 +5992,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6269,8 +6034,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6295,7 +6059,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)([?#&/]|$)", + "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_]|$)", "options": { "case_sensitive": false } @@ -6312,8 +6076,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6355,8 +6118,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6398,8 +6160,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6441,8 +6202,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -6467,7 +6227,7 @@ "address": "server.request.uri.raw" } ], - "regex": "(?:^|/)(?:swagger|api[-/]?docs?|openapi)\\b", + "regex": "(?:/swagger\\b|/api[-/]docs?\\b)", "options": { "case_sensitive": false } @@ -6476,265 +6236,6 @@ ], "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", @@ -6743,8 +6244,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6788,8 +6288,7 @@ "type": "js_code_injection", "category": "attack_attempt", "cwe": "94", - "capec": "1000/152/242", - "module": "waf" + "capec": "1000/152/242" }, "conditions": [ { @@ -6834,8 +6333,7 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6878,8 +6376,7 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6924,8 +6421,7 @@ "category": "attack_attempt", "cwe": "78", "capec": "1000/152/248/88", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -6968,8 +6464,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7012,8 +6507,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7055,8 +6549,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7098,8 +6591,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7127,7 +6619,7 @@ "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|dnslog\\.\\w+)" + "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)" }, "operator": "match_regex" } @@ -7142,8 +6634,7 @@ "category": "attack_attempt", "cwe": "918", "capec": "1000/225/115/664", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7185,8 +6676,7 @@ "category": "attack_attempt", "cwe": "94", "capec": "1000/152/242", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7232,8 +6722,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Joomla exploitation tool", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7262,8 +6751,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nessus", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7292,8 +6780,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Arachni", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7322,8 +6809,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Jorgee", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7352,8 +6838,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Probely", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7382,8 +6867,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Metis", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7412,8 +6896,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLPowerInjector", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7442,8 +6925,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "N-Stealth", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7472,8 +6954,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Brutus", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7501,8 +6982,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7531,8 +7011,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Netsparker", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7561,8 +7040,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "JAASCois", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7591,8 +7069,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nsauditor", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7621,8 +7098,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Paros", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7651,8 +7127,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "DirBuster", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7681,8 +7156,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Pangolin", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7711,8 +7185,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Qualys", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -7741,8 +7214,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLNinja", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7771,8 +7243,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nikto", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7801,8 +7272,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "BlackWidow", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7831,8 +7301,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Grendel-Scan", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7861,8 +7330,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Havij", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7891,8 +7359,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "w3af", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7921,8 +7388,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nmap", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7935,7 +7401,7 @@ ] } ], - "regex": "nmap (nse|scripting engine|icap-client/)" + "regex": "nmap (nse|scripting engine)" }, "operator": "match_regex" } @@ -7951,8 +7417,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nessus", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -7981,8 +7446,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "EvilScanner", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8011,8 +7475,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "WebFuck", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8041,8 +7504,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "OpenVAS", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8071,8 +7533,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Spider-Pig", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8101,8 +7562,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Zgrab", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8131,8 +7591,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Zmeu", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8161,8 +7620,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "GoogleSecurityScanner", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -8191,8 +7649,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Commix", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8221,8 +7678,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Gobuster", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8251,8 +7707,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "CGIchk", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8281,8 +7736,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "FFUF", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8311,8 +7765,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nuclei", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8341,8 +7794,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Tsunami", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8371,8 +7823,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Nimbostratus", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8401,8 +7852,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Datadog Canary Test", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8437,8 +7887,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Datadog Canary Test", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8476,8 +7925,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "AlertLogic", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -8506,8 +7954,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "wfuzz", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8536,8 +7983,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Detectify", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -8566,8 +8012,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "BSQLBF", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8596,8 +8041,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "masscan", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8626,8 +8070,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "WPScan", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8656,8 +8099,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Aon", - "confidence": "0", - "module": "waf" + "confidence": "0" }, "conditions": [ { @@ -8686,8 +8128,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "feroxbuster", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8707,126 +8148,6 @@ ], "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", @@ -8835,8 +8156,7 @@ "category": "attack_attempt", "cwe": "200", "capec": "1000/118/169", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8868,8 +8188,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "SQLmap", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8898,8 +8217,7 @@ "cwe": "200", "capec": "1000/118/169", "tool_name": "Skipfish", - "confidence": "1", - "module": "waf" + "confidence": "1" }, "conditions": [ { @@ -8920,306 +8238,7 @@ "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", @@ -9369,126 +8388,9 @@ }, "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)", @@ -10255,52 +9157,6 @@ "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", @@ -10501,4 +9357,4 @@ } } ] -} +} \ No newline at end of file diff --git a/appsec/rules_test.go b/appsec/rules_test.go deleted file mode 100644 index f03545b..0000000 --- a/appsec/rules_test.go +++ /dev/null @@ -1,24 +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 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 9aa23ba..971552b 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/DataDog/appsec-internal-go -go 1.23.0 +go 1.19 require ( - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.8.4 go.uber.org/goleak v1.3.0 ) @@ -13,5 +13,3 @@ require ( github.com/pmezard/go-difflib v1.0.0 // 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 7dbe38a..5f88626 100644 --- a/go.sum +++ b/go.sum @@ -2,17 +2,15 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 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/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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 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= diff --git a/limiter/limiter.go b/limiter/limiter.go index fbe4f3e..f1f16d3 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -28,21 +28,14 @@ type Limiter interface { type TokenTicker 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 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 @@ -51,7 +44,7 @@ func NewTokenTickerWithInterval(tokens, maxTokens int64, interval time.Duration) // 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(startTime time.Time, ticksChan <-chan time.Time, stopChan <-chan struct{}, syncChan chan<- struct{}) { - nsPerToken := t.interval.Nanoseconds() / t.maxTokens + nsPerToken := time.Second.Nanoseconds() / t.maxTokens elapsedNs := int64(0) prevStamp := startTime diff --git a/limiter/limiter_test.go b/limiter/limiter_test.go index 7d0467c..6eaa3b3 100644 --- a/limiter/limiter_test.go +++ b/limiter/limiter_test.go @@ -349,47 +349,3 @@ func (t *TestTicker) tick(delta time.Duration) { 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") - }) -}