12 runs-on: ubuntu-latest
18 # Current ubuntu-latest (Ubuntu 22.04) provides the following versions of Python:
19 python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
23 - name: Set up Python ${{ matrix.python-version }}
24 uses: actions/setup-python@v1
26 python-version: ${{ matrix.python-version }}
28 - name: Install package
30 python -m pip install --upgrade pip
32 pip --verbose install git+https://github.com/a13xp0p0v/kconfig-hardened-check
33 echo ">>>>> first start <<<<<"
34 kconfig-hardened-check
36 - name: Check all configs with the installed tool
38 echo ">>>>> check all configs <<<<<"
39 CONFIG_DIR=`find /opt/hostedtoolcache/Python/ -name config_files`
40 CONFIGS=`find $CONFIG_DIR -type f | grep "\.config"`
44 COUNT=$(expr $COUNT + 1)
45 echo -e "\n>>>>> checking config number $COUNT <<<<<"
46 kconfig-hardened-check -c $C
48 echo -e "\n>>>>> checking $COUNT configs is done <<<<<"
50 - name: Get source code for collecting coverage
51 uses: actions/checkout@v2
53 - name: Collect coverage for the basic functionality
55 echo ">>>>> get help <<<<<"
56 coverage run -a --branch bin/kconfig-hardened-check
57 coverage run -a --branch bin/kconfig-hardened-check -h
59 echo ">>>>> get version <<<<<"
60 coverage run -a --branch bin/kconfig-hardened-check --version
62 echo ">>>>> print the security hardening preferences <<<<<"
63 coverage run -a --branch bin/kconfig-hardened-check -p X86_64
64 coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m verbose
65 coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m json
67 coverage run -a --branch bin/kconfig-hardened-check -p X86_32
68 coverage run -a --branch bin/kconfig-hardened-check -p X86_32 -m verbose
69 coverage run -a --branch bin/kconfig-hardened-check -p X86_32 -m json
71 coverage run -a --branch bin/kconfig-hardened-check -p ARM64
72 coverage run -a --branch bin/kconfig-hardened-check -p ARM64 -m verbose
73 coverage run -a --branch bin/kconfig-hardened-check -p ARM64 -m json
75 coverage run -a --branch bin/kconfig-hardened-check -p ARM
76 coverage run -a --branch bin/kconfig-hardened-check -p ARM -m verbose
77 coverage run -a --branch bin/kconfig-hardened-check -p ARM -m json
79 echo ">>>>> use local cmdline as an example <<<<<"
82 echo ">>>>> check the example kconfig files and cmdline <<<<<"
83 CONFIG_DIR=`find . -name config_files`
84 CONFIGS=`find $CONFIG_DIR -type f | grep "\.config"`
88 COUNT=$(expr $COUNT + 1)
89 echo -e "\n>>>>> checking config number $COUNT <<<<<"
90 coverage run -a --branch bin/kconfig-hardened-check -c $C
91 coverage run -a --branch bin/kconfig-hardened-check -c $C -m verbose > /dev/null
92 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline
93 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline -m verbose > /dev/null
94 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline -m json
95 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline -m show_ok
96 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline -m show_fail
98 echo -e "\n>>>>> checking $COUNT configs is done <<<<<"
100 - name: Collect coverage for error handling
102 echo ">>>>> lonely -l <<<<<"
103 ! coverage run -a --branch bin/kconfig-hardened-check -l /proc/cmdline
105 echo ">>>>> wrong modes for -p <<<<<"
106 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m show_ok
107 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m show_fail
109 echo ">>>>> -p and -c together <<<<<"
110 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -c kconfig_hardened_check/config_files/distros/fedora_34.config
112 cp kconfig_hardened_check/config_files/distros/fedora_34.config ./test.config
114 echo ">>>>> no kernel version <<<<<"
115 sed '3d' test.config > error.config
116 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
118 echo ">>>>> strange kernel version string <<<<<"
119 sed '3 s/5./version 5./' test.config > error.config
120 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
122 echo ">>>>> no arch <<<<<"
123 sed '305d' test.config > error.config
124 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
126 echo ">>>>> more than one arch <<<<<"
127 cp test.config error.config
128 echo 'CONFIG_ARM64=y' >> error.config
129 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
131 echo ">>>>> invalid disabled kconfig option <<<<<"
132 sed '28 s/is not set/is not set yet/' test.config > error.config
133 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
135 echo ">>>>> invalid enabled kconfig option <<<<<"
136 cp test.config error.config
137 echo 'CONFIG_FOO=is not set' >> error.config
138 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
140 echo ">>>>> one config option multiple times <<<<<"
141 cp test.config error.config
142 echo 'CONFIG_BUG=y' >> error.config
143 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
145 echo ">>>>> invalid compiler versions <<<<<"
146 cp test.config error.config
147 sed '8 s/CONFIG_CLANG_VERSION=0/CONFIG_CLANG_VERSION=120000/' test.config > error.config
148 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
150 echo ">>>>> multi-line cmdline file <<<<<"
151 echo 'hey man 1' > cmdline
152 echo 'hey man 2' >> cmdline
153 ! coverage run -a --branch bin/kconfig-hardened-check -c test.config -l cmdline
155 - name: Prepare final coverage report
157 coverage xml -i -o coverage.xml
159 - name: Handle coverage
160 uses: codecov/codecov-action@v2
163 flags: functional_test
164 name: codecov-umbrella
165 fail_ci_if_error: true