diff --git a/diskover-web/CHANGELOG.md b/diskover-web/CHANGELOG.md index 8b65e14b..618de32e 100644 --- a/diskover-web/CHANGELOG.md +++ b/diskover-web/CHANGELOG.md @@ -1,5 +1,14 @@ # Diskover-web v2 Community Edition Change Log +# [2.0.6] - 2022-11-06 +### fixed +- issue searching for full paths to hidden dot files/folders and files with double extensions (e.g. tar.gz) +- issue searching for full file path +- issue with rootpath not updating and directory searches showing no results +- es search error [ids] unknown field [type] +- occasional php fatal error when search contains parent_path field + + # [2.0.5] - 2022-10-21 ### fixed - changing index in url params doesn't set the index or root path diff --git a/diskover-web/public/logout.php b/diskover-web/public/logout.php index 62fb6a79..0b2968e6 100644 --- a/diskover-web/public/logout.php +++ b/diskover-web/public/logout.php @@ -22,7 +22,6 @@ session_destroy(); // Delete any path cookies setcookie('path'); -setcookie('prevpath'); setcookie('rootpath'); setcookie('parentpath'); setcookie('toppath'); diff --git a/diskover-web/public/search.php b/diskover-web/public/search.php index e528afe8..19e2249f 100644 --- a/diskover-web/public/search.php +++ b/diskover-web/public/search.php @@ -54,7 +54,7 @@ $request = predict_search($searchquery); // check for path in search query and update paths in session and cookies - if (!isset($_GET['path']) && strpos($request, 'parent_path:') !== false) { + if (!isset($_GET['path']) && strpos($request, 'parent_path:\/') !== false) { // parse out actual path from es query string $pp = explode('parent_path:', $request)[1]; $pp = preg_replace('/ (AND|OR) .*/i', '', $pp); @@ -68,6 +68,7 @@ // set path cookie to update tree createCookie('path', $path); createCookie('parentpath', getParentDir($path)); + $_GET['path'] = $path; } } diff --git a/diskover-web/public/view.php b/diskover-web/public/view.php index 89eab1eb..bb37fa82 100644 --- a/diskover-web/public/view.php +++ b/diskover-web/public/view.php @@ -35,7 +35,7 @@ $searchParams['body'] = [ 'query' => [ 'ids' => [ - 'type' => '_doc', + //'type' => '_doc', 'values' => [ $_REQUEST['id'] ] ] ] diff --git a/diskover-web/src/diskover/Diskover.php b/diskover-web/src/diskover/Diskover.php index 0b70993b..510ad38a 100644 --- a/diskover-web/src/diskover/Diskover.php +++ b/diskover-web/src/diskover/Diskover.php @@ -499,7 +499,6 @@ function setPaths() $path = get_es_path($esIndex, 1); $_SESSION['rootpath'] = $path; createCookie('rootpath', $path); - createCookie('prevpath', $path); createCookie('parentpath', getParentDir($path)); } } @@ -507,12 +506,6 @@ function setPaths() if ($path !== "/") { $path = rtrim($path, '/'); } - createCookie('path', $path); - createCookie('parentpath', getParentDir($path)); - // check rootpath session is set - if (!isset($_SESSION['rootpath'])) { - $_SESSION['rootpath'] = $path; - } $toppath = $_SESSION['toppath']; if (empty($toppath)) { @@ -526,15 +519,11 @@ function setPaths() $_SESSION['toppath'] = $toppath; } - $prevpath = getCookie('prevpath'); - - // update prevpath to be current path - createCookie('prevpath', $path); - - // update rootpath session and cookie and parentpath if path changed - if ($path == $toppath && $path != $prevpath) { - $_SESSION['rootpath'] = $path; - createCookie('rootpath', $path); + $rootpath = getRootpath($path); + if (!is_null($rootpath)) { + $_SESSION['rootpath'] = $rootpath; + createCookie('rootpath', $rootpath); + createCookie('path', $path); createCookie('parentpath', getParentDir($path)); } } @@ -632,7 +621,6 @@ function checkIndices() function clearPaths() { deleteCookie('path'); deleteCookie('rootpath'); - deleteCookie('prevpath'); deleteCookie('parentpath'); unset($_SESSION['rootpath']); unset($_SESSION['toppath']); @@ -1095,17 +1083,17 @@ function predict_search($q) // check for wildcard at end of path if (preg_match('/^.*\\*$/', $request)) { $pathnowild = rtrim($request, '\*'); - // update path cookie to update tree $cookiepath = str_replace('\\', '', $pathnowild); createCookie('path', $cookiepath); $request = 'parent_path:' . $pathnowild . '*'; - } elseif (preg_match('/^.*\.\w{3,4}$/', $request)) { // file + } elseif (preg_match('/(^.*\.\w{3,4}(\.\w{2}){0,1}$)|(^.*\/\..*$)/', $request)) { // file $request = 'parent_path:' . rtrim(dirname($request), '\/') . ' AND name:' . rtrim(basename($request), '\/'); + $cookiepath = rtrim(dirname($q), '/'); + createCookie('path', $cookiepath); } else { // directory - // update path cookie to update tree $cookiepath = str_replace('\\', '', $request); createCookie('path', $cookiepath); - $request = 'parent_path:' . $request; + $request = '(parent_path:' . rtrim(dirname($request), '\/') . ' AND name:' . rtrim(basename($request), '\/') . ') OR parent_path:' . $request; } // NOT es field query such as name:filename } elseif (preg_match('/(\w+):/i', $q) == false && !empty($q)) { diff --git a/diskover-web/src/diskover/version.php b/diskover-web/src/diskover/version.php index 4264b443..6486d04e 100644 --- a/diskover-web/src/diskover/version.php +++ b/diskover-web/src/diskover/version.php @@ -17,4 +17,4 @@ */ // diskover-web version -$VERSION = '2.0.5 community edition (ce)'; \ No newline at end of file +$VERSION = '2.0.6 community edition (ce)'; \ No newline at end of file diff --git a/diskover/CHANGELOG.md b/diskover/CHANGELOG.md index caf32456..d2d99b84 100644 --- a/diskover/CHANGELOG.md +++ b/diskover/CHANGELOG.md @@ -1,5 +1,10 @@ # Diskover v2 Community Edition Change Log +# [2.0.6] - 2022-11-06 +### changed +- better handling of errors when importing alternate scanner modules + + # [2.0.5] - 2022-10-21 ### fixed - log file names having 12H format instead of 24H diff --git a/diskover/diskover.py b/diskover/diskover.py index 61f24e32..3cc9a803 100644 --- a/diskover/diskover.py +++ b/diskover/diskover.py @@ -40,7 +40,7 @@ get_file_name, load_plugins, list_plugins, get_plugins_info, set_times, \ get_mem_usage, get_win_path, rem_win_path -version = '2.0.5 community edition (ce)' +version = '2.0.6 community edition (ce)' __version__ = version # Windows check @@ -221,6 +221,16 @@ def config_warn(e): emptyindex = False +class AltScannerError(Exception): + def __init__(self, message): + self.message = message + super().__init__(self.message) + logmsg = 'ALT SCANNER EXCEPTION {0}'.format(self.message) + logger.exception(logmsg) + if logtofile: logger_warn.exception(logmsg) + sys.exit(1) + + def close_app(): """Handle exiting cleanly when a keyboard interupt/sigint occurs.""" global quit @@ -1028,13 +1038,8 @@ def log_setup(): try: full_module_name = 'scanners.' + options.altscanner alt_scanner = importlib.import_module(full_module_name) - except ModuleNotFoundError: - logmsg = 'Alternate scanner {0} not found!'.format(options.altscanner) - logger.error(logmsg) - if logtofile: logger_warn.error(logmsg) - sys.exit(1) - except Exception: - raise + except Exception as e: + raise AltScannerError(e) logger.info('Using alternate scanner {0}'.format(alt_scanner)) # point os.scandir() to scandir() in alt scanner module os.scandir = alt_scanner.scandir @@ -1043,11 +1048,15 @@ def log_setup(): alt_scanner.log_setup(loglevel, logformat, logtofile, handler_file, handler_warnfile, handler_con) except AttributeError: pass + except Exception as e: + raise AltScannerError(e) # call init function to create any connections to api, db, etc try: alt_scanner.init(globals()) except AttributeError: pass + except Exception as e: + raise AltScannerError(e) else: alt_scanner = None