Commit Graph

27 Commits

Author SHA1 Message Date
Stefano Bonicatti
974bdef901 Various fixes and CI steps for packaging (#5881)
* Fix packaging regression on Windows

Component variables should be set only for Linux and macOS,
otherwise on Windows the internal WiX IDs change and the
WiX fragment patch won't work.

Cleanup the version patch component, since WiX doesn't support
version components that are not digits.

* Add the rpm package to the CI Dockerfile, to test rpm packaging

* Fix TGZ generation on other platforms

* Add dpkg-dev and file packages to the CI Dockerfile

They are needed for creating DEB debug packages.

* Add a packaging steps to the CI

Set TGZ as a default packaging system when one cannot detected.

Fix generatePackageTarget indentation.
2019-10-13 12:53:16 +02:00
Stefano Bonicatti
56c69e3cfa Add ccache support also for compiling C (#5872) 2019-10-08 22:39:28 +02:00
Alessandro Gario
225bbaf992
Integrate cppcheck and clang-tidy within the CMake project (#5730) 2019-10-08 18:17:11 +02:00
Teddy Reed
846c392903
cpack: Update package logic to build DEB debuginfo (#5843)
This enables a component install for DEB (only). This is required in
CMake version 3.17.0 (planned) and lower to produce a debuginfo version.

One side-effect is we have to gate the stripping for DEB.
2019-10-07 22:36:18 -07:00
Teddy Reed
92e7b9033d
fuzzing: Restore simple libFuzzer-based config fuzzing (#5844)
This defines a new CMake option: OSQUERY_FUZZ, which appends compiler
and linker flags for libFuzzer to be effective.

There is one example harness that will fuzz config parsing.
2019-10-02 18:09:35 -04:00
Teddy Reed
bb25075599
linux: Add --build-id linker option (#5823) 2019-09-25 15:20:22 -04:00
Stefano Bonicatti
6f3063bef7 Specify PATH when calling format_check if using the custom toolchain (#5834)
The script would not find clang-format or it would use the system one,
which it shouldn't.
2019-09-24 19:17:55 -04:00
Teddy Reed
835ae84635
CPack: Linux package nitpicks and docs (#5822)
This fixes the license for RPMs, sets the homepage for DEBs, and sets
the package revision correctly.
2019-09-23 17:39:27 -04:00
seph
8e678847c2 Fix MSI Service Error handling
When ErrorControl is set to `critical`, a failure to start osquery results in a system reboot. Instead, this should be set to `normal` where it is logged and the startup proceeds.

Upstream docs are Docs are http://wixtoolset.org/documentation/manual/v3/xsd/wix/serviceinstall.html

This was fixed in https://github.com/osquery/osquery/pull/5467 and seems to have gotten lost.
2019-09-19 12:32:35 -04:00
Zachary Wasserman
010949cc4e Suppress Boost warnings about newer compiler (#5816) 2019-09-19 01:19:26 +02:00
Zachary Wasserman
5cec1f4331
Upgrade SQLite to 3.29.0 on macOS and Windows (#5810)
Mitigates recent CVEs in SQLite. It was already this version on Linux.

Establish a pattern for migrating source dependency builds to macOS and Windows.
2019-09-18 15:49:27 -07:00
Alessandro Gario
65aca42e5f
CMake: Add CentOS to the RPM-based distributions (#5809) 2019-09-16 21:19:39 +02:00
Stefano Bonicatti
57f9916473 Patch environment file path in initd and systemd scripts during DEB packaging (#5802)
Also add a check to systemd script to create and empty config file,
if this is missing.

Co-authored-by: seph <seph@directionless.org>
2019-09-12 18:02:23 -04:00
Stefano Bonicatti
c34ef2aaa3
Fix MSI installed service missing quotes on flagfile argument (#5778) 2019-09-09 18:33:48 +02:00
Teddy Reed
f4bd3e1630
deployment: Add Mozilla CA certificate store 2019-08-28 (#5773)
* deployment: Add Mozilla CA certificate store 2019-08-28

This is the cacerts file that was once proviced by the OpenSSL Homebrew
formula. The osquery packages in 3.x and previous provided this store as
the default / fallback.

The hash can be corroborated via:
https://curl.haxx.se/ca/cacert.pem.sha256

38b6230aa4bee062cd34ee0ff6da173250899642b1937fc130896290b6bd91e3

* install certs.pem directly from source
2019-09-08 17:42:01 -04:00
Teddy Reed
e72ae6b48f
cpack: Only use CMAKE_SET_DESTDIR for TGZ generator (#5772) 2019-09-07 18:16:19 -04:00
Teddy Reed
1b0edf5ba4
cpack: Apply existing Linux package conventions (#5770) 2019-09-07 15:53:20 -04:00
Teddy Reed
91379cf73f cpack: Add TGZ optional generator for Linux 2019-09-06 23:50:29 -04:00
Stefano Bonicatti
0b2cd791d3 Linux custom toolchain integration (#5759)
- Always link to libc++abi.a, dl and rt.
- Add OSQUERY_TOOLCHAIN_SYSROOT option which should contain
  the path to the sysroot where the portable compiler and its libraries are in.
- Fix OpenSSL build with custom toolchain.
- Always include the custom toolchain cmake.
  Unfortunately system name detection is done when project() is called
  which is also when compiler detection is done, and we need the compiler
  to be set before that, so we always include the cmake file.
- Do not use getrandom syscall in Boost, for glibc < 2.25 support.
- Remove usage of secure_getenv and getauxval in librpm.
- Update CI to use the toolchain.
- Reflect changes in the docs.
2019-09-06 19:51:25 -04:00
Stefano Bonicatti
dfd6c06b67
Link binaries with Full RELRO on Linux (#5748)
Full RELRO is a useful exploit mitigation which disables lazy
binding of functions, makes the GOT read-only and also reorders the ELF sections so
that a buffer overflow cannot easily overwrite the next ones, where
normally the GOT is.
2019-09-07 00:20:32 +02:00
Alessandro Gario
6481b34e23
Refactor third-party libraries to build from source on Linux (#5706)
Add a way to compile third-party libraries from source instead of downloading prebuilt ones.
Each library source code is downloaded with git into a submodule at configure time,
in response to the find_package(library_name) CMake call,
except for OpenSSL where the official source archive is used.
Each submodule is attached to a release tag on its own upstream repository.
All the libraries are built using CMake directly, except for OpenSSL which uses a formula system,
which permits to build libraries with a separate build system
when there's no easy way to integrate it directly with CMake.

This new dependency system determines which library is fetched from where using the concept of "layers".
Currently we have three of them: source, formula, facebook,
where the last layer represents the pre-built libraries.
The provided order will be used when looking for libraries.

A system to patch submodule source code has been added and it's currently used with googletest, libudev and util-linux.
Patches should be put under libraries/cmake/source/<library name>/patches/<submodule>,
where <submodule> is often one and is "src", but in other cases, like AWS,
there are multiple with a more specific name.
If for whatever reason the submodule cloning or the patching fails,
the submodule has to be unregistered and its folder should be cleared.
This should be achievable with "git submodule deinit -f <submodule path>"

Following some other changes on existing functionality:

- Changed the CMake variable BUILD_TESTING to OSQUERY_BUILD_TESTS
  to avoid enabling tests on third party libraries.
  Due to an issue with glog the BUILD_TESTING variable
  will be always forced to OFF.
- Moved compiler and linker flags to their own file cmake/flags.cmake
- Moved all the third-party CMakeLists.txt used for pre-built libraries under libraries/cmake/facebook
- Added the --exclude-folders option to tools/format-check.py and tools/git-clang-format.py,
  so that it's possible to ignore any third party library source code.
- The format and format_check target use the new --exclude-folders option
  to exclude libraries/cmake/source from formatting.
- The test and osquery binaries are properly compiled with PIE (osquery/osquery#5611)

Co-authored-by: Stefano Bonicatti <stefano.bonicatti@gmail.com>
Co-authored-by: Teddy Reed <teddy@casualhacking.io>
2019-08-30 16:25:19 +02:00
Stefano Bonicatti
a5dfb3da7e
Improve osquery version detection (#5630)
Add OSQUERY_VERSION cache variable to force the version to be set at
that value.
Add OSQUERY_VERSION_AUTODECTED cache variable to show the osquery
version that has been detected through git
Add OSQUERY_VERSION_SUFFIX cache variable to append its value to the
final version, if the version was autodected.
Add OSQUERY_VERSION_INTERNAL variable to globally store the final
osquery version, to be used in other CMake scripts.
Add OSQUERY_VERSION_COMPONENTS variable to globally store the components
of the final osquery version. Currently used by the packaging system.

Modify overwrite_cache_variable so that's possible to specify the type.

The version is always autodetected using "git describe --tags --always --dirty"
and OSQUERY_VERSION_SUFFIX is appended to it, unless OSQUERY_VERSION is manually set.

Incorporates suggestions by @directionless.

CMake part of osquery/osquery#5615
2019-07-23 13:01:20 +02:00
Stefano Bonicatti
72c72b775f Explicitly add BUILD_TESTING CMake option (#5627)
This way is visible as a variable in the cache that can be set.
2019-07-10 03:57:10 +02:00
Stefano Bonicatti
08c36472cf Enable Debug builds on the CI (#5626)
* Add an option to avoid generating debug symbols

A new option, OSQUERY_NO_DEBUG_SYMBOLS, has been added
to avoid generating debug symbols when building in Debug or RelWithDebInfo.
This is especially needed on the CI where the disk size is limited
and symbols are not necessary, because we cannot directly access
processes to debug them.

* Enable Debug builds on the CI

Enabled Debug builds on macOS and Linux; a special job has been created
to represent the combined build status of Release and Debug builds.

Also format the other long cmakeArgs line so that there's one argument
per line.

* Run Docker as privileged also in Debug builds

* Simplify azure pipelines configuration

Use strategy and matrix to avoid repeating the script
for Release and Debug builds.
2019-07-10 00:32:26 +02:00
Stefano Bonicatti
d6a2f2f1df Fix detection of some headers on some IDEs (#5619)
Some IDE require that the headers are assigned to a target, so they know
which TU uses them and also that they are part of the project.
The option ADD_HEADERS_AS_SOURCES has been added, if it's ON,
we assign those headers as INTERFACE sources of the target that publish
them.
2019-06-30 23:24:56 +02:00
Stefano Bonicatti
942878854b Add CMake support
Taken from osql-experimental.

- Change CMake code license to the one present in osquery right now

- Package metadata doesn't mention Trail of Bits or osql anymore

- Set specific ACLs for the osqueryd on Windows when packaging

- Remove LLVM_INSTALL_PATH support on macOS, since we are using AppleClang

- Remove OSQUERY_SOURCE_DIR variable need and source in a submodule support

- Add targets format_check and format to check code formatting and
  format it with clang-format

- Do not warn about not using Clang on macOS when using AppleClang
2019-06-26 21:49:06 -04:00
Alessandro Gario
33fbbecb5f Initial commit
Taken from osql-experimental.

Initial support for Linux and macOS.
2019-06-26 21:49:06 -04:00