# CONSTANTS/VARIABLES
# Regex to catch compiler commands.
-my $cc_regex = qr/(?:[a-z0-9_]+-(?:linux|kfreebsd)-gnu(?:eabi|eabihf)?-)?
- (?:(?<!\.)cc|gcc|g\+\+|c\+\+)
+my $cc_regex = qr/(?:[a-z0-9_]+-(?:linux-|kfreebsd-)?gnu(?:eabi|eabihf)?-)?
+ (?<!\.)(?:cc|gcc|g\+\+|c\+\+)
(?:-[\d.]+)?/x;
# Regex to catch (GCC) compiler warnings.
my $warning_regex = qr/^(.+?):([0-9]+):[0-9]+: warning: (.+?) \[(.+?)\]$/;
error_color(':', 'yellow'),
$line;
}
+sub error_hardening_wrapper {
+ printf "%s%s %s\n",
+ error_color('HARDENING WRAPPER', 'red'),
+ error_color(':', 'yellow'),
+ 'no checks possible, aborting';
+}
sub error_color {
my ($message, $color) = @_;
}
}
+ # If hardening wrapper is used (wraps calls to gcc and adds hardening
+ # flags automatically) we can't perform any checks, abort.
+ if (not $start and $line =~ /^Build-Depends: .*\bhardening-wrapper\b/) {
+ error_hardening_wrapper();
+ $exit |= 1 << 4;
+ exit $exit;
+ }
+
# We skip over unimportant lines at the beginning of the log to prevent
# false positives.
$start = 1 if $line =~ /^dpkg-buildpackage:/;
# Ignore false positives.
#
# `./configure` output.
- next if not $non_verbose and $line =~ /^checking /;
+ next if not $non_verbose
+ and $line =~ /^(?:checking|(?:C|c)onfigure:) /;
next if $line =~ /^\s*(?:Host\s+)?(?:C\s+)?
(?:C|c)ompiler[\s.]*:?\s+
$cc_regex
or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex\s*$/
or $line =~ /^\s*-- Check for working (?:C|CXX) compiler: /
or $line =~ /^\s*(?:echo )?Using [A-Z_]+\s*=\s*/;
- # Debian buildd output.
- next if $line =~ /^\s*Depends: .*?$cc_regex.*?$/
- and $line !~ /\s-./; # option, prevent false negatives
# Check if additional hardening options were used. Used to ensure
# they are used for the complete build.
Missing hardening flags.
+=item B<16>
+
+Hardening wrapper detected, no tests performed.
+
=back
=head1 AUTHOR