Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failed to scan RPM #3489

@pombredanne

Description

@pombredanne

Reported by @chinyeungli

Using http://mirror.centos.org/centos/7/os/x86_64/Packages/apache-commons-io-2.4-12.el7.noarch.rpm

$ SCANCODE_DEBUG_PACKAGE_API=yes  scancode -p apache-commons-io-2.4-12.el7.noarch.rpm --yaml  -
Setup plugins...
Collect file inventory...
Scan files for: packages with 1 process(es)...
[--------------------] 0_parse:.is_datafile: /home/pombreda/w421/scancode.io/apache-commons-io-2.4-12.el7.noarch.rpm
[####################] 2                                                 
headers:
    -   tool_name: scancode-toolkit
        tool_version: 32.0.6
        options:
            input:
                - apache-commons-io-2.4-12.el7.noarch.rpm
            --package: yes
            --yaml: '-'
        notice: |
            Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
            OR CONDITIONS OF ANY KIND, either express or implied. No content created from
            ScanCode should be considered or used as legal advice. Consult an Attorney
            for any legal advice.
            ScanCode is a free software code scanning tool from nexB Inc. and others.
            Visit https://github.com/nexB/scancode-toolkit/ for support and download.
        start_timestamp: '2023-08-16T083251.861239'
        end_timestamp: '2023-08-16T083256.129079'
        output_format_version: 3.0.0
        duration: '4.267852544784546'
        message:
        errors:
            - 'Path: apache-commons-io-2.4-12.el7.noarch.rpm'
        warnings: []
        extra_data:
            system_environment:
                operating_system: linux
                cpu_architecture: 64
                platform: Linux-4.15.0-214-generic-x86_64-with-glibc2.23
                platform_version: '#225~16.04.1-Ubuntu SMP Mon Jul 17 10:25:38 UTC 2023'
                python_version: "3.9.10 (main, Jan 29 2022, 10:01:49) \n[GCC 5.4.0 20160609]"
            spdx_license_list_version: '3.21'
            files_count: 1
packages: []
dependencies: []
files:
    -   path: apache-commons-io-2.4-12.el7.noarch.rpm
        type: file
        package_data: []
        for_packages: []
        scan_errors:
            - |
                ERROR: for scanner: packages:
                ERROR: Unknown error:
                Traceback (most recent call last):
                  File "/scancode-toolkit/scancode/interrupt.py", line 91, in interruptible
                    return NO_ERROR, func(*(args or ()), **(kwargs or {}))
                  File "/scancode-toolkit/scancode/api.py", line 303, in get_package_data
                    package_datas = _get_package_data(
                  File "/scancode-toolkit/scancode/api.py", line 261, in _get_package_data
                    return recognize_package_data(
                  File "/scancode-toolkit/packagedcode/recognize.py", line 66, in recognize_package_data
                    return list(_parse(location, datafile_handlers=datafile_handlers))
                  File "/scancode-toolkit/packagedcode/recognize.py", line 88, in _parse
                    for parsed in handler.parse(location):
                  File "/scancode-toolkit/packagedcode/rpm.py", line 289, in parse
                    evr = EVR(
                  File "/scancode-toolkit/packagedcode/rpm.py", line 99, in __new__
                    if epoch and epoch.strip() and not epoch.isdigit():
                AttributeError: 'int' object has no attribute 'strip'

Scanning done.
Some files failed to scan properly:
Path: apache-commons-io-2.4-12.el7.noarch.rpm
Summary:        packages with 1 process(es)
Errors count:   1
Scan Speed:     10.25 files/sec. 
Initial counts: 1 resource(s): 1 file(s) and 0 directorie(s) 
Final counts:   1 resource(s): 1 file(s) and 0 directorie(s) 
Timings:
  scan_start: 2023-08-16T083251.861239
  scan_end:   2023-08-16T083256.129079
  setup_scan:licenses: 4.13s
  setup: 4.13s
  total: 4.28s

The issue is with this code:

 if epoch and epoch.strip() and not epoch.isdigit():

it should be more or less

if epoch and not isinstance(epoch, int):
    if isinstance(epoch, str) and epoch.strip() and not epoch.isdigit():

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions