| 1 |
blhc for Debian |
| 2 |
--------------- |
| 3 |
|
| 4 |
Since 0.12 version, blhc is able to ignore false positives spotted by |
| 5 |
line(s) "injected" inside .build file via debian/rules. It is useful |
| 6 |
for Salsa automated tests and to skip wrong lines shown in local blhc |
| 7 |
report. From blhc(1) manpage: |
| 8 |
|
| 9 |
FALSE POSITIVES |
| 10 |
To suppress false positives you can embed the following string |
| 11 |
in the build log: |
| 12 |
|
| 13 |
blhc: ignore-line-regexp: REGEXP |
| 14 |
|
| 15 |
All lines fully matching REGEXP (see --ignore-line for details) |
| 16 |
will be ignored. |
| 17 |
|
| 18 |
Please use this feature sparingly so that missing flags are not |
| 19 |
overlooked. If you find false positives which affect more packages |
| 20 |
please report a bug. |
| 21 |
|
| 22 |
To generate this string simply use echo in "debian/rules"; make |
| 23 |
sure to use @ to suppress the echo command itself as it could also |
| 24 |
trigger a false positive. |
| 25 |
|
| 26 |
In the blhc build process, the upstream implemented several tests to |
| 27 |
confirm if blhc works fine. These tests can be found in the t/ directory |
| 28 |
in source code. Some tests have no all hardening flags deliberately. |
| 29 |
Consequently, the command 'blhc --all --debian blhc_<version>.build' will |
| 30 |
show some warning lines, but in this case they are false positives because |
| 31 |
the intend is verify if blhc detects the absence of these flags. See an |
| 32 |
example below: |
| 33 |
|
| 34 |
$ blhc --all --debian ../blhc_0.12-1_amd64.build |
| 35 |
|
| 36 |
CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): ok 47 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (exit code) |
| 37 |
CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ok 47 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (exit code) |
| 38 |
LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): ok 47 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (exit code) |
| 39 |
CFLAGS missing (-g -O2 -fstack-protector-strong -Wformat -Werror=format-security): ok 48 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (output) |
| 40 |
CPPFLAGS missing (-D_FORTIFY_SOURCE=2): ok 48 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (output) |
| 41 |
LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): ok 48 - ./t/logs/ignore-line --ignore-line "\./prepare-script gcc test-[a-z]\.c" --ignore-line "\s*\./prepare-script gcc test-[a-z]\.c .+" (output) |
| 42 |
|
| 43 |
The solution to blhc (>= 0.12) ignore all false positives is write a line |
| 44 |
inside .build file to drop all matches with the following Perl Regexp: |
| 45 |
|
| 46 |
.*prepare-script\ gcc\ test-\[a-z\]\\\.c.* |
| 47 |
|
| 48 |
See a real example from the debian/rules used in blhc package: |
| 49 |
|
| 50 |
override_dh_auto_test: |
| 51 |
@echo 'blhc: ignore-line-regexp: .*prepare-script\ gcc\ test-\[a-z\]\\\.c.*' |
| 52 |
dh_auto_test |
| 53 |
|
| 54 |
Note this is not a magic formula. So, you need to understand the issue and |
| 55 |
write a rule in a right part of debian/rules (sometimes in dh_auto_build, |
| 56 |
sometimes in dh_auto_test, etc.). This technique must be used for FALSE |
| 57 |
POSITIVES only (don't use it to override warnings for unsolved but real |
| 58 |
hardening issues). |
| 59 |
|
| 60 |
A quick reference about Perl Regexp is here[1]. |
| 61 |
|
| 62 |
[1] http://jkorpela.fi/perl/regexp.html |
| 63 |
|
| 64 |
-- Joao Eriberto Mota Filho <[email protected]> Wed, 29 Jul 2020 20:41:39 -0300 |