forked from pool/rpmlint
86 lines
3.2 KiB
Diff
86 lines
3.2 KiB
Diff
From bcc9a315dae3aacf27854f16328c59e32eab2816 Mon Sep 17 00:00:00 2001
|
|
From: Dirk Mueller <dirk@dmllr.de>
|
|
Date: Thu, 28 Sep 2017 23:04:22 +0200
|
|
Subject: [PATCH 3/3] Tighten lib_regex to avoid false positive in python
|
|
bindings
|
|
|
|
Also add unit test coverage for it.
|
|
---
|
|
FilesCheck.py | 2 +-
|
|
test/test_files.py | 17 +++++++++++++++++
|
|
2 files changed, 18 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/FilesCheck.py b/FilesCheck.py
|
|
index 57de8fb..1852b38 100644
|
|
--- a/FilesCheck.py
|
|
+++ b/FilesCheck.py
|
|
@@ -196,7 +196,7 @@ devel_regex = re.compile(r'(.*)-(debug(info|source)?|devel|headers|source|static
|
|
debuginfo_package_regex = re.compile(r'-debug(info)?$')
|
|
debugsource_package_regex = re.compile(r'-debugsource$')
|
|
use_debugsource = Config.getOption('UseDebugSource', False)
|
|
-lib_regex = re.compile(r'lib(64)?/lib[^/]*(\.so\..*|-[0-9.]+\.so)')
|
|
+lib_regex = re.compile(r'lib(?:64)?/lib[^/]*(?:\.so\.[\d\.]+|\.so)$')
|
|
ldconfig_regex = re.compile(r'^[^#]*ldconfig', re.MULTILINE)
|
|
depmod_regex = re.compile(r'^[^#]*depmod', re.MULTILINE)
|
|
install_info_regex = re.compile(r'^[^#]*install-info', re.MULTILINE)
|
|
diff --git a/test/test_files.py b/test/test_files.py
|
|
index f26c0c3..bfffda5 100644
|
|
--- a/test/test_files.py
|
|
+++ b/test/test_files.py
|
|
@@ -62,3 +62,20 @@ def test_scm_regex():
|
|
assert scm_regex.search('/bar/foo,v')
|
|
assert scm_regex.search('bar/.svnignore')
|
|
assert scm_regex.search('bar/.git/refs')
|
|
+
|
|
+
|
|
+def test_lib_regex():
|
|
+ from FilesCheck import lib_regex
|
|
+
|
|
+ # true matches
|
|
+ assert all(
|
|
+ lib_regex.search(x) for x in
|
|
+ ('/lib/libnsl-2.26.so',
|
|
+ '/lib64/libSegFault.so',
|
|
+ '/lib64/libgcc_s.so.1'))
|
|
+
|
|
+ # false positives
|
|
+ assert not any(
|
|
+ lib_regex.search(x) for x in
|
|
+ ('/usr/share/gdb/auto-load/usr/lib/libglib-2.0.so.0.4600.1-gdb.py',
|
|
+ '/usr/lib64/rsocket/binary',))
|
|
--
|
|
2.14.1
|
|
|
|
diff --git a/FilesCheck.py b/FilesCheck.py
|
|
index 6a97601..abb3fa7 100644
|
|
--- a/FilesCheck.py
|
|
+++ b/FilesCheck.py
|
|
@@ -196,7 +196,7 @@ devel_regex = re.compile(r'(.*)-(debug(info|source)?|devel|headers|source|static
|
|
debuginfo_package_regex = re.compile(r'-debug(info)?$')
|
|
debugsource_package_regex = re.compile(r'-debugsource$')
|
|
use_debugsource = Config.getOption('UseDebugSource', False)
|
|
-lib_regex = re.compile(r'lib(?:64)?/lib[^/]*(?:\.so\.[\d\.]+|\.so)$')
|
|
+lib_regex = re.compile(r'/lib(?:64)?/lib[^/]+(?:\.so\.[\d\.]+|-[\d\.]+\.so)$')
|
|
ldconfig_regex = re.compile(r'^[^#]*ldconfig', re.MULTILINE)
|
|
depmod_regex = re.compile(r'^[^#]*depmod', re.MULTILINE)
|
|
install_info_regex = re.compile(r'^[^#]*install-info', re.MULTILINE)
|
|
diff --git a/test/test_files.py b/test/test_files.py
|
|
index bfffda5..0192c13 100644
|
|
--- a/test/test_files.py
|
|
+++ b/test/test_files.py
|
|
@@ -71,11 +71,13 @@ def test_lib_regex():
|
|
assert all(
|
|
lib_regex.search(x) for x in
|
|
('/lib/libnsl-2.26.so',
|
|
- '/lib64/libSegFault.so',
|
|
+ '/usr/lib64/libgnomeui.so.3',
|
|
'/lib64/libgcc_s.so.1'))
|
|
|
|
# false positives
|
|
assert not any(
|
|
lib_regex.search(x) for x in
|
|
('/usr/share/gdb/auto-load/usr/lib/libglib-2.0.so.0.4600.1-gdb.py',
|
|
+ '/usr/share/doc/findlib/lib-1.0.so',
|
|
+ '/usr/lib64/libvulkan_radeon.so',
|
|
'/usr/lib64/rsocket/binary',))
|