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
Shell bug-bountybugbountybugbounty-tooldnshackingnucleiosintpenetration-testingpentestpentest-toolpentestingreconreconnaissancescannersecuritysecurity-toolssubdomainsubdomain-enumerationvulnerabilities
#!/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 rejects TRUE (implementation is case-sensitive)" {
# The regex ^(true|false|1|0|yes|no)$ is lowercase-only
run validate_boolean "TRUE"
[ "$status" -ne 0 ]
}
@test "validate_boolean rejects FALSE (implementation is case-sensitive)" {
run validate_boolean "FALSE"
[ "$status" -ne 0 ]
}
@test "validate_boolean accepts yes" {
# 'yes' is a valid truthy value per the implementation
run validate_boolean "yes"
[ "$status" -eq 0 ]
}
@test "validate_boolean accepts 1" {
# '1' is a valid truthy value per the implementation
run validate_boolean "1"
[ "$status" -eq 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 ]
}
# File validation tests
@test "validate_file_exists returns true for existing file" {
local tmpfile
tmpfile=$(mktemp)
run validate_file_exists "$tmpfile"
[ "$status" -eq 0 ]
rm -f "$tmpfile"
}
@test "validate_file_exists returns false for non-existent file" {
run validate_file_exists "/nonexistent/file/path"
[ "$status" -ne 0 ]
}
@test "validate_file_readable returns true for readable file" {
local tmpfile
tmpfile=$(mktemp)
echo "test" > "$tmpfile"
run validate_file_readable "$tmpfile"
[ "$status" -eq 0 ]
rm -f "$tmpfile"
}
@test "validate_directory returns true for existing directory" {
local tmpdir
tmpdir=$(mktemp -d)
run validate_directory "$tmpdir"
[ "$status" -eq 0 ]
rmdir "$tmpdir"
}
@test "validate_directory returns false for non-existent directory" {
run validate_directory "/nonexistent/directory"
[ "$status" -ne 0 ]
}
@test "validate_writable_directory returns true for writable dir" {
local tmpdir
tmpdir=$(mktemp -d)
run validate_writable_directory "$tmpdir"
[ "$status" -eq 0 ]
rmdir "$tmpdir"
}