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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/understand/weblogs/end-to-end_weblog.md
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,11 @@ Additionally, the method supports the following query parameters to use the sdk

These endpoints are used for the `Dynamic Instrumentation` tests.

#### GET /debugger/budgets/<loops>

Executes the same probe line `loops` times during one request. It is used to verify per-probe and global
Dynamic Instrumentation rate limits.

#### GET /debugger/snapshot/capture-timeout

Creates a collection containing `collectionSize` object chains. Each chain has a leaf wrapped by
Expand Down
4 changes: 3 additions & 1 deletion tests/debugger/test_debugger_guardrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# characters already blow past any evaluation-time budget. Keep it small so the value fits
# comfortably in the request URL.
REDOS_INPUT_LENGTH = 25
# Keep this large enough that optimized runtimes cannot finish the full filter inside the smallest supported budget.
EVALUATION_TIMEOUT_COLLECTION_SIZE = 1_000_000
GUARDRAILS_RFC = "https://docs.google.com/document/d/1OhCH3SMuS_B4Ickays94GpqDlqKcc9b9gLos1T85F-Q/edit?usp=sharing"


Expand Down Expand Up @@ -63,7 +65,7 @@ def setup_evaluation_timeout_collection_filter(self) -> None:
self._setup_evaluation_timeout(
"probe_evaluation_timeout_collection_filter",
"SnapshotLimits",
"/debugger/snapshot/limits?collectionSize=100000",
f"/debugger/snapshot/limits?collectionSize={EVALUATION_TIMEOUT_COLLECTION_SIZE}",
)

def test_evaluation_timeout_collection_filter(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/debugger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def initialize_weblog_remote_config(self) -> None:
def method_and_language_to_line_number(self, method: str, language: str) -> list:
"""method_and_language_to_line_number returns the respective line number given the method and language"""
definitions: dict[str, dict[str, list[int]]] = {
"Budgets": {"java": [140], "dotnet": [138], "python": [144], "golang": [117]},
"Budgets": {"java": [140], "dotnet": [138], "python": [144], "golang": [117], "nodejs": [163]},
"LogProbe": {"nodejs": [20]},
"Pii": {"java": [66], "dotnet": [66], "python": [66], "ruby": [66], "nodejs": [64]},
"Expression": {"java": [73], "dotnet": [76], "python": [74], "ruby": [82], "nodejs": [82], "golang": [71]},
Expand All @@ -204,7 +204,7 @@ def method_and_language_to_line_number(self, method: str, language: str) -> list
"CollectionOperations": {"java": [116], "dotnet": [116], "python": [125], "ruby": [162], "nodejs": [120]},
"Nulls": {"java": [132], "dotnet": [129], "python": [138], "ruby": [192], "nodejs": [126]},
"SnapshotLimits": {"java": [155], "python": [174], "nodejs": [136], "ruby": [233], "dotnet": [152]},
"CaptureTimeout": {"java": [174], "nodejs": [155], "dotnet": [173]},
"CaptureTimeout": {"java": [174], "nodejs": [157], "dotnet": [173]},
}

return definitions.get(method, {}).get(language, [])
Expand Down
12 changes: 11 additions & 1 deletion utils/build/docker/nodejs/express/debugger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ module.exports = {
const nestingDepth = parseInt(req.query.nestingDepth, 10) || 0
res.send(captureTimeoutFixture(collectionSize, nestingDepth))
})

app.get('/debugger/budgets/:loops', budgets)
}
}

Expand All @@ -152,5 +154,13 @@ function captureTimeoutFixture (collectionSize, nestingDepth) {
}
return nested
})
return 'Capture timeout probe' // This needs to be line 155
return 'Capture timeout probe' // This needs to be line 157
}

function budgets (request, reply) {
const loops = Number(request.params.loops)
for (let iteration = 0; iteration < loops; iteration++) {
const currentIteration = iteration // This needs to be line 163
}
return reply.send('Budgets')
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export function initRoutes (app: Express) {
const nestingDepth = parseInt(req.query.nestingDepth as string, 10) || 0
res.send(captureTimeoutFixture(collectionSize, nestingDepth))
})

app.get('/debugger/budgets/:loops', budgets)
}

function captureTimeoutFixture (collectionSize: number, nestingDepth: number): string {
Expand All @@ -152,5 +154,13 @@ function captureTimeoutFixture (collectionSize: number, nestingDepth: number): s
return nested
})

return 'Capture timeout probe' // This needs to be line 155
return 'Capture timeout probe' // This needs to be line 157
}

function budgets (request: Request, reply: Response): Response {
const loops = Number(request.params.loops)
for (let iteration = 0; iteration < loops; iteration++) {
const currentIteration = iteration // This needs to be line 163
}
return reply.send('Budgets')
}
12 changes: 11 additions & 1 deletion utils/build/docker/nodejs/fastify/debugger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ module.exports = {
const nestingDepth = parseInt(request.query.nestingDepth, 10) || 0
return captureTimeoutFixture(collectionSize, nestingDepth)
})

fastify.get('/debugger/budgets/:loops', budgets)
}
}

Expand All @@ -152,5 +154,13 @@ function captureTimeoutFixture (collectionSize, nestingDepth) {
}
return nested
})
return 'Capture timeout probe' // This needs to be line 155
return 'Capture timeout probe' // This needs to be line 157
}

function budgets (request, reply) {
const loops = Number(request.params.loops)
for (let iteration = 0; iteration < loops; iteration++) {
const currentIteration = iteration // This needs to be line 163
}
return reply.send('Budgets')
}
Loading