bin_SCRIPTS = curl-config
SUBDIRS = lib src
-if USE_TIZEN_FEATURE_DLP
+if HAVE_TIZEN_DLP
SUBDIRS += extensions
endif
DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs
AS_HELP_STRING([--enable-dlp], [Enable DLP usage]))
AS_IF([test "x$enable_dlp" = "xyes"], [
- CPPFLAGS+=" -DUSE_TIZEN_FEATURE_DLP"
- SUPPORT_TIZEN_FEATURES="$SUPPORT_TIZEN_FEATURES dlp"
+ AC_DEFINE(HAVE_TIZEN_DLP, 1, [Enadle DLP])
+ LIBS="-ldl $LIBS"
])
-AM_CONDITIONAL(USE_TIZEN_FEATURE_DLP, test "x$enable_dlp" = "xyes")
+AM_CONDITIONAL(HAVE_TIZEN_DLP, test "x$enable_dlp" = "xyes")
dnl **********************************************************************
dnl Check for nghttp2
lib_LTLIBRARIES = libcurl_extension_dlp.la
-libcurl_extension_dlp_la_SOURCES = tizen_dlp.c
+libcurl_extension_dlp_la_SOURCES = dlp.c
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "dlp.h"
+
+#include <dlfcn.h>
+
+#define LIBRARY_PATH "/lib/libprivacy-guard-client.so"
+
+typedef void (*privacy_guard_dlp_init_t)();
+typedef int (*privacy_guard_dlp_check_leak_proto_info_t)(const char* const, PgDlpProtocol,
+ long, long, uint32_t,
+ const char* const, size_t);
+
+static privacy_guard_dlp_init_t privacy_guard_dlp_init = 0;
+static privacy_guard_dlp_check_leak_proto_info_t privacy_guard_dlp_check_leak_proto_info = 0;
+
+static void dlp_init()
+{
+ void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY | RTLD_NODELETE);
+ if(handle) {
+ privacy_guard_dlp_init =
+ (privacy_guard_dlp_init_t) dlsym(handle, "privacy_guard_dlp_init");
+ privacy_guard_dlp_check_leak_proto_info =
+ (privacy_guard_dlp_check_leak_proto_info_t) dlsym(handle, "privacy_guard_dlp_check_leak_proto_info");
+ dlclose(handle);
+
+ if(privacy_guard_dlp_init) {
+ privacy_guard_dlp_init();
+ }
+ }
+}
+
+void dlp_check_leak(const char* const hostname, PgDlpProtocol protocol,
+ long source_port, long destination_port, uint32_t destination_ip,
+ const char* const data, size_t data_length)
+{
+ static unsigned short int is_initialized = 0;
+ if(!is_initialized) {
+ dlp_init();
+ is_initialized = 1;
+ }
+
+ if(privacy_guard_dlp_check_leak_proto_info) {
+ privacy_guard_dlp_check_leak_proto_info(hostname, protocol, source_port,
+ destination_port, destination_ip, data, data_length);
+ }
+}
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifndef HEADER_CURL_DLP_H
+#define HEADER_CURL_DLP_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+typedef enum {
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTP = 1,
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTPS = 2,
+} PgDlpProtocol;
+
+void dlp_check_leak(const char* const hostname, PgDlpProtocol protocol,
+ long source_port, long destination_port, uint32_t destination_ip,
+ const char* const data, size_t data_length);
+
+#endif /* HEADER_CURL_DLP_H */
+++ /dev/null
-/**
- * @file tizen_dlp.cpp
- * @brief external API functions for DLP
- */
-
-#include <dlfcn.h>
-
-#define LIBRARY_PATH "/lib/libprivacy-guard-client.so"
-
-static int first_run = 1;
-static void (*privacy_guard_dlp_init)(void) = 0;
-static void (*privacy_guard_dlp_check_leak)(const char *, char * const, size_t) = 0;
-
-/**
- * @fn void tizen_dlp_init(void)
- * @brief Initialize the DLP creating the Load Rules and Logging threads
- * @callgraph
- */
-void tizen_dlp_init(void)
-{
- if (first_run) {
- void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY|RTLD_NODELETE);
- if (handle) {
- privacy_guard_dlp_init = dlsym(handle, "privacy_guard_dlp_init");
- privacy_guard_dlp_check_leak = dlsym(handle, "privacy_guard_dlp_check_leak");
- dlclose(handle);
- first_run = 0;
- }
- }
-
- if (privacy_guard_dlp_init)
- privacy_guard_dlp_init();
-}
-
-/**
- * @fn void tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
- * @brief Checks for information leak on a given request string
- *
- * @param[in] hostname The hostname of the server to which the request will be sent
- * @param[in] mem Text that we are going to validate for info leak
- * @param[in] len Size of len in bytes
- *
- * @return either PRIV_GUARD_DLP_RESULT_ALLOW or PRIV_GUARD_DLP_RESULT_DENY
- * @callgraph
- */
-void tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
-{
- /**
- * Send data to Tizen DLP verification
- */
- if(privacy_guard_dlp_check_leak)
- privacy_guard_dlp_check_leak(hostname, mem, len);
-}
LIB_VSSH_HFILES = vssh/ssh.h
-if USE_TIZEN_FEATURE_DLP
+if HAVE_TIZEN_DLP
LIB_EXTENSIONS_CFILES = extensions/curl_extensions.c
LIB_EXTENSIONS_HFILES = extensions/curl_extensions.h
endif
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-#ifdef USE_TIZEN_FEATURE_DLP
-#include "extensions/curl_extensions.h"
-#endif
void Curl_version_init(void);
if(initialized++)
return CURLE_OK;
-#ifdef USE_TIZEN_FEATURE_DLP
- /**
- * Initialize Tizen DLP
- */
- curl_extensions_tizen_dlp_init();
-#endif
-
if(memoryfuncs) {
/* Setup the default memory functions here (again) */
Curl_cmalloc = (curl_malloc_callback)malloc;
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
*
***************************************************************************/
-/**
- * @file curl_extensions.cpp
- * @brief external API functions for DLP
- */
-
-#ifdef USE_TIZEN_FEATURE_DLP
+#include "extensions/curl_extensions.h"
#include <dlfcn.h>
-#include <extensions/curl_extensions.h>
-#define LIBRARY_PATH "/usr/lib/libcurl_extension_dlp.so.0"
+#define LIBRARY_PATH "/lib/libcurl_extension_dlp.so.0"
-static int first_run = 1;
-static void (*tizen_dlp_init)(void) = NULL;
-static void (*tizen_dlp_check_leak)(const char *, char * const, size_t) = NULL;
+typedef void (*dlp_check_leak_t)(const char* const, PgDlpProtocol,
+ long, long, uint32_t,
+ const char* const, size_t);
-/**
- * @fn void curl_extensions_init(void)
- * @brief Load the extension shared library looking for the function call
- * symbols it going to use
- * @callgraph
- */
-static void curl_extensions_init(void)
-{
- if (first_run) {
- void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY|RTLD_NODELETE);
- if (handle) {
- tizen_dlp_init = dlsym(handle, "tizen_dlp_init");
- tizen_dlp_check_leak = dlsym(handle, "tizen_dlp_check_leak");
- dlclose(handle);
- first_run = 0;
- }
- }
-}
+static dlp_check_leak_t dlp_check_leak = 0;
-/**
- * @callgraph
- */
-void curl_extensions_tizen_dlp_init(void)
+static void curl_extensions_init()
{
- curl_extensions_init();
+ void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY | RTLD_NODELETE);
+ if(handle) {
+ dlp_check_leak = (dlp_check_leak_t) dlsym(handle, "dlp_check_leak");
+ dlclose(handle);
- if (tizen_dlp_init)
- tizen_dlp_init();
+ }
}
-/**
- * @callgraph
- */
-void curl_extensions_tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
+void curl_extensions_dlp_check_leak(const char* const hostname, PgDlpProtocol protocol,
+ long source_port, long destination_port, uint32_t destination_ip,
+ const char* const data, size_t data_length)
{
- if(tizen_dlp_check_leak)
- tizen_dlp_check_leak(hostname, mem, len);
+ static unsigned short int is_initialized = 0;
+ if(!is_initialized) {
+ curl_extensions_init();
+ is_initialized = 1;
+ }
+
+ if(dlp_check_leak) {
+ dlp_check_leak(hostname, protocol, source_port,
+ destination_port, destination_ip, data, data_length);
+ }
}
-#endif /* USE_TIZEN_FEATURE_DLP */
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
*
***************************************************************************/
-/**
- * @file curl_extensions.h
- * @brief API for privacy-guard-dlp
- */
-
-#ifdef USE_TIZEN_FEATURE_DLP
#ifndef HEADER_CURL_EXTENSIONS_H
#define HEADER_CURL_EXTENSIONS_H
+#include <stdint.h>
#include <stddef.h>
-/**
- * @fn void curl_extensions_tizen_dlp_init(void)
- * @brief Initialize the DLP creating the Load Rules and Logging threads
- * @callgraph
- */
-void curl_extensions_tizen_dlp_init(void);
+typedef enum {
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTP = 1,
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTPS = 2,
+} PgDlpProtocol;
-/**
- * @fn void curl_extensions_tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
- * @brief Checks for information leak on a given request string
- *
- * @param[in] hostname The hostname of the server to which the request will be sent
- * @param[in] mem Text that we are going to validate for info leak
- * @param[in] len Size of len in bytes
- *
- * @return either PRIV_GUARD_DLP_RESULT_ALLOW or PRIV_GUARD_DLP_RESULT_DENY
- * @callgraph
- */
-void curl_extensions_tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len);
+void curl_extensions_dlp_check_leak(const char* const hostname, PgDlpProtocol protocol,
+ long source_port, long destination_port, uint32_t destination_ip,
+ const char* const data, size_t data_length);
#endif /* HEADER_CURL_EXTENSIONS_H */
-#endif /* USE_TIZEN_FEATURE_DLP */
#include <curl/curl.h>
-#ifdef USE_TIZEN_FEATURE_DLP
+#ifdef HAVE_TIZEN_DLP
#include "extensions/curl_extensions.h"
#endif
#include "urldata.h"
CURLcode result = CURLE_OK;
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
-#ifdef USE_TIZEN_FEATURE_DLP
- /**
- * Send data to Tizen DLP verification
- */
- curl_extensions_tizen_dlp_check_leak(conn->host.dispname, (char *const)mem,
- len);
+#ifdef HAVE_TIZEN_DLP
+ u_int32_t destination_ipv4 = 0;
+ if(conn->ip_addr != NULL && conn->ip_addr->ai_family == AF_INET &&
+ conn->ip_addr->ai_addr != NULL) {
+ destination_ipv4 =
+ ((struct sockaddr_in *) conn->ip_addr->ai_addr)->sin_addr.s_addr;
+ }
+
+ curl_extensions_dlp_check_leak(conn->host.dispname,
+ conn->ssl[0].use ?
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTPS :
+ PRIV_GUARD_DLP_PROTOCOL_CURL_HTTP,
+ conn->local_port,
+ conn->remote_port,
+ destination_ipv4,
+ (const char *) mem,
+ len);
#endif
bytes_written = conn->send[num](conn, num, mem, len, &result);