Skip to content

Commit 6ca6c8a

Browse files
Release 2.9.2 (#110)
* Add debug log for number of cached requests in idamClient (#105) * Feature/bytes plugin path expansion (#109) * fixing issue with serverside path expansions in get_bytes plugin * adding negative error codes to log parsers regex * removing gitlab CI and unused plugins --------- Co-authored-by: Koyo MUNECHIKA <51052381+munechika-koyo@users.noreply.github.com>
1 parent 757d84e commit 6ca6c8a

5 files changed

Lines changed: 49 additions & 229 deletions

File tree

.gitlab-ci.yml

Lines changed: 0 additions & 206 deletions
This file was deleted.

source/bin/log_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
from collections import namedtuple
66

7-
RE_STRING = r'(?P<host>\d+\.\d+\.\d+\.\d+) - (?P<uid>[\w\d_\-]+)? \[(?P<datetime>[a-zA-Z0-9: ]+)\] \[(?P<req_id>\d+) (?P<signal>.+) (?P<exp_no>-?\d+) (?P<pass>-?\d+) (?P<path>[\w\d\-_\.\/+]+)? (?P<file>[\w\d\-_\.\/+]+)? (?P<format>[a-zA-Z_]+)? (?P<archive>[a-zA-Z_]+)? (?P<device>[a-zA-Z_]+)? \] (?P<err_code>\d+) (?P<db_size>\d+) \[(?P<err_msg>.*)\] (?P<elapsed_time>\d+(?:\.\d*(?:e[+\-]?\d+)?)?) (?P<client_ver>\d+) (?P<server_ver>\d+) \[(?P<client_pid>\d+) (?P<server_pid>\d+)\] \[\]'
7+
RE_STRING = r'(?P<host>\d+\.\d+\.\d+\.\d+) - (?P<uid>[\w\d_\-]+)? \[(?P<datetime>[a-zA-Z0-9: ]+)\] \[(?P<req_id>\d+) (?P<signal>.+) (?P<exp_no>-?\d+) (?P<pass>-?\d+) (?P<path>[\w\d\-_\.\/+]+)? (?P<file>[\w\d\-_\.\/+]+)? (?P<format>[a-zA-Z_]+)? (?P<archive>[a-zA-Z_]+)? (?P<device>[a-zA-Z_]+)? \] (?P<err_code>-?\d+) (?P<db_size>\d+) \[(?P<err_msg>.*)\] (?P<elapsed_time>\d+(?:\.\d*(?:e[+\-]?\d+)?)?) (?P<client_ver>\d+) (?P<server_ver>\d+) \[(?P<client_pid>\d+) (?P<server_pid>\d+)\] \[\]'
88

99
log_regex = re.compile(RE_STRING)
1010

source/client/udaClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices)
458458
continue;
459459
}
460460
}
461+
UDA_LOG(UDA_LOG_DEBUG, "Number of cached requests: %d\n", num_cached);
461462
# endif // !NOLIBMEMCACHED
462463

463464
//-------------------------------------------------------------------------

source/plugins/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ if( DEFINED BUILD_PLUGINS )
5050
endforeach( PLUGIN )
5151
else()
5252
add_subdirectory( bytes )
53-
add_subdirectory( hdf5 )
5453
add_subdirectory( help )
55-
add_subdirectory( keyvalue )
5654
add_subdirectory( template )
5755
add_subdirectory( testplugin )
5856
add_subdirectory( uda )
59-
add_subdirectory( viewport )
6057
endif( DEFINED BUILD_PLUGINS )
6158

6259
add_definitions( -DSERVERBUILD )

source/plugins/bytes/bytesPlugin.cpp

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,30 @@ int bytesPlugin(IDAM_PLUGIN_INTERFACE* plugin_interface)
114114
//----------------------------------------------------------------------------------------
115115
// Standard methods: version, builddate, defaultmethod, maxinterfaceversion
116116

