Skip to content

Npm package scan bug: cant handle 'dist' field being a string #1026

Description

@steven-esser

Originally reported in #1019

When running a package scan on certain npm packages, the following error occurs:

{
  "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
  "scancode_version": "2.9.1.post25.2212cb68b",
  "scancode_options": {
    "input": "case-sensitive-paths-webpack-plugin/demo/package.json",
    "--json-pp": "/Users/sesser/dump.json",
    "--package": true
  },
  "files_count": 1,
  "files": [
    {
      "path": "package.json",
      "type": "file",
      "packages": [],
      "scan_errors": [
        "ERROR: for scanner: packages:\nERROR: Unknown error:\nTraceback (most recent call last):\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/scancode/interrupt.py\", line 91, in interruptible\n    return NO_ERROR, func(*(args or ()), **(kwargs or {}))\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/scancode/api.py\", line 192, in get_package_info\n    package = recognize_package(location)\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/packagedcode/recognize.py\", line 77, in recognize_package\n    return package_type.recognize(location)\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/packagedcode/npm.py\", line 68, in recognize\n    return parse(location)\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/packagedcode/npm.py\", line 94, in parse\n    return build_package(package_data, base_dir, metafile_name)\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/packagedcode/npm.py\", line 158, in build_package\n    func(value, package)\n  File \"/Users/sesser/Code/nexB/scancode-toolkit/src/packagedcode/npm.py\", line 358, in dist_mapper\n    package.download_sha1 = dist.get('shasum') or None\nAttributeError: 'unicode' object has no attribute 'get'\n"
      ]
    }
  ]
}

This is due to the 'dist' field being a string, instead of a single entity (dictionary).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions