Skip to content

Commit 751c9bc

Browse files
committed
Detect Go binaries and skip some checks for them.
Fixes #598.
1 parent 15b4e45 commit 751c9bc

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

rpmlint/checks/BinariesCheck.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def _check_non_pie(self, pkg, bin_name):
152152
We suppose that the package is arch dependent and bin_name is binary
153153
executable.
154154
"""
155+
if self.is_go_elf:
156+
return
157+
155158
if not self.is_shobj and not self.is_pie_exec:
156159
if any(regex.search(bin_name) for regex in self.pie_exec_regex_list):
157160
self.output.add_info('E', pkg,
@@ -397,7 +400,9 @@ def _check_rpath(self, pkg, pkgfile_path, path):
397400
def _check_library_dependency(self, pkg, pkgfile_path, path):
398401
if self.is_archive:
399402
return
400-
if path.startswith('/lib/modules/'):
403+
elif path.startswith('/lib/modules/'):
404+
return
405+
elif self.is_go_elf:
401406
return
402407

403408
dyn_section = self.readelf_parser.dynamic_section_info
@@ -510,6 +515,7 @@ def _detect_attributes(self, magic):
510515
self.is_archive = 'current ar archive' in magic
511516
self.is_dynamically_linked = 'dynamically linked' in magic
512517
self.is_pie_exec = 'pie executable' in magic
518+
self.is_go_elf = False
513519

514520
def run_elf_checks(self, pkg, pkgfile_path, path):
515521
if self.is_archive and not self._is_standard_archive(pkg, pkgfile_path, path):
@@ -521,6 +527,13 @@ def run_elf_checks(self, pkg, pkgfile_path, path):
521527
self.output.add_info('E', pkg, 'readelf-failed', path, failed_reason)
522528
return
523529

530+
# Detect go binary
531+
for elf_file in self.readelf_parser.section_info.elf_files:
532+
for section in elf_file:
533+
if section.name == '.note.go.buildid':
534+
self.is_go_elf = True
535+
break
536+
524537
if not self.is_archive:
525538
if self.is_dynamically_linked:
526539
is_installed_pkg = isinstance(pkg, InstalledPkg) or isinstance(pkg, FakePkg)
513 KB
Binary file not shown.

test/test_binaries.py

+8
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,11 @@ def test_dependency_information(tmpdir, package, binariescheck):
264264
out = output.print_results(output.results)
265265
assert 'E: shared-library-without-dependency-information /usr/lib64/ruby/enc/gb2312.so' in out
266266
assert 'W: library-not-linked-against-libc /usr/lib64/ruby/continuation.so' in out
267+
268+
269+
@pytest.mark.parametrize('package', ['binary/go-package'])
270+
def test_go_package(tmpdir, package, binariescheck):
271+
output, test = binariescheck
272+
test.check(get_tested_package(package, tmpdir))
273+
out = output.print_results(output.results)
274+
assert not out

0 commit comments

Comments
 (0)