#include #include #include "fold/binary/r2_backend_detail.hpp" TEST_CASE("r2 CLI command inserts option terminator before dash-prefixed binary path", "[binary][r2]") { const std::string command = fold::binary::r2_detail::buildCliTextCommand("-fixture-bin", "izj"); REQUIRE(command == "r2 -q -c 'izj' -- '-fixture-bin' 2>/dev/null"); } TEST_CASE("r2 CLI analysis command preserves -A and option terminator", "[binary][r2]") { const std::string command = fold::binary::r2_detail::buildCliTextCommand("-fixture-bin", "aflj"); REQUIRE(command == "r2 -A -q -c 'aflj' -- '-fixture-bin' 2>/dev/null"); } TEST_CASE("function-byte extraction planner keeps in-cap functions readable", "[binary][r2]") { const auto plan = fold::binary::r2_detail::planFunctionByteExtraction(4096); REQUIRE_FALSE(plan.skip_oversized); REQUIRE(plan.bytes_to_read == 4096); } TEST_CASE("function-byte extraction planner rejects hostile oversized functions", "[binary][r2]") { const auto plan = fold::binary::r2_detail::planFunctionByteExtraction( std::numeric_limits::max()); REQUIRE(plan.skip_oversized); REQUIRE(plan.bytes_to_read == 0); } TEST_CASE("dangerous-import classification suppresses common safe import-only APIs", "[binary][r2][dangerous-import]") { using fold::binary::r2_detail::isDangerousImportName; REQUIRE_FALSE(isDangerousImportName("malloc")); REQUIRE_FALSE(isDangerousImportName("free")); REQUIRE_FALSE(isDangerousImportName("printf")); REQUIRE_FALSE(isDangerousImportName("snprintf")); REQUIRE_FALSE(isDangerousImportName("realloc")); REQUIRE(isDangerousImportName("system")); REQUIRE(isDangerousImportName("strcpy")); REQUIRE(isDangerousImportName("sprintf")); REQUIRE(isDangerousImportName("scanf")); }