Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add support for GitHub Actions #6885

Merged
merged 2 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
954 changes: 954 additions & 0 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Available for Linux, macOS, Windows, and FreeBSD.
- Table Schema: https://osquery.io/schema
- Query Packs: [https://osquery.io/packs](https://github.com/osquery/osquery/tree/master/packs)
- Slack: [Request an auto-invite!](https://join.slack.com/t/osquery/shared_invite/zt-h29zm0gk-s2DBtGUTW4CFel0f0IjTEw)
- Build Status: [![Build Status](https://dev.azure.com/trailofbits/osquery/_apis/build/status/osquery?branchName=master)](https://dev.azure.com/trailofbits/osquery/_build/latest?definitionId=6&branchName=master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/13317/badge.svg)](https://scan.coverity.com/projects/osquery) [![Documentation Status](https://readthedocs.org/projects/osquery/badge/?version=latest)](https://osquery.readthedocs.io/en/latest/?badge=latest)
- Build Status: [![GitHub Actions Build Status](https://github.com/osquery/osquery/workflows/build/badge.svg) ![Azure Build Status](https://dev.azure.com/trailofbits/osquery/_apis/build/status/osquery?branchName=master)](https://dev.azure.com/trailofbits/osquery/_build/latest?definitionId=6&branchName=master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/13317/badge.svg)](https://scan.coverity.com/projects/osquery) [![Documentation Status](https://readthedocs.org/projects/osquery/badge/?version=latest)](https://osquery.readthedocs.io/en/latest/?badge=latest)
- CII Best Practices: [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3125/badge)](https://bestpractices.coreinfrastructure.org/projects/3125)


Expand Down
8 changes: 8 additions & 0 deletions osquery/empty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2014-present, The osquery authors
*
* 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)
*/
9 changes: 7 additions & 2 deletions osquery/filesystem/tests/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,13 @@ TEST_F(FilesystemTests, test_safe_permissions) {
// compiling on linux
#ifdef __linux__
TEST_F(FilesystemTests, test_user_namespace_parser) {
auto temp_path = fs::unique_path().native();
EXPECT_EQ(fs::create_directory(temp_path), true);
auto unique_path = fs::temp_directory_path() /
fs::unique_path("osquery.tests.user_ns_parser.%%%%.%%%%");

auto temp_path = unique_path.native();

boost::system::error_code error_code;
EXPECT_EQ(fs::create_directory(temp_path, error_code), true);

auto symlink_path = temp_path + "/namespace";
EXPECT_EQ(symlink("namespace:[112233]", symlink_path.data()), 0);
Expand Down
8 changes: 6 additions & 2 deletions osquery/tables/system/darwin/ibridge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/**
* This source code is licensed in accordance with the terms specified in
* the LICENSE file found in the root directory of this source tree.
* Copyright (c) 2014-present, The osquery authors
*
* 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)
*/

#include <osquery/core/tables.h>
Expand Down
9 changes: 5 additions & 4 deletions osquery/utils/tests/rot13.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed in accordance with the terms specified in
* the LICENSE file found in the root directory of this source tree.
* 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)
*/

#include <gtest/gtest.h>
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/tables/ibridge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/**
* This source code is licensed in accordance with the terms specified in
* the LICENSE file found in the root directory of this source tree.
* Copyright (c) 2014-present, The osquery authors
*
* 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)
*/

// Sanity check integration test for ibridge
Expand Down
76 changes: 76 additions & 0 deletions tools/ci/scripts/check_copyright_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python3

#
# Copyright (c) 2014-present, The osquery authors
#
# 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)
#

import sys
import os
import pathlib

valid_extension_list = [".c", ".h", ".cpp", ".m", ".mm"]

ignored_folder_list = ["libraries", "osquery/extensions/thrift/gen"]

ignored_file_list = [
"osquery/tables/system/efi_misc.h",
"osquery/tables/system/windows/kva_speculative_info.cpp",
"osquery/devtools/shell.cpp",
"plugins/logger/generated_wel.h"
]

copyright_header="/**\n * Copyright (c) 2014-present, The osquery authors\n *\n * This source code is licensed as defined by the LICENSE file found in the\n * root directory of this source tree.\n *\n * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)\n */\n"

def main():
if not os.path.isfile(".clang-format") or not os.path.isfile("LICENSE"):
print("This script needs to be run from the osquery repository root")
return 1

invalid_file_list = []

for current_path, folder_name_list, file_name_list in os.walk(os.getcwd()):
current_rel_path = str(pathlib.Path(current_path).relative_to(os.getcwd()))

skip_folder = False
for ignored_folder in ignored_folder_list:
if current_rel_path.find(ignored_folder) == 0:
skip_folder = True
break

if skip_folder:
continue

for file_name in file_name_list:
file_path = current_path + "/" + file_name

file_extension = pathlib.Path(file_path).suffix
if not file_extension in valid_extension_list:
continue

with open(file_path, "r") as source_file:
source_file_contents = source_file.read()

if source_file_contents.find(copyright_header) != -1:
continue

rel_file_path = str(pathlib.Path(file_path).relative_to(os.getcwd()))
if rel_file_path not in ignored_file_list:
invalid_file_list.append(file_path)

if len(invalid_file_list) != 0:
print("The following source files do not contain the required copyright header:")

for invalid_file in invalid_file_list:
print("\t{0}".format(invalid_file))

return 1

return 0

if __name__ == "__main__":
sys.exit(main())