Commit Graph

5804 Commits

Author SHA1 Message Date
Mike Myers
de78a66da7
Windows: fix data type macro used for 64-bit timestamp variables (#6897) 2021-02-02 10:11:49 -08:00
Stefano Bonicatti
54b3e1297c
Fix SystemControlsTest adding sunrpc as an expected subsystem (#6932) 2021-01-31 16:57:24 -05:00
Teddy Reed
7affec2c64
libraries: Update librpm to version 4.16.1.2 (#6850) 2021-01-30 19:27:02 -05:00
Teddy Reed
ca015323e6
Add unit tests for RPM DB querying (#6919) 2021-01-29 09:34:00 -05:00
Zach Wasserman
3d2d2ba0f5
Update documentation about denylist schedule key (#6922)
Attempts to clear up a common misconception about the functionality of
the `denylist` key.
2021-01-26 21:31:45 -05:00
Stefano Bonicatti
776eba97c8
Rename yara str functions to avoid symbol collisions (#6917)
Yara publicly exposes the definition of various str functions like
strlcpy, strlcat and so on if they are not present on the system
it is compiled on.

This is not ideal because other libraries use custom implementations
of those functions and those symbols would collide with
the public ones from yara, therefore we rename them
to avoid the collision.
2021-01-26 21:28:43 -05:00
Stefano Bonicatti
6893a72eef
Significantly speed up CMake configuration phase (#6914)
This speeds up the configuration phase and simplifies having
control of the compilation flags used.

Additional changes were required due to other libraries incorrectly
depending on glog and gflags cmake code or headers.
smartmontools especially, was incorrectly publicly depending
on its own config.h, which was though taken from glog
when smartmontools libsmartclt.h header was included by user code.
A fix has been done on the smartmontools side and so the submodule
commit we refer to has been updated.
2021-01-26 21:26:59 -05:00
Alessandro Gario
22fde0abe6 GitHub Actions: Fix .deb artifacts, add scheduled builds 2021-01-26 10:11:26 +01:00
Stefano Bonicatti
d9e657458d
Remove unused empty test file (#6918) 2021-01-25 09:12:52 -05:00
Alessandro Gario
584a70bdab
GitHub Actions: Use Xcode 12.3, SDK 10.12 (#6913) 2021-01-22 22:15:30 +01:00
Sharvil Shah
56755f6b22
Update XCode to 12.3 and Update min macOS version to 10.12 in the macOS CI (#6896) 2021-01-21 10:22:15 -08:00
Mike Myers
51c44799f2
Disable deprecated TLS versions 1.0, 1.1 (#6910) 2021-01-20 14:29:37 -08:00
Stefano Bonicatti
a92b04106f
Fix Github Actions status badge in the README (#6908)
The status badge was incorrectly specified and it was "merged"
with the Azure one.

Add a link that sends to the Github Actions builds on the master branch
when the status badge is clicked.
2021-01-18 16:58:59 -05:00
Stefano Bonicatti
74c5859712
Change libdpkg submodule url to our own github mirror (#6903)
The upstream repository was failing to do shallow clones.
2021-01-18 16:58:34 -05:00
Stefano Bonicatti
fe887e917b
CMake: Add -pthread compile option on posix platforms (#6909)
osquery was already linking with -pthread and so linking
to libpthread on Linux, but it wasn't always defining
the _REENTRANT macro which is done by the -pthread option
given at compile time.
Although in the third party libraries that need it,
it should've been defined in other ways (directly or via a config.h),
always add -pthread for correctness and consistency.

Note: macOS doesn't need -pthread at link time because
pthreads are already implemented inside the libc library.
2021-01-18 16:58:12 -05:00
Zach Wasserman
fa75221db6
Fix additional relative path check in Yara for Windows (#6894)
This is a follow-up to #6893 fixing an additional cross-platform
compatibility issue with the relative path check in Yara.
2021-01-16 18:23:05 +01:00
Stefano Bonicatti
5135904c31
Remove unused tests for Rocksdb and Inmemory db plugins (#6900) 2021-01-16 18:20:58 +01:00
Alessandro Gario
2729225ef2
CI: Add support for GitHub Actions (#6885) 2021-01-16 15:21:34 +01:00
Mike Myers
90e1b57631
Spellcheck and Markdown nits (#6899) 2021-01-14 23:50:13 -08:00
Mike Myers
b803743bf7
Fix typos across source code (#6901) 2021-01-14 23:49:06 -08:00
Stefano Bonicatti
107a744c8e
Disable incremental linking to reduce build size on Windows (#6898) 2021-01-13 16:15:47 -08:00
Mike Myers
de8390525f
Restrict access to Thrift server pipe on Windows (#6875) 2021-01-13 07:45:20 -08:00
Mike Myers
3fc12a2a20
Reduce the compilation units from libarchive (#6886) 2021-01-11 09:26:44 -08:00
kumarak
4bef4e4c78
Add system extension table (#6863) 2021-01-11 10:34:11 -05:00
Zach Wasserman
c93fefb7f1
Fix loading of YARA rules on Windows (#6893)
Make the relative filepath check cross-platform.

Fixes #6788
2021-01-11 10:32:31 -05:00
Seshu Pasam
8fd470ca92
docker_image_history table (#6884)
This table provides output similar to "docker history" command.
See: https://docs.docker.com/engine/reference/commandline/history/
created_by column has useful information related to the command history
2021-01-11 10:31:20 -05:00
Stefano Bonicatti
8cc6d99c66
Fix a leak in libdpkg when querying the deb_packages table (#6892)
libdpkg is leaking memory on every initialization.
Initialization happens everytime deb_packages gets queried.

The memory leaked is allocated for the "triggersdir"
global variable by "dpkg_db_get_path" called in "trigdef_update_start".
"trigdef_update_start" is called by "trig_incorporate" just after
the memory for "triggersdir" has been allocated.
In some occasions "trigdef_update_start" is also called two times in a
row. In all these cases the memory do not get deallocated in between calls,
so the old memory is lost.

Since the result of "dpkg_db_get_path" depends on the database dir that
has been set, and in the "trigdef_update_start" function it's not possible
to know if it has changed from the previous allocation or not,
it's necessary to always deallocate vs just avoid to call "dpkg_db_get_path".

Fix also a couple of other leaks on error.
2021-01-10 16:43:25 -05:00
Brendan Shaklovitz
0ff6e70475
Add docs for tls enroll max attempts (#6888) 2021-01-10 16:42:09 -05:00
SaintMalik
bef509b02f
Fix broken link in developer docs (#6882) 2021-01-04 14:08:48 -08:00
Stefano Bonicatti
3b06d3217a
Fix UB and dangerous casting in the pubsub framework (#6881)
- Downcasting a shared_ptr to a type T2 that's not a derived class or a base class of T1,
  even if they share the same base class B, it's undefined behaviour.
  For instance BPFEventPublisher inherits from EventPublisher<BPFEventSC,BPFEventEC>,
  which is a template that inherits from EventPublisherPlugin, which
  further inherits from Plugin.
  The register function was called passing an instance of std::shared_ptr<BPFEventPublisher>
  which was implicitly upcasted to std::shared_ptr<Plugin> as the
  function parameter.
  Then such parameter was downcasted to std::shared_ptr<EventPublisherPlugin>
  (which was fine), then further downcasted to std::shared_ptr<BaseEventPlugin>
  which actually was std::shared_ptr<EventPublisher<SubscriptionContext, EventContext>>.
  Although the two EventPublisher template parameters are base classes
  of BPFEventSC and BPFEventEC, the resulting concrete EventPublisher
  class is not related to BPFEventPublisher, so this is UB.
  This was done in an attempt to have a common type for all publishers
  to be used to store them into a std::map. Instead of using such type,
  use EventPublisherPlugin.
  A very similar thing happens with subcribers.

- Fix an incorrect success when a std::shared_ptr<Plugin>
  fails to be downcasted to a std::shared_ptr<EventPublisherPlugin>,
  in EventFactory::registerEventPublisher.

- Substitute dangerous reinterpret_cast on a pointer to a member function
  callback in EventSubscriber<PUB>::subscribe with a safer approach
  which uses a lambda that captures the object it has to call the callback on
  and properly converts the arguments, downcasting them to the appropriate type.
  Also remove a redundant template parameter.

- Add a virtual destructor to SubscriptionContext and EventContext
  structs since they are inherited from
  and used in a polymorphic context as pointers.
2021-01-02 20:22:52 -05:00
Stefano Bonicatti
00c04fce5a
Fix heap-use-after-free in deregisterEventSubscriber (#6880)
Do not take a reference to a shared_ptr to be accessed
after being removed from the last persistent place
that was possibly keeping it alive.
2021-01-02 11:07:26 -05:00
Teddy Reed
b56ce6a03b
Update README to include release process comment (#6877) 2021-01-02 11:06:48 -05:00
Stefano Bonicatti
7cbc19038e
Remove unused/experimental ebpf code (#6879) 2021-01-01 15:46:00 -05:00
Stefano Bonicatti
4995a238c5
Remove unused ev2 code (#6878) 2021-01-01 15:45:10 -05:00
Stefano Bonicatti
66a20d0582
Fix config validation oom with duplicated keys (#6876)
This fixes a pathological case where the validation algorithm
is unable to verify if there's a deeply nested tree,
and it can end up into an oom situation.

Added a regression test to verify this case.
2021-01-01 15:44:36 -05:00
Stefano Bonicatti
4e204952a7
Do not ignore mountpoints that have the same mount path (#6871)
Use a vector instead of an unordered_map keyed on the mount path,
since we can have multiple mount points on the same mount path
and since all the other use cases do not need such data layout.
Although multiple mount points on the same mount path will override
each other, we still want to be faithful to the information
that /proc/mounts gives us.

Moreover with autofs mounted filesystems, we will always have two
mount lines when the target filesystem is mounted, one for autofs
and one for the target filesytem.
2020-12-30 21:13:53 -05:00
Sharvil Shah
c6671fe189
Support AWS tables on macOS (#6817) 2020-12-30 21:11:51 -05:00
Stefano Bonicatti
e083dbe839
Don't mark scope and key columns as index in selinux_settings table (#6872)
There's no logic to implement such constraints,
moreover the columns values are not unique,
so they shouldn't be exclusively part of the primary key.

Use a slightly more meaningful error message
when reading SELinux classes fails.
2020-12-30 15:51:27 -05:00
Teddy Reed
7a24b00f18
Add patch for apache/thrift#2083 (#6846) 2020-12-28 20:46:34 -05:00
Stefano Bonicatti
fb655af28d
Improve config fuzzer dictionary creation script (#6860)
Avoid grepping in the libraries folder,
since the script will get stuck on symlink loops.

Add config flags as dictionary values.
2020-12-28 16:32:09 -05:00
Stefano Bonicatti
c02402c883
Avoid running queries for views when fuzzing (#6859)
This gives a 10x execution speed boost to the config fuzzer.
2020-12-28 16:31:24 -05:00
Stefano Bonicatti
1dd51f288d
Remove the last usage of sqlite3 from sleuthkit (#6858)
To completely remove sqlite3 as a dependency of sleuthkit,
case_db.cpp and auto_db.cpp should not be compiled,
because both depend on the header tsk_case_db.h,
which in turn include tsk_db_sqlite.h
which then depends on the sqlite3.h header.
2020-12-28 16:29:53 -05:00
Stefano Bonicatti
858915e195
CMake: Further fix amalgamation file gen on change (#6854)
The previous PR (osquery/osquery#6832) was not enough to cover all type of changes
to the inputs of the generation of the amalgamation file.
The previous PR was only fixing the case where a spec file would change
(it's mtime would be newer than the output, to be specific),
but not if the dependency list itself would change.
So if a new spec file was added or one was removed, it would not rerun.

Moreover, with build systems that are not Ninja,
any generated artifact that due to a config change is not generated anymore,
will remain in the build folder, affecting the amalgamation file
generation.
Specifically if a table is disabled and its .cpp is not generated
anymore, but previously it was generated, the amalgamate script
will still pick it up because it doesn't receive a list of files
to use, but uses the content of a folder.

Finally, better express the dependency of the amalgamation file,
so that it depends on the output of the targets/commands that
generate the table source code, not the spec files
(which are already input/dependency of the custom commands generating
the tables source code) and not the tables source code generating target names
(which would only express the need to run those targets before the
amalgamation file generation, not the need to rerun the generation).
2020-12-28 16:28:52 -05:00
Stefano Bonicatti
c70331130b
CMake: Detect missing headers during include namespace generation (#6855)
When a header specified to be added in a generated include namespace
does not exists because its path is wrong or it shoudn't be added,
issue a fatal error, so that it gets noticed and fixed.

Remove windows/userassist.h as a header to be added in an include
namespace, since it doesn't exists.
2020-12-27 19:42:49 -05:00
Stefano Bonicatti
7455824c43
CMake: Do not attempt to dllimport Thrift symbols (#6856)
The THRIFT_STATIC_DEFINE define should be publicly used,
because it's used in a header that will be included by osquery.
2020-12-27 19:39:33 -05:00
Stefano Bonicatti
14ee87479c
CI: Move cppcheck step after the tests (#6845)
Since cppcheck is a non-blocking check,
prefer running the tests first to have a quicker result
if something is wrong.
2020-12-27 11:22:47 -05:00
Mike Myers
1a91db92d6
Docs: fix all broken or redirected URLs and references (#6835) 2020-12-27 11:22:16 -05:00
Stefano Bonicatti
948a570c51
CMake: Fix platformtablecontaineripc include namespace generation (#6853)
The public header is only present on non Linux platforms.
2020-12-27 11:20:42 -05:00
Stefano Bonicatti
d8c3938d1c
Improve fuzzing speed and stack trace accuracy (#6851)
Add a special define when osquery is built for fuzzing.

With that is possible to enable code that ignores
changing log levels.
With the config fuzzer, even if the fuzzer code was settings
the minloglevel to 4, that was immediately changed by the osquery logic.

Do not run queries parsed from the config to improve
the config fuzzer performance and avoid oom issues.

When built for fuzzing, compile osquery and libraries
without optimizing the frame pointer away.
This in some cases improves the accuracy of the stack trace
presented when a bug is found.
2020-12-26 16:10:34 -05:00
Stefano Bonicatti
2f8e7d9725
Fix leaks when a query fails from the shell (#6849) 2020-12-26 16:09:53 -05:00