From 0f29508c0a959de1a0cf41315bf7ea64a2aec30b Mon Sep 17 00:00:00 2001 From: Vitaly Chipounov Date: Sat, 7 Dec 2024 19:24:09 +0100 Subject: [PATCH] testsuite/cadet0: use hard-coded binary instead of building The build chain doesn't work anymore. Signed-off-by: Vitaly Chipounov --- testsuite/pov-cgc-cadet0/CADET_00001 | Bin 0 -> 3612 bytes testsuite/pov-cgc-cadet0/CADET_00001/Makefile | 7 - .../pov-cgc-cadet0/CADET_00001/README.md | 25 -- .../pov-cgc-cadet0/CADET_00001/cgc-cb.mk | 346 ------------------ .../pov-cgc-cadet0/CADET_00001/lib/libc.c | 61 --- .../pov-cgc-cadet0/CADET_00001/lib/libc.h | 5 - .../poller/for-testing/POLL_00000.xml | 14 - .../CADET_00001/poller/for-testing/machine.py | 41 --- .../poller/for-testing/state-graph.yaml | 17 - .../CADET_00001/pov/POV_00000.xml | 15 - .../pov-cgc-cadet0/CADET_00001/src/service.c | 73 ---- testsuite/pov-cgc-cadet0/Makefile | 10 +- testsuite/pov-cgc-cadet0/config.yml | 2 +- 13 files changed, 3 insertions(+), 613 deletions(-) create mode 100755 testsuite/pov-cgc-cadet0/CADET_00001 delete mode 100755 testsuite/pov-cgc-cadet0/CADET_00001/Makefile delete mode 100755 testsuite/pov-cgc-cadet0/CADET_00001/README.md delete mode 100644 testsuite/pov-cgc-cadet0/CADET_00001/cgc-cb.mk delete mode 100644 testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.c delete mode 100755 testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.h delete mode 100755 testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/POLL_00000.xml delete mode 100644 testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/machine.py delete mode 100644 testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/state-graph.yaml delete mode 100755 testsuite/pov-cgc-cadet0/CADET_00001/pov/POV_00000.xml delete mode 100644 testsuite/pov-cgc-cadet0/CADET_00001/src/service.c diff --git a/testsuite/pov-cgc-cadet0/CADET_00001 b/testsuite/pov-cgc-cadet0/CADET_00001 new file mode 100755 index 0000000000000000000000000000000000000000..469cb3880d9fa00fb1d7bd1f2de12cfefe634a0c GIT binary patch literal 3612 zcmb7HYiwM_6~4x6y4h~DPGzY^Kr^TtH4%7mjEQ&%iO3!YRBz+hUWWt-y}llMZ&>d& z_uft7iU?a93x*+TfA9!xD&+^2@*{$u<)KDFws3x6DQc;N)Tp&8N4hIk)goCUgopXg z?89DTOf#!_o-^M!=giERy)Sg_>uP9d=xRs`*Umb|Ek>i!U>L^NGof%N>U*}LKF`lCMoE zc`aXj>|KI9y>S*A+Cjz+_Hgj8auT2Q`A zO=wdkc`^7ImQtWj1=u0r9q6w^q#?-znOX||amyx%i@_zVKlqPUzdn8P`U+BPh72xz zfC3{Zjo3^-$_nRe#CaF`>o{ph@~blSY4FTuoSy`};4G{`{3{{e`F%thlKhHHeH?7v z4DoVs18&oPDHs3#c4bAoE)_okrnegwto+=c4a_~nfx5jHeRQpw+v$#XJwHrTtm z_9!WE?d3uO&=qzN#V&%evh%k?OY!9j_ww3h{GFBoJVPayW%4|g{EWQ(rb?dq;>+n9 zwA$FrPxbusO=PCz=PM+YX(g39FZrwT%9|?p>KETW_+jk#L|a_~5T^?Sb9WMJ>fL(b z!OO8zIP+L)5oOuSYghCaki;(X3y&OuwCa7X5O01Yg6i7M%jXyNzRX)xvRS2~Di@YH3K=q4e2ITnF?XIXlJbUD|4j=vu=*_sDpoIPt6#xD z`LZV$Rccw~N{zWC*%F7rI$n_z5xb(2e;T|^ZGN?CV%5*u#9u=;eex>Gb+&h4MB9!d z7HWuHOn!z_R*pIpMipOF$t7~jQX##8TY?Z)5d87R%1WQ!YrWP1^;A5(F!kiDKIa1m z`iC&kqI%=4YA}9>^5bk_>d4_kkki^WlZPtug8*m+z#RZ!0EnyS<2x6oo++bHj06gF znxWGIoz{gZjZe?PzyS!N5Hv4L5hvZC4Yi>XQgH1yc_<{!u(YG{xn?=pvis63AVUhz zgNmrbAvGLUN2AJZR=;bRxs+>oR7T^oM~yVSL+Sth2@evzBKf)KQDgO&pKCq)#EysI z!oEKrHJ+FqIsm#TOlbyg%dXG;rjA>C{`=LTBeRi%B4at@g82^XGc$H}#HC&j8p4f4 zj4gc`VS0jztS?+ zYlU|~8j0||1B1Mu@qPQKk2IJTtebcBa}FTuS#wNyEa!<4W@kYonB@x7x1B6=M$xxD zW~I$cMr6kX8@98iJIRgjTO1Ae?&p6-Kt`+GK^5Tor?_pGmPmV%!UR?au+YW6tpxaqUrdW$BUW9vEA z^lz4~Z~su8J>%w>ZEd#wKSEG{;;}VJ0*p`;XlKKdzR;J9pYR0&(+Jx;F_E#Y@|7BO zG8yN%mtfqq(##j;I3kAY+m<~61sown47#D?InQTl^O#^>Zg|}Gec+TMhciBr5!5xu zTp{SPVvd!`jnHfgHiHEEcougZjz!R+KqlZ|bJ)(<{v(E%Ha9kM;!Ups>h zq=i6K#2u!o{1}n+tu7ORtVW)QShdRpSdXF{ZV%h3eYndo5?6=EPTq2&64HQNHzeN8V>20S6>>R#-&Y^xsf83yfL~k>tZOEiY&p3VB?8oc&I@;Al zGRn7AYI<<>Hxu;ed#ReLO?tUVpZ+URx`zKrzbH3#S;eE8u&SvM-*`K#9n>VJ^c`fA B%sT)8 literal 0 HcmV?d00001 diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/Makefile b/testsuite/pov-cgc-cadet0/CADET_00001/Makefile deleted file mode 100755 index 8fcbd2059..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -AUTHOR_ID = CADET -SERVICE_ID = 00001 -CFLAGS = -O0 -g -Werror -Wno-overlength-strings -Wno-packed - -include cgc-cb.mk - - diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/README.md b/testsuite/pov-cgc-cadet0/CADET_00001/README.md deleted file mode 100755 index 7fea0e8e8..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Palindrome - -## Author Information - -CGC Summer Intern 2014 -Cadet from West Point Military Academy - -### DARPA performer group -CADET - -## Description: - -This is an unusually simple service written by a military cadet as his first ever C program. It is intended as a data point as an incredibly simple service, with an incredibly simple vulnerability, written by an inexperienced programmer. - -The underlying service itself is a palindrome detector. - -## Vulnerability - -CWE-121: Stack-based Buffer Overflow - -The palindrome vulnerability is a vanilla buffer overflow on the stack. The program allocates 64 bytes of stack space for network input and reads up to 128 bytes at a time. - -## Challenges - -The only intended challenge posed by this service is that it was written by an inexperienced C programmer and consequently it may look different than other test cases. diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/cgc-cb.mk b/testsuite/pov-cgc-cadet0/CADET_00001/cgc-cb.mk deleted file mode 100644 index a7386cba0..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/cgc-cb.mk +++ /dev/null @@ -1,346 +0,0 @@ -ifndef POLLS_RELEASE_COUNT -POLLS_RELEASE_COUNT=1000 -endif - -ifndef POLLS_RELEASE_SEED -POLLS_RELEASE_SEED=$(shell od -An -i -N 4 /dev/urandom) -endif - -ifndef POLLS_RELEASE_MAX_DEPTH -POLLS_RELEASE_MAX_DEPTH=1048575 -endif - -ifndef POLLS_TESTING_COUNT -POLLS_TESTING_COUNT=1000 -endif - -ifndef POLLS_TESTING_SEED -POLLS_TESTING_SEED=$(shell od -An -i -N 4 /dev/urandom) -endif - -ifndef POLLS_TESTING_MAX_DEPTH -POLLS_TESTING_MAX_DEPTH=1048575 -endif - -ifndef BIN_COUNT -BIN_COUNT=0 -endif - -ifndef POLL_REUSE_COUNT -POLL_REUSE_COUNT=0 -endif - -ifndef VULN_COUNT -VULN_COUNT=0 -endif - -LIBS = -L/usr/lib -lcgc -LDFLAGS = -nostdlib -static -POV_LIBS = -lpov - -CC = /usr/i386-linux-cgc/bin/clang -LD = /usr/i386-linux-cgc/bin/ld -CXX = /usr/i386-linux-cgc/bin/clang++ -OBJCOPY = /usr/i386-linux-cgc/bin/objcopy -LD_ELF = /usr/bin/ld - -SHELL := $(SHELL) -e -BIN_DIR = bin -POV_DIR = pov -BUILD_DIR = build -ifeq ("/usr/i386-linux-cgc/bin/clang", "$(CC)") -CGC_CFLAGS = -nostdlib -fno-builtin -nostdinc -Iinclude -Ilib -I/usr/include $(CFLAGS) -DCGC_BIN_COUNT=$(BIN_COUNT) -else -CGC_CFLAGS = -nostdlib -fno-builtin -nostdinc -nostartfiles -nodefaultlibs -Iinclude -Ilib -I/usr/include $(CFLAGS) -DCGC_BIN_COUNT=$(BIN_COUNT) -endif - -POV_CFLAGS = -nostdlib -fno-builtin -nostdinc -Iinclude -Ilib -I/usr/include $(CFLAGS) - -EXE = $(AUTHOR_ID)_$(SERVICE_ID) -CB_INSTALL_DIR = $(DESTDIR)/usr/share/cgc-challenges/$(EXE) -PATH := /usr/i386-linux-cgc/bin:$(PATH) -BINS = $(wildcard cb_*) -POV_BINS = $(wildcard pov_*) -POV_SRCS = $(wildcard pov_*/*.c) -SRCS = $(wildcard src/*.c src/*.cc lib/*.c lib/*.cc) -CXX_SRCS = $(filter %.cc, $(SRCS)) -EXTENDED_APP = /usr/share/cb-testing/CGC_Extended_Application.pdf -EXTENDED_APP_SZ = $(shell du -b $(EXTENDED_APP) | awk '{print $$1}') - -POLLS_RELEASE = $(wildcard poller/for-release/*.xml) -POLLS_TESTING = $(wildcard poller/for-testing/*.xml) -POVS = $(wildcard $(POV_DIR)/*.xml) -POVXML = $(wildcard $(POV_DIR)/*.povxml) - -CB_ADDITIONS = -ifndef NO_CB_DPKG -CB_ADDITIONS +=dpkg.o -endif -ifndef NO_CB_EXTENDED_APP -CB_ADDITIONS +=cgc-extended-application.o -endif - -has_ids_rules = $(sort $(wildcard ids/*.rules)) -has_cfe_pov = $(sort $(wildcard pov_*) $(wildcard pov/*.povxml)) -get_poll_args = $(if $(call has_cfe_pov),--store_seed --repeat $(POLL_REUSE_COUNT),) -get_pcap_args = $(if $(call has_cfe_pov),,--pcap $(PCAP_FILE_PATH)) -get_test_args = $(if $(call has_cfe_pov),--negotiate,) -get_ids_args = $(if $(call has_ids_rules),--ids_rules $(call has_ids_rules,)) -get_cb_bins = $(sort $(filter-out %_partial, $(filter-out %_patched, $(notdir $(wildcard $(BIN_DIR)/$(EXE)*))))) -get_cb_patched_bins = $(sort $(filter-out %_partial, $(filter %_patched, $(notdir $(wildcard $(BIN_DIR)/$(EXE)*))))) - -OBJS_ = $(SRCS:.c=.o) -OBJS = $(OBJS_:.cc=.o) $(CB_ADDITIONS) -ELF_OBJS = $(OBJS:.o=.elf) - -POV_OBJS = $(POV_SRCS:.c=.o) -BUILD_POV_OBJS = $(addprefix $(BUILD_DIR)/, $(POV_OBJS)) -BUILD_POV_DIRS = $(addprefix $(BUILD_DIR)/, $(POV_BINS)) - -POV_XML_BINS = $(POVXML:.povxml=.pov) - -POLL_RELEASE_LOGS = $(POLLS_RELEASE:.povxml=.log) -POLL_TESTING_LOGS = $(POLLS_TESTING:.povxml=.log) -POV_LOGS = $(POVS:.xml=.log) - -BUILD_POLL_TESTING_LOG = $(addprefix $(BUILD_DIR)/, $(POLL_RELEASE_LOGS)) -BUILD_POLL_RELEASE_LOG = $(addprefix $(BUILD_DIR)/, $(POLL_TESTING_LOGS)) -BUILD_POV_LOG = $(addprefix $(BUILD_DIR)/, $(POV_LOGS)) - -ifeq ($(VULN_COUNT), 0) -PATCHED_CFLAGS = $(CGC_CFLAGS) -DPATCHED -else -PATCHED_CFLAGS = $(CGC_CFLAGS) $(shell seq -f '-DPATCHED_%g ' -s '' $(VULN_COUNT)) -endif - -PATCHED_DIR = patched -PATCHED_EXE = $(EXE)_patched -PATCHED_PATH = $(BIN_DIR)/$(PATCHED_EXE) -PATCHED_OBJS = $(addprefix $(BUILD_DIR)/$(PATCHED_DIR)/, $(OBJS)) -PATCHED_DEBUG_PATH = $(BUILD_DIR)/$(PATCHED_DIR)/$(BIN_DIR)/$(EXE) - -PATCHED_ELF_OBJS = $(addprefix $(BUILD_DIR)/$(PATCHED_DIR)/, $(ELF_OBJS)) -PATCHED_ELF_STUB = $(BUILD_DIR)/$(PATCHED_DIR)/syscall-stub.elf -PATCHED_SO = $(BUILD_DIR)/$(PATCHED_DIR)/so/$(EXE).so - -RELEASE_CFLAGS = $(CGC_CFLAGS) -RELEASE_DIR = release -RELEASE_EXE = $(EXE) -RELEASE_PATH = $(BIN_DIR)/$(RELEASE_EXE) -RELEASE_OBJS = $(addprefix $(BUILD_DIR)/$(RELEASE_DIR)/, $(OBJS)) -RELEASE_DEBUG_PATH = $(BUILD_DIR)/$(RELEASE_DIR)/$(BIN_DIR)/$(EXE) - -PARTIAL_CFLAGS = $(CGC_CFLAGS) -DPATCHED_$(PARTIAL_ID) -PARTIAL_DIR = partial_$(PARTIAL_ID) -PARTIAL_EXE = $(EXE)_patched_$(PARTIAL_ID)_partial -PARTIAL_PATH = $(BIN_DIR)/$(PARTIAL_EXE) -PARTIAL_OBJS = $(addprefix $(BUILD_DIR)/$(PARTIAL_DIR)/, $(OBJS)) -PARTIAL_DEBUG_PATH = $(BUILD_DIR)/$(PARTIAL_DIR)/$(BIN_DIR)/$(EXE) - -PCAP_DIR = pcap -PCAP_FILE_PATH = $(PCAP_DIR)/$(RELEASE_EXE)_poll.pcap -PARTIAL_ID = - -all: build test - -testit: - @echo $(call get_cb_bins) - @echo $(call get_cb_patched_bins) - @echo $(BINS) - -prep: - @mkdir -p $(BUILD_DIR)/$(PATCHED_DIR)/lib $(BUILD_DIR)/$(PATCHED_DIR)/src $(BUILD_DIR)/$(PATCHED_DIR)/$(BIN_DIR) - @mkdir -p $(BUILD_DIR)/$(RELEASE_DIR)/lib $(BUILD_DIR)/$(RELEASE_DIR)/src $(BUILD_DIR)/$(RELEASE_DIR)/$(BIN_DIR) - @mkdir -p $(BUILD_DIR)/$(POV_DIR) - @mkdir -p $(PCAP_DIR) $(BIN_DIR) $(POV_DIR) - @mkdir -p $(BUILD_DIR)/poller/for-testing $(BUILD_DIR)/poller/for-release - @mkdir -p $(BUILD_DIR)/$(PATCHED_DIR)/so $(BUILD_POV_DIRS) -ifneq ($(strip $(PARTIAL_ID)), ) - @mkdir -p $(BUILD_DIR)/$(PARTIAL_DIR)/lib $(BUILD_DIR)/$(PARTIAL_DIR)/src $(BUILD_DIR)/$(PARTIAL_DIR)/$(BIN_DIR) -endif - - -%.pov: %.povxml - pov-xml2c -x $< -o $(BUILD_DIR)/$@.c - $(CC) -c $(POV_CFLAGS) -o $(BUILD_DIR)/$@.o $(BUILD_DIR)/$@.c - $(LD) $(LDFLAGS) -o $@ $(BUILD_DIR)/$@.o $(LIBS) $(POV_LIBS) - -$(BUILD_DIR)/%.o: %.c - $(CC) -c $(POV_CFLAGS) -o $@ $^ - -build_pov_objs: prep $(BUILD_POV_OBJS) - -$(POV_BINS): build_pov_objs - $(LD) $(LDFLAGS) -o $(POV_DIR)/$@.pov $(BUILD_DIR)/$@/*.o $(LIBS) $(POV_LIBS) - -pov: prep $(POV_XML_BINS) $(POV_BINS) - -$(BINS): cb_%: - ( cd $@; make -f ../Makefile build build-partial SERVICE_ID=$(SERVICE_ID)_$* BIN_COUNT=$(words $(BINS)) VULN_COUNT=$(VULN_COUNT)) - cp $@/$(BIN_DIR)/* $(BIN_DIR) - -build-binaries: $(BINS) - -clean-binaries: ; $(foreach dir, $(BINS), (cd $(dir) && make -f ../Makefile clean) &&) : - -$(BUILD_DIR)/$(RELEASE_DIR)/dpkg.o: /etc/decree_version - echo "The DECREE packages used in the creation of this challenge binary were:" > $@.txt - dpkg --list | grep -i cgc >> $@.txt - $(OBJCOPY) --input binary --output cgc32-i386 --binary-architecture i386 $@.txt $@ - -$(BUILD_DIR)/$(PATCHED_DIR)/dpkg.o $(BUILD_DIR)/$(PARTIAL_DIR)/dpkg.o: $(BUILD_DIR)/$(RELEASE_DIR)/dpkg.o - cp $< $@ - -$(BUILD_DIR)/$(RELEASE_DIR)/cgc-extended-application.o $(BUILD_DIR)/$(PATCHED_DIR)/cgc-extended-application.o $(BUILD_DIR)/$(PARTIAL_DIR)/cgc-extended-application.o: $(EXTENDED_APP) - echo "The $(EXTENDED_APP_SZ) byte CGC Extended Application follows. Each team participating in CGC must have submitted this completed agreement including the Team Information, the Liability Waiver, the Site Visit Information Sheet and the Event Participation agreement." > $@.tmp - cat $(EXTENDED_APP) >> $@.tmp - $(OBJCOPY) --input binary --output cgc32-i386 --binary-architecture i386 $@.tmp $@ - -%.elf: %.o - cp $< $@ - cgc2elf $@ - -$(PATCHED_ELF_STUB): - $(CC) -c -nostdlib -fno-builtin -nostdinc -o $(BUILD_DIR)/$(PATCHED_DIR)/syscall-stub.elf /usr/share/cb-testing/syscall-stub.c - cgc2elf $(BUILD_DIR)/$(PATCHED_DIR)/syscall-stub.elf - -build-partial: -ifneq ($(VULN_COUNT), 0) -ifeq ($(BIN_COUNT), 0) - ( for i in $(shell seq $(VULN_COUNT)); do \ - echo $(VULN_COUNT) ; \ - make PARTIAL_ID=$$i partial; \ - done ) -else - ( for i in $(shell seq $(VULN_COUNT)); do \ - echo $(VULN_COUNT) ; \ - make -f ../Makefile PARTIAL_ID=$$i partial; \ - done ) -endif -endif - -# Release rules -release: prep $(RELEASE_PATH) - -$(RELEASE_PATH): $(RELEASE_OBJS) - $(LD) $(LDFLAGS) -s -o $(RELEASE_PATH) -I$(BUILD_DIR)/$(RELEASE_DIR)/lib $^ $(LIBS) - $(LD) $(LDFLAGS) -o $(RELEASE_DEBUG_PATH) -I$(BUILD_DIR)/$(RELEASE_DIR)/lib $^ $(LIBS) - -$(BUILD_DIR)/$(RELEASE_DIR)/%.o: %.c - $(CC) -c $(RELEASE_CFLAGS) -o $@ $< - -$(BUILD_DIR)/$(RELEASE_DIR)/%.o: %.cc - $(CXX) -c $(RELEASE_CFLAGS) $(CXXFLAGS) -o $@ $< - -# Partially patched binary rules -partial: prep $(PARTIAL_PATH) - -$(PARTIAL_PATH): $(PARTIAL_OBJS) - $(LD) $(LDFLAGS) -s -o $(PARTIAL_PATH) -I$(BUILD_DIR)/$(PARTIAL_DIR)/lib $^ $(LIBS) - $(LD) $(LDFLAGS) -o $(PARTIAL_DEBUG_PATH) -I$(BUILD_DIR)/$(PARTIAL_DIR)/lib $^ $(LIBS) - -$(BUILD_DIR)/$(PARTIAL_DIR)/%.o: %.c - $(CC) -c $(PARTIAL_CFLAGS) -o $@ $< - -$(BUILD_DIR)/$(PARTIAL_DIR)/%.o: %.cc - $(CXX) -c $(PARTIAL_CFLAGS) $(CXXFLAGS) -o $@ $< - -# Patched rules -patched: prep $(PATCHED_PATH) $(PATCHED_SO) - -patched-so: prep $(PATCHED_SO) - -$(PATCHED_PATH): $(PATCHED_OBJS) - $(LD) $(LDFLAGS) -s -o $(PATCHED_PATH) $^ $(LIBS) - $(LD) $(LDFLAGS) -o $(PATCHED_DEBUG_PATH) -I$(BUILD_DIR)/$(RELEASE_DIR)/lib $^ $(LIBS) - -$(BUILD_DIR)/$(PATCHED_DIR)/%.o: %.c - $(CC) -c $(PATCHED_CFLAGS) -o $@ $< - -$(BUILD_DIR)/$(PATCHED_DIR)/%.o: %.cc - $(CXX) -c $(PATCHED_CFLAGS) $(CXXFLAGS) -o $@ $< - -ifneq ("$(CXX_SRCS)", "") -$(PATCHED_SO): - @echo "SO build artifact not currently supported for C++ services" -else -$(PATCHED_SO): $(PATCHED_ELF_OBJS) $(PATCHED_ELF_STUB) - $(LD_ELF) -shared -o $@ $^ -endif - -generate-polls: - if [ -f poller/for-release/machine.py ] && [ -f poller/for-release/state-graph.yaml ]; then generate-polls $(call get_poll_args) --count $(POLLS_RELEASE_COUNT) --seed $(POLLS_RELEASE_SEED) --depth $(POLLS_RELEASE_MAX_DEPTH) poller/for-release/machine.py poller/for-release/state-graph.yaml poller/for-release; fi - if [ -f poller/for-testing/machine.py ] && [ -f poller/for-testing/state-graph.yaml ]; then generate-polls $(call get_poll_args) --count $(POLLS_TESTING_COUNT) --seed $(POLLS_TESTING_SEED) --depth $(POLLS_TESTING_MAX_DEPTH) poller/for-testing/machine.py poller/for-testing/state-graph.yaml poller/for-testing; fi - -check: generate-polls -# Polls that the CB author intends to release the resulting network traffic during CQE - if [ -d poller/for-release ]; then cb-test $(call get_test_args) --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-release.txt --cb $(call get_cb_bins) $(call get_pcap_args); fi - if [ -d poller/for-release ]; then cb-test $(call get_test_args) --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-release.txt --cb $(call get_cb_patched_bins); fi - -# Polls that the CB author intends to NOT release the resulting network traffic during CQE - if [ -d poller/for-testing ]; then cb-test $(call get_test_args) --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-testing.txt --cb $(call get_cb_bins); fi - if [ -d poller/for-testing ]; then cb-test $(call get_test_args) --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-testing.txt --cb $(call get_cb_patched_bins); fi - -# POVs that should generate an identified crash for CQE when sent to the release CB but not the patched CB - cb-test $(call get_test_args) --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).pov.txt --failure_ok --should_core --cb $(call get_cb_bins) - cb-test $(call get_test_args) --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).pov.txt --failure_ok --cb $(call get_cb_patched_bins) - -check-ids: - if [ -d poller/for-release ]; then cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-release-ids.txt --cb $(call get_cb_bins); fi - if [ -d poller/for-release ]; then cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-release-ids.txt --cb $(call get_cb_patched_bins); fi - if [ -d poller/for-testing ]; then cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-testing-ids.txt --cb $(call get_cb_bins); fi - if [ -d poller/for-testing ]; then cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-testing-ids.txt --cb $(call get_cb_patched_bins); fi - cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).pov-ids.txt --failure_ok --cb $(call get_cb_bins) - cb-test $(call get_ids_args) $(call get_test_args) --enable_remote --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).pov-ids.txt --failure_ok --cb $(call get_cb_patched_bins) - -check-remote: - if [ -d poller/for-release ]; then cb-test $(call get_test_args) --enable_remote --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-release-remote.txt --cb $(call get_cb_bins); fi - if [ -d poller/for-release ]; then cb-test $(call get_test_args) --enable_remote --xml_dir poller/for-release/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-release-remote.txt --cb $(call get_cb_patched_bins); fi - if [ -d poller/for-testing ]; then cb-test $(call get_test_args) --enable_remote --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).for-testing-remote.txt --cb $(call get_cb_bins); fi - if [ -d poller/for-testing ]; then cb-test $(call get_test_args) --enable_remote --xml_dir poller/for-testing/ --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).for-testing-remote.txt --cb $(call get_cb_patched_bins); fi - cb-test $(call get_test_args) --enable_remote --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(RELEASE_EXE).pov-remote.txt --failure_ok --should_core --cb $(call get_cb_bins) - cb-test $(call get_test_args) --enable_remote --xml_dir $(POV_DIR) --directory $(BIN_DIR) --log $(BUILD_DIR)/$(PATCHED_EXE).pov-remote.txt --failure_ok --cb $(call get_cb_patched_bins) - -clean-test: - @-rm -f $(BUILD_POV_LOG) $(BUILD_POLL_LOG) - -clean: clean-test clean-binaries - -rm -rf $(BUILD_DIR) $(BIN_DIR) $(PCAP_DIR) - -rm -f test.log - -rm -f poller/for-release/edges.png poller/for-release/nodes.png poller/for-release/counts.png - -rm -f poller/for-release/gen_*.xml - -rm -f poller/for-release/GEN_*.xml - -rm -f poller/for-release/graph.dot - -rm -f poller/for-testing/edges.png poller/for-testing/nodes.png poller/for-testing/counts.png - -rm -f poller/for-testing/gen_*.xml - -rm -f poller/for-testing/GEN_*.xml - -rm -f poller/for-testing/graph.dot - -rm -f poller/for-release/machine.pyc - -rm -f poller/for-testing/machine.pyc - -rm -f $(POV_DIR)/*.pov - -if [ -d $(POV_DIR) ]; then rmdir --ignore-fail-on-non-empty $(POV_DIR); fi - -ifeq ($(strip $(BINS)),) -build: prep release patched pov build-partial -else -build: prep build-binaries pov -endif - -install: - install -d $(CB_INSTALL_DIR)/$(BIN_DIR) - install -d $(CB_INSTALL_DIR)/$(POV_DIR) - if [ ! -z "$(POVS)" ]; then install -m 444 $(wildcard $(POV_DIR)/*.xml) $(CB_INSTALL_DIR)/$(POV_DIR) ; fi - if [ ! -z "$(POV_BINS)" ] || [ ! -z "$(POVXML)" ]; then install -m 555 $(wildcard $(POV_DIR)/*.pov) $(CB_INSTALL_DIR)/$(POV_DIR) ; fi - if [ -d ids ]; then install -d $(CB_INSTALL_DIR)/ids ; fi - if [ -d ids ]; then install -m 444 $(wildcard ids/*.rules) $(CB_INSTALL_DIR)/ids ; fi - if [ -d poller/for-release ]; then install -d $(CB_INSTALL_DIR)/poller/for-release ; fi - if [ -d poller/for-release ]; then install -m 444 $(wildcard poller/for-release/*.xml) $(CB_INSTALL_DIR)/poller/for-release ; fi - if [ -d poller/for-testing ]; then install -d $(CB_INSTALL_DIR)/poller/for-testing ; fi - if [ -d poller/for-testing ]; then install -m 444 $(wildcard poller/for-testing/*.xml) $(CB_INSTALL_DIR)/poller/for-testing ; fi - if [ -f $(PCAP_FILE_PATH) ]; then install -d $(CB_INSTALL_DIR)/$(PCAP_DIR) ; fi - if [ -f $(PCAP_FILE_PATH) ]; then install -m 444 $(PCAP_FILE_PATH) $(CB_INSTALL_DIR)/$(PCAP_DIR) ; fi - install -m 555 $(wildcard $(BIN_DIR)/$(EXE)*) $(CB_INSTALL_DIR)/$(BIN_DIR) - -test: build check - -.PHONY: install all clean clean-test patched prep release remake test build-partial $(BINS) $(POV_BINS) diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.c b/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.c deleted file mode 100644 index 05a1d054f..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.c +++ /dev/null @@ -1,61 +0,0 @@ -// clang-format off -#include -#include "libc.h" -// clang-format on - -int transmit_all(int fd, const char *buf, const size_t size) { - size_t sent = 0; - size_t sent_now = 0; - int ret; - - if (!buf) - return 1; - - if (!size) - return 2; - - while (sent < size) { - ret = transmit(fd, buf + sent, size - sent, &sent_now); - if (sent_now == 0) { - // should never return until at least something was transmitted - // so consider this an error too - return 3; - } - if (ret != 0) { - return 3; - } - sent += sent_now; - } - - return 0; -} - -int receive_delim(int fd, char *buf, const size_t size, char delim) { - size_t rx = 0; - size_t rx_now = 0; - int ret; - - if (!buf) - return 1; - - if (!size) - return 2; - - while (rx < size) { - ret = receive(fd, buf + rx, 1, &rx_now); - if (rx_now == 0) { - // should never return until at least something was received - // so consider this an error too - return 3; - } - if (ret != 0) { - return 3; - } - if (buf[rx] == delim) { - break; - } - rx += rx_now; - } - - return 0; -} diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.h b/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.h deleted file mode 100755 index c09f0ce57..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/lib/libc.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef LIBC_H -#define LIBC_H -int transmit_all(int fd, const char *buf, const size_t size); -int receive_delim(int fd, char *buf, const size_t size, char delim); -#endif diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/POLL_00000.xml b/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/POLL_00000.xml deleted file mode 100755 index 7be2fa5b6..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/POLL_00000.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - service - - r\n\nWelcome to Palindrome Finder\n - : \n\tPlease enter a possible palindrome: - race\n - \n\t\tNope, that's not a palindrome\n - : \n\tPlease enter a possible palindrome: - racecar\n - \n\t\tYes, that's a palindrome!\n - - diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/machine.py b/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/machine.py deleted file mode 100644 index 8e811eec2..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/machine.py +++ /dev/null @@ -1,41 +0,0 @@ -from generator.actions import Actions -import random -import string - -class Palindrome(Actions): - def start(self): - pass - - def banner(self): - # Confirm the initial empty line - self.read(delim='\n', expect='\n') - # Confirm the actual banner - self.read(delim='\n', expect='Welcome to Palindrome Finder\n') - - def request(self): - # Skip the empty line - self.read(delim='\n', expect='\n') - # Confirm the request - self.read(length=37, expect='\tPlease enter a possible palindrome: ') - - def palindrome(self): - halfword = self.random_string(random.randint(1, 16)) - self.write(halfword + halfword[::-1] + "\n") - self.read(delim='\n', expect="\t\tYes, that's a palindrome!\n") - - def not_palindrome(self): - word = self.random_string(random.randint(2, 32)) - while self.is_palindrome(word): - word = self.random_string(random.randint(2, 32)) - self.write(word + "\n") - self.read(delim='\n', expect="\t\tNope, that's not a palindrome\n") - - def is_palindrome(self, word): - for i in range(0, len(word) / 2): - if word[i] != word[-i - 1]: - return False - return True - - def random_string(self, size): - chars = string.letters + string.digits - return ''.join(random.choice(chars) for _ in range(size)) diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/state-graph.yaml b/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/state-graph.yaml deleted file mode 100644 index 456345967..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/poller/for-testing/state-graph.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -nodes: -- name: start -- name: banner -- name: request - continue: .9 -- name: palindrome -- name: not_palindrome -edges: -- start: banner -- banner: request -- request: palindrome - weight: .2 -- request: not_palindrome - weight: .8 -- palindrome: request -- not_palindrome: request diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/pov/POV_00000.xml b/testsuite/pov-cgc-cadet0/CADET_00001/pov/POV_00000.xml deleted file mode 100755 index bfc8e6b37..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/pov/POV_00000.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - service - - \x0a\x0a - \x0aWelcome to Palindrome Finder\x0a - \x0a\x0a - 37\x09Please enter a possible palindrome: - - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - - 1 - - diff --git a/testsuite/pov-cgc-cadet0/CADET_00001/src/service.c b/testsuite/pov-cgc-cadet0/CADET_00001/src/service.c deleted file mode 100644 index 29c698496..000000000 --- a/testsuite/pov-cgc-cadet0/CADET_00001/src/service.c +++ /dev/null @@ -1,73 +0,0 @@ -// CADET's first C program - -#include -#include "libc.h" - -#define HI "\nWelcome to Palindrome Finder\n\n" -#define ASK "\tPlease enter a possible palindrome: " -#define YES "\t\tYes, that's a palindrome!\n\n" -#define NO "\t\tNope, that's not a palindrome\n\n" -#define EASTEREGG "\n\nEASTER EGG!\n\n" - -int check(); - -int main(void) { - int r; - - if (transmit_all(1, HI, sizeof(HI) - 1) != 0) { - _terminate(0); - } - - while (1) { - if (transmit_all(1, ASK, sizeof(ASK) - 1) != 0) { - _terminate(0); - } - r = check(); - if (r == -1) { - break; - } else if (r == 0) { - if (transmit_all(1, NO, sizeof(NO) - 1) != 0) { - _terminate(0); - } - } else { - if (transmit_all(1, YES, sizeof(YES) - 1) != 0) { - _terminate(0); - } - } - } - return 0; -} - -int check() { - int len = -1; - int i; - int pal = 1; - char string[64]; - for (i = 0; i < sizeof(string); i++) - string[i] = '\0'; -#ifdef PATCHED - if (receive_delim(0, string, sizeof(string), '\n') != 0) - return -1; -#else - if (receive_delim(0, string, 128, '\n') != 0) - return -1; -#endif - for (i = 0; string[i] != '\0'; i++) { - len++; - } - int steps = len; - if (len % 2 == 1) { - steps--; - } - for (i = 0; i <= steps / 2; i++) { - if (string[i] != string[len - 1 - i]) { - pal = 0; - } - } - if (string[0] == '^') { - if (transmit_all(1, EASTEREGG, sizeof(EASTEREGG) - 1) != 0) { - _terminate(0); - } - } - return pal; -} diff --git a/testsuite/pov-cgc-cadet0/Makefile b/testsuite/pov-cgc-cadet0/Makefile index dd6846e9a..76dd0bbd5 100644 --- a/testsuite/pov-cgc-cadet0/Makefile +++ b/testsuite/pov-cgc-cadet0/Makefile @@ -19,18 +19,12 @@ # SOFTWARE. CB=CADET_00001 -SOURCE=main.c BUILD_SCRIPTS_SRC:=$(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -RUN_DOCKER = docker run --rm -w $(BUILD_SCRIPTS_SRC) -e NO_CB_EXTENDED_APP=1 -v $(BUILD_SCRIPTS_SRC):$(BUILD_SCRIPTS_SRC) linux-build-i386 /run_as.sh $(shell id -u) $(shell id -g) make -C CADET_00001 $(1) - -$(CB)/bin/$(CB): $(CB)/src/service.c - cd $(BUILD_SCRIPTS_SRC) && $(call RUN_DOCKER,build) - -TARGETS=$(CB)/bin/$(CB) +TARGETS=$(CB) all: $(TARGETS) +# Nothing to clean. clean: - $(call RUN_DOCKER,clean) diff --git a/testsuite/pov-cgc-cadet0/config.yml b/testsuite/pov-cgc-cadet0/config.yml index 5e4394643..ee1891e4e 100644 --- a/testsuite/pov-cgc-cadet0/config.yml +++ b/testsuite/pov-cgc-cadet0/config.yml @@ -1,6 +1,6 @@ test: description: "Checks that the CADET_00001 sample produces POVs" targets: - - CADET_00001/bin/CADET_00001 + - CADET_00001 scripts: run_tests: run-tests.tpl