First release of open-appsec source code

This commit is contained in:
roybarda
2022-10-26 19:33:19 +03:00
parent 3883109caf
commit a883352f79
1353 changed files with 276290 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
install(FILES Dockerfile entry.sh DESTINATION .)
add_custom_command(
OUTPUT ${CMAKE_INSTALL_PREFIX}/agent-docker.img
COMMAND docker build -t agent-docker ${CMAKE_INSTALL_PREFIX}
COMMAND docker image save agent-docker -o ${CMAKE_INSTALL_PREFIX}/agent-docker.img
)
add_custom_target(docker DEPENDS ${CMAKE_INSTALL_PREFIX}/agent-docker.img)

View File

@@ -0,0 +1,23 @@
FROM alpine
RUN apk add --no-cache -u busybox
RUN apk add --no-cache -u zlib
RUN apk add --no-cache bash
RUN apk add --no-cache libstdc++
RUN apk add --no-cache libexecinfo
RUN apk add --no-cache boost
RUN apk add --no-cache icu-libs
RUN apk add --no-cache curl
RUN apk add --no-cache libunwind
RUN apk add --no-cache gdb
RUN apk add --no-cache libxml2
RUN apk add --no-cache pcre2
RUN apk add --update coreutils
COPY install*.sh /nano-service-installers/
COPY entry.sh /entry.sh
RUN chmod +x entry.sh /nano-service-installers/*
RUN ln -s entry.sh cp-nano-agent
CMD [ "/cp-nano-agent" ]

View File

@@ -0,0 +1,81 @@
#!/bin/bash
HTTP_TRANSACTION_HANDLER_SERVICE="install-cp-nano-service-http-transaction-handler.sh"
ATTACHMENT_REGISTRATION_SERVICE="install-cp-nano-attachment-registration-manager.sh"
ORCHESTRATION_INSTALLATION_SCRIPT="install-cp-nano-agent.sh"
var_fog_address=
var_proxy=
var_mode=
var_token=
init=
if [ ! -f /nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT ]; then
echo "Error: agent installation package doesn't exist."
exit 1
fi
while true; do
if [ -z "$1" ]; then
break
elif [ "$1" == "--fog" ]; then
shift
var_fog_address="$1"
elif [ "$1" == "--proxy" ]; then
shift
var_proxy="$1"
elif [ "$1" == "--hybrid-mode" ]; then
var_mode="--hybrid_mode"
elif [ "$1" == "--token" ]; then
shift
var_token="$1"
fi
shift
done
if [ -z $var_token ]; then
echo "Error: Token was not provided as input argument."
exit 1
fi
orchestration_service_installation_flags="--token $var_token --container_mode --skip_registration"
if [ ! -z $var_fog_address ]; then
orchestration_service_installation_flags="$orchestration_service_installation_flags --fog $var_fog_address"
fi
if [ ! -z $var_proxy ]; then
orchestration_service_installation_flags="$orchestration_service_installation_flags --proxy $var_proxy"
fi
if [ ! -z $var_mode ]; then
orchestration_service_installation_flags="$orchestration_service_installation_flags $var_mode"
fi
/nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT --install $orchestration_service_installation_flags
/nano-service-installers/$ATTACHMENT_REGISTRATION_SERVICE --install
/nano-service-installers/$HTTP_TRANSACTION_HANDLER_SERVICE --install
touch /etc/cp/watchdog/wd.startup
while true; do
if [ -z "$init" ]; then
init=true
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
sleep 5
active_watchdog_pid=$(pgrep -f -x -o "/bin/bash /etc/cp/watchdog/cp-nano-watchdog")
fi
current_watchdog_pid=$(pgrep -f -x -o "/bin/bash /etc/cp/watchdog/cp-nano-watchdog")
if [ ! -f /tmp/restart_watchdog ] && [ "$current_watchdog_pid" != "$active_watchdog_pid" ]; then
echo "Error: Watchdog exited abnormally"
exit 1
elif [ -f /tmp/restart_watchdog ]; then
rm -f /tmp/restart_watchdog
kill -9 "$(pgrep -f -x -o "/bin/bash /etc/cp/watchdog/cp-nano-watchdog")"
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
sleep 5
active_watchdog_pid=$(pgrep -f -x -o "/bin/bash /etc/cp/watchdog/cp-nano-watchdog")
fi
sleep 5
done