Skip to content

reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities

feat: add testing infrastructure, helpers, and documentation

six2dezde86f1f23f23
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..e44341e
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,27 @@
+# See https://pre-commit.com for more information
+# Install: pip install pre-commit && pre-commit install
+repos:
+ - repo: https://github.com/koalaman/shellcheck-precommit
+ rev: v0.9.0
+ hooks:
+ - id: shellcheck
+ args: ["--severity=error"]
+ files: \.(sh|bash)$
+ exclude: ^tests/mocks/
+
+ - repo: https://github.com/scop/pre-commit-shfmt
+ rev: v3.7.0-1
+ hooks:
+ - id: shfmt
+ args: ["-i", "4", "-ci", "-bn"]
+ files: \.(sh|bash)$
+ exclude: ^tests/mocks/
+
+ - repo: local
+ hooks:
+ - id: bats-tests
+ name: Run bats tests
+ entry: bash -c 'bats tests/unit/'
+ language: system
+ pass_filenames: false
+ files: \.(sh|bash|bats)$
diff --git a/Makefile b/Makefile
index ca331c3..620db8e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,22 @@
GH_CLI := $(shell command -v gh 2> /dev/null)
PRIVATE_REPO := $(shell echo $${PRIV_REPO-reconftw-data})
-.PHONY: sync upload bootstrap rm lint fmt test test-all
+.PHONY: sync upload bootstrap rm lint lint-fix fmt test test-all test-security setup-dev help
+
+help:
+ @echo "reconFTW Development Commands"
+ @echo ""
+ @echo " make test - Run unit tests"
+ @echo " make test-all - Run all tests (unit + integration)"
+ @echo " make test-security - Run security tests"
+ @echo " make lint - Check code with shellcheck"
+ @echo " make lint-fix - Show shellcheck issues with context"
+ @echo " make fmt - Format code with shfmt"
+ @echo " make setup-dev - Install pre-commit hooks"
+ @echo ""
+ @echo " make bootstrap - Create private data repo"
+ @echo " make sync - Sync with upstream"
+ @echo " make upload - Upload data to private repo"
# bootstrap a private repo to store data
bootstrap:
@@ -32,16 +47,26 @@ upload:
lint:
@if command -v shellcheck >/dev/null 2>&1; then \
- shellcheck -S warning reconftw.sh modules/*.sh install.sh; \
+ shellcheck -S error reconftw.sh modules/*.sh lib/*.sh install.sh; \
else \
echo "shellcheck not found. Install: https://www.shellcheck.net/"; \
+ exit 1; \
+ fi
+
+lint-fix:
+ @if command -v shellcheck >/dev/null 2>&1; then \
+ shellcheck -S warning -f gcc reconftw.sh modules/*.sh lib/*.sh install.sh; \
+ else \
+ echo "shellcheck not found. Install: https://www.shellcheck.net/"; \
+ exit 1; \
fi
fmt:
@if command -v shfmt >/dev/null 2>&1; then \
- shfmt -w -i 4 -bn -ci install.sh reconftw.sh modules/*.sh; \
+ shfmt -w -i 4 -bn -ci install.sh reconftw.sh modules/*.sh lib/*.sh; \
else \
echo "shfmt not found. Install: https://github.com/mvdan/sh"; \
+ exit 1; \
fi
test:
@@ -49,11 +74,30 @@ test:
bats tests/unit/*.bats; \
else \
echo "bats-core not found. Install: https://github.com/bats-core/bats-core"; \
+ exit 1; \
+ fi
+
+test-security:
+ @if command -v bats >/dev/null 2>&1; then \
+ bats tests/security/*.bats; \
+ else \
+ echo "bats-core not found. Install: https://github.com/bats-core/bats-core"; \
+ exit 1; \
fi
test-all:
@if command -v bats >/dev/null 2>&1; then \
- bats tests/unit/*.bats tests/integration/*.bats; \
+ bats tests/unit/*.bats tests/security/*.bats; \
else \
echo "bats-core not found. Install: https://github.com/bats-core/bats-core"; \
+ exit 1; \
+ fi
+
+setup-dev:
+ @if command -v pre-commit >/dev/null 2>&1; then \
+ pre-commit install; \
+ echo "Pre-commit hooks installed!"; \
+ else \
+ echo "pre-commit not found. Install: pip install pre-commit"; \
+ exit 1; \
fi
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
new file mode 100644
index 0000000..d1e5143
--- /dev/null
+++ b/docs/ARCHITECTURE.md
@@ -0,0 +1,100 @@
+# reconFTW Architecture
+
+## Overview
+
+reconFTW is a modular reconnaissance framework. The codebase is organized as follows:
+
+```
+reconftw/
+├── reconftw.sh # Main entry point, argument parsing, orchestration
+├── reconftw.cfg # Main configuration file (all settings)
+├── modules/ # Phase-specific modules (what to do)
+│ ├── utils.sh # Utility functions (cleanup, sanitization, caching)
+│ ├── core.sh # Framework core (logging, tools check, lifecycle)
+│ ├── osint.sh # OSINT gathering functions
+│ ├── subdomains.sh # Subdomain enumeration
+│ ├── web.sh # Web analysis and crawling
+│ ├── vulns.sh # Vulnerability scanning
+│ ├── axiom.sh # Axiom distributed scanning
+│ └── modes.sh # Scan mode orchestration
+├── lib/ # Pure utility libraries (how to do it)
+│ ├── config.sh # [FUTURE] Modular config loader
+│ └── validation.sh # Input validation functions
+└── tests/ # Test suite
+ ├── unit/ # Unit tests (bats)
+ ├── security/ # Security tests
+ └── mocks/ # Tool mocks for testing
+```
+
+## Module Load Order
+
+Modules are sourced in this specific order (defined in `reconftw.sh`):
+
+1. `modules/utils.sh` - Base utilities (must be first)
+2. `modules/core.sh` - Framework infrastructure
+3. `modules/osint.sh` - OSINT functions
+4. `modules/subdomains.sh` - Subdomain enumeration
+5. `modules/web.sh` - Web analysis
+6. `modules/vulns.sh` - Vulnerability scanning
+7. `modules/axiom.sh` - Distributed scanning
+8. `modules/modes.sh` - Mode orchestration (must be last)
+
+## Data Flow
+
+```
+Target Input → Sanitization → Phase Execution → Output Files
+ ↓ ↓ ↓ ↓
+ --domain sanitize_domain start_func Recon/$domain/
+ --list sanitize_ip [tool calls] subdomains/
+ --cidr end_func webs/vulns/
+```
+
+## Key Functions
+
+### Lifecycle Functions (core.sh)
+- `start_func(name, description)` - Begin a function, check if already done
+- `end_func(message, name)` - Complete a function, mark as done
+
+### Utility Functions (utils.sh)
+- `sanitize_domain(domain)` - Sanitize domain input (lowercase, safe chars)
+- `sanitize_ip(ip)` - Sanitize IP/CIDR input
+- `should_run_deep(count, limit)` - Check if DEEP mode should run
+- `deleteOutScoped(scopefile, targetfile)` - Remove out-of-scope entries
+- `run_command(cmd, args...)` - Execute with logging (respects DRY_RUN)
+
+### Validation Functions (lib/validation.sh)
+- `validate_domain(domain)` - Validate domain format
+- `validate_ipv4(ip)` - Validate IPv4 address
+- `validate_boolean(value)` - Validate boolean string
+
+## Global Variables
+
+### Required (set before module load)
+- `$SCRIPTPATH` - Path to reconftw installation
+- `$domain` - Target domain
+- `$dir` - Output directory for current scan
+
+### Configuration (from reconftw.cfg)
+- `$DEEP` - Enable deep/thorough scanning
+- `$DEEP_LIMIT` - Threshold for auto-deep mode
+- `$AXIOM` - Enable distributed scanning
+- `$*_THREADS` - Thread counts per tool
+
+## Error Codes
+
+Defined in `lib/validation.sh`:
+- `E_SUCCESS=0` - Success
+- `E_GENERAL=1` - General error
+- `E_MISSING_DEP=2` - Missing dependency
+- `E_INVALID_INPUT=3` - Invalid user input
+- `E_CONFIG=8` - Configuration error
+
+## Testing
+
+```bash
+make test # Unit tests only
+make test-security # Security tests only
+make test-all # All tests
+make lint # Shellcheck errors
+make lint-fix # Shellcheck warnings with context
+```
diff --git a/modules/utils.sh b/modules/utils.sh
index 5fd18e1..abf6a49 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -413,6 +413,30 @@ function sanitize_ip() {
return 0
}
+###############################################################################################################
+####################################### DEEP/AXIOM HELPERS ####################################################
+###############################################################################################################
+
+# Check if we should run in DEEP mode based on flag or item count
+# Usage: should_run_deep <count> [limit]
+# Returns: 0 if should run deep, 1 otherwise
+function should_run_deep() {
+ local count="${1:-0}"
+ local limit="${2:-$DEEP_LIMIT}"
+
+ [[ "$DEEP" == true ]] && return 0
+ [[ "$count" -le "$limit" ]] && return 0
+ return 1
+}
+
+# Check if we should run in DEEP mode with custom limit
+# Usage: should_run_deep2 <count>
+# Returns: 0 if should run deep, 1 otherwise
+function should_run_deep2() {
+ local count="${1:-0}"
+ should_run_deep "$count" "${DEEP_LIMIT2:-500}"
+}
+
###############################################################################################################
####################################### CACHÉ DE RECURSOS #####################################################
###############################################################################################################
diff --git a/modules/web.sh b/modules/web.sh
index b2e11a4..97c3633 100644
--- a/modules/web.sh
+++ b/modules/web.sh
@@ -1102,13 +1102,13 @@ function urlchecks() {
if [[ $DEEP == true ]]; then
process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"
else
- process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"
+ process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\""
fi
else
if [[ $DEEP == true ]]; then
- timeout 4h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null
+ timeout 4h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE"
else
- timeout 3h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null
+ timeout 3h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE"
fi
fi
fi
@@ -1120,15 +1120,15 @@ function urlchecks() {
LINES=$(wc -l <.tmp/katana_targets_slow.txt)
if [[ $LINES -gt ${CHUNK_LIMIT:-2000} ]]; then
if [[ $DEEP == true ]]; then
- process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"
+ process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\""
else
- process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"
+ process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\""
fi
else
if [[ $DEEP == true ]]; then
- timeout 4h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null
+ timeout 4h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE"
else
- timeout 3h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null
+ timeout 3h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE"
fi
fi
fi
diff --git a/reconftw.sh b/reconftw.sh
index f6ba898..3cfdd0f 100755
--- a/reconftw.sh
+++ b/reconftw.sh
@@ -58,6 +58,9 @@ fi
_INIT_SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
SCRIPTPATH="${_INIT_SCRIPTPATH}"
+# Source libraries first (pure utilities)
+source "${_INIT_SCRIPTPATH}/lib/validation.sh"
+
# Source all modules in dependency order
source "${_INIT_SCRIPTPATH}/modules/utils.sh"
source "${_INIT_SCRIPTPATH}/modules/core.sh"
diff --git a/tests/mocks/README.md b/tests/mocks/README.md
new file mode 100644
index 0000000..3c4b33b
--- /dev/null
+++ b/tests/mocks/README.md
@@ -0,0 +1,25 @@
+# Mock Tools for Testing
+
+This directory contains mock implementations of external tools used by reconFTW.
+These mocks allow testing without making actual network calls.
+
+## Usage
+
+Add this directory to PATH before running tests:
+
+```bash
+export PATH="$(pwd)/tests/mocks:$PATH"
+```
+
+## Available Mocks
+
+- `subfinder` - Returns predefined subdomain list
+- `httpx` - Returns predefined HTTP probe results
+- `nuclei` - Returns empty results (no vulns)
+
+## Creating New Mocks
+
+1. Create an executable script with the tool name
+2. Parse arguments to determine expected output
+3. Return realistic-looking output
+4. Exit with appropriate status code
diff --git a/tests/mocks/httpx b/tests/mocks/httpx
new file mode 100644
index 0000000..93fdf44
--- /dev/null
+++ b/tests/mocks/httpx
@@ -0,0 +1,10 @@
+#!/bin/bash
+# Mock httpx for testing
+
+# Read from stdin or file and output with status
+while IFS= read -r line || [[ -n "$line" ]]; do
+ [[ -z "$line" ]] && continue
+ # Simulate HTTP probing - return https version
+ echo "https://$line [200] [OK]"
+done
+exit 0
diff --git a/tests/mocks/subfinder b/tests/mocks/subfinder
new file mode 100644
index 0000000..c983193
--- /dev/null
+++ b/tests/mocks/subfinder
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Mock subfinder for testing
+
+# Parse domain from args
+domain=""
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -d) domain="$2"; shift 2 ;;
+ -silent|-all) shift ;;
+ *) shift ;;
+ esac
+done
+
+if [[ -n "$domain" ]]; then
+ echo "www.$domain"
+ echo "api.$domain"
+ echo "mail.$domain"
+ echo "dev.$domain"
+fi
+exit 0
diff --git a/tests/security/test_injection.bats b/tests/security/test_injection.bats
new file mode 100644
index 0000000..292b9d0
--- /dev/null
+++ b/tests/security/test_injection.bats
@@ -0,0 +1,102 @@
+#!/usr/bin/env bats
+
+# Security tests for command injection prevention
+
+setup() {
+ local project_root
+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
+ export tools="$HOME/Tools"
+ export LOGFILE="/dev/null"
+ export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''
+ export NOTIFICATION=false
+ export AXIOM=false
+ source "$project_root/reconftw.cfg" 2>/dev/null || true
+ export SCRIPTPATH="$project_root"
+ source "$project_root/reconftw.sh" --source-only
+}
+
+# Command injection via domain parameter
+@test "sanitize_domain blocks semicolon injection" {
+ run sanitize_domain "example.com;whoami"
+ [ "$status" -eq 0 ]
+ [[ "$output" != *";"* ]]
+}
+
+@test "sanitize_domain blocks pipe injection" {
+ run sanitize_domain "example.com|cat /etc/passwd"
+ [ "$status" -ne 0 ]
+}
+
+@test "sanitize_domain blocks backtick injection" {
+ run sanitize_domain 'example.com`id`'
+ [ "$status" -ne 0 ]
+}
+
+@test "sanitize_domain blocks dollar substitution" {
+ run sanitize_domain 'example.com$(whoami)'
+ [ "$status" -ne 0 ]
+}
+
+@test "sanitize_domain blocks ampersand injection" {
+ run sanitize_domain "example.com&rm -rf /"
+ [ "$status" -ne 0 ]
+}
+
+@test "sanitize_domain blocks newline injection" {
+ result=$(printf 'example.com\nwhoami' | xargs -I{} bash -c 'sanitize_domain "{}"' 2>&1) || true
+ [[ "$result" != *$'\n'* ]] || [ -z "$result" ]
+}
+
+@test "sanitize_domain blocks redirect injection" {
+ run sanitize_domain "example.com>/etc/passwd"
+ [ "$status" -ne 0 ]
+}
+
+# IP/CIDR injection tests
+@test "sanitize_ip blocks semicolon injection" {
+ run sanitize_ip "192.168.1.1;whoami"
+ [ "$status" -eq 0 ]
+ [[ "$output" != *";"* ]]
+}
+
+@test "sanitize_ip blocks command substitution" {
+ run sanitize_ip '192.168.1.1$(id)'
+ [ "$status" -eq 0 ]
+ [[ "$output" != *"$"* ]]
+}
+
+@test "sanitize_ip allows valid CIDR" {
+ result=$(sanitize_ip "192.168.1.0/24")
+ [ "$result" = "192.168.1.0/24" ]
+}
+
+# Interlace input sanitization
+@test "sanitize_interlace_input removes dangerous chars" {
+ local tmpfile
+ tmpfile=$(mktemp)
+ echo 'safe.domain.com' > "$tmpfile"
+ echo 'evil;rm -rf /' >> "$tmpfile"
+ echo '$(whoami).attacker.com' >> "$tmpfile"
+
+ sanitize_interlace_input "$tmpfile"
+
+ # Check no dangerous chars remain
+ ! grep -q '[;|&$`]' "$tmpfile"
+ rm -f "$tmpfile"
+}
+
+# Path traversal tests
+@test "outscope file handles path traversal attempt" {
+ local tmpfile scopefile
+ tmpfile=$(mktemp)
+ scopefile=$(mktemp)
+
+ echo "safe.example.com" > "$tmpfile"
+ echo "../../../etc/passwd" >> "$tmpfile"
+ echo "*.outscoped.com" > "$scopefile"
+
+ # Should not crash
+ deleteOutScoped "$scopefile" "$tmpfile"
+
+ rm -f "$tmpfile" "$scopefile"
+}
diff --git a/tests/unit/test_utils.bats b/tests/unit/test_utils.bats
index 9593633..d4b97a6 100644
--- a/tests/unit/test_utils.bats
+++ b/tests/unit/test_utils.bats
@@ -84,3 +84,39 @@ setup() {
[ "$E_INVALID_INPUT" -eq 3 ]
[ "$E_CONFIG" -eq 8 ]
}
+
+# Tests for should_run_deep helper
+@test "should_run_deep returns true when DEEP is true" {
+ DEEP=true
+ DEEP_LIMIT=100
+ run should_run_deep 500
+ [ "$status" -eq 0 ]
+}
+
+@test "should_run_deep returns true when count below limit" {
+ DEEP=false
+ DEEP_LIMIT=100
+ run should_run_deep 50
+ [ "$status" -eq 0 ]
+}
+
+@test "should_run_deep returns false when count above limit and DEEP false" {
+ DEEP=false
+ DEEP_LIMIT=100
+ run should_run_deep 200
+ [ "$status" -ne 0 ]
+}
+
+@test "should_run_deep accepts custom limit" {
+ DEEP=false
+ DEEP_LIMIT=100
+ run should_run_deep 150 200
+ [ "$status" -eq 0 ]
+}
+
+@test "should_run_deep2 uses DEEP_LIMIT2" {
+ DEEP=false
+ DEEP_LIMIT2=500
+ run should_run_deep2 300
+ [ "$status" -eq 0 ]
+}
diff --git a/tests/unit/test_validation.bats b/tests/unit/test_validation.bats
new file mode 100644
index 0000000..3fc73bc
--- /dev/null
+++ b/tests/unit/test_validation.bats
@@ -0,0 +1,129 @@
+#!/usr/bin/env bats
+
+# Unit tests for validation functions in lib/validation.sh
+
+setup() {
+ local project_root
+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
+ export tools="$HOME/Tools"
+ export LOGFILE="/dev/null"
+ export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''
+ export NOTIFICATION=false
+ export AXIOM=false
+ source "$project_root/reconftw.cfg" 2>/dev/null || true
+ export SCRIPTPATH="$project_root"
+ source "$project_root/reconftw.sh" --source-only
+}
+
+# validate_domain tests
+@test "validate_domain accepts valid domain" {
+ run validate_domain "example.com"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_domain accepts subdomain" {
+ run validate_domain "sub.example.com"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_domain accepts deep subdomain" {
+ run validate_domain "a.b.c.example.com"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_domain rejects empty string" {
+ run validate_domain ""
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_domain rejects domain with semicolon" {
+ run validate_domain "example.com;ls"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_domain rejects domain with pipe" {
+ run validate_domain "example.com|cat"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_domain rejects domain with backticks" {
+ run validate_domain 'example`id`.com'
+ [ "$status" -ne 0 ]
+}
+
+# validate_ipv4 tests
+@test "validate_ipv4 accepts valid IP" {
+ run validate_ipv4 "192.168.1.1"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_ipv4 accepts 0.0.0.0" {
+ run validate_ipv4 "0.0.0.0"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_ipv4 accepts 255.255.255.255" {
+ run validate_ipv4 "255.255.255.255"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_ipv4 rejects IP with octet > 255" {
+ run validate_ipv4 "256.1.1.1"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_ipv4 rejects incomplete IP" {
+ run validate_ipv4 "192.168.1"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_ipv4 rejects IP with letters" {
+ run validate_ipv4 "192.168.1.abc"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_ipv4 rejects empty string" {
+ run validate_ipv4 ""
+ [ "$status" -ne 0 ]
+}
+
+# validate_boolean tests
+@test "validate_boolean accepts true" {
+ run validate_boolean "true"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_boolean accepts false" {
+ run validate_boolean "false"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_boolean accepts TRUE (case insensitive)" {
+ run validate_boolean "TRUE"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_boolean accepts FALSE (case insensitive)" {
+ run validate_boolean "FALSE"
+ [ "$status" -eq 0 ]
+}
+
+@test "validate_boolean rejects yes" {
+ run validate_boolean "yes"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_boolean rejects 1" {
+ run validate_boolean "1"
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_boolean rejects empty" {
+ run validate_boolean ""
+ [ "$status" -ne 0 ]
+}
+
+@test "validate_boolean rejects random string" {
+ run validate_boolean "maybe"
+ [ "$status" -ne 0 ]
+}