Skip to content

Commit f2ee9f5

Browse files
authored
Merge pull request #1099 from IABTechLab/ian-UID2-4235-enclave-debug-without-debugger-exposed
enclave debug without debugger exposed
2 parents 5c91f18 + c241870 commit f2ee9f5

4 files changed

Lines changed: 43 additions & 10 deletions

File tree

Makefile.eif

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ build/make_config.py: ./scripts/aws/make_config.py
3737

3838
.PHONY: build_configs
3939

40-
build_configs: build/conf/default-config.json build/conf/prod-uid2-config.json build/conf/integ-uid2-config.json build/conf/prod-euid-config.json build/conf/integ-euid-config.json build/conf/logback.xml
40+
build_configs: build/conf/default-config.json build/conf/prod-uid2-config.json build/conf/integ-uid2-config.json build/conf/prod-euid-config.json build/conf/integ-euid-config.json build/conf/logback.xml build/conf/logback-debug.xml
4141

4242
build/conf/default-config.json: build_artifacts ./scripts/aws/conf/default-config.json
4343
cp ./scripts/aws/conf/default-config.json ./build/conf/
@@ -57,6 +57,9 @@ build/conf/integ-euid-config.json: build_artifacts ./scripts/aws/conf/integ-euid
5757
build/conf/logback.xml: build_artifacts ./scripts/aws/conf/logback.xml
5858
cp ./scripts/aws/conf/logback.xml ./build/conf/
5959

60+
build/conf/logback-debug.xml: build_artifacts ./scripts/aws/conf/logback-debug.xml
61+
cp ./scripts/aws/conf/logback-debug.xml ./build/conf/
62+
6063
build/Dockerfile: build_artifacts ./scripts/aws/Dockerfile
6164
cp ./scripts/aws/Dockerfile ./build/
6265

scripts/aws/conf/logback-debug.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<configuration>
2+
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
3+
4+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5+
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
6+
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
7+
<defaultMask>REDACTED - S3</defaultMask>
8+
<value>\S+s3\.amazonaws\.com\/\S*X-Amz-Security-Token=\S+</value>
9+
</jsonGeneratorDecorator>
10+
</encoder>
11+
</appender>
12+
<root level="INFO">
13+
<appender-ref ref="STDOUT" />
14+
</root>
15+
</configuration>

scripts/aws/eks-pod/entrypoint.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CID=42
33
EIF_PATH=/home/uid2operator.eif
44
MEMORY_MB=24576
55
CPU_COUNT=6
6+
DEBUG_MODE="false"
67

78
set -x
89

@@ -87,12 +88,20 @@ function update_config() {
8788
{ set +x; } 2>/dev/null; { CPU_COUNT=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.enclave_cpu_count'); set -x; }
8889
{ set +x; } 2>/dev/null; { MEMORY_MB=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.enclave_memory_mb'); set -x; }
8990
fi
91+
92+
{ set +x; } 2>/dev/null; { DEBUG_MODE=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.debug_mode'); set -x; }
93+
9094
shopt -u nocasematch
9195
}
9296

9397
function run_enclave() {
94-
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID"
95-
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator
98+
if [ "$DEBUG_MODE" == "true" ]; then
99+
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --debug-mode --attach-console"
100+
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator --debug-mode --attach-console
101+
else
102+
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID"
103+
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator
104+
fi
96105
}
97106

98107
echo "starting ..."

scripts/aws/entrypoint.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
LOG_FILE="/home/start.txt"
66

77
set -x
8-
exec > $LOG_FILE
9-
exec 2>&1
8+
exec &> >(tee -a "$LOG_FILE")
109

1110
set -o pipefail
1211
ulimit -n 65536
@@ -19,10 +18,6 @@ ifconfig lo 127.0.0.1
1918
echo "Starting vsock proxy..."
2019
/app/vsockpx --config /app/proxies.nitro.yaml --daemon --workers $(( $(nproc) * 2 )) --log-level 3
2120

22-
# -- setup syslog-ng
23-
echo "Starting syslog-ng..."
24-
/usr/sbin/syslog-ng --verbose
25-
2621
# -- load config from identity service
2722
echo "Loading config from identity service via proxy..."
2823

@@ -42,6 +37,17 @@ do
4237
sleep 2
4338
done
4439

40+
DEBUG_MODE=$(jq -r ".debug_mode" < "${OVERRIDES_CONFIG}")
41+
42+
if [[ "$DEBUG_MODE" == "true" ]]; then
43+
LOGBACK_CONF="./conf/logback-debug.xml"
44+
else
45+
LOGBACK_CONF="./conf/logback.xml"
46+
# -- setup syslog-ng
47+
echo "Starting syslog-ng..."
48+
/usr/sbin/syslog-ng --verbose
49+
fi
50+
4551
# check the config is valid. Querying for a known missing element (empty) makes jq parse the file, but does not echo the results
4652
if jq empty "${OVERRIDES_CONFIG}"; then
4753
echo "Identity service returned valid config"
@@ -101,6 +107,6 @@ java \
101107
-Djava.library.path=/app/lib \
102108
-Dvertx-config-path="${FINAL_CONFIG}" \
103109
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \
104-
-Dlogback.configurationFile=./conf/logback.xml \
110+
-Dlogback.configurationFile=${LOGBACK_CONF} \
105111
-Dhttp_proxy=socks5://127.0.0.1:3305 \
106112
-jar /app/"${JAR_NAME}"-"${JAR_VERSION}".jar

0 commit comments

Comments
 (0)