117+
int err {0};
117118
if (STR_IEQUALS(request->function, "help")) {
118-
return plugin.help(plugin_interface);
119+
err = plugin.help(plugin_interface);
119120
} else if (STR_IEQUALS(request->function, "version")) {
120-
return plugin.version(plugin_interface);
121+
err = plugin.version(plugin_interface);
121122
} else if (STR_IEQUALS(request->function, "builddate")) {
122-
return plugin.build_date(plugin_interface);
123+
err = plugin.build_date(plugin_interface);
123124
} else if (STR_IEQUALS(request->function, "defaultmethod")) {
124-
return plugin.default_method(plugin_interface);
125+
err = plugin.default_method(plugin_interface);
125126
} else if (STR_IEQUALS(request->function, "maxinterfaceversion")) {
126-
return plugin.max_interface_version(plugin_interface);
127+
err = plugin.max_interface_version(plugin_interface);
127128
} else if (STR_IEQUALS(request->function, "read")) {
128-
return plugin.read(plugin_interface);
129+
err = plugin.read(plugin_interface);
129130
} else if (STR_IEQUALS(request->function, "size")) {
130-
return plugin.size(plugin_interface);
131+
err = plugin.size(plugin_interface);
131132
} else {
132133
RAISE_PLUGIN_ERROR_AND_EXIT("Unknown function requested!", plugin_interface);
133134
}
135+
136+
if (err != 0) {
137+
concatUdaError(&plugin_interface->error_stack);
138+
}
139+
return err;
140+
134141
} catch (const std::exception& e) {
135142
std::string err_msg = std::string("Excption raised in bytes plugin:") + e.what();
136143
RAISE_PLUGIN_ERROR_AND_EXIT(err_msg.c_str(), plugin_interface);
@@ -203,19 +210,16 @@ int check_path(const Environment* environment, const std::string& path)
203210
// Block Access to External Users
204211

205212
if (environment->external_user) {
206-
err = 999;
207-
addIdamError(UDA_CODE_ERROR_TYPE, "readBytes", err, "This Service is Disabled");
208213
UDA_LOG(UDA_LOG_DEBUG, "Disabled Service - Requested File: %s \n", path.c_str());
209-
return err;
214+
RAISE_PLUGIN_ERROR("This Service is Disabled");
210215
}
211216

212217
//----------------------------------------------------------------------
213218
// Test the filepath
214219

215220
if (!IsLegalFilePath(path.c_str())) {
216-
err = 999;
217-
addIdamError(UDA_CODE_ERROR_TYPE, "readBytes", err, "The directory path has incorrect syntax");
218221
UDA_LOG(UDA_LOG_DEBUG, "The directory path has incorrect syntax [%s] \n", path.c_str());
222+
RAISE_PLUGIN_ERROR("The directory path has incorrect syntax");
219223
return err;
220224
}
221225

@@ -239,10 +243,6 @@ int BytesPlugin::read(IDAM_PLUGIN_INTERFACE* plugin_interface)
239243

240244
unsigned long offset = 0;
241245
FIND_UNSIGNED_LONG_VALUE(plugin_interface->request_data->nameValueList, offset);
242-
auto file_size = filesystem::file_size(path);
243-
if (offset >= file_size) {
244-
RAISE_PLUGIN_ERROR_AND_EXIT("Offset specified is out of bounds", plugin_interface);
245-
}
246246

247247
const char* checksum = nullptr;
248248
FIND_STRING_VALUE(plugin_interface->request_data->nameValueList, checksum);
@@ -251,9 +251,9 @@ int BytesPlugin::read(IDAM_PLUGIN_INTERFACE* plugin_interface)
251251

252252
char tmp_path[MAXPATH];
253253
StringCopy(tmp_path, path, MAXPATH);
254-
UDA_LOG(UDA_LOG_DEBUG, "expand_environment_variables! \n");
255254
expand_environment_variables(tmp_path);
256-
255+
UDA_LOG(UDA_LOG_DEBUG, "expand_environment_variables: path=%s \n", tmp_path);
256+
257257
int rc = check_allowed_path(tmp_path);
258258
if (rc != 0) {
259259
return rc;
@@ -268,6 +268,14 @@ int BytesPlugin::read(IDAM_PLUGIN_INTERFACE* plugin_interface)
268268
return rc;
269269
}
270270

271+
if (!filesystem::exists(tmp_path)) {
272+
std::string msg = std::string("Path does not exist: ") + tmp_path;
273+
RAISE_PLUGIN_ERROR(msg.c_str());
274+
}
275+
if (offset >= filesystem::file_size(tmp_path)) {
276+
RAISE_PLUGIN_ERROR("Offset specified is out of bounds");
277+
}
278+
271279
errno = 0;
272280

273281
FILE* file = nullptr;
@@ -301,7 +309,27 @@ int BytesPlugin::size(IDAM_PLUGIN_INTERFACE* plugin_interface)
301309
const char* path = "";
302310
FIND_REQUIRED_STRING_VALUE(plugin_interface->request_data->nameValueList, path);
303311

304-
size_t file_size = filesystem::file_size(path);
312+
char tmp_path[MAXPATH];
313+
StringCopy(tmp_path, path, MAXPATH);
314+
expand_environment_variables(tmp_path);
315+
UDA_LOG(UDA_LOG_DEBUG, "expand_environment_variables: path=%s \n", tmp_path);
316+
317+
int rc = check_allowed_path(tmp_path);
318+
if (rc != 0) {
319+
return rc;
320+
}
321+
322+
rc = check_path(plugin_interface->environment, tmp_path);
323+
if (rc != 0) {
324+
return rc;
325+
}
326+
327+
if (!filesystem::exists(tmp_path)) {
328+
std::string msg = std::string("Path does not exist: ") + tmp_path;
329+
RAISE_PLUGIN_ERROR(msg.c_str());
330+
}
331+
332+
size_t file_size = filesystem::file_size(tmp_path);
305333

306334
return setReturnDataLongScalar(data_block, (long)file_size, nullptr);
307335
}

0 commit comments

Comments
 (0)