feat(rate-limiting): Implement core rate limiting functionality with configuration, decision-making, metrics, middleware, and service registration
- Add RateLimitConfig for configuration management with YAML binding support. - Introduce RateLimitDecision to encapsulate the result of rate limit checks. - Implement RateLimitMetrics for OpenTelemetry metrics tracking. - Create RateLimitMiddleware for enforcing rate limits on incoming requests. - Develop RateLimitService to orchestrate instance and environment rate limit checks. - Add RateLimitServiceCollectionExtensions for dependency injection registration.
This commit is contained in:
31
datasets/reachability/ground-truth/basic/gt-0005/main.c
Normal file
31
datasets/reachability/ground-truth/basic/gt-0005/main.c
Normal file
@@ -0,0 +1,31 @@
|
||||
// gt-0005: Recursive function with sink
|
||||
// Expected: REACHABLE (tier: executed)
|
||||
// Vulnerability: CWE-134 (Format String)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char result[1024];
|
||||
|
||||
void process_recursive(const char *input, int depth) {
|
||||
if (depth <= 0 || strlen(input) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Vulnerable: format string in recursive context
|
||||
sprintf(result + strlen(result), input); // SINK: CWE-134
|
||||
|
||||
// Recurse with modified input
|
||||
process_recursive(input + 1, depth - 1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
result[0] = '\0';
|
||||
|
||||
if (argc > 1) {
|
||||
process_recursive(argv[1], 5);
|
||||
printf("Result: %s\n", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://stellaops.io/schemas/sample-manifest.v1.json",
|
||||
"sampleId": "gt-0005",
|
||||
"version": "1.0.0",
|
||||
"category": "basic",
|
||||
"description": "Recursive function with sink - REACHABLE",
|
||||
"language": "c",
|
||||
"expectedResult": {
|
||||
"reachable": true,
|
||||
"tier": "executed",
|
||||
"confidence": 1.0
|
||||
},
|
||||
"source": {
|
||||
"files": ["main.c"],
|
||||
"entrypoint": "main",
|
||||
"sink": "sprintf",
|
||||
"vulnerability": "CWE-134"
|
||||
},
|
||||
"callChain": [
|
||||
{"function": "main", "file": "main.c", "line": 22},
|
||||
{"function": "process_recursive", "file": "main.c", "line": 14},
|
||||
{"function": "process_recursive", "file": "main.c", "line": 14},
|
||||
{"function": "sprintf", "file": "<libc>", "line": null}
|
||||
],
|
||||
"annotations": {
|
||||
"notes": "Recursive call pattern - tests loop/recursion handling",
|
||||
"difficulty": "medium"
|
||||
},
|
||||
"createdAt": "2025-12-17T00:00:00Z",
|
||||
"createdBy": "corpus-team"
|
||||
}
|
||||
Reference in New Issue
Block a user