Skip to content

Commit

Permalink
refactor: Move osquery/include files to appropriate places (osquery#6557
Browse files Browse the repository at this point in the history
)
  • Loading branch information
theopolis authored Aug 11, 2020
1 parent 6c98ab3 commit 8ee7e3a
Show file tree
Hide file tree
Showing 627 changed files with 1,644 additions and 1,611 deletions.
4 changes: 2 additions & 2 deletions docs/wiki/development/config-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ The following code is more-or-less the **filesystem** config plugin. This is the

```cpp
// Note 1: REQUIRED includes
#include <osquery/config.h>
#include <osquery/flags.h>
#include <osquery/config/config.h>
#include <osquery/core/flags.h>

namespace osquery {

Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/development/creating-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Here is that code for `./osquery/tables/utility/time_example.cpp`:
// Copyright 2004-present Facebook. All Rights Reserved.

#include <ctime>
#include <osquery/tables.h>
#include <osquery/core/tables.h>

namespace osquery {
namespace tables {
Expand Down Expand Up @@ -171,7 +171,7 @@ To make this compile, open `./tests/integration/tables/CMakeLists.txt`, find the

## Using where clauses

The `QueryContext` data type is osquery's abstraction of the underlying SQL engine's query parsing. It is defined in [osquery/tables.h](/osquery/include/osquery/tables.h).
The `QueryContext` data type is osquery's abstraction of the underlying SQL engine's query parsing. It is defined in `osquery/core/tables.h`.

The most important use of the context is query predicate constraints (e.g., `WHERE col = 'value'`). Some tables MUST have a predicate constraint, others may optionally use the constraints to increase performance.

Expand Down Expand Up @@ -201,7 +201,7 @@ Examples:

## SQL data types

Data types like `TableRows`, `TableRow`, `DiffResults`, etc. are osquery's built-in data result types. They're all defined in [include/osquery/database.h](https://github.com/osquery/osquery/blob/master/include/osquery/database.h).
Data types like `TableRows`, `TableRow`, `DiffResults`, etc. are osquery's built-in data result types. They're all defined in [osquery/database/database.h](https://github.com/osquery/osquery/blob/master/osquery/database/database.h).

`TableRow` is an interface; each table has a generated implementation with strongly-typed fields for each column in the table. There's also `DynamicTableRow`, which is backed by a `std::map<std::string, std::string>` mapping column names to the string representations of their values. `DynamicTableRow` exists to support tables that were written before the strongly-typed row support was added, and for plugins.

Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/development/options-arguments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
How do I add a command line flag/option/argument to osquery? Well, first familiarize yourself with gflags, then take note of the wrapper below.

[include/osquery/flags.h](https://github.com/osquery/osquery/blob/master/include/osquery/flags.h) contains a single wrapper for `gflags::DEFINE_` type style macros. osquery includes a simple wrapper for defining arguments/options/flags for the osqueryd daemon and shell.
[osquery/core/flags.h](https://github.com/osquery/osquery/blob/master/osquery/core/flags.h) contains a single wrapper for `gflags::DEFINE_` type style macros. osquery includes a simple wrapper for defining arguments/options/flags for the osqueryd daemon and shell.

Instead of writing the normal gflags macro for defining a new option:

Expand All @@ -13,7 +13,7 @@ DEFINE_bool(you_are_awesome, true, "Ground truth for awesome."); // DON'T DO TH
Use the following wrapper:
```cpp
#include <osquery/flags.h>
#include <osquery/core/flags.h>
FLAG(bool, you_are_awesome, true, "Ground truth for awesome.");
```
Expand All @@ -22,4 +22,4 @@ If you are declaring a flag before defining it, no change is needed. Use `DECLAR

This will allow osquery callers to show pretty displays when `-h, --help` is used.

> NOTICE: restrict your default values to code literals. It does not help to abstract the default variable into a constant then use it singularly in the macro.
> NOTICE: restrict your default values to code literals. It does not help to abstract the default variable into a constant then use it singularly in the macro.
4 changes: 2 additions & 2 deletions docs/wiki/development/pubsub-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ implementation("new_etc_files@NewETCFilesEventSubscriber::genTable")
Now with the simplest table spec possible, we need to write `NewETCFilesEventSubscriber`!

