2024-03-25 18:01:56 +00:00
import ./make-test-python.nix (
{ pkgs , . . . }:
rec {
2022-10-02 11:43:54 +01:00
name = " t r a c e e - i n t e g r a t i o n " ;
2023-04-05 10:47:26 +01:00
meta . maintainers = pkgs . tracee . meta . maintainers ;
2024-03-25 18:01:56 +00:00
passthru . hello-world-builder =
pkgs :
pkgs . dockerTools . buildImage {
name = " h e l l o - w o r l d " ;
tag = " l a t e s t " ;
config . Cmd = [ " ${ pkgs . hello } / b i n / h e l l o " ] ;
} ;
2022-10-02 11:43:54 +01:00
nodes = {
machine =
{ config , pkgs , . . . }:
{
2023-02-01 15:27:41 +00:00
# EventFilters/trace_only_events_from_new_containers and
# Test_EventFilters/trace_only_events_from_"dockerd"_binary_and_contain_it's_pid
# require docker/dockerd
virtualisation . docker . enable = true ;
2025-05-27 17:47:28 +02:00
environment = {
variables . PATH = " / t m p / t e s t d i r " ;
systemPackages = with pkgs ; [
# 'ls', 'uname' and 'who' are required by many tests in event_filters_test.go
coreutils
# the go integration tests as a binary
tracee . passthru . tests . integration-test-cli
] ;
} ;
2024-12-10 20:26:33 +01:00
} ;
2022-10-02 11:43:54 +01:00
} ;
2024-03-25 18:01:56 +00:00
testScript =
let
skippedTests = [
# these comm tests for some reason do not resolve.
# something about the test is different as it works fine if I replicate
# the policies and run tracee myself but doesn't work in the integration
# test either with the automatic run or running the commands by hand
# while it's searching.
2025-05-27 17:47:28 +02:00
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ m a g i c _ w r i t e _ s e t _ i n _ m u l t i p l e _ p o l i c i e s _ u s i n g _ m u l t i p l e _ f i l t e r _ t y p e s "
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s e c u r i t y _ f i l e _ o p e n _ a n d _ m a g i c _ w r i t e _ u s i n g _ m u l t i p l e _ f i l t e r _ t y p e s "
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s e c u r i t y _ f i l e _ o p e n _ a n d _ m a g i c _ w r i t e _ u s i n g _ m u l t i p l e _ f i l t e r _ t y p e s _ c o m b i n e d "
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s e c u r i t y _ f i l e _ o p e n _ s e t _ i n _ m u l t i p l e _ p o l i c i e s _ \\ ( w i t h _ a n d _ w i t h o u t _ i n - k e r n e l _ f i l t e r \\ ) "
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s e c u r i t y _ f i l e _ o p e n _ s e t _ i n _ m u l t i p l e _ p o l i c i e s _ u s i n g _ m u l t i p l e _ f i l t e r _ t y p e s "
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s e t _ i n _ a _ s p e c i f i c _ p o l i c y _ w i t h _ d a t a _ f r o m _ l s _ c o m m a n d "
2024-03-25 18:01:56 +00:00
" T e s t _ E v e n t F i l t e r s / c o m m : _ e v e n t : _ t r a c e _ e v e n t s _ s e t _ i n _ t w o _ s p e c i f i c _ p o l i c i e s _ f r o m _ l s _ a n d _ u n a m e _ c o m m a n d s "
2025-05-27 17:47:28 +02:00
" T e s t _ E v e n t F i l t e r s / p i d : _ e v e n t : _ d a t a : _ t r a c e _ e v e n t _ s c h e d _ s w i t c h _ w i t h _ d a t a _ f r o m _ p i d _ 0 "
" T e s t _ E v e n t s D e p e n d e n c i e s / n o n _ e x i s t i n g _ k s y m b o l _ d e p e n d e n c y _ w i t h _ s a n i t y "
" T e s t _ E v e n t s D e p e n d e n c i e s / n o n _ e x i s t i n g _ p r o b e _ f u n c t i o n _ w i t h _ s a n i t y "
" T e s t _ E v e n t s D e p e n d e n c i e s / s a n i t y _ o f _ e x e c _ t e s t _ e v e n t "
" T e s t _ T r a c e e C a p t u r e / c a p t u r e _ p a c k e t _ c o n t e x t "
2024-03-25 18:01:56 +00:00
] ;
in
''
with subtest ( " p r e p a r e f o r i n t e g r a t i o n t e s t s " ) :
machine . wait_for_unit ( " d o c k e r . s e r v i c e " )
machine . succeed ( ' which bash' )
# EventFilters/trace_only_events_from_new_containers also requires a container called "hello-world"
machine . succeed ( ' docker load < $ { passthru . hello-world-builder pkgs } ' )
2023-02-01 15:27:41 +00:00
2024-03-25 18:01:56 +00:00
# exec= needs fully resolved paths
machine . succeed (
' mkdir /tmp/testdir ' ,
' cp $ ( which who ) /tmp/testdir/who ' ,
' cp $ ( which uname ) /tmp/testdir/uname ' ,
)
2022-10-02 11:43:54 +01:00
2024-03-25 18:01:56 +00:00
with subtest ( " r u n i n t e g r a t i o n t e s t s " ) :
2025-05-27 17:47:28 +02:00
# Test_EventFilters/comm:_event:_data:_trace_event_set_in_a_specific_policy_with_data_from_ls_command expects to be in a dir that includes "integration"
2024-03-25 18:01:56 +00:00
# tests must be ran with 1 process
print ( machine . succeed (
' mkdir /tmp/integration ' ,
2025-05-27 17:47:28 +02:00
' cd /tmp/integration && integration . test - test . v - test . parallel 1 - test . skip = " ^ ${ builtins . concatStringsSep " $ | ^ " skippedTests } $ " '
2024-03-25 18:01:56 +00:00
) )
'' ;
2022-10-02 11:43:54 +01:00
}
)