Commit Graph

42 Commits

Author SHA1 Message Date
Teddy Reed
c08322b764
ci: Fix pip upgrade warning (#6576) 2020-08-03 10:40:03 -04:00
Stefano Bonicatti
e17e3b659b
Azure Pipelines: Update compiler version used to v142 (#6528)
Also update the Windows Server version used from 2016 to 2019,
update Ninja to the latest stable and update the docs.
2020-06-27 10:17:23 -04:00
Stefano Bonicatti
46c1e6d8be Implement container access from tables on Linux
- Add the possibility of running table logic inside a container
  namespace, so that's possible to query it instead of the host.
  Needs minor modifications to each table logic and how they use logging.

  In practice it works by having a pid_with_namespace column, which should
  contain pids that are in the same mount namespace of the container one
  wants to query.
  The worker receives that column as a constraint, prepares two unnamed
  pipes for read/write communications with the future child, then forks
  into a new process.

  While the parent sends a query job to the just created child and then waits
  for results, the child receives the job, takes all the values given in the
  pid_with_namespace constraint, retrieves the fd of the mount namespace
  under "/proc/<constraint pid>/ns/mnt", then switches to it.
  Finally it runs the table logic, sending the results back to the parent
  through the pipe with a JSON message.

  Important to note that the logging in the table logic is not GLOG
  directly, because in the child this is in an unknown state; a custom
  logging system that resembles glog and that takes advantage of the
  existing communication channel is used to send the messages in JSON
  format to the parent, which will take care to forward to GLOG.

- Add FLAGS_keep_container_worker_open so that the process used for
  accessing a container is kept open, until the queries are for the same
  table; when the table changes, the process will be closed
  and a new one created.
  This is off by default, which means that a new process will be always
  created.

- Implemented a way to run tests that require root separated
  from the others.
  The OSQUERY_BUILD_ROOT_TESTS has been added to requests such tests to
  be built.
  To run only tests which require a normal user, one has to use
  `ctest -LE "root-required"`, while `sudo ctest -L "root-required"`
  to run those who need root.

PR: osquery/osquery#6209
2020-04-20 17:49:57 +02:00
Stefano Bonicatti
52f310a5a8
First steps to remove the Buck build system (#6361)
* First steps to remove the Buck build system

* Azure Pipelines: Rename jobs for consistency
2020-04-09 01:56:21 +02:00
Stefano Bonicatti
c22ab5c404
Simplify how third party libraries formula work (#6303)
Remove a level of indirection when configuring and building formulas.
This should simplify working with them and also remove some issues
encountered when trying to build on Windows.
2020-03-31 15:45:20 +02:00
Stefano Bonicatti
7ff9cf5a3f
Update osquery-toolchain to the 1.1.0 version (#6315)
This new toolchain contains a newer LLVM version (9.0.1),
a fix for the scan-build scripts and it keeps the LLVM static libraries,
necessary to implement the new BPF framework and tables.
2020-03-24 16:19:32 +01:00
Stefano Bonicatti
17aa6f2b4f
Azure Pipelines: Fix Python2 discovery in Buck builds (#6311)
In the past the Windows agent changed the path where Python2
was installed; a special logic was added which should've tested
if the path existed, though it wasn't correct in the case
the powershell script is configured to be aborted at the first error.

Since the old path should not be present anymore,
we simply remove the logic and use the path we expect to exist.
2020-03-19 09:54:03 -04:00
Stefano Bonicatti
58be58c29d
Azure Pipelines: reclaim disk space after building (#6307)
With the increasing size of the build and the respective ccache
and sccache caches, the disk space sometimes is not enough
and the build fails.
This deletes the build folder as the last step since it shouldn't
be necessary anymore.
2020-03-18 10:06:29 -04:00
Stefano Bonicatti
3c544388c7
Azure Pipelines: Do not ignore a build failure on Windows (#6270)
When the batch script that implements the build step has been
changed to stop the sccache server as the last command,
all build failures started to be ignored because the last command,
always succeeding, was clearing out the exit status.
Batch scripts do not have a global "exit on error" option,
so manually checking the error level and exiting with such error is needed.
2020-02-27 16:02:37 +01:00
scoders-tob
3eae135bc1
Adding docker_container_fs_changes table (#6178)
* adding docker pip package to dockerfile

* adding docker fs changes table

Co-authored-by: scoders <sahil@cs.toronto.edu>
2020-02-24 01:00:38 +01:00
Stefano Bonicatti
9a99c6b4c0
Add sccache to the Windows job (#6231)
* Add sccache to the Windows job

Also fix debug symbols on googletest,
so that it doesn't try to create a separate pdb.

* Fix uploading the submodule cache

sccache needs its cache to be uploaded as normal files,
not with a tar, otherwise the cache when extracted
will contain extraneous files and folders (PaxHeader).
The Files mode though by default ignores the .git folder,
so we have to use the .artifactignore file to unignore it,
and we have to copy in the cached path for the cache task to see it.
2020-02-06 16:07:58 +01:00
Stefano Bonicatti
68ee6a2c67
Add git submodule db to the Azure Pipelines cache (#6229)
This will speed up the CMake configure phase since
it won't have to download the submodules data each time
through git, which is slower than downloading it
as an Azure Pipeline cache.
2020-02-05 19:42:37 +01:00
Stefano Bonicatti
03b178103d Print CMake version in the CI (#6119)
This helps debugging issues that may arise
between different Azure Pipelines instances.
2019-12-12 20:33:47 -05:00
Stefano Bonicatti
a5afb35175 Update azure-pipelines.yml to install needed Python packages
Add an init process so that reaping works in the CI Docker image

Update Docker image name.
2019-12-07 20:51:09 -05:00
Stefano Bonicatti
45cf390c2a Force git to create symlinks on the CI (#6064)
git on Windows supports cloning a repository with symlinks
without actually creating them; it will substitute them
with text files containing the target path.
This can potentially break the build of some of osquery
third party libraries.

Moreover this is the default on the CI,
which is different compared to the setup on local machines,
which means that it can hide other kind of issues.
2019-11-20 21:36:23 -05:00
Teddy Reed
c8cd366c03
docs: Recommend macOS 10.11 deployment target (#6000) 2019-11-15 15:20:34 -05:00
SS
39405447f9 formatting functions py2->3 (PR #6011) 2019-11-09 01:26:45 +01:00
Alessandro Gario
7fee358178 CMake: Update the OpenSSL formula (#5976) 2019-11-01 21:25:14 -04:00
Teddy Reed
9a336877fd
cpack: Update build-id and create debug RPMs (#5936) 2019-10-31 11:39:46 -04:00
Stefano Bonicatti
4768b0997a
Explicitly select Xcode version 10.3 in azure-pipelines.yml (#5973) 2019-10-30 22:46:36 +01:00
Stefano Bonicatti
33e5fcb3b6
Add elfutils to the CI Dockerfile (#5940)
Needed to create RPM debuginfo packages.

Also update the azure-pipelines.yml to use the new Docker image.
2019-10-27 16:27:11 +01:00
Alessandro Gario
41fb4efba1
CMake: Migrate macOS and Windows to the OpenSSL formula (#5928) 2019-10-26 14:03:31 +02:00
Zachary Wasserman
30a7507c95
Fix shallow clone support for libraries in recent git versions (#5897)
Enables the v2 protocol which allows the repositories to be shallow
cloned without error.
2019-10-17 21:19:24 -07:00
Zachary Wasserman
419a2c97e8 Use git 2.21.0 for macOS CI (#5892)
This fixes issues with shallow clones of submodules and will enable
#5889 to pass CI.
2019-10-16 10:18:46 -04:00
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
Alessandro Gario
225bbaf992
Integrate cppcheck and clang-tidy within the CMake project (#5730) 2019-10-08 18:17:11 +02:00
Stefano Bonicatti
f2007c7057 Temporarily disable Buck tests on Linux (#5856)
Buck compiles tests in Debug mode even if supposedly told otherwise,
this exhausts disk space available on the CI and makes the step always fail.
2019-10-03 21:26:34 -04:00
Teddy Reed
52171f5676
azure/macos: Fix for brew/ant install failing (#5845) 2019-09-30 11:35:27 -04:00
Stefano Bonicatti
dd575f93f4 Add a test for the format_check script (#5835)
The test modifies the source code, appending "\n\n" at the end of each .cpp files.

Then runs the format_check target and verifies if the list of files to be formatted,
identified by the script, are the same ones previously modified.
2019-09-25 23:35:43 -04:00
Stefano Bonicatti
66601db099 Fix OpenSSL build when no system ar is installed (#5782)
OpenSSL should use the ar binary provided by the custom toolchain.
Also updated the docker image to avoid installing binutils and hiding the
issue.
2019-09-09 19:19:20 -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
0861929498
Implement caching on the CI (#5754)
Use the new CacheBeta task to cache and restore the ccache
directory, which greatly improves build times.

The cache is saved only if the job ends with success.

A pipeline variable CacheVersion present in the cache key
is used to invalidate all old caches if such a need arises.
2019-09-06 22:11:45 +02:00
Stefano Bonicatti
e51098b76a Add missing tests not run in Buck (#5752)
All the tests under tests/ and plugins/from the root of the project were not run.
2019-09-05 19:32:58 -04: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
f2514a347e
Fix python detection on Azure Pipelines (#5673)
A new Windows VM has been recently deployed that moves the
Python 2 installation, Windows Buck builds are now failing.

Support the old and new path for Python 2 and
support multiple minor versions of python instead of hardcoding one.
2019-07-29 10:26:23 +02:00
Stefano Bonicatti
31e35ae276 Add buck builds on Azure Pipelines (#5632)
First part of osquery/osquery#5620

Remove travis.
2019-07-11 17:12:54 -07: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
f34afd223c Fix ConfigTests.test_content_update
Do not checkout with carriage returns on Windows, otherwise it would
mess up with code that expect unix style files.
2019-07-09 12:59:45 +02:00
Stefano Bonicatti
6e928157b3 Fix ebpf tests failing.
Fix ebpfTests.sysEbpf_null_attr, ebpfTests.sysEbpf_create_map,
ebpfMapTests.int_key_int_value, ebpfMapTests.int_key_struct_value
by running Docker as privileged on Azure Pipelines.

Docker is used only to get a new distribution running, it's not used
for any security purpose, so there's no point in limiting it.
2019-07-09 12:59:45 +02:00
Stefano Bonicatti
dc7ffb820a
Fix tests output and yaml formatting for Azure Pipelines (#5613)
Apparently there's a bug in the visualization of the logs,
where color codes eat characters.
So we disable tests colored output until a fix on Azure Pipelines appears.

Formatting a bit more consistently the yaml file.
2019-06-29 12:48:08 +02:00
Stefano Bonicatti
2addb87602
Merge Azure Pipelines build and test jobs (#5610)
Originally the separation existed because there were multiple branches,
and only one of them was protected by PRs.
So broken commits could land and differentiating from broken build
or tests was useful.

This is not true anymore and PRs checks are per pipeline, not per job,
so the separation wouldn't make a difference.
2019-06-28 08:59:14 -04:00
Stefano Bonicatti
f8e279b4b9 Add Azure Pipelines support
Taken from osql-experimental.

- Use AppleClang compiler for macOS

- Run format_check on Linux

- Run pipeline only on master
2019-06-26 21:49:06 -04:00