Commit Graph

90 Commits

Author SHA1 Message Date
Jeremy Calvert
c8bb439442 OSQueryd changes for encoding type in JSON syntax
Summary:
Add log_numerics_as_numbers flag.

Internal SQLite query has method that returns QueryDataTyped (instead of QueryData), which are boost::variant<string, double, long long>.

Ints are encoded as such if and only if new log_numerics_as_numbers flag is set to true.

Reviewed By: fmanco

Differential Revision: D13778323

fbshipit-source-id: 7d7bb31781486f63fcc088cd479d3b6f255a5cb4
2019-03-04 09:15:21 -08:00
Filipe Manco
d14fd5d538 Move plugins to a separate directory [5/?] (#5483)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5483

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

Reviewed By: guliashvili

Differential Revision: D14259760

fbshipit-source-id: deaaa148fac25b3f534a8881a1ea9eda0ec6bdc9
2019-03-02 04:23:06 -08:00
William Woodruff
fe70a514af windows/logged_in_users: Add sid, hive columns (#5454)
Summary:
This introduces two new (Windows-only) columns to the `logged_in_users` table:

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

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

Differential Revision: D14195466

Pulled By: fmanco

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

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

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

Differential Revision: D14131722

Pulled By: fmanco

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

Reviewed By: marekcirkos

Differential Revision: D14224206

fbshipit-source-id: 218dc05d87e1ffaca37783185fc672a20684d757
2019-02-26 11:20:08 -08:00
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
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
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
Alexander Kindyakov
676820998e fix up test ProcessOpenFilesTest.test_sanity
Summary: It fails on some platforms because of permissions, let's just check if file path is not empty and is absolute

Reviewed By: marekcirkos

Differential Revision: D14086996

fbshipit-source-id: 98068e4b93e6be12a2392345fa74b547d26a2d43
2019-02-15 07:24:19 -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
Alexander Kindyakov
51b35f8664 More assertive sanity check for process abs start time column
Summary: We fixed the meaning of `start_time` in previous PR/diffs, let's check it in the integration test.

Reviewed By: SAlexandru

Differential Revision: D13918628

fbshipit-source-id: 60f4ff74eadfbe286dfb325d713389f01142a0f8
2019-02-05 03:50:20 -08:00
Alexander Kindyakov
59afbfb3b3 Sanity checks for processess table (#5411)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5411

Just uncommented sanity checks

Reviewed By: guliashvili

Differential Revision: D13918627

fbshipit-source-id: f3b7f406598f81e6ed55c828a7c1df3da810317f
2019-02-05 03:50:19 -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
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
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
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
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
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
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
Alexander Kindyakov
e2abdf65c5 Integration test for the users table (#5357)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5357

Basically rebase PR #5134 on top of experimental branch

Reviewed By: guliashvili

Differential Revision: D13675072

fbshipit-source-id: d609399be9661b9dbc38a0a226af2529a4ef3eac
2019-01-16 07:42:09 -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
George Guliashvili
f39ec0bd52 cpu_info
Summary: add integration test for cpu_info #5048

Reviewed By: akindyakov

Differential Revision: D13565408

fbshipit-source-id: c76be90515f4ace730f790ff88ad74cd0fd1f511
2019-01-11 07:11:29 -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
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
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
Alexander Kindyakov
3bbe6c511f win_timestamp column of time table is windows specific
Reviewed By: guliashvili

Differential Revision: D13398138

fbshipit-source-id: 9c37c50d551770ba55e175dca633ba85b94b6753
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
bcf0ab8e3a interface column of routes table could be empty on windows
Summary: also type could be [remote] as well

Reviewed By: guliashvili

Differential Revision: D13398132

fbshipit-source-id: 3cc56b612ff9984f20ad74e1a0a9d356e97b8967
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
7bceba4bdc Name column in programs table could be emtpy on windows
Reviewed By: guliashvili

Differential Revision: D13398137

fbshipit-source-id: 4999bccfae56a6ef5eb27e5304ca32c04d22203a
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
0adb5df8b7 Fix up os_version table integration test
Summary:
- column patch could be empty on windows
  - install_date was misstyped

Reviewed By: guliashvili

Differential Revision: D13398136

fbshipit-source-id: bf0b2fa1ecc7e51312eaa3a8d3ba42f70be6749b
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
3cda36c4d3 Fix up ntdomains table integration test for windows: most of the columns could be empty
Reviewed By: guliashvili

Differential Revision: D13398139

fbshipit-source-id: 31ab035701927f75dd7d3e6e8005ecf2475b03ed
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
8687d8b4fa Fix up logged_in_users table integration test for windows: column pid could be -1
Reviewed By: guliashvili

Differential Revision: D13398134

fbshipit-source-id: 39371da1c7669325eb73859859ae22b309a982d1
2018-12-11 03:31:18 -08:00
Alexander Kindyakov
43e25c5e35 Fix up interface_details table integration test for windows: some colums could be empty on windows
Reviewed By: guliashvili

Differential Revision: D13398135

fbshipit-source-id: d662567e19dce9d1703c86496cd7b51b38953d71
2018-12-11 03:31:17 -08:00
Alexander Kindyakov
e8354cd9ca Fix up hash table integration test for windows: ssdeep is posix specific column
Reviewed By: guliashvili

Differential Revision: D13398133

fbshipit-source-id: e873724e4954951924180ebe4dfa05a7a9487f96
2018-12-11 03:31:17 -08:00
Alexander Kindyakov
00b9084397 Sort a bit out tables integration tests by target platforms
Summary: accordint to osquery/specs/BUCK platform specification

Reviewed By: guliashvili

Differential Revision: D13398140

fbshipit-source-id: 64c44c33c39920f33c4647646f66b48e707ef5b4
2018-12-11 03:31:17 -08:00
George Guliashvili
c58f69bba2 fix macos test
Summary: mac address can be incomplete, lets add it in the verifier.

Reviewed By: fmanco

Differential Revision: D13377450

fbshipit-source-id: 057549d058f292fac7969adb242da2e313922c53
2018-12-11 03:31:17 -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
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
George Guliashvili
971bee4441 Move build system to BUCK
fbshipit-source-id: 8ffef5e6a393ac67ce56dcb74845402e43d964a0
2018-12-07 16:12:35 +00:00