Commit Graph

3186 Commits

Author SHA1 Message Date
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
Alexander Kindyakov
9d12502139 Fix up start_time column for macos (#5412)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5412

Now on different platforms column `start_time` in `processes` table means different things. On Linux it is seconds since system boot, but it works correct only for some platforms, because the number of clock ticks per second was hardcoded. On windows it was abs unix time in seconds since Epoch. On macos it is a time in milliseconds (may be?) since system boot. On freeBSD as far as I can see it an abs time since boot, but also I'm not sure.

In order to make it consistent for all OS we changed to more convenient format - absolute time since Epoch. This commit is about macos.

Reviewed By: marekcirkos

Differential Revision: D13918625

fbshipit-source-id: eacb297358b36ce72cb0d5a7d9171553688ab2a3
2019-02-05 03:50:20 -08:00
Alexander Kindyakov
84b7f4f7a4 Change semantics of 'start_time' colume in processes table (#5414)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5414

Now on different platforms column `start_time` in `processes` table means different things. On Linux it is seconds since system boot, but it works correct only for some platforms, because the number of clock ticks per second was hardcoded. On windows it was abs unix time in seconds since Epoch. On macos it is a time in milliseconds (may be?) since system boot. On freeBSD as far as I can see it an abs time since boot, but also I'm not sure.

In order to make it consistent for all OS we changed to more convenient format - absolute time since Epoch. This commit is about Linux. Next diffs going to be about Darwin and freeBSD.

Reviewed By: guliashvili

Differential Revision: D13918626

fbshipit-source-id: a9cf0570dc6ac9fa125bc8233e9965c4e01566a6
2019-02-05 03:50:20 -08:00
Max Kareta
8e81e5b259 fixed last gtest direct dependency
Summary: Another fix for multiple mains in osqueryd binary

Reviewed By: guliashvili

Differential Revision: D13901871

fbshipit-source-id: 8802bf8a9de6c333b6c592195435071fcc1b57ca
2019-02-05 03:18:49 -08:00
Alexander Kindyakov
00bb3991ec Let's EbpfTracepoint own the ebpf::Program and tracing::NativeEvent (#5418)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5418

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

Reviewed By: SAlexandru

Differential Revision: D13787759

fbshipit-source-id: 35bb4b41f7cebfeb91aa848a1583c9eae3e2a363
2019-02-05 02:16:54 -08:00
Alexander Kindyakov
fbd5b99231 Class to join exit-enter event pairs (#5417)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5417

Hash multimap based joiner with ability to perform clean up old unpaired events from time to time.

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

Reviewed By: SAlexandru

Differential Revision: D13761675

fbshipit-source-id: f4b17cbeed495b2a9e6616a005f001963849875e
2019-02-05 02:16:54 -08:00
George Guliashvili
6f8b044a4c Use machine identity for monitoring
Summary: For some monitoring, we need to include machine identity. Two example, I found is hostname or similar hostnames schema name.

Reviewed By: SAlexandru

Differential Revision: D13880705

fbshipit-source-id: e1d0238f4981adad1554d73f0ef6e5ef65a98c33
2019-02-04 11:08:32 -08:00
Alexander Kindyakov
344fbed429 Add flipType, isTypeEnter, isTypeExit for the systemcall event types (#5416)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5416

To able to invert type from enter to exit and determine if type is exit or enter.

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

Reviewed By: SAlexandru

Differential Revision: D13761673

fbshipit-source-id: 2bf668219fd996d9d5b67e0e1ccf5c1161a41481
2019-02-04 07:56:39 -08:00
Alexander Kindyakov
8871a1a493 Linux eBPF program to track setuid syscall (#5415)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5415

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

Reviewed By: SAlexandru

Differential Revision: D13669863

fbshipit-source-id: aadd14734cdc3586526be59f76f3176fa981a57f
2019-02-04 07:56:39 -08:00
Alexander Kindyakov
79cd575790 Make message realated methods of class Error shorter and less diverse (#5410)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5410

 - get rid of *Short* methods
 - getFullMessage -> getNonRecursiveMessage
 - getFullMessageRecursive -> getMessage

Reviewed By: mkareta

Differential Revision: D13897854

fbshipit-source-id: 3e97ceefb2a48a16cd400f7ba7dd730724957ef0
2019-02-01 07:33:53 -08:00
Alexander Kindyakov
da91d8cfe8 to<std::string>() conversion template for c++ enums (#5408)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5408

Move out c++ enums to std::string conversion function from
osquery/utils/error.h to separate module. To be able to use it somewhere else.

Reviewed By: guliashvili

Differential Revision: D13896772

fbshipit-source-id: 0a9f6327d5b2f115ce688446a67677879411eb1f
2019-02-01 07:33:53 -08:00
Alexander Kindyakov
32385bd9ca Hash function for enum classes (#5409)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5409

This is just a ad-hoc fix up to handle libc++ and libstdc++ bug:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
Eventually it will be removed.

Reviewed By: guliashvili

Differential Revision: D13896844

fbshipit-source-id: 38b3cd43b913e5e64d8d9ac40417e6ed0fcb6c41
2019-02-01 03:47:02 -08:00
Max Kareta
188a229d8c fixed double main function
Summary: before this diff osqueryd was relying on linker order to use right main function, since gtest also contains main function

Reviewed By: guliashvili

Differential Revision: D13897622

fbshipit-source-id: d260b7496f513c7052f4db87c8e7ff9300493671
2019-01-31 15:09:12 -08:00
Alexander Kindyakov
ee2756f95c eBPF tracking program for any syscall exit event (#5403)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5403

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

Reviewed By: SAlexandru

Differential Revision: D13690684

fbshipit-source-id: 039fc89929de49fcc7bd2287a98ffc68450fcada
2019-01-31 07:37:25 -08:00
Alexander Kindyakov
3719770c06 Linux kill() enter/exit ebpf programs definitions (#5386)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5386

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

Reviewed By: SAlexandru

Differential Revision: D13654124

fbshipit-source-id: 8db63e584bd772132c1ba1c80853c60613e8036a
2019-01-31 07:37:25 -08:00
drakearonhalt
e205458be0 Added is_hidden column to the users and groups tables on macOS. (#5368)
Summary:
This PR is the result of the discussion in a previous PR (#5348) after we determined account_policy_data was the wrong place for the column.

Add `is_hidden` column to the users and groups tables in macOS. `is_hidden` is populated by looking for the `dsAttrTypeNative:IsHidden` attribute in the OpenDirectory record for the user/group if the value is `1`, `True`, or `Yes` is_hidden is 1. If the value is anything else it's set to 0. Invalid values have the same affect as the attribute not existing at all.

The `dsAttrTypeNative:IsHidden` attribute controls whether a user account is is visible in the preferences panel similar to having a uid < 500.

One test failed when running buck test:
```
====STANDARD OUT====
tests/integration/tables/helper.cpp:159: Failure
Value of: boost::get<CustomCheckerType>(validator)(value)
  Actual: false
Expected: true
Custom validator of the column "mask" with value "" failed
```
This also fails when I ran the test on the current experimental branch as well.

Important to note I had to remove the optimization on both the user and group tables that just called `getpwnam` if the query specified the `uid` or `gid` since the struct returned doesn't contain the `IsHidden` attribute.  I'm not sure if or how much this will affect performance since I wasn't able to get the profiling to work with the new version (very likely I'm just doing it incorrectly).
Pull Request resolved: https://github.com/facebook/osquery/pull/5368

Differential Revision: D13862375

Pulled By: akindyakov

fbshipit-source-id: 1fec88a6ba71884f7e611e1d96ea00630c5be655
2019-01-30 09:07:56 -08:00
George Guliashvili
5ec525aaed Rename profiler.[cpp|h] to code_profiler.[cpp|h]
Summary: profiler file contained the CodeProfiler class, which is a bit odd. Thanks alecx

Reviewed By: akindyakov

Differential Revision: D13861320

fbshipit-source-id: 11d711fd1d15830d4cce0be084cc6da3b1c6589c
2019-01-30 08:11:21 -08:00
George Guliashvili
7edf72ed6d Split query name and pack name
Summary:
Split query name and pack name with the delimiter(dot) which should not accrue inside their names(instead of _ or -).
Also log things per pack name

Reviewed By: SAlexandru

Differential Revision: D13854471

fbshipit-source-id: 181e7e19fcfb5d57a779cea6a2804eda09dc5a91
2019-01-30 06:50:08 -08:00
George Guliashvili
c7a9338819 Split query name and pack name
Summary:
Split query name and pack name with the delimiter(dot) which should not accrue inside their names(instead of _ or -).
Also log things per pack name

Reviewed By: mkareta

Differential Revision: D13854389

fbshipit-source-id: 35ba80813d98371dd36a83ec32aad677f24aa6eb
2019-01-30 06:50:07 -08:00
George Guliashvili
745758d5cd Allow CodeProfiler to send the same thing for multiple keys
Reviewed By: SAlexandru

Differential Revision: D13844446

fbshipit-source-id: aabdde2aa1e5480868d2363c88891559ce12b4f6
2019-01-30 06:50:07 -08:00
George Guliashvili
11cc046992 Add pack name in the ScheduledQuery
Reviewed By: SAlexandru

Differential Revision: D13859408

fbshipit-source-id: 74ddf8e308aca01df17ec96ce095c0b963740e08
2019-01-30 06:50:07 -08:00
George Guliashvili
87ed5ebd30 Remove duplicated ScheduledQuery
Summary: ScheduledQuery was declared both in query.h and in scheduled_query.h. Let's keep scheduled_query.h only.

Reviewed By: mkareta

Differential Revision: D13859371

fbshipit-source-id: 241b948d21fe619be360037a4e2e52a833a23b2b
2019-01-30 06:50:07 -08:00
Jeremy Calvert
2e31aa40da New QueryDataTyped methods
Summary: In the interest of making changes smaller, I'm replicating stuff around QueryData to QueryDataTyped in intermediate commits.  I'll come back and remove stuff that's no longer used when subsequent changes eliminate use of them.

Reviewed By: guliashvili

Differential Revision: D13741994

fbshipit-source-id: de0b00ddb0ad4b344d68ce799fe9fac759bb6199
2019-01-29 18:12:44 -08:00
Filipe Manco
438a6e1464 Basic ev2 framework (#5401)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5401

Extremely rough implementation of the basic componenets to get things going.

Blueprint issue #5158 .

Reviewed By: akindyakov

Differential Revision: D13779295

fbshipit-source-id: c7373794e8152ffea8a7c5d97f0c937bf97a2a0a
2019-01-29 09:30:20 -08:00
Alexander Kindyakov
e1045be13e Do not run tryTo on invalid string if status is not ok
Summary: Also it causes debug failure on unchecked Expected when status is not ok

Reviewed By: mkareta

Differential Revision: D13859377

fbshipit-source-id: 596410350cb91d469dc0a19f0e8eec558e8627bd
2019-01-29 08:22:47 -08:00
Filipe Manco
aad04ed428 Fix link to expected tests on comment. (#5398)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5398

The file moved to a different location.

Reviewed By: marekcirkos

Differential Revision: D13817331

fbshipit-source-id: 6bd3947894daa712edae84b71502af997947b9b0
2019-01-27 06:53:38 -08:00
Alexander Kindyakov
5744099183 wrapper around perf_event socket to bind ebpf program to some linux event (#5384)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5384

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

Reviewed By: guliashvili

Differential Revision: D13622999

fbshipit-source-id: 905bbb3a3763fdd6fbe2ba5211f091184275f246
2019-01-25 09:25:18 -08:00
George Guliashvili
a6069b85bc Remove duplication of the target names (#5391)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5391

Make target names unique

Reviewed By: marekcirkos

Differential Revision: D13785378

fbshipit-source-id: 5bdf02d57ecbf574a1376feb13d07331b43ff89d
2019-01-25 07:23:20 -08:00
Alexander Kindyakov
f62a5eb8df Increase the amount of MaxRecvRetries for thrift socket (#5390)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5390

to eliminate the effect of dropping privileges in other threads causing poll-ing EINTR errors in thrift.

According to ref to [bugzilla.redhat](https://bugzilla.redhat.com/show_bug.cgi?id=473907) in case of changing privileges `glibc` sends SIGRT_1 to other threads which lead to poll be interrupted. On posix we can not have different credentials for thread of one process. Therefore the solution is either to do not use dropping privileges for the whole osquery process or patch all usages of poll in thrift code. I like first option more because playing with permissions of the whole `osqueryd` can cause unpredicted interferences between threads. For instance the same table can provide different results because some other thread dropping and regaining privileges at the same time.

So, the solution for now I'd like to suggest is remove dropping privileges from safe places like reading files with known hostnames or shell history files. And because we can not interact with apt/rpm/yum databases as root and should drop to none user for it I'd suggest to increase the number of attempts to poll in case of EINTR. It can significantly eliminate the problem for now.

To address the problem in issue: [#5326](https://github.com/facebook/osquery/issues/5326)

Thanks fmanco for the help to investigate this problem.

Reviewed By: fmanco

Differential Revision: D13781886

fbshipit-source-id: 4b1f2b7d20c925cc19ba79cc0a2906b65e815c0b
2019-01-23 11:29:05 -08:00
Alexander Kindyakov
c83685866a Remove dropTo from tables with safe file reading and parsing (#5389)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5389

to eliminate the effect of dropping privileges causing poll-ing EINTR errors in thrift code on Linux

To address the problem in issue: [#5326](https://github.com/facebook/osquery/issues/5326)

Reviewed By: fmanco

Differential Revision: D13781880

fbshipit-source-id: 7744b614d5b1c54fc09fc4a7a8c2d0a8aea47e6f
2019-01-23 11:29:05 -08:00
Alexander Kindyakov
94683a22db remove unused include of boost/optional.hpp in process.h
Summary: Just to clean it up

Reviewed By: fmanco

Differential Revision: D13750145

fbshipit-source-id: a9aa5564f15334cf5da74147fcb28b2bf8f88b76
2019-01-23 04:49:47 -08:00
Jeremy Calvert
82c62d7599 Tweak: Use long instead of int64_t
Summary: We went with 'long' rather than 'int64_t' in the JSON serialization methods that were added, so change our variant type to match

Reviewed By: marekcirkos

Differential Revision: D13675340

fbshipit-source-id: 1ccde4ce9f651fe68db968b367507aa67823c74f
2019-01-22 20:49:09 -08:00
George Guliashvili
08c032bbf5 Typed Row fix left shift overflow (#5385)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5385

Left shift with >= 31 steps was done to integer type. Using unisgned long long(1ULL) instead of the int (1).

Reviewed By: fmanco

Differential Revision: D13751355

fbshipit-source-id: 4564b33e2d26a0cb459ee86d180c0af492fa1f43
2019-01-22 09:52:03 -08:00
Marek Cirkos
3a2bbf3b05 Make system utils target name unique
Summary: Pull Request resolved: https://github.com/facebook/osquery/pull/5382

Reviewed By: guliashvili

Differential Revision: D13761609

fbshipit-source-id: 76437e5c84903bfa31272c3145192aa17600bcb4
2019-01-22 05:28:28 -08:00
Alexander Kindyakov
3acaf40d78 eBPF output via perf_event_output kernel mechanism (#5374)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5374

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

Reviewed By: mkareta

Differential Revision: D13622579

fbshipit-source-id: d88b49d785e532b0dbcc42d9245bfee2a9209145
2019-01-22 03:53:48 -08:00
Alexander Kindyakov
4d38dba2ac wrapper for perf_event_open syscall (#5373)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5373

I made wrapper for the syscall  perf_event_open to isolate syscall code definition and use `Expected<>` as a return value.

Reviewed By: mkareta

Differential Revision: D13622565

fbshipit-source-id: 616080a64376d4b042629513ad715b1d2458b8a2
2019-01-22 03:53:48 -08:00
Filipe Manco
68cf457709 Make linter happy, remove whitespaces
Summary: Pull Request resolved: https://github.com/facebook/osquery/pull/5376

Reviewed By: jessek

Differential Revision: D13750590

fbshipit-source-id: 230be8e0930b00b80150a21eedf0668411ef6d56
2019-01-21 11:51:55 -08:00
Filipe Manco
a67525fae1 Fix LICENSE information on file headers (#5375)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5375

LICENSE is now defined in a single file on the root of the project, update the
header to contain that information.

**Project LICENSE did not change.**

Reviewed By: akindyakov

Differential Revision: D13750575

fbshipit-source-id: 1e608a81b260b8395f9d008fc67f463160c1fc2b
2019-01-21 11:51:54 -08:00
Alexander Kindyakov
e7d01f84d2 linux native events wrapper (#5370)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5370

Handler to enable event with certain type, get an id of the event and make sure it will be disables afterwards.

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

Reviewed By: mkareta

Differential Revision: D13621388

fbshipit-source-id: 8adfbe3cc1d87f70538851c5036eae51c93bede8
2019-01-21 02:46:36 -08:00
William Woodruff
bab228b8fa sudoers table: Support file and directory includes (#5350)
Summary:
This adds support for the `#includedir` and `#include` directives to the `sudoers` table, making `sudoers` behave more like the actual `sudo` rule parser:

* When an `includefile` directive is encountered, the referenced file will be parsed using the same rules as the top-level sudoers file.
* When an `includedir` directive is encountered, the referenced directory will be listed and each valid file within (i.e., each file *not* containing a `.` and *not* ending with `~`) will be parsed using the same rules as the top-level sudoers file.
* An additional `source` column tracks the file that provides the row's rule.
* Like `sudoers(5)`, nesting is limited to 128 individual files, with directory inclusions being counted once for each file they contain.
Pull Request resolved: https://github.com/facebook/osquery/pull/5350

Differential Revision: D13717394

Pulled By: akindyakov

fbshipit-source-id: 9659526f21e82c712c495caa80775b15d7e47e37
2019-01-18 05:49:07 -08:00
Alexander Kindyakov
57d4f31b16 eBPF program loader class (#5355)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5355

C++ wrapper to load and keep track of eBPF program in order to close if afterwards.

Blueprint: [#5218](https://github.com/facebook/osquery/issues/5218)

Reviewed By: guliashvili

Differential Revision: D13609628

fbshipit-source-id: dd4ecb547a37c7d83753249e156b0d2c56194ec0
2019-01-18 03:07:35 -08:00
Alexander Kindyakov
dbe467b1a7 eBPF map cpp wrapper (#5356)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5356

To make the process of interacting with eBPF map structure more clear

Blueprint: [#5218](https://github.com/facebook/osquery/issues/5218)

Reviewed By: guliashvili

Differential Revision: D13608479

fbshipit-source-id: cffe76883c280a947da12641b7db6824a571ab1e
2019-01-18 03:07:35 -08:00
Alexander Kindyakov
668c4f7f51 eBPF initial declarations and isSupportedBySystem function (#5354)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5354

eBPF system call osquery wrapper with Expected as a return value and function to check if functionality is supported by current kernel.

Blueprint: [#5218](https://github.com/facebook/osquery/issues/5218)

Reviewed By: mkareta

Differential Revision: D13607442

fbshipit-source-id: 58be84a86aba3fe5e33ca5ab15418976fd36107c
2019-01-18 03:07:35 -08:00
George Guliashvili
d498bcbd65 unique target names for xcode (#5328)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5328

xcode needs unique target names to properly parse buck generated project

Reviewed By: marekcirkos

Differential Revision: D13487400

fbshipit-source-id: cf0c76145344d0873a0973e226d007597a06d17d
2019-01-16 12:28:04 -08:00
micheal-o
7169a1a120 Quick fix in database and disk_encryption (#5273)
Summary:
Fixes #4836
Pull Request resolved: https://github.com/facebook/osquery/pull/5273

Reviewed By: guliashvili

Differential Revision: D13693558

Pulled By: fmanco

fbshipit-source-id: 6160bc54f44c638f00cad745ac70657f58bf38ca
2019-01-16 09:20:23 -08:00
micheal-o
a07b444dde bug fix: last table doesn't properly filter events (#5274)
Summary:
Fixes #5139
Pull Request resolved: https://github.com/facebook/osquery/pull/5274

Differential Revision: D13690840

Pulled By: fmanco

fbshipit-source-id: a0874cd3d904fd40b7dcb9de0995d50f8b49dc3c
2019-01-16 08:23:52 -08:00
seph
637eb104b8 Spelling (#5256)
Summary:
While running `misspell` on a different codebase. I happened to notice that some misspellings in the osquery code base. So, I fixed them
Pull Request resolved: https://github.com/facebook/osquery/pull/5256

Reviewed By: guliashvili

Differential Revision: D13670897

Pulled By: fmanco

fbshipit-source-id: 5d33d858284955c376e8c3980acdf366d4edf3d3
2019-01-16 08:17:07 -08:00
Nick Anderson
3a1da3f9d4 bug: actually remove additional newline from event data (#5271)
Summary:
I had previously attempted to land a fix to the extra newline that was trailing on Windows Event Logs, but had failed. This actually fixes the extra newline, which I verified. I'd love to have unit tests for this, however we don't currently have any unit tests setup for Windows Event Logging.
Pull Request resolved: https://github.com/facebook/osquery/pull/5271

Differential Revision: D13690844

Pulled By: fmanco

fbshipit-source-id: b7447fe2f6e2313c8e7f8765d636f7999d2b5909
2019-01-16 08:02:16 -08:00
Mitchell Grenier
166a55b841 Include weekends on the kernel_panics table (#5298)
Summary:
The set accidentally missed Saturday and Sunday days of the week. This just adds them in.

Fixes #5297.
Pull Request resolved: https://github.com/facebook/osquery/pull/5298

Reviewed By: guliashvili

Differential Revision: D13690812

Pulled By: fmanco

fbshipit-source-id: 1859d32ad635d63548435fed8e9da131530be5ce
2019-01-16 07:53:48 -08:00
Filip Hrenić
6d159d4046 Osquery support for atom packages
Summary:
Add support for listing atom packages on Linux and Mac. Shouldn't be a problem adding support for Windows, but have no way to test it right now.
Lists package name, version, description, package path, license and homepage (see test).

Reviewed By: fiorix

Differential Revision: D13636097

fbshipit-source-id: f38a57128cedde2d027a0205588c8b563e2b188c
2019-01-16 03:12:54 -08:00
micheal-o
6fe7b4cbc2 Epoch in rpm_packages table (#5248)
Summary:
code for issue: #5202
Pull Request resolved: https://github.com/facebook/osquery/pull/5248

Differential Revision: D13677333

Pulled By: fmanco

fbshipit-source-id: e245c3733bb73a1d4d6ab61e007c1cf274c29e59
2019-01-15 16:53:35 -08:00
Alexander Kindyakov
0f15c5fc6a C++ enum wrapper for posix general error codes (#5342)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5342

This sort of enumeration is required to pass posix system errors with `Expected<>`

Reviewed By: mkareta, fmanco

Differential Revision: D13608306

fbshipit-source-id: 0b787b12fac915f097dc310b616df507772da455
2019-01-15 05:38:12 -08:00
Alexander Kindyakov
d893ec4aa8 Semantic version parser (#5343)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5343

Just a parser for the semantic version in string. I gonna use it later to parse kernel version from the `int uname()` result.

Reviewed By: guliashvili

Differential Revision: D13607313

fbshipit-source-id: d6d01fe220f242d3811406dcd63d609feb0d6688
2019-01-15 05:38:12 -08:00
George Guliashvili
615d6485af Revert profiler reporting type to default
Summary: Currently osquery extension uses old osquery core SDK. So does not know, types other than none, sum, min, max(Others were added later) . Let's revert profiler reporting type until new SDK is generated, so that I'm not blocked in rolling out the profiler.

Reviewed By: akindyakov

Differential Revision: D13654143

fbshipit-source-id: 07ded5c6a1bc85d5c2ed983e7a55f3fff9826980
2019-01-14 10:57:57 -08:00
George Guliashvili
96de926d1c Improve event expiration mechanism (#5335)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5335

It was reported that osquery eventing mechanism uses too much disk space. As daebeike found it, event expiring was failing in some cases to be executed.

More specifically, expiration check was supposed to run every time EVENTS_CHECKPOINT number of events where added. However, in between the checks for expiration more than EVENTS_CHECKPOINT events could be added and no expiration would be executed. I suppose, this behaviour would be easily reproducible under the high load

Reviewed By: fmanco

Differential Revision: D13565250

fbshipit-source-id: 78bbad3f7aded4beb9e5f42bafd9184e9c2f8efb
2019-01-14 10:53:47 -08:00
Alexander Kindyakov
3d5309b615 One place to define version of api (#5346)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5346

Let's define win32 api version only inside of buck files, but not in cpp header

Reviewed By: guliashvili

Differential Revision: D13635704

fbshipit-source-id: cd978661ed6f733950363c2ac261811045263ed2
2019-01-14 09:46:36 -08:00
Max Kareta
8c0c403796 fixed headers_namespace to match file path
Summary: Some tools does not support virtual headers namespaces and expect header path to match actual file path from project root. This diff will fix few namespaces in utils library

Reviewed By: guliashvili

Differential Revision: D13552878

fbshipit-source-id: 2a06f73550c69777bf73be73abdde297fe580583
2019-01-14 03:33:32 -08:00
Jonathan Keljo
43cb6d7535 Fix NODISCARD on C++17
Summary:
On C++17 `NODISCARD` maps to a `[[nodiscard]]` attribute, which must
appear at the start of the function signature.

Reviewed By: j-calvert, guliashvili

Differential Revision: D13627821

fbshipit-source-id: d308650cf0188141a4942f528b7ec91825a0c318
2019-01-11 14:28:40 -08:00
Jeremy Calvert
80351aff7d Get rid of size field in QueryPerformance
Summary: As discussed in [an old PR](37ffdf8a48 (r213278358)) this is of questionable benefit and will get complicated when we change to typed values, so dropping.

Reviewed By: guliashvili

Differential Revision: D13631227

fbshipit-source-id: ada9b5434297d8c1c4b3e3855fe595faf5937bf6
2019-01-11 12:25:49 -08:00
Jeremy Calvert
27e57a2300 Fix processing of null prepared statements.
Summary: Please see comment in T38999664

Reviewed By: guliashvili

Differential Revision: D13639493

fbshipit-source-id: d56fdc26dc9d1f1f3f024438310979637311887e
2019-01-11 12:04:20 -08:00
Steven Peters
41b785b86c Fix build with boost 1.69: add missing boost/noncopyable.hpp includes (#5325)
Summary:
boost 1.69 is in a pull request in homebrew-core at https://github.com/Homebrew/homebrew-core/pull/35030 and `osquery` is failing to compile due to using `boost::noncopyable` in a couple header files without including `boost/noncopyable.hpp`:

* [jenkins log of build failure](https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/34941/version=high_sierra/testReport/junit/brew-test-bot/high_sierra/install_osquery/)

The build still fails on homebrew due to #5284.
Pull Request resolved: https://github.com/facebook/osquery/pull/5325

Differential Revision: D13464741

Pulled By: fmanco

fbshipit-source-id: bdaf573b180f8cdfd08dc719db4829911249caaf
2019-01-10 08:48:37 -08:00
Jeremy Calvert
a1058b7372 s/processesRow/ProcessesRow/ on osquery/oss/osquery/tables/system/tests/darwin/processes_tests.cpp
Reviewed By: jkeljo

Differential Revision: D13618914

fbshipit-source-id: 48c0d86107723446497638e6a2367d92b3876586
2019-01-09 18:44:01 -08:00
Jonathan Keljo
f7ec202778 Optimize process command line computation
Summary:
Previously we computed the args and environment, then discarded the environment and joined the args together to make the command line. By cutting out all that extra work, we get a ~3% CPU win for a typical `processes` query.

Before:
```
 D:0  C:0  M:2  F:0  U:0  pack_processes_resources (1/5): duration: 0.592410087585 cpu_time: 0.053588293 memory: 12603392 fds: 4 utilization: 5.05
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (2/5): duration: 0.52742600441 cpu_time: 0.05227561 memory: 12578816 fds: 4 utilization: 4.95
 D:0  C:0  M:2  F:0  U:0  pack_processes_resources (3/5): duration: 0.524594068527 cpu_time: 0.052265788 memory: 12582912 fds: 4 utilization: 4.95
 D:0  C:0  M:2  F:0  U:0  pack_processes_resources (4/5): duration: 0.519255876541 cpu_time: 0.052351296 memory: 12697600 fds: 4 utilization: 5.0
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (5/5): duration: 0.525310993195 cpu_time: 0.05189243 memory: 12570624 fds: 4 utilization: 4.9
 D:0  C:0  M:2  F:0  U:0  pack_processes_resources   avg: duration: 0.537799406052 cpu_time: 0.0524746834 memory: 12606668.8 fds: 4.0 utilization: 4.97
```

After:
```
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (1/5): duration: 0.577349901199 cpu_time: 0.052007643 memory: 12525568 fds: 4 utilization: 4.9
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (2/5): duration: 0.516617059708 cpu_time: 0.050582555 memory: 12480512 fds: 4 utilization: 4.8
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (3/5): duration: 0.519332170486 cpu_time: 0.049710162 memory: 12492800 fds: 4 utilization: 4.7
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (4/5): duration: 0.523589849472 cpu_time: 0.051366226 memory: 12578816 fds: 4 utilization: 4.9
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources (5/5): duration: 0.528687000275 cpu_time: 0.049640225 memory: 12529664 fds: 4 utilization: 4.7
 D:0  C:0  M:1  F:0  U:0  pack_processes_resources   avg: duration: 0.533115196228 cpu_time: 0.0506613622 memory: 12521472.0 fds: 4.0 utilization: 4.8
```

(Adapted from https://github.com/facebook/osquery/pull/5200)

Reviewed By: guliashvili

Differential Revision: D13458612

fbshipit-source-id: 5642225a673f8ce954a60ec01fb7ddfcc79c0608
2019-01-09 13:50:15 -08:00
Jonathan Keljo
5bb1ec75a0 Migrate processes to strongly-typed TableRows on macOS
Summary:
Continuing to march toward low-overhead, type-safe table rows, this commit
converts the Darwin `processes` table to using the generated row types.

My march concludes here, but there's a lot of work yet to be done with
migrating other tables.

(Adapted from https://github.com/facebook/osquery/pull/5199)

Reviewed By: guliashvili

Differential Revision: D13438014

fbshipit-source-id: 0e8365f26fe95131fe53ba3491cf07899600e997
2019-01-09 13:50:15 -08:00
Jonathan Keljo
068efc9d67 Generate strongly-typed TableRow subclasses for each table
Summary:
Continuing to march toward low-overhead, type-safe table rows, this commit
introduces the code generation for said rows. Nothing uses it yet; see the
next commit for that.

(Adapted from https://github.com/facebook/osquery/pull/5199)

Reviewed By: guliashvili

Differential Revision: D13438017

fbshipit-source-id: 959a6e092aee38d33e1c6539cbe14b85172c0135
2019-01-09 13:50:15 -08:00
Jonathan Keljo
1870fd86d8 Introduce TableRow interface
Summary:
Continuing to march toward low-overhead, type-safe table rows, this commit
changes `TableRow` to be an interface rather than simply an alias for `Row`.
Accordingly, `DynamicTableRow` becomes an implementation of that interface
backed by a `Row`. The few remaining pieces of code that treated `TableRow`s as
`Row`s now call methods on the `TableRow` interface. Subsequent commits will
add code generation for strongly-typed table-specific implementations of
`TableRow`.

(Adapted from https://github.com/facebook/osquery/pull/5198)

Reviewed By: guliashvili

Differential Revision: D13438015

fbshipit-source-id: 61d5547e878e519c9706f94f844aab9d3e553410
2019-01-09 13:50:15 -08:00
Jonathan Keljo
78a6960dcd Make TableRows more abstract
Summary:
Continuing to march toward low-overhead, type-safe table rows, this commit changes
much of the code that uses `TableRow`s to stop assuming that they're just `vector`s
by another name. (`TableRow` is on the way to becoming an interface with multiple
implementations.) They're now held in `unique_ptr`s (`TableRowHolder`). For cases
where we really want a `vector`-backed `TableRow` (mostly test code and extension
support), we have a factory function (`make_table_row`) and a helper class
(`DynamicTableRowHolder`) to make that smoother.

(Adapted from https://github.com/facebook/osquery/pull/5198)

Reviewed By: mkareta

Differential Revision: D13438016

fbshipit-source-id: 2de9ce46a64c0a067b5d3299c59bbe3ccacd4abe
2019-01-09 13:50:15 -08:00
Jonathan Keljo
b9f1e94fc8 Prefactor: QueryData -> TableRows for virtual tables
Summary:
Continuing to march toward low-overhead, type-safe table rows, this commit introduces
a distinction between rows being returned from a table (`TableRows`) and as the
result of a query (`QueryData`). Right now the two are simply aliases for each other;
that will change shortly.

(Adapted from https://github.com/facebook/osquery/pull/5198)

Reviewed By: guliashvili

Differential Revision: D13438019

fbshipit-source-id: 6563fc8c372d9d6c4b05705943ddf39b42260feb
2019-01-09 13:50:15 -08:00
Jeremy Calvert
5461a3b79d Get typed data from sqlite
Summary:
Step towards completion of https://github.com/facebook/osquery/pull/4904
- Add boost variant (typed) counterparts for RowData, Row, and QueryData.
- Add a queryInternal to sqlite_util that returns QueryDataTyped.
- Replace the queryInternal that returns QueryData with one that's a simple wrapper around the new typed implementation.

Reviewed By: guliashvili

Differential Revision: D13586036

fbshipit-source-id: d1d9b56470fbfcfb5802de422f87d9b9d6da7fb7
2019-01-09 09:06:57 -08:00
George Guliashvili
75dade56b3 fix null dereference (#5332)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5332

malloc might return null and memcpy will crash in that case

Reviewed By: akindyakov

Differential Revision: D13517060

fbshipit-source-id: 261f493823974dcc40a40139094eb4a98cd24dec
2019-01-08 08:01:14 -08:00
Alexander Kindyakov
081d5053ee Create OSQUERY_NODISCARD to prevent non returning errors (#5331)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5331

Let's use attributes to prevent such mistakes (see previous diff in the stack)

Reviewed By: guliashvili

Differential Revision: D13504146

fbshipit-source-id: 7cab2dd345599b036fa2a27bf682f2a159fd1c08
2018-12-19 03:58:50 -08:00
Alexander Kindyakov
a724147c22 created error should be returned (#5330)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5330

small bug in killswitch and rocksdb code

Reviewed By: guliashvili

Differential Revision: D13504145

fbshipit-source-id: be9ae605a8c5588c5613889eb9a1af408935bfc8
2018-12-19 03:58:50 -08:00
George Guliashvili
ae2486ff16 fix xcode duplicate target names (#5323)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5323

xcode needs unique target names not to fail on buck generated project

Reviewed By: marekcirkos, akindyakov

Differential Revision: D13449869

fbshipit-source-id: 73511aeaa3245586adc293fbe0311f51f71ea12f
2018-12-13 16:13:44 -08:00
George Guliashvili
4967cf3de1 osquery windows oss build fix
Summary: osquery windows oss build fix

Reviewed By: fmanco

Differential Revision: D13431552

fbshipit-source-id: c13f1edac9c08d49901c5db3f58fc5c558ad8410
2018-12-13 05:21:47 -08:00
Jonathan Keljo
a88a010e30 Plumb columns used as a bitfield
Summary:
Hand port of https://github.com/facebook/osquery/pull/5154 to the new build system

I'm moving toward generating constants for each column so that we
can do used column lookups without having to do a string set lookup,
but first I need to have the used columns information plumbed through
as a bitfield.

Once the code generation is in and all cases have been migrated to it,
I'll remove the string variants of `isColumnUsed`/`isAnyColumnUsed`.

Reviewed By: guliashvili

Differential Revision: D13423615

fbshipit-source-id: 6a2afe7dad42942610dfe0f6f55bcee4603a25af
2018-12-12 10:40:58 -08:00
Jonathan Keljo
5f81138eaf Four new "add" wrapper JSON methods
Summary:
Manual port of https://github.com/facebook/osquery/pull/5153 to the new build system.

New methods to allow adding larger numeric types.

Reviewed By: guliashvili

Differential Revision: D13422612

fbshipit-source-id: 6b503553f05139351f803ea6fcc5c825e62c35ea
2018-12-12 10:40:58 -08:00
Jonathan Keljo
898ed37dfb Table for OSX Running and Active Applications
Summary:
This is a manual port of https://github.com/facebook/osquery/pull/5216 to the new build system.

This table allows you to fetch a list of running applications on OSX. Contains PID, Bundle ID and whether or not the application is in focus. (The latter can be used to figure out what application was being used at a given moment.)

Reviewed By: guliashvili

Differential Revision: D13422150

fbshipit-source-id: 236b28d9140a9a9062fb913815d0c9f1da21c8b5
2018-12-12 09:17:19 -08:00
Filipe Manco
22da13d863 Remove unused and most likely broken operator== overload from error (#5318)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5318

This is most likely broken and is causing problems with some toolchains (e.g. clang on Ubuntu xenial).

Reviewed By: guliashvili

Differential Revision: D13415457

fbshipit-source-id: b4aa686913d3cfe6bb26089b0525144fae7cc928
2018-12-11 16:10:38 -08:00
George Guliashvili
c80bd28e5f inotify_tests buckify
Summary: inotify_tests buckify

Reviewed By: fmanco

Differential Revision: D13399806

fbshipit-source-id: 2ea33d61c9a3f48cf3914ed2f8e60b5012e5808c
2018-12-11 08:29:15 -08:00
George Guliashvili
059645a078 buckify fsevents test
Summary: buckify fsevents test

Reviewed By: akindyakov

Differential Revision: D13399058

fbshipit-source-id: d8ee81aa203cc8ffc30cf53922e4a76426604c4b
2018-12-11 08:29:15 -08:00
Filipe Manco
6ebabe6ce0 Add missing includes to posix/filepath.cpp
Summary: These missing includes make the build fail with some toolchains.

Reviewed By: guliashvili

Differential Revision: D13414926

fbshipit-source-id: b9a7992e37751da81ec1f5a9055703bc1e3cc4bc
2018-12-11 05:00:18 -08:00
Alexander Kindyakov
3b992f03bd events_tests should not depend on yara utils
Reviewed By: guliashvili

Differential Revision: D13398243

fbshipit-source-id: 1cb956df89843eb647dd0ba65f8ff46e73faaf5b
2018-12-11 03:31:18 -08:00
George Guliashvili
3775b82cdb auditprocess_file_events_tests buckify
Summary: auditprocess_file_events_tests buckify

Reviewed By: fmanco

Differential Revision: D13377453

fbshipit-source-id: 819d56b42eb55aefcb403003f0ad6fc46b481bf0
2018-12-11 03:31:17 -08:00
George Guliashvili
4704892aca fix operator=
Summary: operator= should be returning value.

Reviewed By: fmanco

Differential Revision: D13377348

fbshipit-source-id: e3a5e0adf9a79bf6e76795423c9b88cd425c02f3
2018-12-11 03:31:17 -08:00
George Guliashvili
e28335998a events_database_tests buckify
Summary: events_database_tests buckify

Reviewed By: akindyakov

Differential Revision: D13377334

fbshipit-source-id: c347f05e66af2c0777857352b591b8dad83e7317
2018-12-11 03:31:17 -08:00
Alexander Kindyakov
3a0683f049 Switch off osquery/remote tests for windows
Summary: Switch off osquery/remote tests for windows, it takes time to fix it. I'll do it later.

Reviewed By: fmanco

Differential Revision: D13378357

fbshipit-source-id: 21077630864fc4a27ba65078c634e115875f3970
2018-12-11 03:31:17 -08:00
Alexander Kindyakov
dcf27a5956 Fix up config/tests:test_config_update for windows
Summary: It turns out we already fixed that old issue

Reviewed By: guliashvili

Differential Revision: D13376876

fbshipit-source-id: a7822a1c79aa180e40f7ce54faa7c811b0d1b24b
2018-12-11 03:31:17 -08:00
Alexander Kindyakov
f60d2100de fix up extenstions tests on windows
Summary: Windows named pipe requires a bit different name format in compare to posix platforms.

Reviewed By: guliashvili

Differential Revision: D13376805

fbshipit-source-id: 443c8f963863adbacd1edb76945919f00a1a2e4e
2018-12-11 03:31:17 -08:00
George Guliashvili
971bee4441 Move build system to BUCK
fbshipit-source-id: 8ffef5e6a393ac67ce56dcb74845402e43d964a0
2018-12-07 16:12:35 +00:00
Alexander Kindyakov
29df1efe00 CarbonBlack table have to assume any key in sensor settings file could be missing
Fix up failing tests with exception 'No such node (CB.SensorBackendServer)' thrown in the test body
2018-12-07 16:02:09 +00:00
Alexander Kindyakov
e3037331d4 Fix up bug in NonNegativeInt and NonNegativeOrErrorInt table column data validator 2018-12-07 16:01:38 +00:00
George Guliashvili
a31d7582f4 Fix rocksdb crash
Configuration of OptimizeForSmallDb was crashing osquery. To be more specific ColumnFamilyOptions::OptimizeForSmallDb part was doing it.
2018-12-07 16:00:46 +00:00
George Guliashvili
a32ed7c45d Fix random port problem
random port was not really random. Seed was never set so it was generating the same port.
2018-12-07 16:00:46 +00:00
Marek Cirkos
6a64e353e9 Refactor battery table and return some information even if advanced information is missing 2018-12-07 16:00:46 +00:00
Filipe Manco
bf4c0a3117 Move iptables querying to a C based proxy
The iptables uapi kernel headers are incompatible with C++. To avoid
depending on modified kernel headers query iptables from a C based
proxy. This is a temporary solution until the problem is fixed on
upstream Linux.
2018-12-07 16:00:36 +00:00
packetzero
5188ce5288 update aws-sdk-cpp 1.4.55 on windows (#5255) 2018-10-29 21:24:29 +00:00
Nick Anderson
0314871908
bug: explicitly set safe permissions on osquery dbs (#5229) 2018-09-18 22:51:29 -07:00
Michael McGrew
e6302379fd Add per process performance data to windows processes table (#5224) 2018-09-18 20:59:35 -07:00
James Jerger
b8d7243aa9 Add InstallDate to os_version for Windows (#5226) 2018-09-14 16:07:37 -07:00
Giorgi Guliashvili
7bac8cb7f6
remove old boost bug supprot (#5221) 2018-09-14 23:51:44 +01:00
Nick Anderson
bf93fcf2f9
database: changing default path of the database for pathing uniformity (#4832) 2018-09-14 11:36:24 -07:00
James Jerger
e10b243ecf Add NTDomain Table for Windows (#5152) 2018-09-14 11:25:49 -07:00
Max Kareta
61d415c6bc
added database migration class (#5112) 2018-09-14 20:58:03 +03:00
Adrien Schildknecht
bdf504f6b6 tables: netmask should be an integer (#5217) 2018-09-14 16:13:37 +01:00
Alessandro Gario
52805dca44 chrome_extensions: Use the translation dictionary with case insensitive keys (#5215) 2018-09-14 16:06:31 +01:00
Giorgi Guliashvili
53a48d8fb4
posix profiling (#5187) 2018-09-14 16:04:28 +01:00
Giorgi Guliashvili
70806ae4fc
numeric_monitoring recursive sync record (#5204) 2018-09-14 12:17:24 +01:00
Alexander
dcd653ce33
Create helper functions to get CPU cores info on linux (#5209)
Helper functions to get CPU cores info exposed via sysfs on linux.
I need this information to use kprobes in osquery on linux.
2018-09-14 11:32:25 +01:00
Alexander
8ab08ed6c0
Prepare the filesystem directories in initialisation routine (#5207)
Create directory for the database only if database is switched on and do not fail on unsuccessful creation, just write down a message to log.
2018-09-14 11:19:07 +01:00
Alexander
9b3e14789b
Non throwing directory creation function. (#5206)
Directory creation function to osquery/filesystem.h

Status was used as a return value, as far as all function in this file operate with Status not Expected. Let's move from Status to Expected in another PR.
2018-09-12 11:48:11 +01:00
Alessandro Gario
e2f1a11d75 Add a 'permission' field to the chrome_extensions table (#5193) 2018-09-12 01:03:36 +01:00
Giorgi Guliashvili
9bfd3f4a2d boost throwing is_directory bug (#5208) 2018-09-11 16:54:37 -07:00
yying
6e9f23a0e2 Add ReleaseDate to table for platform_info queries on Windows (#5182) 2018-09-10 17:05:44 -07:00
Adrien Schildknecht
0b686c4834 Add interface_ipv6 table (#4903) 2018-09-10 05:50:03 +02:00
Adrien Schildknecht
07961f314c [Table sanity check] routes & arp_cache (#5189) 2018-09-10 05:47:52 +02:00
Alexander
2ddd10b3df
Remove the rest of the safeStrto* function from conversion.h (#5190)
Remove the rest of the safeStrto* function from conversion.h
Used tryTo<> from PR #4676 instead
2018-09-07 15:48:15 +01:00
Alexander
b44110aaaa
Expected::takeOr have to accept rvalue as an argument (#5191)
Fix up checking the type for argument in template definition.
Fixes: #5190
2018-09-07 14:59:10 +01:00
Giorgi Guliashvili
ceb3e6896d
dispatcher static destructor (#5192) 2018-09-07 14:47:46 +01:00
Alexander
0f0440fa61
Removing potentially risky method getOr(T const&) from Expected (#5174)
Too dangerous, because it is so easy to create a dangling reference (to local object for instance) with it.

It was discussed in terms of PR #4833
2018-09-07 11:49:47 +01:00
Allan Liu
5457ef0ea9 tables: add pci_class_id and pci_subclass_id to pci_devices (#5183) 2018-09-06 01:05:11 +01:00
Allan Liu
37ae0ef4d5 tables: augment pci_devices table on linux with pci_subclass (#5175) 2018-09-05 20:20:27 +01:00
Giorgi Guliashvili
bf95191e5c
total number of queries sent numeric_monitor (#5172) 2018-09-04 16:30:37 +01:00
Alessandro Gario
6c59b6df38 intel_me_info/Windows: Fix the buffer size for the GetFirmwareVersion command (#5111) 2018-09-04 14:50:56 +01:00
Giorgi Guliashvili
f903ec02bc
monitor number of times osquery starts (#5171) 2018-09-04 14:05:11 +01:00
Giorgi Guliashvili
2cfaf8aa94
numeric monitoring aggregation types (#5169) 2018-09-04 13:49:04 +01:00
Giorgi Guliashvili
87a8260a5e
integration test helper NonNegativeOrErrorInt (#5150) 2018-09-04 13:48:12 +01:00
Giorgi Guliashvili
c301e361ca
executing query monitor under killswitch (#5170) 2018-09-03 18:02:40 +01:00
Giorgi Guliashvili
1a7e241483
[Table sanity check] kernel_info (#5140) 2018-08-31 20:21:41 +01:00
Alexander
5835484027
[Table sanity check] Integration test for the registry table (#5155)
Fixes: #5034
2018-08-31 17:45:04 +01:00
Giorgi Guliashvili
9fa67def23
allow numeric_monitoring flush for non testing purposes (#5156) 2018-08-31 17:38:32 +01:00
Giorgi Guliashvili
120e061c64
[Table sanity check] process_open_files (#5145) 2018-08-31 17:37:30 +01:00
Alexander
c23cc190ae
[Table sanity check] Integration test for the 'apt_sources' table (#5157) 2018-08-31 17:32:51 +01:00
Alexander
ba08abb982
[Table sanity check] Integration test for the known_hosts table (#5130)
Fixes: #4879
2018-08-31 16:07:38 +01:00
Alexander
11c38ad99d
[Table sanity check] sanity check for the table interface_details (#5143) 2018-08-31 15:14:29 +01:00
Alexander
5db628b7e8
Make more talkative in terms of unexpected columns (#5149) 2018-08-31 14:50:49 +01:00
Alexander
dad4507725
[Table sanity check] Integration test for the table (#5147) 2018-08-31 14:49:51 +01:00
Alexander
831becc7d2
[Table sanity check] sanity check for the table logged_in_users (#5144) 2018-08-31 14:48:53 +01:00
Alexander
2b24cf22de
[Table sanity check] sanity check for the table interface_addresses (#5142) 2018-08-31 14:28:26 +01:00
Giorgi Guliashvili
29550c0ecc
[Table sanity check] memory_map (#5146) 2018-08-31 12:15:59 +01:00
Giorgi Guliashvili
e01149d51e
[Table sanity check] programs (#5141) 2018-08-31 10:41:59 +01:00
Filipe Manco
fe5c7d990c
[Table sanity check] sanboxes (#5137) 2018-08-31 10:40:00 +01:00
Giorgi Guliashvili
b5e1cdc81a
[Table sanity check] user_group (#5128) 2018-08-31 10:25:21 +01:00
Mathieu Martin
c7803fdefd Fix typo. It's Comma, not Coma :-) (#5151) 2018-08-30 21:42:13 +01:00
Alexander
723f077c3b
Add quotes for the key and value in assertion messages (#5148) 2018-08-30 18:15:51 +01:00
Giorgi Guliashvili
566dd75671
[Table sanity check] file (#5126) 2018-08-30 18:15:29 +01:00
Alexander
e901bb35e8
Fix up wrong integer types from validating values from the tables (#5133) 2018-08-30 10:56:08 +01:00
Filipe Manco
7214331832
[Table sanity check] time (#5123) 2018-08-30 10:44:37 +01:00
Filipe Manco
40a770025c
[Table sanity check] process_events (#5132) 2018-08-30 10:02:45 +01:00
Filipe Manco
873c6555d0
[Table sanity check] os_version (#5124) 2018-08-30 09:39:43 +01:00
Teddy Reed
7a2bc0bc28
virtual tables: Handle SQLite3 BLOB_TYPE (#5118) 2018-08-29 21:40:33 -04:00
Giorgi Guliashvili
637d301853
validate rows assert debugging (#5125) 2018-08-29 20:16:00 +01:00
Alexander
f7b5447871
Use just std::function for custom validator in table integration tests (#5129) 2018-08-29 18:48:49 +01:00
Alexander
80bfdf914c
[Table sanity check] Integration tests for deb_packages (#5120)
[Table sanity check] Integration tests for deb_packages
2018-08-29 18:04:15 +01:00
Max Kareta
85d78c768e
[Table sanity check] crontab (#5127) 2018-08-29 16:16:23 +01:00
Alexander
7ed337d008
[Table sanity check] Integration test for the linux kernel modules table (#5121) 2018-08-29 15:13:38 +01:00
Max Kareta
ba1a933b90
[Table sanity check] system info (#5119) 2018-08-29 12:53:38 +01:00
Filipe Manco
59925a2706
[Table sanity check] hash (#5122) 2018-08-29 12:42:19 +01:00
Giorgi Guliashvili
a06af88b18
simplify logger initilization (#5078) 2018-08-29 00:21:59 +01:00
Giorgi Guliashvili
d5ccbd1813
treat warnings as error only in the osquery core (#5113) 2018-08-28 17:22:06 +01:00
Alessandro Gario
3082b7cb87 socket_events: Use local_port/local_address for bind() (#5098) 2018-08-28 15:52:36 +01:00
Alexander
6a460f22c7
RAII based scope guard class (#4980)
To be sure that resources are always released/removed/closed/verified/stoped
in face of multiple return statements from the function.
2018-08-28 12:32:02 +01:00
Alexander
dcfe83a0aa
Helper functions tryTake, tryTakeCopy to lookup in key-value tables (#4833)
There are a lot of lookups in the maps the osquery code. Most of them are verbose and not-optimal with check if such key exists in the table before get access. Some of them consists error e.g.:
```c++
    r["uid"] = row.count("uuid") > 0 ? row.at("uid") : "";
```
Introduced code will help to avoid the most of such problems.
2018-08-28 12:31:10 +01:00
Jibola
e05be701ed Expand "opaque" values in system_controls table (#5082) 2018-08-28 11:52:06 +01:00
Alexander
ae09a6e95b
Fix up debug build for InMemoryDatabaseTest (#5086)
Fix up debug build for InMemoryDatabaseTest

  - add checks for return status of the operations
  - fix up check funtion for types in DB
2018-08-28 11:22:57 +01:00
Adrien Schildknecht
d7b701cb2a Implement setThreadName() for FreeBSD (#5097)
FreeBSD supports renaming threads with pthread_np.
The difference with Linux or Darwin is that there's no error code:
  "Because of the debugging nature of this function, all errors that may
   appear inside are silently ignored"
This isn't really a problem because thread names are meant for debugging
and osquery does not check the retun value of `setThreadName()` anyway.

Test plan:
  adrs@freebsd: procstat -t `pidof old_osqueryi`
    PID    TID COMM                TDNAME              CPU  PRI STATE   WCHAN
   7612 100059 osqueryi            -                    -1  152 sleep   ttyin
   7612 100162 osqueryi            -                    -1  152 sleep   uwait
   7612 100163 osqueryi            -                    -1  152 sleep   select
  adrs@freebsd: procstat -t `pidof osqueryi`
    PID    TID COMM                TDNAME              CPU  PRI STATE   WCHAN
   7278 100151 osqueryi            -                    -1  120 sleep   ttyin
   7278 100160 osqueryi            ExtensionWatcher     -1  120 sleep   uwait
   7278 100161 osqueryi            ExtensionRunnerCore  -1  131 sleep   select
2018-08-28 11:11:11 +01:00
Giorgi Guliashvili
fd5b103c63
rearrange initLogger disable capabilities (#5077) 2018-08-27 17:33:10 +01:00
Max Kareta
78020a127e
added stubs for sanity checks (#5109) 2018-08-27 17:21:26 +01:00
Giorgi Guliashvili
21228c3172
put config backup feature behind killswitch (#5100) 2018-08-27 17:16:43 +01:00
Max Kareta
63fb35af74
added uptime sanity check (#5108) 2018-08-27 17:00:40 +01:00
Max Kareta
5dc0e5a7d5
added integration tests target and helper functions to tests table sanity (#5107) 2018-08-27 15:25:28 +01:00
Allan Liu
a17d6b5963 SMBIOS oem_strings table (#4849) 2018-08-22 20:02:40 -04:00
Giorgi Guliashvili
5f9552fa0e
writeTextFile optional mode argument (#5081) 2018-08-22 14:23:01 +01:00
Alexander
b6edf00892
Make error messages in Expected check different to distinguish problems (#5088)
Make error messages in Expected check different to know for sure which check is failed.
2018-08-22 13:26:55 +01:00
Giorgi Guliashvili
2a9a9ef666
cleanup after the primary logger concept removal (#5089) 2018-08-22 01:58:00 +01:00
Giorgi Guliashvili
81d53394fa
unused code after refactor (#5083) 2018-08-21 21:25:48 +01:00
Giorgi Guliashvili
dc3bb9ebba
remove unused force_permissions (#5080) 2018-08-21 20:58:52 +01:00
Max Kareta
cbfcd875cd
disk_encryption macOS, fix for issue #4658 (#4691) 2018-08-21 18:45:56 +01:00
Filipe Manco
d0486499ea
Log when an extension is registered or dies (#5076) 2018-08-21 10:31:20 +01:00
Giorgi Guliashvili
fa98cd5cc6
get rid of aliased flag log_result_events (#4970) 2018-08-20 20:42:40 +01:00
Giorgi Guliashvili
b30af3b6f2
remove primary logger concept (#4969) 2018-08-20 20:38:26 +01:00
Giorgi Guliashvili
77b0dbffa7
Match how logger_min_status works to doc (#4977) 2018-08-20 15:37:33 +01:00
Giorgi Guliashvili
13bdf72682
default logtostderr to true (remove logStderrOnly) (#4971) 2018-08-20 15:36:52 +01:00
Giorgi Guliashvili
5314fc6034
Match how logger_min_stderr works to doc (#4978) 2018-08-20 15:11:29 +01:00
Filipe Manco
2f50d1a13d Correct --enable_extensions_watchdog description (#5066) 2018-08-20 14:35:26 +01:00
Adrien Schildknecht
a86603e9fd route table: get the value of the MTU on Linux (#4981) 2018-08-20 14:27:37 +01:00
Giorgi Guliashvili
561fda3aa0
config backup (#4935) 2018-08-20 14:24:24 +01:00
Giorgi Guliashvili
84698b3e84
get rid of alias verbose_debug and debug (#4972) 2018-08-20 14:17:03 +01:00
Max Kareta
78ba6e0e62
rocksdb implementation part (#4912) 2018-08-20 12:49:56 +01:00
Teddy Reed
512f775c58
Remove boost SHA1 UUID dependency (#5070) 2018-08-19 21:55:00 -04:00
ryandeivert
68be4f10fa [aws] adding aws proxy support in ClientConfiguration (#4850) 2018-08-17 10:25:10 +01:00
Allan Liu
9091fd98a5 pci_devices: model and vendor information from system PCI db && add subsystem info (#4391) 2018-08-16 23:51:38 +01:00
Adrien Schildknecht
fc88135f3b route table: properly display the default IPv6 route on Linux (#4934) 2018-08-16 23:43:09 +01:00
Teddy Reed
b0815c78c7
tables: Harden SMBIOS data parsing (#4853) 2018-08-15 12:23:01 -04:00
Teddy Reed
c62ebce5c4
libfuzz: Add SMBIOS table fuzzing (#4852) 2018-08-15 12:03:03 -04:00
Allan Liu
2081cf8e02 tables: fix cpu_physical_cores and cpu_logical_cores on linux (#4848) 2018-08-14 15:30:38 +01:00
Adrien Schildknecht
ba1bde1d8f Add hopcount entry to the 'routes' table (#4900) 2018-08-14 15:29:50 +01:00
Giorgi Guliashvili
ce0592b464
fix set thread warnings (#4911) 2018-08-14 14:16:53 +01:00
Giorgi Guliashvili
82212e0de4
fix freebsd warning incorrect comparison (#4910) 2018-08-14 12:21:59 +01:00
Giorgi Guliashvili
2296fe0603
fix unused lambda captures warning (#4908) 2018-08-14 12:21:15 +01:00
Giorgi Guliashvili
79f8307d2f
fix unused lambda capture warning (#4909) 2018-08-14 12:20:38 +01:00
Giorgi Guliashvili
c50a0c4b08
ignore osx warning (#4907)
ignore -Wdeprecated osx warning
2018-08-14 12:19:27 +01:00
Jason Meller
1c42e21750 A missing Gatekeeper prefs file indicates it is on (#4856) 2018-08-13 11:36:00 +01:00
Giorgi Guliashvili
135bc9d1cf
clang flexible-array-extensions warnings fix (#4857) 2018-08-13 09:53:00 +01:00
Giorgi Guliashvili
cf59b05bf4
removed additional unused function signatures (#4844) 2018-08-11 20:24:21 +01:00
Alexander
f850714642
Remove safeStrtol from conversion.h (use tryTo<long> instead) (#4768) 2018-08-10 11:05:57 +01:00
Max Kareta
00ad073574
added in memory db (#4797) 2018-08-09 15:10:07 +01:00
Giorgi Guliashvili
47f07f8f06
resolve -Wwritable-strings warning (#4831) 2018-08-09 13:31:50 +01:00
narendhar15
40f1320bfa Add constness for the methods of class WmiRequest (#4807) 2018-08-09 10:16:49 +01:00
Giorgi Guliashvili
6ff3262139
regex replace (#4847) 2018-08-09 09:55:48 +01:00
Allan Liu
6e8f7eac9a tables: dmiString function param to use string index (#4845) 2018-08-09 09:54:51 +01:00