2018-08-27 16:21:26 +00:00
|
|
|
/**
|
2020-08-11 20:46:54 +00:00
|
|
|
* Copyright (c) 2014-present, The osquery authors
|
2018-08-27 16:21:26 +00:00
|
|
|
*
|
2020-08-11 20:46:54 +00:00
|
|
|
* This source code is licensed as defined by the LICENSE file found in the
|
|
|
|
* root directory of this source tree.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
|
2018-08-27 16:21:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Sanity check integration test for process_open_sockets
|
|
|
|
// Spec file: specs/process_open_sockets.table
|
|
|
|
|
|
|
|
#include <osquery/tests/integration/tables/helper.h>
|
2019-12-13 01:45:15 +00:00
|
|
|
#include <osquery/utils/info/platform_type.h>
|
2018-08-27 16:21:26 +00:00
|
|
|
|
|
|
|
namespace osquery {
|
2018-09-21 18:54:31 +00:00
|
|
|
namespace table_tests {
|
2018-08-27 16:21:26 +00:00
|
|
|
|
2018-09-21 18:54:31 +00:00
|
|
|
class processOpenSockets : public testing::Test {
|
|
|
|
protected:
|
|
|
|
void SetUp() override {
|
|
|
|
setUpEnvironment();
|
|
|
|
}
|
|
|
|
};
|
2018-08-27 16:21:26 +00:00
|
|
|
|
|
|
|
TEST_F(processOpenSockets, test_sanity) {
|
2019-12-13 01:45:15 +00:00
|
|
|
ValidationMap row_map = {
|
|
|
|
{"pid", IntType},
|
|
|
|
{"fd", IntOrEmpty},
|
|
|
|
{"socket", IntOrEmpty},
|
|
|
|
{"family", IntType},
|
|
|
|
{"protocol", IntType},
|
|
|
|
{"local_address", NormalType},
|
|
|
|
{"remote_address", NormalType},
|
|
|
|
{"local_port", IntType},
|
|
|
|
{"remote_port", IntType},
|
|
|
|
{"path", NormalType},
|
|
|
|
{"state", NormalType},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isPlatform(PlatformType::TYPE_LINUX)) {
|
|
|
|
row_map["net_namespace"] = IntType;
|
|
|
|
}
|
|
|
|
|
2018-09-21 18:54:31 +00:00
|
|
|
auto const data = execute_query("select * from process_open_sockets");
|
2019-12-13 01:45:15 +00:00
|
|
|
ASSERT_FALSE(data.empty());
|
|
|
|
validate_rows(data, row_map);
|
2018-08-27 16:21:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 18:54:31 +00:00
|
|
|
} // namespace table_tests
|
2018-08-27 16:21:26 +00:00
|
|
|
} // namespace osquery
|