feat: add constant-time credential comparison, rate limiting, SSL hostname verification, and update coverage threshold to 69%
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+14
-12
@@ -15,6 +15,8 @@
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define IGNORE_RESULT(x) do { if (x) {} } while(0)
|
||||
|
||||
extern connection_t connections[MAX_FDS];
|
||||
extern int epoll_fd;
|
||||
|
||||
@@ -938,7 +940,7 @@ void test_connection_buffer_compaction(void) {
|
||||
conn.read_buf.tail = 2500;
|
||||
|
||||
const char *test_data = "Test data for compaction";
|
||||
write(sockfd[1], test_data, strlen(test_data));
|
||||
IGNORE_RESULT(write(sockfd[1], test_data, strlen(test_data)));
|
||||
|
||||
int bytes = connection_do_read(&conn);
|
||||
TEST_ASSERT(bytes > 0 || (bytes < 0 && conn.read_buf.head < 2000), "Buffer compacted or data read");
|
||||
@@ -1266,7 +1268,7 @@ void test_connection_do_read_grow_buffer(void) {
|
||||
|
||||
char large_data[128];
|
||||
memset(large_data, 'A', sizeof(large_data));
|
||||
write(sockfd[1], large_data, sizeof(large_data));
|
||||
IGNORE_RESULT(write(sockfd[1], large_data, sizeof(large_data)));
|
||||
|
||||
int bytes = connection_do_read(&conn);
|
||||
TEST_ASSERT(bytes > 0 || conn.read_buf.capacity > 64, "Buffer grew or data read");
|
||||
@@ -1297,7 +1299,7 @@ void test_connection_close_with_splice_pipes(void) {
|
||||
buffer_init(&conn->write_buf, 4096);
|
||||
|
||||
int pipefd[2];
|
||||
pipe(pipefd);
|
||||
IGNORE_RESULT(pipe(pipefd));
|
||||
conn->splice_pipe[0] = pipefd[0];
|
||||
conn->splice_pipe[1] = pipefd[1];
|
||||
conn->can_splice = 1;
|
||||
@@ -1439,7 +1441,7 @@ void test_connection_handle_event_client_read(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *partial_request = "GET / HTTP/1.1\r\n";
|
||||
write(sockfd[1], partial_request, strlen(partial_request));
|
||||
IGNORE_RESULT(write(sockfd[1], partial_request, strlen(partial_request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1485,7 +1487,7 @@ void test_connection_handle_complete_request(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *request = "GET / HTTP/1.1\r\nHost: test.example.com\r\n\r\n";
|
||||
write(sockfd[1], request, strlen(request));
|
||||
IGNORE_RESULT(write(sockfd[1], request, strlen(request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1531,7 +1533,7 @@ void test_connection_handle_dashboard_request(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *request = "GET /rproxy/dashboard HTTP/1.1\r\nHost: localhost\r\n\r\n";
|
||||
write(sockfd[1], request, strlen(request));
|
||||
IGNORE_RESULT(write(sockfd[1], request, strlen(request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1577,7 +1579,7 @@ void test_connection_handle_stats_api(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *request = "GET /rproxy/api/stats HTTP/1.1\r\nHost: localhost\r\n\r\n";
|
||||
write(sockfd[1], request, strlen(request));
|
||||
IGNORE_RESULT(write(sockfd[1], request, strlen(request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1629,7 +1631,7 @@ void test_connection_handle_oversized_header(void) {
|
||||
huge_header[2] = 'T';
|
||||
huge_header[3] = ' ';
|
||||
huge_header[sizeof(huge_header)-1] = '\0';
|
||||
write(sockfd[1], huge_header, sizeof(huge_header) - 1);
|
||||
IGNORE_RESULT(write(sockfd[1], huge_header, sizeof(huge_header) - 1));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1675,7 +1677,7 @@ void test_connection_handle_empty_host(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *request = "GET / HTTP/1.1\r\n\r\n";
|
||||
write(sockfd[1], request, strlen(request));
|
||||
IGNORE_RESULT(write(sockfd[1], request, strlen(request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1721,7 +1723,7 @@ void test_connection_handle_malformed_request(void) {
|
||||
conn->epoll_events = EPOLLIN;
|
||||
|
||||
const char *request = "INVALID REQUEST\r\n\r\n";
|
||||
write(sockfd[1], request, strlen(request));
|
||||
IGNORE_RESULT(write(sockfd[1], request, strlen(request)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1839,7 +1841,7 @@ void test_connection_handle_forwarding_state(void) {
|
||||
upstream->epoll_events = EPOLLIN;
|
||||
|
||||
const char *response = "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK";
|
||||
write(sockfd2[1], response, strlen(response));
|
||||
IGNORE_RESULT(write(sockfd2[1], response, strlen(response)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd2[0] };
|
||||
connection_handle_event(&event);
|
||||
@@ -1976,7 +1978,7 @@ void test_connection_handle_client_forwarding_read(void) {
|
||||
upstream->epoll_events = EPOLLIN;
|
||||
|
||||
const char *data = "More client data\r\n";
|
||||
write(sockfd1[1], data, strlen(data));
|
||||
IGNORE_RESULT(write(sockfd1[1], data, strlen(data)));
|
||||
|
||||
struct epoll_event event = { .events = EPOLLIN, .data.fd = sockfd1[0] };
|
||||
connection_handle_event(&event);
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user