diff --git a/scripts/base/protocols/ftp/main.bro b/scripts/base/protocols/ftp/main.bro index 3d7b1fe61a..69e7c331ae 100644 --- a/scripts/base/protocols/ftp/main.bro +++ b/scripts/base/protocols/ftp/main.bro @@ -56,10 +56,10 @@ export { tags: set[string] &log &default=set(); ## Current working directory that this session is in. By making - ## the default value '/.', we can indicate that unless something + ## the default value '.', we can indicate that unless something ## more concrete is discovered that the existing but unknown ## directory is ok to use. - cwd: string &default="/."; + cwd: string &default="."; ## Command that is currently waiting for a response. cmdarg: CmdArg &optional; @@ -172,7 +172,12 @@ function ftp_message(s: Info) local arg = s$cmdarg$arg; if ( s$cmdarg$cmd in file_cmds ) - arg = fmt("ftp://%s%s", addr_to_uri(s$id$resp_h), build_path_compressed(s$cwd, arg)); + { + local comp_path = build_path_compressed(s$cwd, arg); + if ( s$cwd[0] != "/" ) + comp_path = cat("/", comp_path); + arg = fmt("ftp://%s%s", addr_to_uri(s$id$resp_h), comp_path); + } s$ts=s$cmdarg$ts; s$command=s$cmdarg$cmd; diff --git a/scripts/base/utils/paths.bro b/scripts/base/utils/paths.bro index aa083ddf5b..f8ad384ea7 100644 --- a/scripts/base/utils/paths.bro +++ b/scripts/base/utils/paths.bro @@ -19,7 +19,7 @@ function extract_path(input: string): string } ## Compresses a given path by removing '..'s and the parent directory it -## references and also removing '/'s. +## references and also removing dual '/'s and extraneous '/./'s. ## dir: a path string, either relative or absolute ## Returns: a compressed version of the input path function compress_path(dir: string): string @@ -41,7 +41,7 @@ function compress_path(dir: string): string return compress_path(dir); } - const multislash_sep = /(\/){2,}/; + const multislash_sep = /(\/\.?){2,}/; parts = split_all(dir, multislash_sep); for ( i in parts ) if ( i % 2 == 0 ) diff --git a/scripts/policy/misc/loaded-scripts.bro b/scripts/policy/misc/loaded-scripts.bro index 468478e682..516826aa7e 100644 --- a/scripts/policy/misc/loaded-scripts.bro +++ b/scripts/policy/misc/loaded-scripts.bro @@ -1,4 +1,5 @@ ##! Log the loaded scripts. +@load base/utils/paths module LoadedScripts; @@ -34,5 +35,5 @@ event bro_init() &priority=5 event bro_script_loaded(path: string, level: count) { - Log::write(LoadedScripts::LOG, [$name=cat(depth[level], path)]); + Log::write(LoadedScripts::LOG, [$name=cat(depth[level], compress_path(path))]); } \ No newline at end of file