Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LicenseRef-scancode-proprietary-license is reported for correct BSD3-Clause #3922

Open
bilbothebaggins opened this issue Sep 16, 2024 · 2 comments

Comments

@bilbothebaggins
Copy link

Description

I am scanning a textual version of https://licenses.nuget.org/BSD-3-Clause and I'm getting a proprietary-license hit!

How To Reproduce

Scan Text File:

BSD 3-Clause "New" or "Revised" License

SPDX identifier
BSD-3-Clause

License text

Copyright (c) <year> <owner>.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

with this command:

...\scancode.bat -lci --license-text --json-pp here.json .
scancode.bat --version
ScanCode version: 32.1.0
ScanCode Output Format version: 3.1.0
SPDX License list version: 3.23

This results in:

        {
          "license_expression": "proprietary-license",
          "license_expression_spdx": "LicenseRef-scancode-proprietary-license",
          "from_file": "https___licenses.nuget.org_BSD-3-Clause/LICENSE.downloaded",
          "start_line": 4,
          "end_line": 16,
          "matcher": "3-seq",
          "score": 99.1,
          "matched_length": 219,
          "match_coverage": 99.1,
          "rule_relevance": 100,
          "rule_identifier": "proprietary-license_890.RULE",
          "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/proprietary-license_890.RULE",
          "matched_text": "BSD-3-Clause\r\n\r\nLicense text\r\n\r\nCopyright (c) <year> <owner>.\r\n\r\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\r\n\r\n    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\r\n    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\r\n    3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
        }

where clearly the rule https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/licensedcode/data/rules/proprietary-license_890.RULE should not actually match. NO "not permitted" as far as I can see.

Maybe the "minimum_coverage: 99" in the rule is the problem, when the only difference is the "not" ?

Thanks.

@bilbothebaggins
Copy link
Author

I suspect the problem here is that the rule text is much too long.
It does not need to hit the whole of a BSD-3 like license. I think it would be sufficient to match for the "inverted" paragraph:

---
license_expression: proprietary-license
is_license_text: yes
minimum_coverage: 99 ??
notes: ... note the "not permitted"
---

Redistribution and use in source and binary forms, with or without
modification, are not permitted provided that the following condition are met:

(note the not)

AyanSinhaMahapatra added a commit that referenced this issue Sep 16, 2024
Reference: #3922
Reported-by: Martin Ba @bilbothebaggins
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
@AyanSinhaMahapatra
Copy link
Member

AyanSinhaMahapatra commented Sep 16, 2024

@bilbothebaggins Thanks for the report.

I ran the same scan with SCTK latest (v32.2.1 in contrast to your v32.1) and this seems to be fixed there as I do not get any wrong match there, attaching the result file here for your review:

  "files": [
    {
      "path": "text",
      "type": "file",
      "detected_license_expression": "bsd-new",
      "detected_license_expression_spdx": "BSD-3-Clause",
      "license_detections": [
        {
          "license_expression": "bsd-new",
          "license_expression_spdx": "BSD-3-Clause",
          "matches": [
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 2,
              "end_line": 2,
              "matcher": "2-aho",
              "score": 38.0,
              "matched_length": 7,
              "match_coverage": 100.0,
              "rule_relevance": 38,
              "rule_identifier": "bsd-new_1083.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1083.RULE",
              "matched_text": "BSD 3-Clause \"New\" or \"Revised\" License",
              "matched_text_diagnostics": "BSD 3-Clause \"New\" or \"Revised\" License"
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 4,
              "end_line": 5,
              "matcher": "2-aho",
              "score": 100.0,
              "matched_length": 4,
              "match_coverage": 100.0,
              "rule_relevance": 100,
              "rule_identifier": "bsd-new_360.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_360.RULE",
              "matched_text": "BSD-3-Clause\nLicense",
              "matched_text_diagnostics": "BSD-3-Clause\nLicense"
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 9,
              "end_line": 15,
              "matcher": "2-aho",
              "score": 100.0,
              "matched_length": 216,
              "match_coverage": 100.0,
              "rule_relevance": 100,
              "rule_identifier": "bsd-new_105.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_105.RULE",
              "matched_text": "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n    3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
              "matched_text_diagnostics": "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n    3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 18,
              "end_line": 18,
              "matcher": "2-aho",
              "score": 100.0,
              "matched_length": 6,
              "match_coverage": 100.0,
              "rule_relevance": 100,
              "rule_identifier": "edl-1.0_1.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/edl-1.0_1.RULE",
              "matched_text": "Eclipse Distribution License - v 1.0 (",
              "matched_text_diagnostics": "Eclipse Distribution License - v 1.0 ("
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 18,
              "end_line": 18,
              "matcher": "2-aho",
              "score": 99.0,
              "matched_length": 3,
              "match_coverage": 100.0,
              "rule_relevance": 99,
              "rule_identifier": "bsd-new_919.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_919.RULE",
              "matched_text": "EDL 1.0)",
              "matched_text_diagnostics": "EDL 1.0)"
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 18,
              "end_line": 18,
              "matcher": "2-aho",
              "score": 100.0,
              "matched_length": 3,
              "match_coverage": 100.0,
              "rule_relevance": 100,
              "rule_identifier": "bsd-new_10.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_10.RULE",
              "matched_text": "BSD-3-Clause,",
              "matched_text_diagnostics": "BSD-3-Clause,"
            },
            {
              "license_expression": "bsd-new",
              "spdx_license_expression": "BSD-3-Clause",
              "from_file": "text",
              "start_line": 21,
              "end_line": 21,
              "matcher": "2-aho",
              "score": 95.0,
              "matched_length": 8,
              "match_coverage": 100.0,
              "rule_relevance": 95,
              "rule_identifier": "bsd-new_url_2.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_url_2.RULE",
              "matched_text": "https://spdx.org/licenses/BSD-3-Clause.html",
              "matched_text_diagnostics": "https://spdx.org/licenses/BSD-3-Clause.html"
            }
          ],
          "detection_log": [],
          "identifier": "bsd_new-16f16531-d8ef-1af3-a09b-585144d3122e"
        }
      ],
      "license_clues": [],[],
      "percentage_of_license_text": 82.06,
      "scan_errors": []
    }
  ]

nuget.org.bsd.json.txt

Moreover, I'm also adjusting a couple rules to avoid similar issues:

  • Adding a required phrase at proprietary-license_890.RULE
  • Adjusting the relevance of and add a required phrase at bsd-new_1083.RULE so the score is not low anymore

Required phrases in rules are words which are required to be present and matched to match with that rule, this reduces false positives in approximate detections. Some work is also ongoing at #3254 do mark required phrases across all rules automatically, to reduce false positive detections like this in SCTK.

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

No branches or pull requests

2 participants