Commit Graph

4846 Commits

Author SHA1 Message Date
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
Alexandru Stefanica
4dd69ab2cc use new vs toolchain flag file (#5406)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5406

use new flag file for windows toolchain configuration

Reviewed By: mkareta

Differential Revision: D13859827

fbshipit-source-id: 7560c989e2590663d511b5b644ba6bc3c6b5e5f4
2019-01-31 03:32:32 -08:00
Alexandru Stefanica
a61f527554 automatically generate buck flags for windows (#5405)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5405

this should find where VS is installed and set the buck flags properly.
Have tested on my VM and the paths are ok.  This only works for 2017 and newer (hopefully)
I'm not sure how future proof this is, Microsoft usually changes directory structures randomly.

Reviewed By: muffins

Differential Revision: D13762391

fbshipit-source-id: 894e6a6d5888e13ab646ca9cb4a0d604bcf53ee5
2019-01-31 02:06:46 -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
Zachary Wasserman
04f632f16e Fix typo in provision script
Summary: Pull Request resolved: https://github.com/facebook/osquery/pull/5392

Reviewed By: mkareta

Differential Revision: D13838392

Pulled By: guliashvili

fbshipit-source-id: 0ad56503cd9bb0120e4ef669dea02e759131c823
2019-01-28 04:31:02 -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
George Guliashvili
238b7b00ae sqlite dependency for windows (#5402)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5402

sqlite dependency for windows

Reviewed By: SAlexandru

Differential Revision: D13829704

fbshipit-source-id: 2c35ab214ca3a2b862bbdcef0ae2e619103a6628
2019-01-26 13:04:10 -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
c1765ed0f7 Buckify sqlite 3.26.0 (#5396)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5396

Buckify new version of the sqlite.

Reviewed By: marekcirkos

Differential Revision: D13801135

fbshipit-source-id: 0acb5c90c962b114dc2a699cfe84f9264efae336
2019-01-25 07:23:20 -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
aporlebeke@gmail.com
96e0cd2fd6 Fix typo: "Extensions" (#5388)
Summary:
Fix minor typo in description.  Moved original PR (#5380) from master to experimental
Pull Request resolved: https://github.com/facebook/osquery/pull/5388

Differential Revision: D13781801

Pulled By: guliashvili

fbshipit-source-id: d57d5e45c1597c6d640dbf908a42ced4f4bbf54c
2019-01-23 09:50:49 -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
2976db5eca iptables integration test
Summary: iptables table integration test

Reviewed By: fmanco

Differential Revision: D13746974

fbshipit-source-id: 79762510e8d955d179b98e96a7553403cfd219e0
2019-01-22 09:57:36 -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
78832379bc Use apple_binary to generate binary for MacOS (#5383)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5383

It is better supported and also allows us to generate Xcode project

Reviewed By: akindyakov

Differential Revision: D13761638

fbshipit-source-id: 4a1cec6106f5e427e23a85ccee9760579ec4d597
2019-01-22 06:33:44 -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
e00a30ef87 Fix files with no newline at end of file
Summary: Pull Request resolved: https://github.com/facebook/osquery/pull/5377

Reviewed By: jessek

Differential Revision: D13750577

fbshipit-source-id: a646ff61dcbf1559a9d6f8379fa0295bd3be0451
2019-01-21 11:51:54 -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
Alexandru Stefanica
e401a5e5a1 automatic mode selection (#5369)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5369

automatically select the appropriate config files based on the current platform and the flavor that was provided

Reviewed By: fmanco, guliashvili

Differential Revision: D13695981

fbshipit-source-id: acdb03bfe4e5d6a352e7a52d5b9812c0e1b05010
2019-01-18 05:28:25 -08:00
Julia
039b40288b Fix plist.table description (#5242)
Summary:
The column "path" is a required column.  Fixed description.
Pull Request resolved: https://github.com/facebook/osquery/pull/5242

Reviewed By: guliashvili

Differential Revision: D13693342

Pulled By: fmanco

fbshipit-source-id: ba7bcb88a201cadaf913054900294c3b1d342ead
2019-01-18 03:11:46 -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
Marek Cirkos
85438c100e Mirror/bridge cxx.bzl (#5365)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5365

Rather than having two copies of the same implementation it would be better to just bridge it's implementation

Reviewed By: akindyakov

Differential Revision: D13684438

fbshipit-source-id: 3faf5ddfcc302b6e1e59613169905497d6e98504
2019-01-18 02:45:55 -08:00
Marek Cirkos
70c90c1e54 Mirror/bridge third_party.bzl (#5366)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5366

Rather than having two copies of the same implementation it would be better to just bridge it's implementation

Reviewed By: akindyakov, fmanco

Differential Revision: D13684437

fbshipit-source-id: 95693317c7219ea1d0e0b94f604bd61c4e3a444f
2019-01-18 02:45:55 -08:00
Marek Cirkos
27f8583b73 Mirror/bridge native.bzl (#5364)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5364

Rather than having two copies of the same implementation it would be better to just bridge it's implementation

Reviewed By: akindyakov, fmanco

Differential Revision: D13671592

fbshipit-source-id: e8f9ebbaee587e4f28f63bef3561a84559c278ab
2019-01-17 09:53:14 -08:00
Marek Cirkos
6c868ca3d4 Mirror/bridge python.bzl (#5363)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5363

Rather than having two copies of the same implementation it would be better to just bridge it's implementation

Reviewed By: akindyakov, fmanco

Differential Revision: D13671460

fbshipit-source-id: d1b1b1097ede178d0d645a8ef886f8cecb9e302a
2019-01-17 07:23:25 -08:00
Filipe Manco
f6735531f8 Adding testing and fix build instructions on BUILD.md (#5362)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5362

Add basic buck test command and fix build command instructions.

Reviewed By: guliashvili

Differential Revision: D13712520

fbshipit-source-id: ec18545a85e0d9ffbfdd6024c866a8cd3b9e1b0c
2019-01-17 06:56:18 -08:00
bransmartUK
9edcde9083 Added function examples to documentation, SQL Additions (#5305)
Summary:
This pull request is for the addition of examples under the functions in the SQL Additions sub title in the documentation. Specifically the introduction section of the documentation. The file that was changed was sql.md in the osquery/docs/wiki/introduction path. This is the addition I made:

- Added a minimalist drop down design under every subsection of new functions added. (ex. Math Functions like 'sqrt', 'log', ect.). This will allow for newcomers to the documentation to understand even deeper the new Sql added functions that the osquery team supplied, and how to use them in the actual program.

- Each added example tackles every function the osquery team listed in the documentation. Allowing for closer understanding of the functions.
Pull Request resolved: https://github.com/facebook/osquery/pull/5305

Reviewed By: guliashvili

Differential Revision: D13693267

Pulled By: fmanco

fbshipit-source-id: 9c3cd5b5950ce019f5ea5fc74f780f50a291ca71
2019-01-16 14:57:12 -08:00