Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b27a56a296 |
@@ -98,22 +98,22 @@ RUN gcc -static -O2 -Wall -Wextra -std=c99 \
|
|||||||
src/main.c src/config.c src/dm_admin.c src/request_validator.c \
|
src/main.c src/config.c src/dm_admin.c src/request_validator.c \
|
||||||
src/nip009.c src/nip011.c src/nip013.c src/nip040.c src/nip042.c \
|
src/nip009.c src/nip011.c src/nip013.c src/nip040.c src/nip042.c \
|
||||||
src/websockets.c src/subscriptions.c src/api.c src/embedded_web_content.c \
|
src/websockets.c src/subscriptions.c src/api.c src/embedded_web_content.c \
|
||||||
-o /build/c_relay_static_musl \
|
-o /build/c_relay_static \
|
||||||
nostr_core_lib/libnostr_core_x64.a \
|
nostr_core_lib/libnostr_core_x64.a \
|
||||||
-lwebsockets -lssl -lcrypto -lsqlite3 -lsecp256k1 \
|
-lwebsockets -lssl -lcrypto -lsqlite3 -lsecp256k1 \
|
||||||
-lcurl -lz -lpthread -lm -ldl
|
-lcurl -lz -lpthread -lm -ldl
|
||||||
|
|
||||||
# Strip binary to reduce size
|
# Strip binary to reduce size
|
||||||
RUN strip /build/c_relay_static_musl
|
RUN strip /build/c_relay_static
|
||||||
|
|
||||||
# Verify it's truly static
|
# Verify it's truly static
|
||||||
RUN echo "=== Binary Information ===" && \
|
RUN echo "=== Binary Information ===" && \
|
||||||
file /build/c_relay_static_musl && \
|
file /build/c_relay_static && \
|
||||||
ls -lh /build/c_relay_static_musl && \
|
ls -lh /build/c_relay_static && \
|
||||||
echo "=== Checking for dynamic dependencies ===" && \
|
echo "=== Checking for dynamic dependencies ===" && \
|
||||||
(ldd /build/c_relay_static_musl 2>&1 || echo "Binary is static") && \
|
(ldd /build/c_relay_static 2>&1 || echo "Binary is static") && \
|
||||||
echo "=== Build complete ==="
|
echo "=== Build complete ==="
|
||||||
|
|
||||||
# Output stage - just the binary
|
# Output stage - just the binary
|
||||||
FROM scratch AS output
|
FROM scratch AS output
|
||||||
COPY --from=builder /build/c_relay_static_musl /c_relay_static_musl
|
COPY --from=builder /build/c_relay_static /c_relay_static
|
||||||
@@ -53,17 +53,17 @@ ARCH=$(uname -m)
|
|||||||
case "$ARCH" in
|
case "$ARCH" in
|
||||||
x86_64)
|
x86_64)
|
||||||
PLATFORM="linux/amd64"
|
PLATFORM="linux/amd64"
|
||||||
OUTPUT_NAME="c_relay_static_musl_x86_64"
|
OUTPUT_NAME="c_relay_static_x86_64"
|
||||||
;;
|
;;
|
||||||
aarch64|arm64)
|
aarch64|arm64)
|
||||||
PLATFORM="linux/arm64"
|
PLATFORM="linux/arm64"
|
||||||
OUTPUT_NAME="c_relay_static_musl_arm64"
|
OUTPUT_NAME="c_relay_static_arm64"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "WARNING: Unknown architecture: $ARCH"
|
echo "WARNING: Unknown architecture: $ARCH"
|
||||||
echo "Defaulting to linux/amd64"
|
echo "Defaulting to linux/amd64"
|
||||||
PLATFORM="linux/amd64"
|
PLATFORM="linux/amd64"
|
||||||
OUTPUT_NAME="c_relay_static_musl_${ARCH}"
|
OUTPUT_NAME="c_relay_static_${ARCH}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -107,14 +107,14 @@ $DOCKER_CMD build \
|
|||||||
--platform "$PLATFORM" \
|
--platform "$PLATFORM" \
|
||||||
--target builder \
|
--target builder \
|
||||||
-f "$DOCKERFILE" \
|
-f "$DOCKERFILE" \
|
||||||
-t c-relay-musl-builder-stage:latest \
|
-t c-relay-static-builder-stage:latest \
|
||||||
. > /dev/null 2>&1
|
. > /dev/null 2>&1
|
||||||
|
|
||||||
# Create a temporary container to copy the binary
|
# Create a temporary container to copy the binary
|
||||||
CONTAINER_ID=$($DOCKER_CMD create c-relay-musl-builder-stage:latest)
|
CONTAINER_ID=$($DOCKER_CMD create c-relay-static-builder-stage:latest)
|
||||||
|
|
||||||
# Copy binary from container
|
# Copy binary from container
|
||||||
$DOCKER_CMD cp "$CONTAINER_ID:/build/c_relay_static_musl" "$BUILD_DIR/$OUTPUT_NAME" || {
|
$DOCKER_CMD cp "$CONTAINER_ID:/build/c_relay_static" "$BUILD_DIR/$OUTPUT_NAME" || {
|
||||||
echo "ERROR: Failed to extract binary from container"
|
echo "ERROR: Failed to extract binary from container"
|
||||||
$DOCKER_CMD rm "$CONTAINER_ID" 2>/dev/null
|
$DOCKER_CMD rm "$CONTAINER_ID" 2>/dev/null
|
||||||
exit 1
|
exit 1
|
||||||
@@ -180,7 +180,7 @@ echo "Binary: $BUILD_DIR/$OUTPUT_NAME"
|
|||||||
echo "Size: $(du -h "$BUILD_DIR/$OUTPUT_NAME" | cut -f1)"
|
echo "Size: $(du -h "$BUILD_DIR/$OUTPUT_NAME" | cut -f1)"
|
||||||
echo "Platform: $PLATFORM"
|
echo "Platform: $PLATFORM"
|
||||||
if [ "$TRULY_STATIC" = true ]; then
|
if [ "$TRULY_STATIC" = true ]; then
|
||||||
echo "Type: Fully static MUSL binary"
|
echo "Type: Fully static binary (Alpine MUSL-based)"
|
||||||
echo "Portability: Works on ANY Linux distribution"
|
echo "Portability: Works on ANY Linux distribution"
|
||||||
else
|
else
|
||||||
echo "Type: Static binary (may have minimal dependencies)"
|
echo "Type: Static binary (may have minimal dependencies)"
|
||||||
|
|||||||
@@ -163,14 +163,15 @@ rm -f db/c_nostr_relay.db* 2>/dev/null
|
|||||||
echo "Embedding web files..."
|
echo "Embedding web files..."
|
||||||
./embed_web_files.sh
|
./embed_web_files.sh
|
||||||
|
|
||||||
# Build the project first - use static build by default
|
# Build the project - ONLY static build
|
||||||
echo "Building project (static binary with SQLite JSON1 extension)..."
|
echo "Building project (static binary with SQLite JSON1 extension)..."
|
||||||
./build_static.sh
|
./build_static.sh
|
||||||
|
|
||||||
# Fallback to regular build if static build fails
|
# Exit if static build fails - no fallback
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Static build failed, falling back to regular build..."
|
echo "ERROR: Static build failed. Cannot proceed without static binary."
|
||||||
make clean all
|
echo "Please fix the build errors and try again."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore database files if preserving
|
# Restore database files if preserving
|
||||||
@@ -187,37 +188,32 @@ if [ $? -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if relay binary exists after build - prefer static binary, fallback to regular
|
# Check if static relay binary exists after build - ONLY use static binary
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
case "$ARCH" in
|
case "$ARCH" in
|
||||||
x86_64)
|
x86_64)
|
||||||
STATIC_BINARY="./build/c_relay_static_x86_64"
|
BINARY_PATH="./build/c_relay_static_x86_64"
|
||||||
REGULAR_BINARY="./build/c_relay_x86"
|
|
||||||
;;
|
;;
|
||||||
aarch64|arm64)
|
aarch64|arm64)
|
||||||
STATIC_BINARY="./build/c_relay_static_arm64"
|
BINARY_PATH="./build/c_relay_static_arm64"
|
||||||
REGULAR_BINARY="./build/c_relay_arm64"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
STATIC_BINARY="./build/c_relay_static_$ARCH"
|
BINARY_PATH="./build/c_relay_static_$ARCH"
|
||||||
REGULAR_BINARY="./build/c_relay_$ARCH"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Prefer static binary if available
|
# Verify static binary exists - no fallbacks
|
||||||
if [ -f "$STATIC_BINARY" ]; then
|
if [ ! -f "$BINARY_PATH" ]; then
|
||||||
BINARY_PATH="$STATIC_BINARY"
|
echo "ERROR: Static relay binary not found: $BINARY_PATH"
|
||||||
echo "Using static binary: $BINARY_PATH"
|
echo ""
|
||||||
elif [ -f "$REGULAR_BINARY" ]; then
|
echo "The relay requires the static binary with JSON1 support."
|
||||||
BINARY_PATH="$REGULAR_BINARY"
|
echo "Please run: ./build_static.sh"
|
||||||
echo "Using regular binary: $BINARY_PATH"
|
echo ""
|
||||||
else
|
|
||||||
echo "ERROR: No relay binary found. Checked:"
|
|
||||||
echo " - $STATIC_BINARY"
|
|
||||||
echo " - $REGULAR_BINARY"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Using static binary: $BINARY_PATH"
|
||||||
|
|
||||||
echo "Build successful. Proceeding with relay restart..."
|
echo "Build successful. Proceeding with relay restart..."
|
||||||
|
|
||||||
# Kill existing relay if running - start aggressive immediately
|
# Kill existing relay if running - start aggressive immediately
|
||||||
|
|||||||
28
test_results_20251011_105627.log
Normal file
28
test_results_20251011_105627.log
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
2025-10-11 10:56:27 - ==========================================
|
||||||
|
2025-10-11 10:56:27 - C-Relay Comprehensive Test Suite Runner
|
||||||
|
2025-10-11 10:56:27 - ==========================================
|
||||||
|
2025-10-11 10:56:27 - Relay URL: ws://127.0.0.1:8888
|
||||||
|
2025-10-11 10:56:27 - Log file: test_results_20251011_105627.log
|
||||||
|
2025-10-11 10:56:27 - Report file: test_report_20251011_105627.html
|
||||||
|
2025-10-11 10:56:27 -
|
||||||
|
2025-10-11 10:56:27 - Checking relay status at ws://127.0.0.1:8888...
|
||||||
|
2025-10-11 10:56:27 - \033[0;32m✓ Relay HTTP endpoint is accessible\033[0m
|
||||||
|
2025-10-11 10:56:27 -
|
||||||
|
2025-10-11 10:56:27 - Starting comprehensive test execution...
|
||||||
|
2025-10-11 10:56:27 -
|
||||||
|
2025-10-11 10:56:27 - \033[0;34m=== SECURITY TEST SUITES ===\033[0m
|
||||||
|
2025-10-11 10:56:27 - ==========================================
|
||||||
|
2025-10-11 10:56:27 - Running Test Suite: SQL Injection Tests
|
||||||
|
2025-10-11 10:56:27 - Description: Comprehensive SQL injection vulnerability testing
|
||||||
|
2025-10-11 10:56:27 - ==========================================
|
||||||
|
==========================================
|
||||||
|
C-Relay SQL Injection Test Suite
|
||||||
|
==========================================
|
||||||
|
Testing against relay at ws://127.0.0.1:8888
|
||||||
|
|
||||||
|
=== Basic Connectivity Test ===
|
||||||
|
Testing Basic connectivity... [0;32mPASSED[0m - Valid query works
|
||||||
|
|
||||||
|
=== Authors Filter SQL Injection Tests ===
|
||||||
|
Testing Authors filter with payload: '; DROP TABLE events; --... [1;33mUNCERTAIN[0m - Connection timeout (may indicate crash)
|
||||||
|
2025-10-11 10:56:32 - \033[0;31m✗ SQL Injection Tests FAILED\033[0m (Duration: 5s)
|
||||||
Reference in New Issue
Block a user