```cpp
#include <osquery/database.h>
#include "osquery/events/linux/inotify.h"
#include <osquery/database/database.h>
#include <osquery/events/linux/inotify.h>

namespace osquery {
namespace tables {
Expand Down
17 changes: 0 additions & 17 deletions osquery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,9 @@ function(osqueryMain)
add_subdirectory("system")
add_subdirectory("worker")

generateOsqueryHeaders()
generateOsqueryd()
endfunction()

function(generateOsqueryHeaders)
add_osquery_library(osquery_headers INTERFACE)
target_include_directories(osquery_headers INTERFACE "${CMAKE_SOURCE_DIR}/osquery/include")

target_link_libraries(osquery_headers INTERFACE
osquery_cxx_settings
osquery_core_plugins
osquery_utils_info
osquery_utils_macros
osquery_utils_system_systemutils
thirdparty_gflags
thirdparty_sqlite
thirdparty_googletest_headers
)
endfunction()

function(generateOsqueryd)
# Upstream uses an empty executable that links to a library with a
# a main() entry point; try to emulate this.
Expand Down
10 changes: 5 additions & 5 deletions osquery/carver/carver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#include <boost/algorithm/string.hpp>

#include <osquery/carver/carver.h>
#include <osquery/database.h>
#include <osquery/distributed.h>
#include <osquery/database/database.h>
#include <osquery/distributed/distributed.h>
#include <osquery/filesystem/fileops.h>
#include <osquery/flags.h>
#include <osquery/core/flags.h>
#include <osquery/hashing/hashing.h>
#include <osquery/logger.h>
#include <osquery/logger/logger.h>
#include <osquery/remote/serializers/json.h>
#include <osquery/system.h>
#include <osquery/core/system.h>
#include <osquery/utils/base64.h>
#include <osquery/utils/json/json.h>

Expand Down
2 changes: 1 addition & 1 deletion osquery/carver/carver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <set>
#include <string>

#include <osquery/dispatcher.h>
#include <osquery/dispatcher/dispatcher.h>
#include <osquery/filesystem/filesystem.h>
#include <osquery/utils/status/status.h>

Expand Down
8 changes: 4 additions & 4 deletions osquery/carver/tests/carver_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

#include <osquery/carver/carver.h>
#include <osquery/config/tests/test_utils.h>
#include <osquery/database.h>
#include <osquery/core/system.h>
#include <osquery/database/database.h>
#include <osquery/filesystem/fileops.h>
#include <osquery/hashing/hashing.h>
#include <osquery/registry.h>
#include <osquery/sql.h>
#include <osquery/system.h>
#include <osquery/registry/registry.h>
#include <osquery/sql/sql.h>
#include <osquery/utils/json/json.h>

namespace osquery {
Expand Down
4 changes: 3 additions & 1 deletion osquery/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ function(generateOsqueryConfig)

target_link_libraries(osquery_config PUBLIC
osquery_cxx_settings
osquery_headers
osquery_events_eventsregistry
osquery_filesystem
osquery_hashing
osquery_registry
osquery_utils
osquery_utils_system_time
)

set(public_header_files
config.h
packs.h
)

generateIncludeNamespace(osquery_config "osquery/config" "FILE_ONLY" ${public_header_files})
Expand Down
20 changes: 10 additions & 10 deletions osquery/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
#include <boost/iterator/filter_iterator.hpp>

#include <osquery/config/config.h>
#include <osquery/database.h>
#include <osquery/events.h>
#include <osquery/flagalias.h>
#include <osquery/flags.h>
#include <osquery/config/packs.h>
#include <osquery/core/flagalias.h>
#include <osquery/core/flags.h>
#include <osquery/core/shutdown.h>
#include <osquery/core/system.h>
#include <osquery/core/tables.h>
#include <osquery/database/database.h>
#include <osquery/events/events.h>
#include <osquery/hashing/hashing.h>
#include <osquery/logger.h>
#include <osquery/packs.h>
#include <osquery/registry.h>
#include <osquery/shutdown.h>
#include <osquery/system.h>
#include <osquery/tables.h>
#include <osquery/logger/logger.h>
#include <osquery/registry/registry.h>

#include <osquery/utils/conversions/split.h>
#include <osquery/utils/conversions/tryto.h>
Expand Down
2 changes: 1 addition & 1 deletion osquery/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <memory>
#include <vector>

#include <osquery/core/query.h>
#include <osquery/core/sql/query_performance.h>
#include <osquery/plugins/plugin.h>
#include <osquery/query.h>
#include <osquery/utils/expected/expected.h>
#include <osquery/utils/json/json.h>

Expand Down
10 changes: 5 additions & 5 deletions osquery/config/packs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include <mutex>
#include <random>

#include <osquery/database.h>
#include <osquery/config/packs.h>
#include <osquery/core/system.h>
#include <osquery/database/database.h>
#include <osquery/hashing/hashing.h>
#include <osquery/logger.h>
#include <osquery/packs.h>
#include <osquery/sql.h>
#include <osquery/system.h>
#include <osquery/logger/logger.h>
#include <osquery/sql/sql.h>
#include <osquery/utils/conversions/split.h>
#include <osquery/utils/conversions/tryto.h>
#include <osquery/utils/info/version.h>
Expand Down
4 changes: 2 additions & 2 deletions osquery/include/osquery/packs.h → osquery/config/packs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <boost/noncopyable.hpp>

#include <osquery/query.h>
#include <osquery/core/query.h>

#include <gtest/gtest_prod.h>

Expand Down Expand Up @@ -182,4 +182,4 @@ size_t splayValue(size_t original, size_t splay_percent);
* @return either the restored previous calculated splay, or a new splay.
*/
size_t restoreSplayedValue(const std::string& name, size_t interval);
}
} // namespace osquery
14 changes: 7 additions & 7 deletions osquery/config/tests/config_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include <osquery/filesystem/filesystem.h>
#include <osquery/filesystem/mock_file_structure.h>

#include <osquery/core.h>
#include <osquery/database.h>
#include <osquery/dispatcher.h>
#include <osquery/flags.h>
#include <osquery/packs.h>
#include <osquery/registry.h>
#include <osquery/system.h>
#include <osquery/config/packs.h>
#include <osquery/core/core.h>
#include <osquery/core/flags.h>
#include <osquery/core/system.h>
#include <osquery/database/database.h>
#include <osquery/dispatcher/dispatcher.h>
#include <osquery/registry/registry.h>
#include <osquery/utils/json/json.h>

#include <osquery/utils/info/platform_type.h>
Expand Down
12 changes: 6 additions & 6 deletions osquery/config/tests/packs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

#include <osquery/config/tests/test_utils.h>

#include <osquery/core.h>
#include <osquery/database.h>
#include <osquery/flags.h>
#include <osquery/packs.h>
#include <osquery/registry.h>
#include <osquery/system.h>
#include <osquery/config/packs.h>
#include <osquery/core/core.h>
#include <osquery/core/flags.h>
#include <osquery/core/system.h>
#include <osquery/database/database.h>
#include <osquery/registry/registry.h>

#include <osquery/filesystem/filesystem.h>

Expand Down
22 changes: 16 additions & 6 deletions osquery/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ function(generateOsqueryCoreInit)
)

set(dependencies
osquery_headers
osquery_cxx_settings
osquery_config
osquery_core
osquery_numericmonitoring
osquery_extensions
)

Expand Down Expand Up @@ -75,11 +76,12 @@ function(generateOsqueryCore)
)

set(dependencies
osquery_headers
osquery_cxx_settings
osquery_core_plugins
osquery_core_sql
osquery_filesystem
osquery_process
osquery_registry
osquery_utils
osquery_utils_conversions
osquery_utils_info
Expand All @@ -103,17 +105,25 @@ function(generateOsqueryCore)
${dependencies}
)

set(public_header_files
core.h
flags.h
flagalias.h
query.h
tables.h
shutdown.h
system.h
)

if(DEFINED PLATFORM_WINDOWS)
list(APPEND windows_public_header_files
list(APPEND public_header_files
windows/handle.h
windows/ntapi.h
windows/wmi.h
)

generateIncludeNamespace(osquery_core "osquery/core" "FULL_PATH" ${windows_public_header_files})
endif()

generateIncludeNamespace(osquery_core "osquery/core" "FILE_ONLY" ${public_header_files})
generateIncludeNamespace(osquery_core "osquery/core" "FULL_PATH" ${public_header_files})

add_test(NAME osquery_core_tests_flagstests-test COMMAND osquery_core_tests_flagstests-test)
add_test(NAME osquery_core_tests_systemtests-test COMMAND osquery_core_tests_systemtests-test)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion osquery/core/database/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cstdint>

#include <osquery/debug/debug_only.h>
#include <osquery/logger.h>
#include <osquery/logger/logger.h>
#include <osquery/utils/error/error.h>
#include <osquery/utils/expected/expected.h>

Expand Down
4 changes: 2 additions & 2 deletions osquery/core/database/in_memory_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

#include <osquery/core/database/in_memory_database.h>
#include <osquery/database.h>
#include <osquery/logger.h>
#include <osquery/database/database.h>
#include <osquery/logger/logger.h>

#include <boost/algorithm/string.hpp>
#include <boost/core/demangle.hpp>
Expand Down
2 changes: 1 addition & 1 deletion osquery/core/database/rocksdb_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif

#include <osquery/core/database/rocksdb_database.h>
#include <osquery/logger.h>
#include <osquery/logger/logger.h>

#include <boost/algorithm/string.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <boost/lexical_cast.hpp>

#include <osquery/flags.h>
#include <osquery/core/flags.h>

namespace boost {
/// We define a lexical_cast template for boolean for Gflags boolean string
Expand Down
6 changes: 3 additions & 3 deletions osquery/core/flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* the LICENSE file found in the root directory of this source tree.
*/

#include <osquery/flagalias.h>
#include <osquery/flags.h>
#include <osquery/registry.h>
#include <osquery/core/flagalias.h>
#include <osquery/core/flags.h>
#include <osquery/registry/registry.h>
#include <osquery/utils/conversions/tryto.h>

namespace boost {
Expand Down
2 changes: 1 addition & 1 deletion osquery/include/osquery/flags.h → osquery/core/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define STRIP_FLAG_HELP 1
#include <gflags/gflags.h>

#include <osquery/core.h>
#include <osquery/core/core.h>
#include <osquery/utils/status/status.h>

#ifdef FREEBSD
Expand Down
Loading

0 comments on commit 8ee7e3a

Please sign in to comment.