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:
@@ -0,0 +1,28 @@
|
||||
// gt-0012: Compile-time constant false condition
|
||||
// Expected: UNREACHABLE (tier: imported)
|
||||
// Vulnerability: CWE-120 (Buffer Overflow)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG_MODE 0 // Compile-time constant
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char buffer[64];
|
||||
|
||||
// This branch is constant false - will be optimized out
|
||||
if (DEBUG_MODE) {
|
||||
// Vulnerable code in dead branch
|
||||
gets(buffer); // SINK: CWE-120 (but unreachable)
|
||||
printf("Debug: %s\n", buffer);
|
||||
} else {
|
||||
// Safe path always taken
|
||||
if (argc > 1) {
|
||||
strncpy(buffer, argv[1], sizeof(buffer) - 1);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
printf("Input: %s\n", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user