Commit Graph

68 Commits

Author SHA1 Message Date
Teddy Reed
160ac6c906
refactor: Change the include path for osquery/core/plugins (#6619) 2020-08-29 20:24:39 -04:00
seph
29f4694df2
Update copyright notices (#6589)
Bulk update copyright notices from Facebook to "The osquery authors"
2020-08-11 16:46:54 -04:00
Teddy Reed
8ee7e3a3b0
refactor: Move osquery/include files to appropriate places (#6557) 2020-08-11 11:54:54 -04:00
Breakwell
893744238b
Return error detaching table, only use primary database (#6373) 2020-04-08 19:47:53 -04:00
calve
600f21dcfb flags: Implement enable_tables (#6150)
Adds an ``--enable_tables`` CLI flag to specify a limited set of
tables to expose. This is the contrary of ``--disable_tables``.
2020-01-17 18:59:20 -05:00
Teddy Reed
13290ed7ac
leak: Fix memory leak when SQL query fails (#5911)
There is a memory leak when a SQL statement is evaluated and returns an
error while stepping. An example includes returning sqlite3_result_error
from regexStringMatchFunc. The root cause is not finalizing a prepared
statement.
2019-10-20 14:59:07 -04:00
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
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
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
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
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
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
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
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
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
George Guliashvili
971bee4441 Move build system to BUCK
fbshipit-source-id: 8ffef5e6a393ac67ce56dcb74845402e43d964a0
2018-12-07 16:12:35 +00:00
Giorgi Guliashvili
ac4cbbe062
pvs-studio errors and warnings fix (#4744) 2018-07-30 23:51:35 +01:00
Alessandro Gario
8fe570bed7 feature: Write support for tables implemented from extensions (#4094) 2018-07-17 09:12:09 -07:00
Teddy Reed
fa4f63fb84
tables: Remove lexical_cast include from tables (#4683) 2018-07-14 11:42:44 -04:00
Max Kareta
5aca61375f
reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
Max Kareta
6047e7d6f8
Added custom path functions (#4265) 2018-05-24 12:26:43 +01:00
Jonathan Keljo
1ea714a325 Plumb used columns into QueryContext; use that to make processes table more efficient on macOS (#4269) 2018-05-12 09:07:57 -07:00
Jonathan Keljo
7a7c43dbe2 Enable query planner to understand CAST statements (#4326) 2018-05-01 12:24:10 -07:00
Teddy Reed
f6d077cbf7
license: Change license to Apache 2.0 and GPLv2 (#4007) 2017-12-18 16:04:06 -08:00
Teddy Reed
4aa3db30ca [Fix #3859] Lock every access to SQLiteDBInstance::db (#3883) 2017-10-24 11:40:26 -07:00
Teddy Reed
979cd4e5d1 [Fix #3831] Apply per-DB instance attach locking (#3862) 2017-10-21 11:19:57 -07:00
Teddy Reed
d106647c7f tables: Require explicit requests for query results caching (#3805) 2017-10-12 20:00:51 -07:00
Nick Anderson
c4b6b33ad1 carver: gating carver code in CMake (#3407) 2017-06-15 09:40:58 -07:00
Teddy Reed
73848c10ff virtual tables: Add optional --table_delay between scans (#3349) 2017-05-28 22:37:38 -07:00
Mitchell Grenier
600a5d017a Add an sql function for carving paths (#3317) 2017-05-26 11:19:43 -07:00
Mitchell Grenier
21395f7cb5 Add base64 encode and decoding functions (#3312) 2017-05-24 09:38:10 -07:00
Teddy Reed
e8c39c5572 hashing: Add sha1, sha256, md5 functions (#3267) 2017-05-09 23:55:49 -07:00
Teddy Reed
3a5aca9c94 Add getQueryTables to inspect tables scanned (#3056) 2017-03-15 18:48:01 -07:00
Teddy Reed
5604a7a99b freebsd: Rollup of build and source fixes (#3022) 2017-02-26 18:25:49 -08:00
Teddy Reed
0de5d3c381 external: Enable external applications through make external (#3023) 2017-02-26 17:38:01 -08:00
Teddy Reed
d1d21cda78 darwin: Use boost shared_mutex for OS X (#3003) 2017-02-15 14:17:40 -08:00
Teddy Reed
691aefe1f8 sql: Reorder SQLite manager mutex locking (#2965) 2017-02-03 22:58:09 -08:00
Teddy Reed
58ed5cc628 Introduce scheduler reload feature (#2917) 2017-01-25 17:48:33 -08:00
Teddy Reed
f9599d60d0 Move Mutex to shared_timed_mutex and add ReadLock (#2915) 2017-01-15 02:16:40 -08:00
Teddy Reed
0e9733f94c Simplify Registry and plugin concepts (#2887) 2017-01-07 12:21:35 -08:00
Teddy Reed
cefaf0cc59 [#2809] Emit verbose warning on column collisions (#2810) 2016-11-30 14:06:19 -08:00
yying
84e6a3401a Reducing compiler warnings and fails on warn in VS (#2433) 2016-09-02 15:04:03 -07:00
Teddy Reed
65dd56e113 Introduce table 'attributes' (#2431) 2016-08-31 15:32:20 -07:00
Teddy Reed
05882d717c Add basic string split and inet_aton functions (#2124)
The three new SQLite functions:
- split: Splits a column using a set of tokens and a selected index.
- regex_split: Similar to split but with a regex instead of tokens.
- inet_aton: Returns the IPv4 decimal value for a string-formatted address.
2016-05-29 02:06:02 -07:00
Teddy Reed
37544138b5 Add basic math extension functions (#2123) 2016-05-28 17:46:24 -07:00
Teddy Reed
b28c4d8d0f Introduce table options (#2101)
Table options includes a change to the Registry::call API for TablePlugins.
When requesting route information or the 'columns' action, a new 'op' key is included.
2016-05-18 12:23:52 -07:00
Teddy Reed
947799d28e Introduce within-query caching (#2077)
This adds a new optimization feature that allows expensive tables to cache
their results between JOINs. Consider JOINing a list of open sockets, for each
process, then requesting to hash each process path. This query may hash
the same path multiple times.

Within-query caching allows the hash table to respond with the previous
result of the hash request as long as the requested computation was the result
of a single query. Subsequent queries will perform subsequent hashing.
2016-05-09 10:32:33 -07:00
Teddy Reed
ebb0ab30ce Fix shell's --profile switch 2016-03-20 16:05:13 -07:00
Teddy Reed
afd17f8134 1. Reorganize RocksDB database handle into a plugin
2. Introduce a SQLite-based database plugin
3. Refactor database usage to include local 'fast-calls'
4. Introduce an 'ephemeral' database plugin for testing (like a mock)
2016-03-06 20:40:16 -08:00
Teddy Reed
b21c2ed943 [#1816] Refactor DB instance management 2016-02-25 19:07:52 -08:00