diff --git a/modules/verify/CMakeLists.txt b/modules/verify/CMakeLists.txt index 4ae13f9..4c1ab3e 100644 --- a/modules/verify/CMakeLists.txt +++ b/modules/verify/CMakeLists.txt @@ -13,8 +13,10 @@ endif() # Create shared library - add CommonModuleAPI.cpp to the sources add_library(verify MODULE verify.cpp - src/verify_commands.cpp - ${DPM_ROOT_DIR}/dpmdk/src/CommonModuleAPI.cpp # Add this line + src/commands.cpp + ${DPM_ROOT_DIR}/dpmdk/src/CommonModuleAPI.cpp + src/cli_parsers.cpp + src/verification.cpp ) # Set output properties @@ -28,7 +30,7 @@ set_target_properties( target_include_directories(verify PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${DPM_ROOT_DIR} - ${DPM_ROOT_DIR}/dpmdk/include # Add this line + ${DPM_ROOT_DIR}/dpmdk/include ) # Link with required libraries @@ -37,8 +39,10 @@ target_link_libraries(verify dl) # Standalone version - used for debugging add_executable(verify_standalone verify.cpp - src/verify_commands.cpp - ${DPM_ROOT_DIR}/dpmdk/src/CommonModuleAPI.cpp # Add this line + src/commands.cpp + ${DPM_ROOT_DIR}/dpmdk/src/CommonModuleAPI.cpp + src/cli_parsers.cpp + src/verification.cpp ) # Define the BUILD_STANDALONE macro for the standalone build @@ -48,7 +52,7 @@ target_compile_definitions(verify_standalone PRIVATE BUILD_STANDALONE) target_include_directories(verify_standalone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${DPM_ROOT_DIR} - ${DPM_ROOT_DIR}/dpmdk/include # Add this line + ${DPM_ROOT_DIR}/dpmdk/include ) # Link with required libraries for standalone too @@ -58,4 +62,4 @@ target_link_libraries(verify_standalone dl) set_target_properties( verify_standalone PROPERTIES OUTPUT_NAME "verify_debug" -) \ No newline at end of file +) diff --git a/modules/verify/include/cli_parsers.hpp b/modules/verify/include/cli_parsers.hpp new file mode 100644 index 0000000..f08669d --- /dev/null +++ b/modules/verify/include/cli_parsers.hpp @@ -0,0 +1,27 @@ +#pragma once +#include +#include + +/** +* @enum Command + * @brief Enumeration of supported commands for the verify module + */ +enum Command { + CMD_UNKNOWN, /**< Unknown or unsupported command */ + CMD_HELP, /**< Display help information */ + CMD_CHECKSUM, /**< Verify package checksums */ + CMD_SIGNATURE, /**< Verify package signatures */ + CMD_CHECK /**< Check build module integration */ +}; + +/** + * @brief Parses a command string into a Command enum value + * + * Converts a command string to the appropriate Command enum value + * for internal routing. + * + * @param cmd_str The command string to parse + * @return The corresponding Command enum value + */ +Command parse_command(const char* cmd_str); + diff --git a/modules/verify/include/verify_commands.hpp b/modules/verify/include/commands.hpp similarity index 84% rename from modules/verify/include/verify_commands.hpp rename to modules/verify/include/commands.hpp index 32adcfe..bf5a0ee 100644 --- a/modules/verify/include/verify_commands.hpp +++ b/modules/verify/include/commands.hpp @@ -1,5 +1,5 @@ /** - * @file verify_commands.hpp + * @file commands.hpp * @brief Header file for the verify module command handlers * * Defines functions and enumerations for the verify module which verifies @@ -19,18 +19,6 @@ #include #include -/** - * @enum Command - * @brief Enumeration of supported commands for the verify module - */ -enum Command { - CMD_UNKNOWN, /**< Unknown or unsupported command */ - CMD_HELP, /**< Display help information */ - CMD_CHECKSUM, /**< Verify package checksums */ - CMD_SIGNATURE, /**< Verify package signatures */ - CMD_CHECK /**< Check build module integration */ -}; - /** * @brief Handler for the checksum command * @@ -121,17 +109,6 @@ int cmd_check_help(int argc, char** argv); */ int cmd_unknown(const char* command, int argc, char** argv); -/** - * @brief Parses a command string into a Command enum value - * - * Converts a command string to the appropriate Command enum value - * for internal routing. - * - * @param cmd_str The command string to parse - * @return The corresponding Command enum value - */ -Command parse_command(const char* cmd_str); - /** * @brief Helper function to check and load the build module * diff --git a/modules/verify/include/verification.hpp b/modules/verify/include/verification.hpp new file mode 100644 index 0000000..5084551 --- /dev/null +++ b/modules/verify/include/verification.hpp @@ -0,0 +1,57 @@ +/** +* @file verification.hpp + * @brief Functions for verifying package integrity and signatures + * + * Defines functions for verifying checksums and signatures of DPM packages + * and package stage directories. + * + * @copyright Copyright (c) 2025 SILO GROUP LLC + * @author Chris Punches + * + * Part of the Dark Horse Linux Package Manager (DPM) + */ +#pragma once + +#include +#include +#include + +/** + * @brief Verifies checksums for a package file + * + * Checks the integrity of a package file by verifying its checksums. + * + * @param package_path Path to the package file + * @return 0 on success, non-zero on failure + */ +int verify_checksums_package(const std::string& package_path); + +/** + * @brief Verifies checksums for a package stage directory + * + * Checks the integrity of a package stage directory by verifying its checksums. + * + * @param stage_dir Path to the stage directory + * @return 0 on success, non-zero on failure + */ +int verify_checksums_stage(const std::string& stage_dir); + +/** + * @brief Verifies signatures for a package file + * + * Checks the signatures of a package file. + * + * @param package_path Path to the package file + * @return 0 on success, non-zero on failure + */ +int verify_signature_package(const std::string& package_path); + +/** + * @brief Verifies signatures for a package stage directory + * + * Checks the signatures of a package stage directory. + * + * @param stage_dir Path to the stage directory + * @return 0 on success, non-zero on failure + */ +int verify_signature_stage(const std::string& stage_dir); diff --git a/modules/verify/src/cli_parsers.cpp b/modules/verify/src/cli_parsers.cpp new file mode 100644 index 0000000..9fac1bf --- /dev/null +++ b/modules/verify/src/cli_parsers.cpp @@ -0,0 +1,22 @@ +#include "../include/cli_parsers.hpp" + +Command parse_command(const char* cmd_str) { + if (cmd_str == nullptr || strlen(cmd_str) == 0) { + return CMD_HELP; + } + + if (strcmp(cmd_str, "help") == 0) { + return CMD_HELP; + } + else if (strcmp(cmd_str, "checksum") == 0) { + return CMD_CHECKSUM; + } + else if (strcmp(cmd_str, "signature") == 0) { + return CMD_SIGNATURE; + } + else if (strcmp(cmd_str, "check") == 0) { + return CMD_CHECK; + } + + return CMD_UNKNOWN; +} diff --git a/modules/verify/src/verify_commands.cpp b/modules/verify/src/commands.cpp similarity index 76% rename from modules/verify/src/verify_commands.cpp rename to modules/verify/src/commands.cpp index 5a2bb0b..b504864 100644 --- a/modules/verify/src/verify_commands.cpp +++ b/modules/verify/src/commands.cpp @@ -1,5 +1,5 @@ /** - * @file verify_commands.cpp + * @file commands.cpp * @brief Implementation of command handlers for the verify module * * Implements the command handlers for verifying package checksums and signatures. @@ -10,7 +10,7 @@ * Part of the Dark Horse Linux Package Manager (DPM) */ -#include "verify_commands.hpp" +#include "commands.hpp" int check_and_load_build_module(void*& module_handle) { // Check if build module exists @@ -29,74 +29,6 @@ int check_and_load_build_module(void*& module_handle) { return 0; } -int verify_checksums_package(const std::string& package_path) { - // Check if the package file exists - if (!std::filesystem::exists(package_path)) { - dpm_log(LOG_ERROR, ("Package file not found: " + package_path).c_str()); - return 1; - } - - // Placeholder implementation - dpm_log(LOG_INFO, ("Verifying checksums for package: " + package_path).c_str()); - dpm_log(LOG_INFO, "Package checksum verification not yet implemented"); - - return 0; -} - -int verify_checksums_stage(const std::string& stage_dir) { - // Check if the stage directory exists - if (!std::filesystem::exists(stage_dir)) { - dpm_log(LOG_ERROR, ("Stage directory not found: " + stage_dir).c_str()); - return 1; - } - - // Check if it's actually a directory - if (!std::filesystem::is_directory(stage_dir)) { - dpm_log(LOG_ERROR, ("Path is not a directory: " + stage_dir).c_str()); - return 1; - } - - // Placeholder implementation - dpm_log(LOG_INFO, ("Verifying checksums for stage directory: " + stage_dir).c_str()); - dpm_log(LOG_INFO, "Stage directory checksum verification not yet implemented"); - - return 0; -} - -int verify_signature_package(const std::string& package_path) { - // Check if the package file exists - if (!std::filesystem::exists(package_path)) { - dpm_log(LOG_ERROR, ("Package file not found: " + package_path).c_str()); - return 1; - } - - // Placeholder implementation - dpm_log(LOG_INFO, ("Verifying signatures for package: " + package_path).c_str()); - dpm_log(LOG_INFO, "Package signature verification not yet implemented"); - - return 0; -} - -int verify_signature_stage(const std::string& stage_dir) { - // Check if the stage directory exists - if (!std::filesystem::exists(stage_dir)) { - dpm_log(LOG_ERROR, ("Stage directory not found: " + stage_dir).c_str()); - return 1; - } - - // Check if it's actually a directory - if (!std::filesystem::is_directory(stage_dir)) { - dpm_log(LOG_ERROR, ("Path is not a directory: " + stage_dir).c_str()); - return 1; - } - - // Placeholder implementation - dpm_log(LOG_INFO, ("Verifying signatures for stage directory: " + stage_dir).c_str()); - dpm_log(LOG_INFO, "Stage directory signature verification not yet implemented"); - - return 0; -} - int cmd_checksum_help(int argc, char** argv) { dpm_con(LOG_INFO, "Usage: dpm verify checksum [options]"); dpm_con(LOG_INFO, ""); @@ -285,27 +217,6 @@ int cmd_unknown(const char* command, int argc, char** argv) { return 1; } -Command parse_command(const char* cmd_str) { - if (cmd_str == nullptr || strlen(cmd_str) == 0) { - return CMD_HELP; - } - - if (strcmp(cmd_str, "help") == 0) { - return CMD_HELP; - } - else if (strcmp(cmd_str, "checksum") == 0) { - return CMD_CHECKSUM; - } - else if (strcmp(cmd_str, "signature") == 0) { - return CMD_SIGNATURE; - } - else if (strcmp(cmd_str, "check") == 0) { - return CMD_CHECK; - } - - return CMD_UNKNOWN; -} - int cmd_check(int argc, char** argv) { // Parse command line arguments bool verbose = false; diff --git a/modules/verify/src/verification.cpp b/modules/verify/src/verification.cpp new file mode 100644 index 0000000..69cb2ec --- /dev/null +++ b/modules/verify/src/verification.cpp @@ -0,0 +1,82 @@ +/** + * @file verification.cpp + * @brief Implementation of package verification functions + * + * Implements functions for verifying checksums and signatures of DPM packages + * and package stage directories. + * + * @copyright Copyright (c) 2025 SILO GROUP LLC + * @author Chris Punches + * + * Part of the Dark Horse Linux Package Manager (DPM) + */ + +#include "verification.hpp" + +int verify_checksums_package(const std::string& package_path) { + // Check if the package file exists + if (!std::filesystem::exists(package_path)) { + dpm_log(LOG_ERROR, ("Package file not found: " + package_path).c_str()); + return 1; + } + + // Placeholder implementation + dpm_log(LOG_INFO, ("Verifying checksums for package: " + package_path).c_str()); + dpm_log(LOG_INFO, "Package checksum verification not yet implemented"); + + return 0; +} + +int verify_checksums_stage(const std::string& stage_dir) { + // Check if the stage directory exists + if (!std::filesystem::exists(stage_dir)) { + dpm_log(LOG_ERROR, ("Stage directory not found: " + stage_dir).c_str()); + return 1; + } + + // Check if it's actually a directory + if (!std::filesystem::is_directory(stage_dir)) { + dpm_log(LOG_ERROR, ("Path is not a directory: " + stage_dir).c_str()); + return 1; + } + + // Placeholder implementation + dpm_log(LOG_INFO, ("Verifying checksums for stage directory: " + stage_dir).c_str()); + dpm_log(LOG_INFO, "Stage directory checksum verification not yet implemented"); + + return 0; +} + +int verify_signature_package(const std::string& package_path) { + // Check if the package file exists + if (!std::filesystem::exists(package_path)) { + dpm_log(LOG_ERROR, ("Package file not found: " + package_path).c_str()); + return 1; + } + + // Placeholder implementation + dpm_log(LOG_INFO, ("Verifying signatures for package: " + package_path).c_str()); + dpm_log(LOG_INFO, "Package signature verification not yet implemented"); + + return 0; +} + +int verify_signature_stage(const std::string& stage_dir) { + // Check if the stage directory exists + if (!std::filesystem::exists(stage_dir)) { + dpm_log(LOG_ERROR, ("Stage directory not found: " + stage_dir).c_str()); + return 1; + } + + // Check if it's actually a directory + if (!std::filesystem::is_directory(stage_dir)) { + dpm_log(LOG_ERROR, ("Path is not a directory: " + stage_dir).c_str()); + return 1; + } + + // Placeholder implementation + dpm_log(LOG_INFO, ("Verifying signatures for stage directory: " + stage_dir).c_str()); + dpm_log(LOG_INFO, "Stage directory signature verification not yet implemented"); + + return 0; +} \ No newline at end of file diff --git a/modules/verify/verify.cpp b/modules/verify/verify.cpp index f03bc90..b0d7a90 100644 --- a/modules/verify/verify.cpp +++ b/modules/verify/verify.cpp @@ -27,7 +27,8 @@ * mailing list at: https://lists.darkhorselinux.org/mailman/listinfo/dhlp-contributors */ -#include "include/verify_commands.hpp" +#include "include/commands.hpp" +#include "include/cli_parsers.hpp" /** * @def MODULE_VERSION