Commit Graph

2995 Commits

Author SHA1 Message Date
Filipe Manco
bc35638678 Define osquery version on base.cfg (#5478)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5478

This makes it easier to update the osquery version and simplifies cxx.bzl by removing osquery specific preprocessor flags.

This will also make rebuilding osquery after changing versions faster, since the flags are now only defined for the headers which need them.

Reviewed By: akindyakov

Differential Revision: D14183142

fbshipit-source-id: 396d550f5b35a1d294fee802d2364cd9f7ab1d7a
2019-02-27 11:23:03 -08:00
Alexander Kindyakov
e7ae02c572 remove 'update' config plugin from config package and move it to oss/plugins (#5474)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5474

To be able to exclude config:update plugin from osquery plugin sdk.

Reviewed By: guliashvili

Differential Revision: D14241686

fbshipit-source-id: e378718b1e79e3dbe314a676945c18d15d054a3d
2019-02-27 08:32:19 -08:00
Alexander Kindyakov
2b808e3296 Move out to plugins/ registration of enroll:tls plugin in registry (#5473)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5473

to be able to exclude dependency on enroll:tls plugin from plugins_sdk.
Only plugin registration was moved by now. The actual plugin code will be moved a bit later.

Reviewed By: guliashvili

Differential Revision: D14241687

fbshipit-source-id: 814d52719ff27bd1283bcaecdc912fca3830ff5e
2019-02-27 08:32:19 -08:00
Alexander Kindyakov
cf743f77b7 New cli flag [tls_enroll_max_attempts] instead of reusing [config_tls_max_attempts] (#5472)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5472

To get rid of dependency on `plugins/config:tls_config` from `osquery/remote/enroll/tls_enroll`.
To be able to remove dependency on `plugins/config:tls_config` from plugins_sdk.

Reviewed By: guliashvili

Differential Revision: D14241685

fbshipit-source-id: 27cda0be9d0b6dc142374cc3a9e7c40a4fa97b94
2019-02-27 08:32:19 -08:00
William Woodruff
fe70a514af windows/logged_in_users: Add sid, hive columns (#5454)
Summary:
This introduces two new (Windows-only) columns to the `logged_in_users` table:

* `sid` corresponds to the logged in user's security identifier, used to uniquely identify the user and their permissions on the local system.
* `registry_hive` corresponds to the user's HKU registry hive, used to look up per-user configuration information.

I've updated the integration tests to test for these columns on Windows only. Please let me know if there's anything else I can do!
Pull Request resolved: https://github.com/facebook/osquery/pull/5454

Differential Revision: D14195466

Pulled By: fmanco

fbshipit-source-id: def9c362fac1b5a68b68f826916daafee224295b
2019-02-27 05:52:56 -08:00
William Woodruff
139aaef0ed windows/logical_drives: Refactor (#5400)
Summary:
This generally refactors the `logical_drives` table on Windows to conform more closely to C++11 idioms. It also enables the integration test for `logical_drives`.

See #5367. I'll open a PR for the boot partition fixes once this is merged.

cc akindyakov guliashvili
Pull Request resolved: https://github.com/facebook/osquery/pull/5400

Differential Revision: D14131722

Pulled By: fmanco

fbshipit-source-id: c3077da48147a9880ce08925d165e5d1da363bb9
2019-02-26 16:03:20 -08:00
Alexander Kindyakov
ee8142a99c impl_fbthrift injection for fbcode build of osquery PROD extensions
Summary:
Let's create a fbcode wrapper for osuery plugin SDK to wrap it up with fbthrift implementation from fbcode. Also we should trick the build system and add empty function `registerForeignTables()` to avoid including all osquery builtin tables implementation.

Since that, SDK suppose to be full functional and ready to be used to build facebook PROD extensions in fbcode with dependency on it (see next diff).

Reviewed By: fmanco

Differential Revision: D14224205

fbshipit-source-id: c08cbb374f2d68f6b93637809b97dcf0159c9e08
2019-02-26 11:20:08 -08:00
Alexander Kindyakov
b7d635ec2b remove thrift_impl from osquery plugin_sdk
Summary: To be able to build with different `thrift_impl` modules in extensions (like facebook does with fbthrift) I removed implementation from `extensions` lib and explicitly used for `osqueryd` and for all tests. This allows us to remove `thrift_impl` from sdk dependencies list. If you need it - please use explicitly as I did for `osqueryd`. If you want to use your own implementation of `thrift_impl` - build it and link against it and sdk simultaneously.

Reviewed By: marekcirkos

Differential Revision: D14224206

fbshipit-source-id: 218dc05d87e1ffaca37783185fc672a20684d757
2019-02-26 11:20:08 -08:00
Alexander Kindyakov
84e573751c Separate osquery/extensions:extensions into extensions, interface, thrift_impl (#5466)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5466

To be able to use other implementation (like `fbthrift_impl.cpp`) instead of `thrift_impl.cpp`, if required.

Reviewed By: marekcirkos

Differential Revision: D14208053

fbshipit-source-id: ba379ea85fc66deef517763eaca896e88729d68e
2019-02-26 11:20:08 -08:00
Nick Anderson
01ce1ad1cb tables: re-architect the processes table to not use WMI queries (#5293)
Summary:
tables: re-architect the processes table to not use WMI queries

This PR re-writes the processes table to no longer rely on WMI queries. We do this to ensure that the processes table is robust and performant, as we rely on this table for the watcher process to regulate the worker processes. Further, this table further employs the selective column generation introduced to the processes table on darwin to allow us to more selectively generate column data only when necessary.

Lastly, this table removes a couple of extraneous columns from the Windows table schema, as these column values are achievable via sqlite logic. Specifically:

* `elapsed_time`: to get this column one can use the `start_time` column along with the sqlite built in `strftime` function:
```
osquery> select name, (strftime('%s', 'now') - start_time) as uptime from processes limit 5;
+------------------+--------+
| name             | uptime |
+------------------+--------+
| [System Process] |        |
| System           | 7131   |
| Registry         | 7154   |
| smss.exe         | 7131   |
| csrss.exe        | 7127   |
+------------------+--------+
```
* `percent_processor_time`: to obtain the total time that a process has been executing on a system, one can add together the `user_time` and `system_time` together to get the same value returned by the WMI value, the difference being that the sumation of `user_time` and `system_time` are in milliseconds whereas the values returned from WMI are in 100 nanosecond ticks:
osquery `percent_processor_time`:
```
osquery> select pid, name, (user_time + system_time) as percent_processor_time from processes where name = 'osqueryd.exe';
I1112 21:54:11.809412  2152 processes.cpp:461] Failed to open handle to process 0 with 203
+-------+--------------+------------------------+
| pid   | name         | percent_processor_time |
+-------+--------------+------------------------+
| 3892  | osqueryd.exe | 5952                   |
| 808   | osqueryd.exe | 0                      |
| 5892  | osqueryd.exe | 52374                  |
| 11688 | osqueryd.exe | 280                    |
+-------+--------------+------------------------+
```
Same data obtained with WMI.
```
λ  Get-WmiObject -Query "Select IDProcess, Name, PercentProcessorTime from Win32_PerfRawData_PerfProc_Process" | Where-Object {$_.Name -like 'osqueryd*'}

IDProcess            : 3892
Name                 : osqueryd
PercentProcessorTime : 59531250

IDProcess            : 808
Name                 : osqueryd#1
PercentProcessorTime : 0

IDProcess            : 5892
Name                 : osqueryd#2
PercentProcessorTime : 523750000

IDProcess            : 11688
Name                 : osqueryd#3
PercentProcessorTime : 2812500
```

Some additional notes, just to verify we're getting all data:
```
C:\Users\Nick\work\repos\osquery [windows-process-rearch ↑]
λ  .\build\windows10\osquery\RelWithDebInfo\osqueryd.exe -S --json "select count(*) from processes;"
[
  {"count(*)":"160"}
]
C:\Users\Nick\work\repos\osquery [windows-process-rearch ↑]
λ  C:\ProgramData\osquery\osqueryd\osqueryd.exe -S --json "select count(*) from processes;"
[
  {"count(*)":"160"}
]
```
Also we achieve a considerable speed up from this re-arch:
```
C:\Users\Nick\work\repos\osquery [windows-process-rearch ↑]
λ  (Measure-Command {.\build\windows10\osquery\RelWithDebInfo\osqueryd.exe -S --json "select count(*) from processes;"}).Milliseconds
168
C:\Users\Nick\work\repos\osquery [windows-process-rearch ↑]
λ  (Measure-Command {C:\ProgramData\osquery\osqueryd\osqueryd.exe -S --json "select count(*) from processes;"}).Milliseconds
223
```
Pull Request resolved: https://github.com/facebook/osquery/pull/5293

Reviewed By: fmanco

Differential Revision: D13561337

Pulled By: muffins

fbshipit-source-id: 61435611d34d2cfd5f61ea52512a9dc208d259a5
2019-02-25 09:39:14 -08:00
Jesse Kornblum
f26de32fe3 Add error message for when we don't send an item name to the registry lookup (#5464)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5464

While attempting to debug this issue I have discovered we are attempting to look up an empty item name in the registry. This doesn't make sense as we are clearly passing in an item name. This diff doesn't solve the issue, but it does add an error message for when it happens.

While we're here, appeasing Lint by using a more modern call to the `Status` return type.

Reviewed By: guliashvili

Differential Revision: D14207654

fbshipit-source-id: a53035ea84357f9ffe1d216b66e116257f291a7f
2019-02-25 09:31:15 -08:00
George Guliashvili
8df421d827 Trim whitespace in Darwin system_info table from hardware_serial column
Summary: Trim whitespace in Darwin system_info table from hardware_serial column.

Reviewed By: jessek

Differential Revision: D14207715

fbshipit-source-id: 2948b8687c0c40d43f13ab42ddc4bbfec8e59a48
2019-02-25 07:55:13 -08:00
Jason Meller
c7dd74f83c Trim whitespace from Darwin system_info fields (#5167)
Summary:
This PR fixes #5106 by trimming the whitespace we get from the data returned from the macOS API. At first I thought this was an osquery regression, but going as far back as 2.x this looks like it has always been a problem.

Before the fix...

```
echo "select hardware_model, hardware_vendor, hardware_version from system_info;" | osqueryi --json | jq
[
  {
    "hardware_model": "MacBookPro13,3 ",
    "hardware_vendor": "Apple Inc. ",
    "hardware_version": "1.0 "
  }
]
```

After the fix... (note the lack of trailing spaces)

```
echo "select hardware_version, hardware_vendor, hardware_model from system_info;" | /Users/jmeller/source/osquery/build/darwin10.13/osquery/osqueryi --json | jq
[
  {
    "hardware_model": "MacBookPro13,3",
    "hardware_vendor": "Apple Inc.",
    "hardware_version": "1.0"
  }
]
```
Pull Request resolved: https://github.com/facebook/osquery/pull/5167

Reviewed By: jessek

Differential Revision: D14207353

Pulled By: guliashvili

fbshipit-source-id: 4012e04b38e2b5bfc299684baf86d0ab34cd42f8
2019-02-25 07:55:13 -08:00
Alexander Kindyakov
1822881c21 move pthread and libresolv to third-party/glibc
Summary: as far as they are actually part of glibc, that would be less confusing. Later it will help us to deal with fully static build.

Reviewed By: marekcirkos

Differential Revision: D14183689

fbshipit-source-id: 8b712286e171305a49be6703b846f6f935b7dcc2
2019-02-25 03:05:40 -08:00
Alexander Kindyakov
17850e3040 Let's use glibc:ld thirdparty dependency instead of linker flag -ldl
Summary: to be able to proxy it inside `osquery_tp_target` function.

Reviewed By: marekcirkos

Differential Revision: D14182918

fbshipit-source-id: d56b7135664ecd5afcc87b1c1cd2cde5394368a0
2019-02-25 03:05:40 -08:00
Alexander Kindyakov
0ae1de3d86 Remove Initializer::shutdown() from process.cpp
Summary:
It cause implicit dependency to osquery/core:core, that cause circular dependency :(. The point is to get rid of it. Let's use just exit() instead.

As far as we don't have decent implementation of Initializer::shutdown it will not cause us any more problems.
We can live with it for a while.

Reviewed By: marekcirkos

Differential Revision: D14182915

fbshipit-source-id: 22c54cde910ea29b1fb19d96598db381b9d1c60d
2019-02-25 03:05:40 -08:00
Jeremy Calvert
67447bbd96 Custom cast so that 0.0 as a double casts as "0.0"
Summary:
This fixes a regression introduced in D13586036 .

The tailer downstream sometimes determines type by trying to parse the string as an int.  We want this to consistently fail to do so when the value is in fact a float.

Reviewed By: SAlexandru

Differential Revision: D14161125

fbshipit-source-id: 8e2bb9c59559a5774813a7c7777257742f885c35
2019-02-22 10:23:07 -08:00
Alexander Kindyakov
3e3ff5dc5d split up events target and move events.cpp to separate target
Summary: only events.cpp required by plugin_sdk, everything else is not necessary

Reviewed By: marekcirkos

Differential Revision: D14131365

fbshipit-source-id: 18e101b3e549d8403aa22ee3d5a5fadd2b296c82
2019-02-22 09:33:27 -08:00
Alexander Kindyakov
4d0ed75372 Use osquery.thrift file from xplat in fbcode
Summary:
I didn't find a way to refer file in fbcode thrift_library from xplat. So, let's copy it.

There is something wrong with a namespaces in python - I'll fix it later. This is not a problem for now - file is not used.

Reviewed By: marekcirkos

Differential Revision: D14124542

fbshipit-source-id: 1060e23675a8086af494aa93037e1c613f250c71
2019-02-22 09:33:27 -08:00
Alexander Kindyakov
3fb4acbdfa osquery/extensions/impl_fbthrift.cpp are moved to fbcode/osquery/sdk
Summary:
As far as this file is only for internal build, to be able to build osquery sdk against fbthrift I moved it to fbcode from oss.
Later if we want to osqeruy work with fbthrift we can copy/move it again

Reviewed By: marekcirkos

Differential Revision: D14124448

fbshipit-source-id: aaeadb40a6fac19621423b225cf6d522607d1313
2019-02-22 05:46:01 -08:00
Alexander Kindyakov
906e42863c Remove colorlogtostderr glog flag from logger.cpp
Summary: This thing doesn't work with fbcode build :(

Reviewed By: fmanco

Differential Revision: D14123217

fbshipit-source-id: 1a3be9adb6f77d065a8df2ee2a64a4c1f154ad16
2019-02-22 05:46:01 -08:00
Alexander Kindyakov
87ba7daedb Remove unnecessary internal header definition from core/plugins/BUCK and core/sql/BUCK (#5461)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5461

They duplicate exported_headers and cause failures in cpp_library target definition

Reviewed By: fmanco

Differential Revision: D14164702

fbshipit-source-id: 78d096abb6d87221ffca9bf725ccacf648520edb
2019-02-22 05:46:00 -08:00
Mark Mossberg
5edb4c5b81 Add Windows product version information to file table (#5431)
Summary:
Hi! This PR adds a new column called `product_version` to the file table, which is only
populated when queries are done on Windows. It is a very minimal PR that uses an existing helper function (`windowsGetFileVersion`) to populate the column.

The column is not named `file_version`, despite the name of the helper function because the underlying data retrieved by that helper function is actually the `dwProductVersion*` fields of the `VS_FIXEDFILEINFO` struct. In the future, if we want to add a column that _actually_ contains the results of the `dwFileVersion*` fields, we can add a new column called `file_version` without modifying existing functionality.
Pull Request resolved: https://github.com/facebook/osquery/pull/5431

Differential Revision: D14169773

Pulled By: fmanco

fbshipit-source-id: 6fa7c92425fc92aa2e83a37383b1a8c796b17644
2019-02-21 13:45:46 -08:00
Alexander Kindyakov
31ede55573 remove osquery/third-party/googletest:gmock_headers target
Summary: It cause problems with compiling against tp2 because in tp2 there is no such target. As far as I can see there is no necessity to depend on that target separatelly from gtest. So, the simplest solution is to remove it

Reviewed By: SAlexandru

Differential Revision: D14149801

fbshipit-source-id: fe0fcd0593bded7c8f2c6fd247b1d52bd29bac9f
2019-02-21 02:52:53 -08:00
Filipe Manco
3dfea42d58 Disable flaky test test_tls_enroll
Summary: This test is flaky on some systems. Need to investigate and fix.

Reviewed By: guliashvili

Differential Revision: D14149533

fbshipit-source-id: 7df570c84c66cad8bdc67a1286d91a7c7e8e3502
2019-02-20 06:00:17 -08:00
Filipe Manco
dfa46426fe Improve tls_enroll_tests (#5458)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5458

Use ASSERTs where necessary. ASSERTs are fatal and terminate the test immediately, so should be used when subsequent tests aren't meaningful in case of previous failures. Only use EXPECTED when it makes sense for the tests to continue.

Reviewed By: jessek

Differential Revision: D14138382

fbshipit-source-id: aae0cd8640e602ac467861303457f9cf017bc5e8
2019-02-20 06:00:17 -08:00
Jesse Kornblum
c7355b19aa Update osquery licensing wording (#5452)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5452

As suggested in another diff, this diff updates the language we use to describe the osquery licensing terms. We are changing all instances of

//This source code is licensed as defined on the LICENSE file found in the root directory of this source tree.//

to

//This source code is licensed in accordance with the terms specified in the LICENSE file found in the root directory of this source tree.//

We accomplish this with a codemod:

  $ codemod -md xplat/osquery/oss --extensions cpp,h,in,py,sh,mm,ps1 "(.\s+)This source code is licensed as defined on the LICENSE file found in the(.*)root directory of this source tree\." "\1This source code is licensed in accordance with the terms specified in\2the LICENSE file found in the root directory of this source tree."

Reviewed By: fmanco

Differential Revision: D14131290

fbshipit-source-id: 52c90da342263e2a80f5a678ecd760c19cf7513e
2019-02-19 10:59:48 -08:00
Filipe Manco
484520e1ff Move plugins to a separate directory [4/?] (#5449)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5449

Initial steps to separate plugins from the rest of osquery. On the long run separating plugins will provide more build flexibility such that we can have configurable builds that include only the bits and pieces we actually need per deployment. Reducing the attack surface, possibility of supply chain attacks, binary size, etc.

Move killswitch

Move test declaration to it's own BUCK file for consistency with the rest of the project.

Reviewed By: marekcirkos

Differential Revision: D14121618

fbshipit-source-id: 3e30e57befed4387585ed553ec087fdf8db6efc3
2019-02-19 07:14:37 -08:00
Filipe Manco
7a8e13c06b Move plugins to a separate directory [3/?] (#5448)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5448

Initial steps to separate plugins from the rest of osquery. On the long run separating plugins will provide more build flexibility such that we can have configurable builds that include only the bits and pieces we actually need per deployment. Reducing the attack surface, possibility of supply chain attacks, binary size, etc.

Move logger

Reviewed By: marekcirkos

Differential Revision: D14121620

fbshipit-source-id: cef15e7cc354cbe597c6c6878ee63ff09b5fb06d
2019-02-19 07:14:37 -08:00
Jesse Kornblum
4c14814ec3 Relicense yara_utils to Facebook (#5450)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5450

This file was originally written by wxsBSD in 2015. He has since joined Facebook and has graciously agreed to re-license this file to Facebook. This diff formalizes the relicensing by changing the copyright notice on the file. Note that wxsBSD still retains a copyright to all previous versions of the file.

Reviewed By: wxsBSD

Differential Revision: D14131447

fbshipit-source-id: 3148eafc0162a23b86e064a9784ea01b685164ef
2019-02-19 06:49:50 -08:00
Filipe Manco
2d5572d51e Move plugins to a separate directory [2/?]
Summary:
Initial steps to separate plugins from the rest of osquery. On the long run separating plugins will provide more build flexibility such that we can have configurable builds that include only the bits and pieces we actually need per deployment. Reducing the attack surface, possibility of supply chain attacks, binary size, etc.

Move distributed

Reviewed By: marekcirkos

Differential Revision: D14121619

fbshipit-source-id: 9ad8a837450874e79a819ab4f11258ae24ec8014
2019-02-19 00:55:27 -08:00
Filipe Manco
be07c2938a Move plugins to a separate directory [1/?]
Summary:
Initial steps to separate plugins from the rest of osquery. On the long run separating plugins will provide more build flexibility such that we can have configurable builds that include only the bits and pieces we actually need per deployment. Reducing the attack surface, possibility of supply chain attacks, binary size, etc.

Move config and config_parser plugins

Reviewed By: marekcirkos

Differential Revision: D14119102

fbshipit-source-id: 0bc956398b3829c6f1013b38ebba2f0fc1071a93
2019-02-19 00:55:27 -08:00
Jesse Kornblum
910e46b28f Add Facebook Copyright message to Facebook owned, open-source osquery files (#5445)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5445

This diff adds a Facebook copyright header to files in the osquery open source repository which:
* Facebook owns
* Do not currently have a Facebook copyright header

Reviewed By: marekcirkos

Differential Revision: D14122845

fbshipit-source-id: 5a0fea10189ec4ec893f7a036911fd51de0e01ae
2019-02-18 13:51:04 -08:00
Mark Mossberg
1a6dd2a6dc system/windows: Correct spelling (#5442)
Summary:
Corrects a spelling mistake in authenticode.
Pull Request resolved: https://github.com/facebook/osquery/pull/5442

Differential Revision: D14100550

Pulled By: SAlexandru

fbshipit-source-id: ed2855e3ca8afa35618033dccbc60a0cd45e4fda
2019-02-15 13:58:26 -08:00
George Guliashvili
0da8b0227b Agregate query stats by Min and Sum (#5427)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5427

Updating query performance monitoring.

Reviewed By: akindyakov

Differential Revision: D14025530

fbshipit-source-id: a50ba0244e0baf83134209258549f86f0717b976
2019-02-14 06:22:45 -08:00
Alexander Kindyakov
51b104823c Fix up flaky tests: FileOpsTests.test_safe_permissions and FileOpsTests.test_safe_db_permissions
Summary: Please never reuse tmp directory with the same name :(

Reviewed By: guliashvili

Differential Revision: D14066968

fbshipit-source-id: 164d0b9e6f34b102759bc5919dadc37197ff0798
2019-02-14 03:51:50 -08:00
Alexandru Stefanica
1621213813 fix magic table (#5438)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5438

currently the magic table is broken. libmagic which is used to generate this information needs a database/configuration file that it usually auto-finds.
Our libmagic library tries to open the following file ```open("/usr/local/osquery/Cellar/libmagic/5.32_200/share/misc/magic.mgc", O_RDONLY) = -1 ENOENT (No such file or directory)``` (you can generate  this by using strace like ```trace -q -e trace=open ./buck-out/debug/gen/xplat/osquery/oss/osquery/osqueryd#gcc-5-glibc-2.23-clang -verbose -S "select * from magic where path = '/etc/passwd'"```).
How it auto-finds it I don't know 100%, but I guess it has something to with how the libmagic.so is actually build and installed. Basically this never works unless you are a developer on mac and used our previous build system.

I've updated the table to be able to specify the path to magic database file. If you don't specify it, I tried to check if one of the default files (files that should be present under /usr/share/ exists and use the first found). If all fail, I try the default one, but that most likely will fail.

Reviewed By: guliashvili

Differential Revision: D14066467

fbshipit-source-id: d9d2aca4829b2275e6792f974de1f2a7808dc321
2019-02-13 13:58:52 -08:00
Alexander Kindyakov
e7d1a56cfc Rename syscall::Type to syscall::EventType (#5429)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5429

thanks Alexandru for a question in review :)

Reviewed By: guliashvili

Differential Revision: D13895951

fbshipit-source-id: 66c85a35d53bcf1cc8c5a7b8202bfaa0f03b05a2
2019-02-13 10:55:34 -08:00
Alexander Kindyakov
70d1e25cb2 Move setting up routine of output channels inside LinuxProbesControl class (#5428)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5428

This is a final diff to be able to track syscalls by using eBPF + kernel events. Basically that one and previous are about to join high level initialisation routine in one place.

Part of a linux  tracing system, blueprint: [#5218](https://github.com/facebook/osquery/issues/5218)

Reviewed By: SAlexandru

Differential Revision: D13801093

fbshipit-source-id: db8503b0d42127281a975ff517600872e9ed4302
2019-02-13 10:55:34 -08:00
Alexander Kindyakov
40a4276b4d Fix up windows (cygwin) specific problem in carver tests (#5437)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5437

- test should not assume that fs::temp_directory_path() is always the same
- test should clean everithin up in TearDown() method
- tests should no depend on the order (test_decompression previously was depending on test_compression)

Reviewed By: mkareta

Differential Revision: D14064645

fbshipit-source-id: 653e2061c3de8e3fc30a4f0fc553831f22e62fb7
2019-02-13 10:55:34 -08:00
Alexander Kindyakov
59437ee9a5 std::getenv doesn't work for windows sometimes, let's use osquery::getEnvVar instead
Reviewed By: jessek

Differential Revision: D14065193

fbshipit-source-id: 62523b183a87dc8d49eee6e4146cf41825baceeb
2019-02-13 10:55:34 -08:00
Nick Anderson
6075f31393 addressing deadlock regression in windows dispatcher threads (#5421)
Summary:
This addresses a slight regression to ensure that we set `set_terminate_threads` on Windows. Without this flag being set, Windows threads will deadlock on exit as the boost managed io service threads never receive termination notifications.

I'm opening this PR up against the old master as I feel we should likely cut a 3.3.3, and I'm happy to re-open this PR against the upstream experimental as well, but we'll want a fix for this released as quickly as possible to Windows deployments.
Pull Request resolved: https://github.com/facebook/osquery/pull/5421

Reviewed By: marekcirkos

Differential Revision: D13972916

Pulled By: muffins

fbshipit-source-id: 55e3b23c80091d5fb51a97d1efc043b52dc48ba3
2019-02-12 12:59:56 -08:00
George Guliashvili
e98f439caf Revert small db optimization
Summary: Revert rocksdb small db optimization for osquery.

Reviewed By: marekcirkos

Differential Revision: D14045578

fbshipit-source-id: baec8f22658844bc202dd099001ea361661d2d72
2019-02-12 12:45:35 -08:00
Alexander Kindyakov
e44cbe0f3f Add thirdparty [boost] dependency to osquery/utils:utils
Summary: It was apparently missed

Reviewed By: guliashvili

Differential Revision: D13991104

fbshipit-source-id: aadc22de6a679e2ede97c483bbedf17d066ea0ae
2019-02-12 04:08:17 -08:00
Alexander Kindyakov
77279b034f linux tracing probes control (#5419)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5419

to load new programs, enable native events and attach program to them.

Reviewed By: SAlexandru

Differential Revision: D13787783

fbshipit-source-id: cfc001da15b343e5c80fd0ab6a276f263aa0ef7a
2019-02-11 03:17:37 -08:00
Alexander Kindyakov
6ee0fd18ea Do not mess with namaspace which comes from thirdparty library (rapidjson) (#5424)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5424

Let's use `SizeType` definition from rapidjson itself

Reviewed By: marekcirkos, fmanco

Differential Revision: D13986840

fbshipit-source-id: 53b3bf4dcb41c27e2cf18fee3aed97b9e2e42202
2019-02-11 02:33:19 -08:00
George Guliashvili
758706331f Remove unused flag enable_monitor
Summary: Removing flag which was declared but never used. enable_monitor

Reviewed By: marekcirkos

Differential Revision: D13958265

fbshipit-source-id: 3a812330950b101abdbd83ada4afd5b262cabd26
2019-02-07 08:16:00 -08:00
George Guliashvili
52ef26e96e Use SQLITE_CONSTRAINT when required constraint does not exist (#5422)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5422

We were just de-prioritizing type of queries not constraining required columns. However, when the query is just useless without specific constraint, sqlite suggestion is to return SQLITE_CONSTRAINT status.

Reviewed By: marekcirkos

Differential Revision: D13964562

fbshipit-source-id: ee0e5f8baf9abbf83c34f7a39d2b5bd705cbac6d
2019-02-07 03:14:38 -08:00
Max Kareta
6ade85a5f3 fixed crash in virtual table implementaion
Summary:
Fixed crash in virtual tables that occurs after following steps:
1. sqlite opens VT with xCreate
2. during query executions invokes xFilter with multiple tables
3. Few tables accumulated in affectedTables
4. xDestroy called before finishing query (last step of query execution)
5. query execution finished, SQL instance try to cleanup affected tables, but they were already destroyed by xDestory

This is only hotfix for this crash and this code base require full memory management review in future

Reviewed By: SAlexandru

Differential Revision: D13917015

fbshipit-source-id: 15396e47e4c4e592cf30608a783bc80d560c776f
2019-02-05 07:20:00 -08:00
Max Kareta
40742aa582 temp solution for xcode support
Summary:
This diff adds Xcode support for osquery.
Part of this diff will be reverted in future after adding prebuilt library and platform deps support to buck.

To use it you need to build osquery in debug mode and then run buck with following flags:
  --config osquery.xcode=true --config project.ide=xcode

Reviewed By: SAlexandru

Differential Revision: D13903315

fbshipit-source-id: 4d131964d7a61236f25d917dc060a2f3c3d782bc
2019-02-05 07:20:00 -08:00