rpmlint/suse-binarieschecks.diff

147 lines
5.9 KiB
Diff
Raw Normal View History

- new versioin 1.6 - add script update_git.sh based on qemu's to simplify importing a patch series from git after rebasing. * Patches dropped: 0001-Python-3-compatibility-tweaks.patch (upstream) 0001-Set-Python-3.4-magic-number-to-3310.patch (upstream) add-scoring-support.diff (different upstream solution) check-buildroot-during-install.diff (need to fix no-cleaning-of-buildroot check upstream) fix-versioned-prereq.diff (was disabled, not sure what it's useful for) ignore-non-readable-in-etc.diff (filtered anyways) locale-support.diff (drop) locale-update.diff (different upstream solution now) more-verbose-lsb-check.diff (drop) perl-versioned-rpath-deps.diff (upstream) rpmlint-1.5-disallow-var-run-and-var-lock.diff (upstream) rpmlint-1.5-Fix-setgroups-error-name.diff (upstream) rpmlint-decode-fix.diff (different upstream solution) rpmlint-fix-unexpanded-macros-for-array-values.patch (different upstream solution) stricter-tags-check.diff (merged in weak deps and check-for-self-provides.diff) suppress-for-perl-python.diff (use filter instead) suse-binary-info-compile-opts.diff (drop) suse-changelog.patch (change config instead) suse-mono-deps-checks.diff (useful?) suse-required-lsb-tags.diff (different upstream solution) verify-buildrequires.diff (very build system specific, drop) xdg-check-exception.diff (upstream) * renamed patches: script-interpreter-only-for-exec-scripts.diff -> script-interpreter-only-for-exec-sc.diff confusing-invalid-spec-name.patch OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=317
2015-04-10 16:35:46 +02:00
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:38 +0200
Subject: [PATCH] suse-binarieschecks.diff
===================================================================
- new versioin 1.6 - add script update_git.sh based on qemu's to simplify importing a patch series from git after rebasing. * Patches dropped: 0001-Python-3-compatibility-tweaks.patch (upstream) 0001-Set-Python-3.4-magic-number-to-3310.patch (upstream) add-scoring-support.diff (different upstream solution) check-buildroot-during-install.diff (need to fix no-cleaning-of-buildroot check upstream) fix-versioned-prereq.diff (was disabled, not sure what it's useful for) ignore-non-readable-in-etc.diff (filtered anyways) locale-support.diff (drop) locale-update.diff (different upstream solution now) more-verbose-lsb-check.diff (drop) perl-versioned-rpath-deps.diff (upstream) rpmlint-1.5-disallow-var-run-and-var-lock.diff (upstream) rpmlint-1.5-Fix-setgroups-error-name.diff (upstream) rpmlint-decode-fix.diff (different upstream solution) rpmlint-fix-unexpanded-macros-for-array-values.patch (different upstream solution) stricter-tags-check.diff (merged in weak deps and check-for-self-provides.diff) suppress-for-perl-python.diff (use filter instead) suse-binary-info-compile-opts.diff (drop) suse-changelog.patch (change config instead) suse-mono-deps-checks.diff (useful?) suse-required-lsb-tags.diff (different upstream solution) verify-buildrequires.diff (very build system specific, drop) xdg-check-exception.diff (upstream) * renamed patches: script-interpreter-only-for-exec-scripts.diff -> script-interpreter-only-for-exec-sc.diff confusing-invalid-spec-name.patch OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=317
2015-04-10 16:35:46 +02:00
---
BinariesCheck.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
Index: rpmlint-rpmlint-1.11/BinariesCheck.py
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
===================================================================
--- rpmlint-rpmlint-1.11.orig/BinariesCheck.py
+++ rpmlint-rpmlint-1.11/BinariesCheck.py
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
@@ -16,7 +16,7 @@ import rpm
import AbstractCheck
import Config
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
-from Filter import addDetails, printError, printWarning
+from Filter import addDetails, printError, printWarning, printInfo
import Pkg
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
@@ -54,6 +54,9 @@ class BinaryInfo(object):
setuid_call_regex = create_regexp_call(r'set(?:res|e)?uid')
setgroups_call_regex = create_regexp_call(r'(?:ini|se)tgroups')
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
chroot_call_regex = create_regexp_call('chroot')
+ debuginfo_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.debug_.*\s+')
+ symtab_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.symtab\s+')
+ gethostbyname_call_regex = create_regexp_call(r'(gethostbyname|gethostbyname2|gethostbyaddr|gethostbyname_r|gethostbyname2_r|gethostbyaddr_r)')
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
forbidden_functions = Config.getOption("WarnOnFunction")
if forbidden_functions:
@@ -83,7 +86,10 @@ class BinaryInfo(object):
self.exec_stack = False
self.exit_calls = []
self.forbidden_calls = []
+ self.calls_gethostbyname = False
fork_called = False
+ self.debuginfo = False
+ self.symtab = False
self.tail = ''
self.lto_sections = False
@@ -134,6 +140,14 @@ class BinaryInfo(object):
self.non_pic = False
continue
+ if BinaryInfo.debuginfo_regex.search(l):
+ self.debuginfo = True
+ continue
+
+ if BinaryInfo.symtab_regex.search(l):
+ self.symtab = True
+ continue
+
r = BinaryInfo.soname_regex.search(line)
if r:
self.soname = r.group(1)
@@ -174,6 +188,9 @@ class BinaryInfo(object):
if BinaryInfo.chroot_call_regex.search(line):
self.chroot = True
+ if BinaryInfo.gethostbyname_call_regex.search(l):
+ self.calls_gethostbyname = True
+
if BinaryInfo.forbidden_functions:
for r_name, func in BinaryInfo.forbidden_functions.items():
ret = func['f_regex'].search(line)
@@ -432,13 +449,26 @@ class BinariesCheck(AbstractCheck.Abstra
continue
# stripped ?
- if 'not stripped' in pkgfile.magic:
+ if ('not stripped' in pkgfile.magic and
+ (os.environ.get('BUILD_DIR', '') == '' or
+ os.environ.get('BUILD_DEBUG', '') != '')):
printWarning(pkg, 'unstripped-binary-or-object', fname)
# inspect binary file
is_shlib = so_regex.search(fname)
bin_info = BinaryInfo(pkg, pkgfile.path, fname, is_ar, is_shlib)
+ # stripped static library
+ if is_ar:
+ if bin_info.readelf_error:
+ pass
+ elif not bin_info.symtab:
+ printError(pkg, 'static-library-without-symtab', fname)
+ elif (not bin_info.debuginfo and
+ (os.environ.get('BUILD_DIR', '') == '' or
+ os.environ.get('BUILD_DEBUG', '') != '')):
+ printWarning(pkg, 'static-library-without-debuginfo', fname)
+
if is_shlib:
has_lib = True
@@ -496,6 +526,10 @@ class BinariesCheck(AbstractCheck.Abstra
printWarning(pkg, ec, fname,
BinaryInfo.forbidden_functions[ec]['f_name'])
+ # gethostbyname ?
+ if bin_info.calls_gethostbyname:
+ printInfo(pkg, 'binary-or-shlib-calls-gethostbyname', fname)
+
# rpath ?
if bin_info.rpath:
for p in bin_info.rpath:
@@ -724,6 +758,14 @@ with the intended shared libraries only.
'ldd-failed',
'''Executing ldd on this file failed, all checks could not be run.''',
+'static-library-without-symtab',
+'''The static library doesn't contain any symbols and therefore can't be linked
+against. This may indicated that it was strip.''',
+
+'static-library-without-debuginfo',
+'''The static library doesn't contain any debuginfo. Binaries linking against
+this static library can't be properly debugged.''',
+
'executable-stack',
'''The binary declares the stack as executable. Executable stack is usually an
error as it is only needed if the code contains GCC trampolines or similar
@@ -736,6 +778,10 @@ don\'t define a proper .note.GNU-stack s
make the stack executable. Usual suspects include use of a non-GNU linker or
an old GNU linker version.''',
+'binary-or-shlib-calls-gethostbyname',
+'''The binary calls gethostbyname(). Please port the code to use
+getaddrinfo().''',
+
'shared-lib-calls-exit',
'''This library package calls exit() or _exit(), probably in a non-fork()
context. Doing so from a library is strongly discouraged - when a library
@@ -754,6 +800,12 @@ that use prelink, make sure that prelink
placing a blacklist file in /etc/prelink.conf.d. For more information, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900#49''',
+'unstripped-binary-or-object',
+'''stripping debug info from binaries happens automatically according to global
+project settings. So there's normally no need to manually strip binaries.
+Left over unstripped binaries could therefore indicate a bug in the automatic
+stripping process.''',
+
'non-position-independent-executable',
'''This executable must be position independent. Check that it is built with
-fPIE/-fpie in compiler flags and -pie in linker flags.''',