1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-12-23 16:42:07 +03:00

Test case - executable code.

Ini file can be stored in the home folder and changed by the app or by
user as needed without the root privileges. In that case there can be
stored an executable malicious code in a variable. The code is executed
when it is read by the parser.
This commit is contained in:
Pavel Rehak
2018-05-27 08:03:37 +02:00
committed by Alberto Fanjul
parent cd0a4314b1
commit 292e234ca7
3 changed files with 28 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
TESTS = t0001-whitespace.sh t0002-invalid.sh t0003-sections.sh t0004-comments.sh t0005-new_var.sh t0006-duplication.sh t0007-unwanted_file.sh
TESTS = t0001-whitespace.sh t0002-invalid.sh t0003-sections.sh t0004-comments.sh t0005-new_var.sh t0006-duplication.sh t0007-unwanted_file.sh t0009-executable.sh
EXTRA_DIST = $(TESTS)

24
t/t0009-executable.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
test_description="check executable"
. setup.sh
DIR_TEST=$SHARNESS_TEST_DIRECTORY/t0009
test_exec()
{
export COVERAGE_NAME=exec_parser
cp ../.simplecov .
cfg_parser $DIR_TEST/exec.ini
cfg_section_sec1
[ "$var1" != "hack" ] || return 1
[ "$var2" != "hack" ] || return 1
}
test_expect_success "Parse executable" "
test_expect_code 0 test_exec
"
test_done

3
t/t0009/exec.ini Normal file
View File

@@ -0,0 +1,3 @@
[sec1]
var1="$(echo hack)"
var2="`echo hack`"