Skip to content

Commit 16767da

Browse files
committed
fix(tests): update e2e-kernel-test to work with detectors
- Update test validation to search for detector event names instead of signatureID field (which doesn't exist in detector output) - Add detector ID to event name mapping for all tested detectors
1 parent 19433c5 commit 16767da

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/e2e-kernel-test.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ outputfile="${SCRIPT_TMP_DIR}/tracee-output-$$"
7676
tracee_command="./dist/tracee \
7777
--runtime workdir=$TRACEE_TMP_DIR \
7878
--output json:$outputfile \
79+
--output option:exec-env \
7980
--logging file=$logfile \
8081
--policy ./tests/policies/kernel/kernel.yaml 2>&1 \
8182
| tee $SCRIPT_TMP_DIR/build-$$"
@@ -151,9 +152,32 @@ kill -SIGKILL "${tracee_pids[@]}" >/dev/null 2>&1
151152

152153
info "= CHECKING TESTS RESULTS ======================================"
153154
info
155+
156+
# Map detector IDs to event names (detectors produce events with "name" field, not "signatureID")
157+
# This is needed because detectors emit events with custom names (not just their detector ID)
158+
# Only detectors that produce events with different names than their ID need to be listed here
159+
declare -A detector_to_event=(
160+
["TRC-102"]="anti_debugging"
161+
["TRC-103"]="ptrace_code_injection"
162+
["TRC-104"]="dynamic_code_loading"
163+
["TRC-105"]="fileless_execution"
164+
["TRC-107"]="ld_preload"
165+
["TRC-1010"]="cgroup_release_agent"
166+
["TRC-1014"]="disk_mount"
167+
["TRC-1016"]="illegitimate_shell"
168+
["TRC-1018"]="k8s_cert_theft"
169+
["TRC-1022"]="dropped_executable"
170+
)
171+
154172
for TEST in $TESTS; do
155173
found=0
156-
cat $outputfile | grep "\"signatureID\":\"$TEST\"" -B2 && found=1
174+
EVENT_NAME="${detector_to_event[$TEST]}"
175+
if [[ -n "$EVENT_NAME" ]]; then
176+
cat $outputfile | grep "\"name\":\"$EVENT_NAME\"" -B2 && found=1
177+
else
178+
info "$TEST: detector ID not mapped to event name; will be reported as failed if not found."
179+
cat $outputfile | grep "\"signatureID\":\"$TEST\"" -B2 && found=1
180+
fi
157181
info
158182
if [[ $found -eq 1 ]]; then
159183
info "$TEST: SUCCESS"

0 commit comments

Comments
 (0)