Commit Graph

3126 Commits

Author SHA1 Message Date
Teddy Reed
15d522f447
json: Configure rapidjson to use iterative parsing (#5893) 2019-10-19 15:25:21 -04:00
Will Newton
599e9d6f3a macOS keychain sanity test (#5885)
When requesting kSecClassIdentity items from the keychain sometimes
invalid items are returned. These cause errSecInvalidItemRef to
be returned from SecKeychainItemCopyAttributesAndData and result
in an empty row in the table. Catch the error and avoid returning
empty rows.
2019-10-17 08:50:17 -04:00
Nick Anderson
3957d8e948
version: fix windows os codename lookup (#5887) 2019-10-16 21:42:06 -07:00
Allan Liu
e1e75aac88 genPCIDevices for linux refactor (#5446) 2019-10-16 16:27:29 -04:00
William Woodruff
1ca47d3e7a (Windows) New table: default_environment (#5441) 2019-10-16 14:20:52 -04:00
Teddy Reed
2b9ea20563
fuzz: Silence config parsing log lines in fuzz-config (#5886) 2019-10-16 10:19:18 -04:00
Alessandro Gario
6ba37014ef
BPF/Map: Add missing return value in move assignment operator (#5874) 2019-10-14 21:45:23 +02:00
Sharvil Shah
bdca64fbcd [shell] support previously supported on|off toggle for osqueryi shell functions (#5876) 2019-10-11 17:17:10 -07:00
Stefano Bonicatti
e1dca49663 Fix regression in calling core only plugins from extensions (#5875)
PR osquery/osquery#5464 makes it impossible to call plugins
which are only registered in the core, as its happening with osquery/osquery#5839.

What happens when this is working is that the filesystem plugin is not present
in the extension registry, so when Registry::call tries to search for a plugin
that provides the "config" feature, it won't find one and the resulting plugin name,
and later item_name, will be empty.

This results in the RegistryInterface::call reroute the call to the core,
through Thrift, which will end up in the plugin correctly answering.
2019-10-11 17:15:19 -07:00
Stefano Bonicatti
8de035ba94 Improve error reporting from extension manager (#5860)
Change the message that is logged when a required extension is not
loaded or found from "Extension not autoloaded: <extension id>" to
"Required extension not found or not loaded: <extension id>".

Change the message that is logged when the extension manager has an
error happening during startup from "Cannot start extension manager:
<error>" to "An error occurred during extension manager startup: <error>"

Add the possibility of startExtensionManager returning with an error
if the Dispatcher failed to properly add the ExtensionManagerWatcher
or ExtensionManagerRunner.

Fallback to logging the startExtensionManager error message with a
severity of INFO only if extensions are required to be disabled.

Add tests for starting the extension manager with a nonexistent
socket path and a nonexistent required extension.

Issue osquery/osquery#5679
2019-10-04 15:44:54 -04:00
William Woodruff
a9b23807b2 darwin/firewall: Fixes for alf_exceptions, make alf_services an alias for sharing_preferences (#5378) 2019-10-04 15:42:10 -04:00
William Woodruff
06dd05cd33 (Windows) New table: connectivity (#5500) 2019-10-04 15:18:15 -04:00
Teddy Reed
92e7b9033d
fuzzing: Restore simple libFuzzer-based config fuzzing (#5844)
This defines a new CMake option: OSQUERY_FUZZ, which appends compiler
and linker flags for libFuzzer to be effective.

There is one example harness that will fuzz config parsing.
2019-10-02 18:09:35 -04:00
Teddy Reed
0f3ad48b77
bug: Use RecursiveMutex and additional read locking on getEventSubscriber (#5841) 2019-10-02 01:02:24 -04:00
Zachary Wasserman
2a6ddd62ea Implementation of windows_security_products table (#5479)
Provides information about the security products registered on a Windows
system.
2019-09-23 17:44:31 -04:00
Nick Anderson
789f70f2d9 deploy: updating osquery --install to wrap binary path and flagfile (#5824) 2019-09-23 17:38:20 -04:00
Tomohito Nakayama
553ab52b38 Fix error with implicitly-deleted default constructor of glob_t (#5828) 2019-09-22 01:03:46 -04:00
Alessandro Gario
c83e70f91f
Intel ME table refactor (#5476)
Reimplement the intel_me_info table, adding support for all the
three available query protocols.
2019-09-08 10:26:56 +02:00
Teddy Reed
925250dc92 aws: Fix preprocessor define check 2019-09-07 02:08:00 -04:00
seph
6550462468 Don't return nil rows for the programs table (#5715) 2019-09-06 20:44:44 -04:00
pawel-lmcb
1a4b277ce2 Fix optional AWS table compilation on Windows (#5719) 2019-09-06 13:19:29 -07:00
Mike Myers
c8bcba151b Fix the reading of the Serial of a certificate (little-endian big int). Resolves #5104 (#5742) 2019-09-06 15:18:25 -04:00
Stefano Bonicatti
2a0e389c35 Fix registry table exception closing an uninitialized key handle (#5718) 2019-09-03 20:27:05 -07:00
Alessandro Gario
6481b34e23
Refactor third-party libraries to build from source on Linux (#5706)
Add a way to compile third-party libraries from source instead of downloading prebuilt ones.
Each library source code is downloaded with git into a submodule at configure time,
in response to the find_package(library_name) CMake call,
except for OpenSSL where the official source archive is used.
Each submodule is attached to a release tag on its own upstream repository.
All the libraries are built using CMake directly, except for OpenSSL which uses a formula system,
which permits to build libraries with a separate build system
when there's no easy way to integrate it directly with CMake.

This new dependency system determines which library is fetched from where using the concept of "layers".
Currently we have three of them: source, formula, facebook,
where the last layer represents the pre-built libraries.
The provided order will be used when looking for libraries.

A system to patch submodule source code has been added and it's currently used with googletest, libudev and util-linux.
Patches should be put under libraries/cmake/source/<library name>/patches/<submodule>,
where <submodule> is often one and is "src", but in other cases, like AWS,
there are multiple with a more specific name.
If for whatever reason the submodule cloning or the patching fails,
the submodule has to be unregistered and its folder should be cleared.
This should be achievable with "git submodule deinit -f <submodule path>"

Following some other changes on existing functionality:

- Changed the CMake variable BUILD_TESTING to OSQUERY_BUILD_TESTS
  to avoid enabling tests on third party libraries.
  Due to an issue with glog the BUILD_TESTING variable
  will be always forced to OFF.
- Moved compiler and linker flags to their own file cmake/flags.cmake
- Moved all the third-party CMakeLists.txt used for pre-built libraries under libraries/cmake/facebook
- Added the --exclude-folders option to tools/format-check.py and tools/git-clang-format.py,
  so that it's possible to ignore any third party library source code.
- The format and format_check target use the new --exclude-folders option
  to exclude libraries/cmake/source from formatting.
- The test and osquery binaries are properly compiled with PIE (osquery/osquery#5611)

Co-authored-by: Stefano Bonicatti <stefano.bonicatti@gmail.com>
Co-authored-by: Teddy Reed <teddy@casualhacking.io>
2019-08-30 16:25:19 +02:00
Stefano Bonicatti
81e12f718c Add audit processeventstests-test to the running tests (#5726)
The test was built but wasn't running with the other tests.
2019-08-28 01:18:44 +02:00
Alessandro Gario
7cc21aa648 Update the license header used on smart_drives and windows_crashes (#5722) 2019-08-27 10:24:50 -04:00
Alessandro Gario
444b2cc017
Audit: Implement support for fork/vfork/clone/execveat (#5701)
* Audit: Implement support for fork/vfork/clone/execveat

Also implement a test target for the process_events table
2019-08-23 16:09:00 +02:00
Sharvil Shah
d9fdc5b8fd tables: implement ibridge table to report on T1/T2 chip for mac notebooks (#5707) 2019-08-19 17:41:24 -04:00
Stefano Bonicatti
4f78848794 Fix undefined-behavior in osquery::ebpf::consumeWrappedMessagesFromCircularBuffer
Issue highlighted by asan activated in PR osquery/osquery#5628

Ensure WrappedMessage has no padding since its members are written
consecutively in the buffer.
Also use memcpy when retrieving a WrappedMessage from a buffer, since
it could be written at a misaligned address.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
fb5585976b Fix undefined-behavior in osquery::tables::getCanonicalEfiDevicePath
Issue highlighted by asan activated in PR osquery/osquery#5628

EFI_DEVICE_PATH_PROTOCOL and HARDDRIVE_DEVICE_PATH were using
the wrong alignment/padding, since on disk they are written
with no padding.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
ea17c51bb8 Fix undefined-behavior in copyValueFromJValue
Issue highlighted by asan activated in PR osquery/osquery#5628

Imprecisions between float -> double -> json -> double -> float
lead to out of range values been saved into a float variable.
Since json has only the notion of doubles as floating point numbers,
it's better to require to use them.

Also forced the json parser to parse floating point numbers
with full precision, otherwise the test testing for precision would fail.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
0a302cd08e Fix undefined-behavior in smc_keys strtoul
Issue highlighted by asan activated in PR osquery/osquery#5628

When shifting left or right a byte, that must be positive, so
ensure it is.

Light cleanup of a bugged and unused function.
A deeper look into the table implementation is needed.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
2e88c4214f Fix heap-buffer-overflow in osquery::tables::netmaskFromIP
Issue highlighted by asan activated in PR osquery/osquery#5628

Do not try to read the destination address of a netmask if such address
is a default route.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
cc2787a27d Fix undefined-behavior in osquery::tables::genMemoryRegion
Issue highlighted by asan activated in PR osquery/osquery#5628

Reading a 8 byte field from a 4 byte aligned struct needs to be
done with memcpy.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
a322a951ec Fix heap-buffer-overflow in osquery::tables::genDetailsFromAddr
Issue highlighted by asan activated in PR osquery/osquery#5628

Do not use memcpy to copy strings around.
Also, ifa_name size is not guaranteed to be IFNAMSIZ.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
f4885df19d Fix container-overflow in Carver::carve
Issue highlighted by asan activated in PR osquery/osquery#5628

Do not use clear() on a vector inizialized with a fixed size to clear
it of its contents when using it as a char buffer.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
Stefano Bonicatti
3f5d2debc4 Fix stack-use-after-scope in procEnumerateProcesses
Issue highlighted by PR osquery/osquery#5628

Do not take a reference of a string which is owned by a temporary,
copy it instead.

PR: osquery/osquery#5665
2019-08-16 16:47:18 +02:00
seph
7a96a9660e sql function regex_match (and some tests for other sql functions) (#5444) 2019-08-14 11:51:21 -04:00
Mark Mossberg
c3b34763e8 windows/certificates: Fix bug in environment variable expansion (#5697) 2019-08-13 19:26:06 -04:00
Mark Mossberg
59a68ad5ef windows/certificates: Do not filter out system accounts
When proactively searching disk for personal certificates, there is no
need to filter system accounts (SYSTEM, Local Service, etc) anymore
because `findUserPersonalCertsOnDisk` is now capable of handling those
accounts by dynamically finding a user's home dir (as rather than
constructing a hard coded path).

This now makes the table even more complete; any certificates found in
the system accounts directories will always be found. Previously they
could be found but only if there was a store location other than the
`Users` store location that had a system store string that looked like
`S-1-5-18\My` or `.DEFAULT\My`.
2019-08-08 18:50:56 +02:00
Mark Mossberg
f9c1fd88cc windows/certificates: Improve table's coverage of Personal certificates (#5640) 2019-08-07 10:58:22 -04:00
@emptymonkey
f1cd3e1d86 Fix for mount table interacting with direct autofs. (#5635) 2019-08-05 22:23:34 -04:00
seph
2c0da99016 Light refactor and fixes for the users and groups table
- Lightly update the logic, to make the code paths similar between
  no-constraint, and specified uid cases.
- Add tests to the group table.
2019-08-05 22:15:13 -04:00
Teddy Reed
1145140016 tables: Add optimization back to macOS users and groups
This PR supersedes #5669 with an alternate approach of moving forward
without a revert of #5368.
2019-08-05 22:15:13 -04:00
Teddy Reed
d7c7a1de88
Remove cloud tables from windows (#5657)
It does not look like the EC2 tables are available on Windows
(due to spec-file configuration).

Please see https://osquery.io/schema/3.3.2#ec2_instance_tags

This removes the EC2 library linking requirement until we revisit this
feature.
2019-07-23 08:13:03 -07:00
Teddy Reed
22d51ddc20 rpm: Check for glibc version and librpm secure_getenv
The librpm dependency may be configured with a glibc version < 2.17. If
so then it will expect __secure_getenv to be available.
2019-07-23 14:19:57 +02:00
Stefano Bonicatti
a5dfb3da7e
Improve osquery version detection (#5630)
Add OSQUERY_VERSION cache variable to force the version to be set at
that value.
Add OSQUERY_VERSION_AUTODECTED cache variable to show the osquery
version that has been detected through git
Add OSQUERY_VERSION_SUFFIX cache variable to append its value to the
final version, if the version was autodected.
Add OSQUERY_VERSION_INTERNAL variable to globally store the final
osquery version, to be used in other CMake scripts.
Add OSQUERY_VERSION_COMPONENTS variable to globally store the components
of the final osquery version. Currently used by the packaging system.

Modify overwrite_cache_variable so that's possible to specify the type.

The version is always autodetected using "git describe --tags --always --dirty"
and OSQUERY_VERSION_SUFFIX is appended to it, unless OSQUERY_VERSION is manually set.

Incorporates suggestions by @directionless.

CMake part of osquery/osquery#5615
2019-07-23 13:01:20 +02:00
seph
bf7e9f5c96
Don't return a battery row, if there are no results (#5650)
If there are no battery results, don't return a nil row. Return an empty set.
2019-07-20 21:23:05 -07:00
Stefano Bonicatti
9cf33c84f8 Restore AugeasTests test
PR: osquery/osquery#5629
2019-07-19 22:36:40 +02:00
Stefano Bonicatti
c56020cac3 Restore WindowsEventLogTests test
PR: osquery/osquery#5629
2019-07-19 22:36:40 +02:00