Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterTea committed May 5, 2022
2 parents 04670c2 + 6b1c575 commit 7f26f20
Show file tree
Hide file tree
Showing 37 changed files with 1,451 additions and 150 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- checkout
- run:
name: Set up ssh & known_hosts
command: sudo /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; sudo rm ~/.ssh/authorized_keys; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
command: sudo /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; sudo rm -f ~/.ssh/authorized_keys; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- checkout
- run:
name: Set up ssh & known_hosts
command: sudo /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; sudo rm ~/.ssh/authorized_keys; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
command: sudo /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; sudo rm -f ~/.ssh/authorized_keys; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
Expand Down
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BasedOnStyle: Google
---
45 changes: 45 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/cpp/.devcontainer/base.Dockerfile

# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}

ARG USERNAME=vscode

# [Optional] Install CMake version different from what base image has already installed.
# CMake reinstall choices: none, 3.21.5, 3.22.2, or versions from https://cmake.org/download/
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.23.1"

# Use installed binaries from the system.
# Do not download latest version of CMake and Ninja during vcpkg bootstrap!
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
ENV VCPKG_USE_SYSTEM_BINARIES=1

# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# Install dependencies.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
libboost-dev \
libsodium-dev \
libncurses5-dev \
libprotobuf-dev \
protobuf-compiler \
libgflags-dev \
libutempter-dev \
build-essential \
ninja-build \
# Note that in Ubuntu 21.04, there is no libcurl-dev, use libcurl4-openssl-dev
libcurl4-openssl-dev

#
# Set up command history volume
# See https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
#
RUN mkdir /commandhistory \
&& chown -R $USERNAME /commandhistory
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/cpp
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
// Use Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
"args": { "VARIANT": "ubuntu-21.04" }
},
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "git submodule update --init --recursive",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

// For sharing shell history out of the container.
"mounts": [
"source=eternalterminal-history,target=/commandhistory,type=volume"
]
}
58 changes: 58 additions & 0 deletions .devcontainer/reinstall-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
set -e

CMAKE_VERSION=${1:-"none"}

if [ "${CMAKE_VERSION}" = "none" ]; then
echo "No CMake version specified, skipping CMake reinstallation"
exit 0
fi

# Cleanup temporary directory and associated files when exiting the script.
cleanup() {
EXIT_CODE=$?
set +e
if [[ -n "${TMP_DIR}" ]]; then
echo "Executing cleanup of tmp files"
rm -Rf "${TMP_DIR}"
fi
exit $EXIT_CODE
}
trap cleanup EXIT


echo "Installing CMake..."
apt-get -y purge --auto-remove cmake
mkdir -p /opt/cmake

architecture=$(dpkg --print-architecture)
case "${architecture}" in
arm64)
ARCH=aarch64 ;;
amd64)
ARCH=x86_64 ;;
*)
echo "Unsupported architecture ${architecture}."
exit 1
;;
esac

CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)

echo "${TMP_DIR}"
cd "${TMP_DIR}"

curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O

sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license

ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
24 changes: 23 additions & 1 deletion .github/workflows/vcpkg_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
extension: .exe
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
Expand All @@ -21,7 +24,26 @@ jobs:

steps:
- name: Install Dependencies (Linux)
run: sudo apt-get update && sudo apt-get install curl zip unzip tar cmake ninja-build libutempter-dev libunwind-dev libcurl4-openssl-dev
run: |
sudo apt-get update && \
sudo apt-get install --no-install-recommends \
libboost-dev \
libsodium-dev \
libncurses5-dev \
libprotobuf-dev \
protobuf-compiler \
libgflags-dev \
libutempter-dev \
build-essential \
ninja-build \
libcurl4-openssl-dev \
curl \
zip \
unzip \
tar \
cmake \
libutempter-dev \
libunwind-dev
if: matrix.os == 'ubuntu-latest'
- name: Install Dependencies (Windows)
run: choco install ninja
Expand Down
71 changes: 70 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_TELEMETRY")
endif()

