Skip to content

The --license-text does not work as expected (for JSON output) #504

Description

@sschuberth

I would expect the --license-text option to put the full license text as defined by the start and end lines into the JSON result file. However, it seems this option only adds a key called matched_text which only contains the excerpt of the license text that triggered the match. See e.g. this result from scanning re2's BUILD file:

  "licenses": [
    {
      "key": "bsd-new",
      "score": 92.31,
      "short_name": "BSD-Modified",
      "category": "Permissive",
      "owner": "Regents of the University of California",
      "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause",
      "text_url": "",
      "dejacode_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new",
      "spdx_license_key": "BSD-3-Clause",
      "spdx_url": "http://spdx.org/licenses/BSD-3-Clause",
      "start_line": 1,
      "end_line": 3,
      "matched_rule": {
        "identifier": "bsd-new_25.RULE",
        "license_choice": false,
        "licenses": [
          "bsd-new"
        ],
        "matcher": "3-seq",
        "rule_length": 26,
        "matched_length": 24,
        "match_coverage": 92.31,
        "rule_relevance": 100
      },
      "matched_text": "Authors.  All Rights Reserved.\n# Use of this source code is governed by a BSD-style\n# license that can be found in the LICENSE file"
    }

In this example, I would have expected matched_text to contain "# Copyright 2009 The RE2 Authors. All Rights Reserved.\n# Use of this source code is governed by a BSD-style\n# license that can be found in the LICENSE file." (also note the trailing dot at the end of the sentence here).

Also, matched_text seems to be defined at the wrong level. As it's value should be defined by the contents of the file from start_line to end_line, it should also be defined at the level of start_line / end_line.

If changing the semantics of matched_text is not possibe for compatibility reasons, I'd suggest to create a new key called license_text listed directly after end_line containing the specified lines of the scanned file.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions