Commit Graph

355 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Giorgi Guliashvili
0ce40c4ac5
remove resolvedpath class (#4805) 2018-08-08 10:32:13 +01:00
Giorgi Guliashvili
5b8d80ea65
gracefully shutdown - AuditdNetlinkParser will not wait indefinitely (#4801) 2018-08-03 15:27:39 +01:00
Alessandro Gario
25e72c0e48 Audit fixes (#4714) 2018-08-03 15:18:00 +01:00
Giorgi Guliashvili
4b7e211965
pauseMili to pause transform (#4796) 2018-08-02 16:57:02 +01:00
Giorgi Guliashvili
3ea36a60d0
size check after Resize dead code (#4780) 2018-07-31 15:49:11 +01:00
Alexander
e5f279699f
method. To make checks 'if expected is not an error then...' less verbose and clear (#4774)
Inspired by PR #4768
2018-07-30 17:50:48 +01:00
Alexander
9e798eb162
Remove safeStrtoll from conversions.h and change all usecases to tryTo<> (#4754)
Also I've used a throwning std::stoll because the tests should not be exception safety and must fail if something goes wrong.
2018-07-26 10:57:52 +01:00
Giorgi Guliashvili
80bfef9f77
setThreadName boilerplate removal (#4749) 2018-07-23 19:50:35 +01:00
Mitchell Grenier
69d307b64c
Add labels for threads (#4295) 2018-07-23 11:13:43 -07:00
Giorgi Guliashvili
2d5fc8df0a
udev fd check (#4736) 2018-07-20 10:55:57 +01:00
Giorgi Guliashvili
94397d3c04
get rid of unnecessary ptree includes (#4727) 2018-07-19 10:45:40 +01:00
Giorgi Guliashvili
d4e444c999
incorrect assumption about reserve behavior (#4728) 2018-07-19 10:44:56 +01:00
Alessandro Gario
8b864f1935 Improving audit-based table performances (#4647) 2018-07-12 10:10:52 -04:00
Alessandro Gario
9497df67cc Add a new audit-based table to collect SELinux events (#4224) 2018-07-08 11:22:03 -04:00
Max Kareta
a2e1e37219
Refactor/cmake (#4644) 2018-06-26 18:27:24 +01:00
Giorgi Guliashvili
257bcfa546 events proof read (#4591) 2018-06-22 19:35:36 -07:00
Giorgi Guliashvili
6bb1f93fc2 udev resource protection (#4599) 2018-06-22 19:01:59 -07:00
Max Kareta
2084c74238
updated another set of cmake files (#4622) 2018-06-21 18:43:22 +01:00
Giorgi Guliashvili
f9e60dbb74
toIndex simplification (#4586) 2018-06-19 23:16:18 +01:00
Max Kareta
408c54565e
Removing macOS kernel module (#4572) 2018-06-17 19:21:07 +01:00
Giorgi Guliashvili
ff1747347e
InterruptableRunnable RunnerInterruptPoint redesign (#4545)
* InterruptableRunnable RunnerInterruptPoint redesign

There were several inefficiencies in the old version of RunnerInterruptPoint and InterruptableRunnable.

1) RunnerInterruptPoint was throwing the exception when interrupted, however, the exception was always ignored.

2) InterruptableRunnable used the read-write lock, however only write lock was used.

3) InterruptableRunnable InterruptableRunnable, stored almost similar variable stop_, interrupted_.

4) std::atomic<bool> interrupted_ was used with locks, even though it was accessed by default safest access mode memory_order_seq_cst. So no additional cache invalidation was needed.

5) InterruptableRunnable contained code(in method interrupted() and variables bypass_check_, checked) just for testing. Which was slowing down method interrupted().

6) Some more confusing things. notify_all was not needed, as only one thread could be waiting for the conditional variable. RunnerInterruptPoint:: pause(void) looks ambiguous and that's why was not used anywhere.

I resolved all these problems by merging InterruptableRunnable and RunnerInterruptPoint into the InterruptableRunnable.

1) No use of the exception.
2) 4) Simple mutex, which is only used for pauseMilli. InterruptableRunnable::interrupted and InterruptableRunnable::interrupt function lock-free.
3) Single variable interrupted_.
5) Made InterruptableRunnable::interrupt virtual. Tests override interrupt to make things testable.
6) change to notify_one and removed pause without the specific time.
2018-06-15 16:15:43 +01:00
Nick Anderson
428094ef72 bug: correctly check windows event log channels for firing (#4550) 2018-06-13 21:40:50 +01:00
Filipe Manco
98ccbcc250
Remove /dev/null monitoring from fsevents (#4549) 2018-06-13 20:33:32 +01:00