if(USE_SENTRY)
if(DISABLE_VCPKG)
set(SENTRY_BUILD_RUNTIMESTATIC ON)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory("${EXTERNAL_DIR}/sentry-native")
include_directories(
${EXTERNAL_DIR}/sentry-native/include
)
else()
find_package(sentry CONFIG REQUIRED)
endif()
endif()

set(CMAKE_MODULE_PATH "${EXTERNAL_DIR}/cotire/CMake"
Expand All @@ -157,6 +164,7 @@ if(POLICY CMP0058)
endif()

option(CODE_COVERAGE "Enable code coverage" OFF)
option(FUZZING "Enable builds for fuzz testing" OFF)
option(DISABLE_CRASH_LOG "Disable installing easylogging crash handler" OFF)

add_definitions(-DET_VERSION="${PROJECT_VERSION}")
Expand Down Expand Up @@ -288,14 +296,33 @@ macro(DECORATE_TARGET TARGET_NAME)
endif()
endmacro()

macro(DECORATE_FUZZER TARGET_NAME)
add_sanitizers(${TARGET_NAME})

if(FUZZING)
# ASAN must also be enabled to build fuzzers.
if(NOT SANITIZE_ADDRESS)
message(FATAL_ERROR "Fuzzing requires SANITIZE_ADDRESS=ON to detect memory errors.")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_property(TARGET ${TARGET_NAME} APPEND_STRING
PROPERTY COMPILE_FLAGS " -fsanitize=fuzzer")
set_property(TARGET ${TARGET_NAME} APPEND_STRING
PROPERTY LINK_FLAGS " -fsanitize=fuzzer")
else()
message(FATAL_ERROR "Currently fuzzing is only supported with Clang.")
endif()
endif()
endmacro()

include_directories(
${EXTERNAL_DIR}/easyloggingpp/src
${EXTERNAL_DIR}/ThreadPool
${EXTERNAL_DIR}/PlatformFolders
${EXTERNAL_DIR}/Catch2/single_include
${EXTERNAL_DIR}/cxxopts/include
${EXTERNAL_DIR}/msgpack-c/include
${EXTERNAL_DIR}/sentry-native/include
${EXTERNAL_DIR}/json/single_include/nlohmann
${EXTERNAL_DIR}/sole
${EXTERNAL_DIR}/base64
Expand Down Expand Up @@ -378,6 +405,8 @@ add_library(
src/terminal/UserTerminalRouter.cpp
src/terminal/TerminalClient.hpp
src/terminal/TerminalClient.cpp
src/terminal/ServerFifoPath.hpp
src/terminal/ServerFifoPath.cpp
src/terminal/SshSetupHandler.hpp
src/terminal/SshSetupHandler.cpp
src/terminal/UserTerminalHandler.hpp
Expand Down Expand Up @@ -513,6 +542,46 @@ else(WIN32)
add_test(et-test et-test)
decorate_target(et-test)

if(FUZZING)
add_executable(
TerminalServerFuzzer
test/TerminalServerFuzzer.cpp
test/FuzzableTerminalServer.hpp
)
add_dependencies(TerminalServerFuzzer TerminalCommon et-lib)
target_link_libraries(
TerminalServerFuzzer
TerminalCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBS}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${Boost_LIBRARIES}
${CORE_LIBRARIES})
decorate_fuzzer(TerminalServerFuzzer)

add_executable(
TerminalServerRouterFuzzer
test/TerminalServerRouterFuzzer.cpp
test/FuzzableTerminalServer.hpp
)
add_dependencies(TerminalServerRouterFuzzer TerminalCommon et-lib)
target_link_libraries(
TerminalServerRouterFuzzer
TerminalCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBS}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${Boost_LIBRARIES}
${CORE_LIBRARIES})
decorate_fuzzer(TerminalServerRouterFuzzer)
endif(FUZZING)

install(
TARGETS etserver etterminal et htm htmd
PERMISSIONS
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindUnwind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
set (Unwind_ARCH "unwind-x86_64" "unwind-x86")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
set (Unwind_ARCH "unwind-x86" "unwind-x86_64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc64|ppc64)")
set (Unwind_ARCH "unwind-ppc64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set (Unwind_ARCH "unwind-ppc32")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
set (Unwind_ARCH "unwind-mips")
Expand Down
1 change: 1 addition & 0 deletions etc/et.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ port = 2022
verbose = 0
silent = 0
logsize = 20971520
telemetry = 1
2 changes: 1 addition & 1 deletion external/sentry-native
Submodule sentry-native updated 79 files
+6 −2 .github/workflows/ci.yml
+1 −0 .gitignore
+70 −2 CHANGELOG.md
+14 −7 CMakeLists.txt
+1 −0 CONTRIBUTING.md
+8 −5 Makefile
+7 −3 README.md
+43 −0 examples/example.c
+2 −2 external/CMakeLists.txt
+1 −1 external/breakpad
+1 −1 external/crashpad
+526 −13 include/sentry.h
+2 −0 src/CMakeLists.txt
+18 −0 src/backends/sentry_backend_crashpad.cpp
+2 −0 src/backends/sentry_backend_inproc.c
+103 −17 src/modulefinder/sentry_modulefinder_linux.c
+6 −0 src/modulefinder/sentry_modulefinder_linux.h
+1 −0 src/sentry_backend.h
+416 −24 src/sentry_core.c
+37 −4 src/sentry_core.h
+34 −1 src/sentry_database.c
+10 −0 src/sentry_database.h
+62 −1 src/sentry_envelope.c
+6 −0 src/sentry_envelope.h
+44 −0 src/sentry_json.c
+5 −1 src/sentry_options.c
+67 −14 src/sentry_os.c
+8 −0 src/sentry_ratelimiter.c
+6 −0 src/sentry_ratelimiter.h
+74 −7 src/sentry_scope.c
+16 −0 src/sentry_scope.h
+10 −6 src/sentry_session.c
+0 −61 src/sentry_string.c
+56 −18 src/sentry_string.h
+72 −0 src/sentry_sync.c
+6 −0 src/sentry_sync.h
+520 −0 src/sentry_tracing.c
+51 −0 src/sentry_tracing.h
+19 −0 src/sentry_transport.c
+7 −0 src/sentry_transport.h
+8 −10 src/sentry_utils.c
+1 −1 src/sentry_utils.h
+1 −2 src/sentry_uuid.h
+35 −0 src/sentry_value.c
+19 −0 src/sentry_value.h
+13 −0 src/transports/sentry_transport_curl.c
+18 −0 src/transports/sentry_transport_winhttp.c
+48 −2 tests/__init__.py
+36 −19 tests/assertions.py
+1 −1 tests/requirements.txt
+60 −1 tests/test_integration_http.py
+12 −0 tests/test_integration_ratelimits.py
+22 −0 tests/test_integration_stdout.py
+2 −0 tests/unit/CMakeLists.txt
+0 −2 tests/unit/fuzz.c
+0 −1 tests/unit/test_attachments.c
+69 −1 tests/unit/test_basic.c
+28 −1 tests/unit/test_concurrency.c
+0 −1 tests/unit/test_consent.c
+32 −1 tests/unit/test_envelopes.c
+0 −1 tests/unit/test_failures.c
+1 −1 tests/unit/test_fuzzfailures.c
+0 −1 tests/unit/test_logger.c
+0 −1 tests/unit/test_modulefinder.c
+0 −1 tests/unit/test_mpack.c
+0 −1 tests/unit/test_path.c
+0 −1 tests/unit/test_ratelimiter.c
+37 −0 tests/unit/test_sampling.c
+0 −1 tests/unit/test_session.c
+0 −1 tests/unit/test_slice.c
+0 −1 tests/unit/test_symbolizer.c
+20 −0 tests/unit/test_sync.c
+811 −0 tests/unit/test_tracing.c
+0 −2 tests/unit/test_uninit.c
+0 −1 tests/unit/test_unwinder.c
+16 −15 tests/unit/test_utils.c
+2 −2 tests/unit/test_uuid.c
+56 −1 tests/unit/test_value.c
+23 −0 tests/unit/tests.inc
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 2942 files
Loading

0 comments on commit 7f26f20

Please sign in to comment.