Repository navigation
Open
Labels
Description
Description
This code snippet:
/*
* Simple square root algorithm. This is from:
* http://stackoverflow.com/questions/1623375/writing-your-own-square-root-function
* Written by Chihung Yu
* Creative Commons license
* http://creativecommons.org/licenses/by-sa/3.0/legalcode
* It has been modified to compile correctly, and for U-Boot style.
*/
static double tt_sqrt(double value)
{
double lo = 1.0;
double hi = value;
while (hi - lo > 0.00001) {
double mid = lo + (hi - lo) / 2;
if (mid * mid - value > 0.00001)
hi = mid;
else
lo = mid;
}
return lo;
}
from https://github.com/Xilinx/u-boot-xlnx/blob/3290b109bfa70d65ed4ce49ed84afed0ed4335e0/drivers/video/console_truetype.c#L39 gets detected as CC-BY-NC-SA-3.0 instead of CC-BY-SA-3.0
How To Reproduce
user@laptop:~$ scancode --license --copyright --json-pp uboot-test.json ./drivers/video/console_truetype.cI have tested it also with the patches from #3644, but it does not fix the issue.
Logs
Log Snippet with SCANCODE_DEBUG_LICENSE=True:
LicenseMatch: 'cc-by-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-3.0_23.RULE, sc=54.55, cov=54.55, len=6, hilen=3, rlen=11, qreg=(87, 92), ireg=(1, 8)
...
LicenseMatch: 'cc-by-nc-sa-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-nc-sa-3.0_23.RULE, sc=54.55, cov=54.55, len=12, hilen=4, rlen=22, qreg=(85, 96), ireg=(3, 21)
...
LicenseMatch: 'cc-by-sa-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-sa-3.0_1.RULE, sc=100.0, cov=100.0, len=8, hilen=2, rlen=8, qreg=(88, 95), ireg=(0, 7)
...
matches before final merge: 2
matches before final merge MATCHED TEXTS
LicenseMatch: 'cc-by-nc-sa-3.0', lines=(43, 44), matcher='3-seq', rid=cc-by-nc-sa-3.0_23.RULE, sc=54.55, cov=54.55, len=12, hilen=4, rlen=22, qreg=(85, 96), ireg=(3, 21)
MATCHED QUERY TEXT: Creative Commons license *
http://creativecommons.org/licenses/by-sa/3.0/legalcode
MATCHED RULE TEXT: creative commons license <attribution> <noncommercial> <sharealike> <3> <0>
<unported> http creativecommons org licenses by <nc> sa 3 0 legalcode
LicenseMatch: 'gpl-2.0-plus', lines=(4, 4), matcher='1-spdx-id', rid=spdx-license-identifier-gpl_2_0_plus-6a7800b229dd3f061ec9f8deeaf5fc1cd1310d8d, sc=100.0, cov=100.0, len=6, hilen=3, rlen=6, qreg=(5, 10), ireg=(0, 5)
MATCHED QUERY TEXT: SPDX-License-Identifier: GPL-2.0+
MATCHED RULE TEXT: spdx license identifier gpl 2 0+
final matches: 2
final matches MATCHED TEXTS
LicenseMatch: 'gpl-2.0-plus', lines=(4, 4), matcher='1-spdx-id', rid=spdx-license-identifier-gpl_2_0_plus-6a7800b229dd3f061ec9f8deeaf5fc1cd1310d8d, sc=100.0, cov=100.0, len=6, hilen=3, rlen=6, qreg=(5, 10), ireg=(0, 5)
MATCHED QUERY TEXT: SPDX-License-Identifier: GPL-2.0+
MATCHED RULE TEXT: spdx license identifier gpl 2 0+
LicenseMatch: 'cc-by-nc-sa-3.0', lines=(43, 44), matcher='3-seq', rid=cc-by-nc-sa-3.0_23.RULE, sc=54.55, cov=54.55, len=12, hilen=4, rlen=22, qreg=(85, 96), ireg=(3, 21)
MATCHED QUERY TEXT: Creative Commons license *
http://creativecommons.org/licenses/by-sa/3.0/legalcode
MATCHED RULE TEXT: creative commons license <attribution> <noncommercial> <sharealike> <3> <0>
<unported> http creativecommons org licenses by <nc> sa 3 0 legalcode
How do I need to interpret the log output? Is the token <nc> of the URL optional here? Why is the match for src/licensedcode/data/rules/cc-by-3.0_1.RULE with 100% cov not considered?
System configuration
- OS: Linux (openSUSE 15.5)
- scancode-toolkit version: 32.0.8
- Installation Method: pip and source from git
Activity
pombredanne commentedon Mar 20, 2024
Thanks for the report!
The in angle brackets is for words from the rules that were NOT matched.
All the license matching is word-based (actually each word is mapped to an integer internally and we manipulate sequences of ints)
It is shorter and contained in another match. Let me explain what happens.
You get these three matches:
Match 1: LicenseMatch: 'cc-by-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-3.0_23.RULE, sc=54.55, cov=54.55, len=6, hilen=3, rlen=11, qreg=(87, 92), ireg=(1, 8)
Match 2: LicenseMatch: 'cc-by-nc-sa-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-nc-sa-3.0_23.RULE, sc=54.55, cov=54.55, len=12, hilen=4, rlen=22, qreg=(85, 96), ireg=(3, 21)
Match 3: LicenseMatch: 'cc-by-sa-3.0', lines=(0, 0), matcher='3-seq', rid=cc-by-sa-3.0_1.RULE, sc=100.0, cov=100.0, len=8, hilen=2, rlen=8, qreg=(88, 95), ireg=(0, 7)
The Match 1 attributes are:
Here is what happens:
FWIW, this is something @AyanSinhaMahapatra is working on to massively fix likely with #3254
In the meantime the fix is going to be like in #3644
The faulty rule is https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/cc-by-nc-sa-3.0_23.RULE and the cure will be to add required phrases and may be a new rule.
cc-by-sa-3.0with this text.jloehel commentedon Mar 21, 2024
Hi @pombredanne,
Thank you very much for the detailed explanation. It helps a lot to understand what's going on. I have tried the suggested quick fix:
But I still get this output (
❯ cat uboot-test.json | jq '.files'):[ { "path": "console_truetype.c", "type": "file", "detected_license_expression": "gpl-2.0-plus", "detected_license_expression_spdx": "GPL-2.0-or-later", "license_detections": [ { "license_expression": "gpl-2.0-plus", "license_expression_spdx": "GPL-2.0-or-later", "matches": [ { "license_expression": "gpl-2.0-plus", "spdx_license_expression": "GPL-2.0-or-later", "from_file": "console_truetype.c", "start_line": 4, "end_line": 4, "matcher": "1-spdx-id", "score": 100, "matched_length": 6, "match_coverage": 100, "rule_relevance": 100, "rule_identifier": "spdx-license-identifier-gpl_2_0_plus-6a7800b229dd3f061ec9f8deeaf5fc1cd1310d8d", "rule_url": null } ], "identifier": "gpl_2_0_plus-1dbf5e2e-83b4-624b-6a02-72ea175258bd" } ], "license_clues": [ { "license_expression": "cc-by-nc-sa-3.0", "spdx_license_expression": "CC-BY-NC-SA-3.0", "from_file": "console_truetype.c", "start_line": 43, "end_line": 44, "matcher": "3-seq", "score": 54.55, "matched_length": 12, "match_coverage": 54.55, "rule_relevance": 100, "rule_identifier": "cc-by-nc-sa-3.0_23.RULE", "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/cc-by-nc-sa-3.0_23.RULE" } ], "percentage_of_license_text": 0.83, "copyrights": [ { "copyright": "Copyright (c) 2016 Google, Inc", "start_line": 2, "end_line": 2 } ], "holders": [ { "holder": "Google, Inc", "start_line": 2, "end_line": 2 } ], "authors": [ { "author": "Chihung Yu Creative", "start_line": 42, "end_line": 43 } ], "scan_errors": [] } ]I will add the full log here:
Is it necessary to clear some cache?
pombredanne commentedon Mar 22, 2024
Yes, you need to regen the index with
scancode-reindex-licenses. It used to be automated in the past but manual control is much simpler, because cache invalidation is not a simple thing to get right all the times.Quick fix for aboutcode-org#3703
jloehel commentedon Nov 28, 2024
@pombredanne Hi :-) Can you pls give me a quick update about the PR #3924. Will you merge the PR soon?
Quick fix for aboutcode-org#3703
Quick fix for aboutcode-org#3703