PS-10068 Production code for new KMIP C++ library#23
PS-10068 Production code for new KMIP C++ library#23lukin-oleksiy wants to merge 4 commits intoPercona-Lab:masterfrom
Conversation
f5f8fbc to
6da142e
Compare
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -g") | ||
|
|
||
| include_directories(${PROJECT_SOURCE_DIR}/include) |
There was a problem hiding this comment.
Change to target_include_directories
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) # Optional, but recommended for standard compliance |
There was a problem hiding this comment.
Use target-specific options
target_compile_features(target INTERFACE cxx_std_20)
set_target_properties(my_target PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
There was a problem hiding this comment.
Fixed. Kid of. I still need 2 statements at the top of CMakeLists.txt to compile
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -g") |
There was a problem hiding this comment.
Unconditionaly always enabled Address Sanitazer looks weird to me. I would declare an option
option(WITH_ASAN "Enable Address Sanitizer" OFF)
if(WITH_ASAN)
target_compile_options(mytarget INTERFACE "-fsanitize=address")
target_link_options(mytarget INTERFACE "-fsanitize=address")
endif()
| ) | ||
|
|
||
| target_link_libraries(kmipclient kmip) | ||
| set_property(TARGET kmipclient PROPERTY POSITION_INDEPENDENT_CODE ON) |
There was a problem hiding this comment.
set_target_property()
There was a problem hiding this comment.
Not fixed, there's no such funtion
kmipclient/CMakeLists.txt
Outdated
|
|
||
| macro(add_example name) | ||
| add_executable(example_${name} examples/example_${name}.cpp) | ||
| target_link_libraries(example_${name} kmipclient) |
There was a problem hiding this comment.
| target_link_libraries(example_${name} kmipclient) | |
| target_link_libraries(example_${name} PRIVATE kmipclient) |
kmipclient/src/KmipClient.cpp
Outdated
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client) | ||
| { | ||
| io = std::make_unique<IOUtils> (net_client); | ||
| logger = log; | ||
| } |
There was a problem hiding this comment.
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client) | |
| { | |
| io = std::make_unique<IOUtils> (net_client); | |
| logger = log; | |
| } | |
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client), | |
| io(std::make_unique<IOUtils> (net_client)), | |
| logger(log) | |
| {} |
There was a problem hiding this comment.
Fixed in all constructors
| int buffer_blocks = 1; | ||
| const int buffer_block_size = 1024; |
There was a problem hiding this comment.
Again, signed types for sizes
There was a problem hiding this comment.
Well, the reason is signed types in the lower level functions (kmip.h).
| inline void | ||
| KmipRequest::add_batch_item (RequestBatchItem *rbi) | ||
| { | ||
| // Sorry, C++ guys, we have to use address arithmetic here because of the lower level |
There was a problem hiding this comment.
Yeah, I know, I know... The goal of the next development iteration is to replace kmip.c with KmipSerializer and KmipDeserializer classes and get rid of all malloc's and address arithmetic. So, ... let's keep it for a while this way. You can't imageine what a mess we have in a "heritage" code.
kmipclient/src/NetClientOpenSSL.cpp
Outdated
| return BIO_read (bio_, data, dlen); | ||
| } | ||
|
|
||
| } // namespace No newline at end of file |
There was a problem hiding this comment.
No EOL at the end of file
| static void create_get_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_activate_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_create_aes_rq (KmipCtx &ctx, const name_t &name, const name_t &group); | ||
| static void create_register_key_rq (KmipCtx &ctx, const name_t &name, const name_t &group, const Key &k); | ||
| static void create_register_secret_rq (KmipCtx &ctx, const name_t &name, const name_t &group, std::string &secret, | ||
| int secret_data_type); | ||
| static void create_revoke_rq (KmipCtx &ctx, const id_t &id, int reason, const name_t &message, | ||
| time_t occurrence_time); | ||
| static void create_destroy_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_get_attributes_rq (KmipCtx &ctx, const id_t &id, const std::vector<std::string> &attr_names); | ||
| static void create_get_attribute_list_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_locate_by_name_rq (KmipCtx &ctx, const name_t &name, enum object_type o_type, int max_items, | ||
| int offset); | ||
| static void create_locate_by_group_rq (KmipCtx &ctx, const name_t &group_name, enum object_type o_type, int max_items, | ||
| size_t offset); | ||
| static void create_locate_all_rq (KmipCtx &ctxm, enum object_type o_type, int max_items, int offset); | ||
|
|
||
| private: | ||
| static void create_locate_rq (KmipCtx &ctx, bool is_group, const name_t &name, enum object_type o_type, int max_items, | ||
| size_t offset); |
There was a problem hiding this comment.
remove enum for types, use std::size_t for sizes
95a4c5f to
8e534f5
Compare
https://perconadev.atlassian.net/browse/PS-9609 op_locate_secrets_by_group() and op_all_secrets() operationos added to kmippp library to be able to load audit log encryption passwords into component_keyring_kmip cache. Version bumped to 0.3.2
https://perconadev.atlassian.net/browse/PS-9861 Fortanix is strict about secret usage mask, it does not allow encrypt/decryypt usage mask, only key derivation and export. Other servers just ignore this mask. So this path fixies libkmip with Fortanix server. Version is 0.3.3 now
https://perconadev.atlassian.net/browse/PS-9861 The key format type RAW added besides OPAQUE to support Fortanix server. Now "GET SECRET" operations works correct
c86e1e8 to
5c45b26
Compare
based on: PS-9697 new KMIP C++ client library that replaces midle and top levels of old one The "kmipclient" C++ library implementation is added, that wraps low-level "kmip.h" calls and bypasses mid-level "kmip_bio" level; Replaces old kmippp library. ----------------------------------------------------------------------------------- PS-10068 Making KMIP C++ library productgion ready https://perconadev.atlassian.net/browse/PS-10068 Addressing PR comments and other fixes, finallizing the interface of the library, adding test suite
5c45b26 to
dc27384
Compare
The "kmipclient" C++ library implementation is added, that wraps low-level "kmip.h" calls and bypasses mid-level "kmip_bio" level. The kmip.h file was splitted in 3 to export enums, structures and functions separately.
Comparing to the 1st version (POC), The interface was simplified and uses exceptions now.
There are plans to replace C implementation of the protocol serialization/deserialization (kmip.c and others) with C++ code, so the current version of "kmipclient" library contains a lot of TODO and skeletons for future work. Ath this stage of development, the middle-level C implementation (kmip_bio.c) is removed and the library works directly with kmip.c.
Previous PR of POC is closed.