diff --git a/include/osquery/filesystem.h b/include/osquery/filesystem.h index 1ce8d424..998cfae9 100644 --- a/include/osquery/filesystem.h +++ b/include/osquery/filesystem.h @@ -185,6 +185,19 @@ Status resolveFilePattern(const boost::filesystem::path& pattern, std::vector& results, GlobLimits setting); +/** + * @brief Returns the OS root system directory. + * + * Some applications store configuration and application data inside of the + * Windows directory. This function retrieves the path to the current + * configurations Windows location. + * + * On POSIX systems this returns "/". + * + * @return an instance of fs::path, containing the OS root location. + */ +boost::filesystem::path getSystemRoot(); + /** * @brief Transform a path with SQL wildcards to globbing wildcard. * diff --git a/osquery/filesystem/filesystem.cpp b/osquery/filesystem/filesystem.cpp index d8fbb674..f55aeccb 100644 --- a/osquery/filesystem/filesystem.cpp +++ b/osquery/filesystem/filesystem.cpp @@ -295,6 +295,16 @@ Status resolveFilePattern(const fs::path& fs_path, return Status(0, "OK"); } +fs::path getSystemRoot() { +#ifdef WIN32 + char winDirectory[MAX_PATH] = {0}; + GetWindowsDirectory(winDirectory, MAX_PATH); + return fs::path(winDirectory); +#else + return fs::path("/"); +#endif +} + inline void replaceGlobWildcards(std::string& pattern, GlobLimits limits) { // Replace SQL-wildcard '%' with globbing wildcard '*'. if (pattern.find("%") != std::string::npos) { diff --git a/tools/audit.sh b/tools/audit.sh index bf6cfc43..01987ee8 100755 --- a/tools/audit.sh +++ b/tools/audit.sh @@ -32,21 +32,23 @@ function check_format() { function audit() { log "Running various code/change audits!" + + echo "" log "Initializing and updating all submodules" checkout_thirdparty - # Check the docs creation echo "" - log "Running: make docs" - make docs + log "Running: make format" + check_format echo "" log "Running: make check" make check + # Check the docs creation echo "" - log "Running: make format" - check_format + log "Running: make docs" + make docs } audit