Commit Graph

4492 Commits

Author SHA1 Message Date
Max Kareta
3c9ba5827d
fixed error when wrong directory separator was used (#4695) 2018-07-12 10:42:49 +01:00
Nick Esposito
ca324ab831 round negative reported durations in query profiler to zero (#4696) 2018-07-11 21:13:48 -04:00
Mitchell Grenier
978a3f82bb
Add unique pid field to the processes table on macOS (#4667) 2018-07-11 13:49:50 -07:00
Teddy Reed
04796f2687
logger: Fix logfile writes to /tmp with verbose flag (#4681) 2018-07-11 16:28:39 -04:00
Alexander
6e2c9014e7
Pre-aggregation cache implementation for numeric monitoring plugins (#4677)
Pre-aggregation cache implementation for numeric monitoring plugins.

For the most of monitoring data some aggregations are going to be applied on the user side. To do analytics you rarely need to see all points on the graph. It means for such paths (unique keys for points subsets) particular points means not much. And to reduce a disk usage and a network traffic some pre-aggreagation could be applied on osquery side.

This PR is implementation of such pre-aggreagtion.

It based of PR #4626
2018-07-11 18:38:12 +01:00
Vova Mishatkin
0cc9b84e4f
Add tests for file_paths_query (#4693) 2018-07-11 18:29:55 +01:00
Jan Beich
b675632603 Unbreak with boost 1.68 (#4692) 2018-07-10 23:05:37 -04:00
Teddy Reed
6d5f94b2c6
flags: Separate flags and flagalias (#4682) 2018-07-10 23:04:39 -04:00
Vova Mishatkin
dbac4ea67c
Add the ability to specify file_paths with sql queries (#4678) 2018-07-10 16:24:13 +01:00
Filipe Manco
9197810c76
Fix documentation for flag decorations_top_level (#4688) 2018-07-10 14:04:10 +01:00
Alexander
508b147aa1
Remove using instance() from serviceCount() (#4685)
As far serviceCount is not a static function there is absolutely legal to use
2018-07-10 10:35:45 +01:00
Alexander
1945db71b5
Numeric monitoring system concept (#4626)
Just an interface and simple implementation dumping points to file on disk.
And I add also few monitoring records to some places of osquery code as an example.

Brief
Just an interface and simple implementation dumping points to file on disk.
And I add also few monitoring records to some places of osquery code as an example.

Motivation
osquery can monitor system health. But at some point we need to monitor the condition of osquery itself. Vast majority of interesting parameters can be represented by
numbers. How many queries it runs, how long does each query takes, what is the performance hit of each query, how long was last downtime and so on and so far. For obviou
s reason it hard to measure most of this parameters by external instrument. And it is almost impossible to evaluate it on production. But we can do it from inside of osquery.

What this PR is for
The systems like graphite or RRDtool can store and plot time-series data for us. We just have to
be able to feed data to it. We can create different plugins to be able to send data to different instruments. And we need some proper internal interface to all potential plugins. This PR is attempt to create generic interface.

Interface description
The most systems accept data as sequences of 2-dimensional points. One of the dimensions is value, the other is time. Each particular sequence has unique key, to be distinguished from the others.
Data descriptions for carbon. I have used this three parameters as an attributes of one monitoring point.

To send one point from some particular place in the code you just need to call the function record from namespace monitoring declared in the file include/osquery/num eric_monitoring.h with 3 arguments (path, value, time). Where path is the unique key of sequence; value is some interesting value to watch; time is the time of the point (can be omitted, current system time is the default vaule).
2018-07-09 13:19:50 +01:00
Teddy Reed
ee65b95f3c
bug: Fix SELinux events rebase (#4684) 2018-07-08 16:07:25 -04:00
Alessandro Gario
9497df67cc Add a new audit-based table to collect SELinux events (#4224) 2018-07-08 11:22:03 -04:00
uptycs-nishant
1cf5cb7dbc Fixing user_time, system_time bug and changing the cpu utilization logic (#4431) 2018-07-08 11:20:45 -04:00
Jonathan Keljo
f088f26c61 Add documentation for conditional column gen (#4673) 2018-07-08 10:10:42 -04:00
Javier Marcos
53dc36d735 Adding OSX Dummy malware to osx-attacks query pack (#4668) 2018-07-06 11:06:29 -04:00
Alexander
af647a4251
Add get_or, take_or shortcuts to Expected class (#4662)
* Add get_or, take_or shortcuts to Expected class
* Make take_or more strict with accept types
2018-07-06 14:27:06 +01:00
Alexander
5fa1ebad13
Output stream like operator << for Error (#4670)
To create an error human readable message should be provided among other argmunts.
Which is good to better understanding what happend by log records.
To make it more informative user in most cases should put in those message some data (numbers, strings etc.).
This operator will help us to avoid using verbose constructions like boost::format or std::ostringstream or something similar to format a proper error message.
We will be able just to "stream" in a created error any "printable" variables from the context.

Additionaly we will be able to use "fancy" tools for streams like boost::io::quoted or std::hex to format messages.

Example:
```c++
createError(SystemErorr::NoSuchFile, "Could not read pidfile: ")
  << boost::io::quoted(pidfile_path)
  << " " << read_status.toString();
```
2018-07-05 16:12:18 +01:00
Jason Schroth
b75821658b adding bash_session logging (#4640)
* adding bash_session logging

* adding genShellHistoryFromBashSessions

updated to include new function for adding bash_sessions

* adding genShellHistoryFromBashSessions and tests and header
updated test use canonical for filepath

updated to include new function for adding bash_sessions
2018-07-04 15:25:38 +01:00
Giorgi Guliashvili
159d893655
Confusing excepted comment correction (#4669) 2018-07-04 14:55:57 +01:00
Teddy Reed
ab5442d26d
deps: reinstall for portable gcc and mojave support (#4664) 2018-07-03 12:44:26 -04:00
Alexander
4051b0fc79
Create a template implementation of tryTo<> for the one type (#4665) 2018-07-03 17:12:17 +01:00
Chris
f0ed24d826 Initd script (#4661) 2018-07-03 12:00:56 -04:00
M Amin
9075d7265c deps: Update win64 openssl provisioning script (#4636) 2018-07-02 19:56:44 +01:00
Alessandro Gario
e622f62d8a macOS signature: Add a hash_resources parameter to the table (#4246) 2018-07-02 19:47:18 +01:00
Alexander
02e29c48a1
Remove container specific join implementation from conversions.h (#4656)
using templates generic version for any iterable container could be done
Also, realisation for std::set were using a useless copy of data.
2018-07-02 14:14:36 +01:00
Vova Mishatkin
29b596dc85 Add ssdeep table for posix (#4629) 2018-06-29 19:50:47 +01:00
Alexander
9f69a0f8c8 Explicit use ValueType and EnumErrorType in Expected full type definition (#4650) 2018-06-28 14:46:48 +01:00
Rich5
50f66f8baa Using TOKEN_USER instead of TOKEN_OWNER struct (#4651) 2018-06-28 11:22:24 +01:00
Alexander
13081420ae
Remove platformStrncpy function from osquery/core/utils.h (#4645)
On the one heand there is no place of use for it. And on the other, if code rely on all this checks it must be pretty unsafe and messy.
2018-06-27 19:18:35 +01:00
Alexander
ed7c5ca69d
Connecte expected.h and error.h tests to build system (#4648)
* Connecte expected.h and error.h tests to build system

% ./build/darwin/osquery/osquery_tests --gtest_filter='Expected*'
Note: Google Test filter = Expected*
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[  PASSED  ] 0 tests.

% ./build/darwin/osquery/osquery_tests --gtest_filter='Expected*'
Note: Google Test filter = Expected*
[==========] Running 2 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from ExpectedValueTest
[ RUN      ] ExpectedValueTest.initialization
[       OK ] ExpectedValueTest.initialization (0 ms)
[----------] 1 test from ExpectedValueTest (0 ms total)
[----------] 1 test from ExpectedPointerTest
[ RUN      ] ExpectedPointerTest.initialization
[       OK ] ExpectedPointerTest.initialization (0 ms)
[----------] 1 test from ExpectedPointerTest (0 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 2 test cases ran. (0 ms total)
[  PASSED  ] 2 tests.

* Check error message and name of error enum separatelly

Different compilers produce different names for C++ classes
2018-06-27 18:42:17 +01:00
Max Kareta
c382a8a739
Refactor/cmake (#4646) 2018-06-27 18:08:52 +01:00
Teddy Reed
e2a53388b8
deps: Small changes for Ubuntu18 build (#4630) 2018-06-26 19:02:29 -04:00
Max Kareta
a2e1e37219
Refactor/cmake (#4644) 2018-06-26 18:27:24 +01:00
Alexander
5ef576a99c
Create a success and failure static factory for Status (#4627)
Consider this PR as a cosmetic one.

Creating Status class object in the code is not so clear. It is not so obvious that defatult costructed Status is success. Also it is not obvious that status with zero code is success and non-zero is failure.

To fix it I created 2 static methods to make construction of some particular status clear to reader.

* Use assert to check code in Status::failure in debut mode

* Rename success_code constant to kSuccessCode
according to style guide
2018-06-26 17:36:26 +01:00
Max Kareta
6344f58712
Improved xcode compatibility (#4643) 2018-06-26 17:13:48 +01:00
Max Kareta
6ab2a83a61
Refactor/cmake 5 (#4642) 2018-06-26 16:54:08 +01:00
Alexander
f9e9fdb962 Remove unused unused mutex 'config_valid_mutex_' from config (#4637) 2018-06-26 16:01:28 +01:00
Max Kareta
8f7ea728d2
reworked part of cmake files (#4638) 2018-06-26 12:03:35 +01:00
Jason Schroth
ec22af9fc8 Refactor before adding bash_sessions history files to shell_history (#4634) 2018-06-25 17:42:48 +01:00
Alexander
1179915350
The default timestamp was added for shell_history without timestamp (#4618)
If the shell history file does not contain a timestamps for the lines
osquery will miss the time in rows and will show an confusing error
about attempt to convert empty string to INTEGER.

```
% head -n 3 ~/.zsh_history
ls
cd source
ls
```

```
osquery> select * from shell_history limit 1;
I0621 11:56:37.804193 2629124992 virtual_table.cpp:292] Error casting time () to INTEGER
+------------+------+---------+-------------------------------+
| uid        | time | command | history_file                  |
+------------+------+---------+-------------------------------+
| 1868255265 |      | exit    | /home/akindyakov/.zsh_history |
+------------+------+---------+-------------------------------+
```
So, default value for the time in shell history can solve the problem.
2018-06-25 16:55:49 +01:00
Kolokotronis Panagiotis
4270f75b94 Kafka logging plugin is called kafka_producer (#4594) 2018-06-23 12:01:27 +01:00
mchaffe
191fc7df53 Fix regular files being tagged as symlinks (#4579) 2018-06-23 10:32:13 +01:00
Kyle Creyts
19843b8253 first pass at ssh_config table (#4380) 2018-06-22 19:37:29 -07:00
Giorgi Guliashvili
257bcfa546 events proof read (#4591) 2018-06-22 19:35:36 -07:00
Teddy Reed
a165a8f89a
deps: Use static libfl in thrift build (#4442) 2018-06-22 19:03:14 -07:00
Giorgi Guliashvili
6bb1f93fc2 udev resource protection (#4599) 2018-06-22 19:01:59 -07:00
Nick Anderson
f032cd7e83
tests: ensuring services have been cleared from the system before starting (#4625) 2018-06-22 12:28:04 -07:00
Max Kareta
d085f2dca1
added custom version of realpath function (#4416) 2018-06-22 15:02:22 +01:00