Skip to content

Commit 9a7df2c

Browse files
Add more license rules and fix test failures
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 2751fec commit 9a7df2c

File tree

8 files changed

+171
-50
lines changed

8 files changed

+171
-50
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
is_false_positive: yes
3+
notes: haha
4+
---
5+
6+
sizeof(license) - 1) < 0)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
is_false_positive: yes
3+
notes: haha
4+
---
5+
6+
license[sizeof(license) - 1] = 0;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
license_expression: gpl-2.0-plus
3+
is_license_tag: yes
4+
---
5+
6+
MODULE_LICENSE("GPL"); /* Actually dual-licensed, but it doesn't matter for */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
license_expression: gpl-2.0
3+
is_license_notice: yes
4+
---
5+
6+
and used with permission.
7+
*
8+
*
9+
* This program is free software; you can redistribute it and/or modify
10+
* it under the terms of the {{GNU General Public License version 2}} as
11+
* published by the Free Software Foundation. See README and COPYING for
12+
* more details.
13+
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
license_expression: unknown-license-reference
3+
is_license_intro: yes
4+
---
5+
6+
Permission to use code in the Developer's manual was granted
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
license_expressions:
22
- gpl-2.0
3+
- gpl-2.0
4+
- gpl-2.0

tests/licensedcode/data/plugin_license/scan/ffmpeg-license.expected.json

Lines changed: 131 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,47 @@
8282
}
8383
]
8484
},
85+
{
86+
"identifier": "gpl_2_0_and_lgpl_2_0_plus-e597690d-3d55-0948-8697-914f460389e8",
87+
"license_expression": "gpl-2.0 AND lgpl-2.0-plus",
88+
"license_expression_spdx": "GPL-2.0-only AND LGPL-2.0-or-later",
89+
"detection_count": 1,
90+
"detection_log": [],
91+
"reference_matches": [
92+
{
93+
"license_expression": "gpl-2.0",
94+
"license_expression_spdx": "GPL-2.0-only",
95+
"from_file": "ffmpeg-LICENSE.md",
96+
"start_line": 100,
97+
"end_line": 100,
98+
"matcher": "2-aho",
99+
"score": 100.0,
100+
"matched_length": 1,
101+
"match_coverage": 100.0,
102+
"rule_relevance": 100,
103+
"rule_identifier": "gpl-2.0_bare_single_word.RULE",
104+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE",
105+
"matched_text": "are incompatible with the GPLv2 and v3. We do not know for certain if their",
106+
"matched_text_diagnostics": "GPLv2"
107+
},
108+
{
109+
"license_expression": "lgpl-2.0-plus",
110+
"license_expression_spdx": "LGPL-2.0-or-later",
111+
"from_file": "ffmpeg-LICENSE.md",
112+
"start_line": 101,
113+
"end_line": 101,
114+
"matcher": "2-aho",
115+
"score": 60.0,
116+
"matched_length": 1,
117+
"match_coverage": 100.0,
118+
"rule_relevance": 60,
119+
"rule_identifier": "lgpl_bare_single_word.RULE",
120+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
121+
"matched_text": "licenses are compatible with the LGPL.",
122+
"matched_text_diagnostics": "LGPL."
123+
}
124+
]
125+
},
85126
{
86127
"identifier": "ijg_and_mit-e50613dc-8a09-65cc-c498-5d9527795382",
87128
"license_expression": "ijg AND mit",
@@ -141,6 +182,31 @@
141182
}
142183
]
143184
},
185+
{
186+
"identifier": "lgpl_2_0_plus-e66c5b24-33ce-ea1b-0e3b-28952361ec32",
187+
"license_expression": "lgpl-2.0-plus",
188+
"license_expression_spdx": "LGPL-2.0-or-later",
189+
"detection_count": 1,
190+
"detection_log": [],
191+
"reference_matches": [
192+
{
193+
"license_expression": "lgpl-2.0-plus",
194+
"license_expression_spdx": "LGPL-2.0-or-later",
195+
"from_file": "ffmpeg-LICENSE.md",
196+
"start_line": 104,
197+
"end_line": 104,
198+
"matcher": "2-aho",
199+
"score": 60.0,
200+
"matched_length": 1,
201+
"match_coverage": 100.0,
202+
"rule_relevance": 60,
203+
"rule_identifier": "lgpl_bare_single_word.RULE",
204+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
205+
"matched_text": "be under a complex license mix that is more restrictive than the LGPL and that",
206+
"matched_text_diagnostics": "LGPL"
207+
}
208+
]
209+
},
144210
{
145211
"identifier": "lgpl_2_1_plus_and_other_permissive_and_gpl_2_0_plus-666058ef-8c38-3b17-d8e7-448b304de833",
146212
"license_expression": "lgpl-2.1-plus AND other-permissive AND gpl-2.0-plus",
@@ -228,8 +294,8 @@
228294
{
229295
"path": "ffmpeg-LICENSE.md",
230296
"type": "file",
231-
"detected_license_expression": "(lgpl-2.1-plus AND other-permissive AND gpl-2.0-plus) AND (lgpl-3.0 AND lgpl-3.0-plus AND (lgpl-3.0 AND gpl-3.0)) AND (ijg AND mit) AND gpl-1.0-plus AND (gpl-2.0 AND apache-2.0 AND lgpl-3.0-plus)",
232-
"detected_license_expression_spdx": "(LGPL-2.1-or-later AND LicenseRef-scancode-other-permissive AND GPL-2.0-or-later) AND (LGPL-3.0-only AND LGPL-3.0-or-later AND (LGPL-3.0-only AND GPL-3.0-only)) AND (IJG AND MIT) AND GPL-1.0-or-later AND (GPL-2.0-only AND Apache-2.0 AND LGPL-3.0-or-later)",
297+
"detected_license_expression": "(lgpl-2.1-plus AND other-permissive AND gpl-2.0-plus) AND (lgpl-3.0 AND lgpl-3.0-plus AND (lgpl-3.0 AND gpl-3.0)) AND (ijg AND mit) AND gpl-1.0-plus AND (gpl-2.0 AND apache-2.0 AND lgpl-3.0-plus) AND (gpl-2.0 AND lgpl-2.0-plus) AND lgpl-2.0-plus",
298+
"detected_license_expression_spdx": "(LGPL-2.1-or-later AND LicenseRef-scancode-other-permissive AND GPL-2.0-or-later) AND (LGPL-3.0-only AND LGPL-3.0-or-later AND (LGPL-3.0-only AND GPL-3.0-only)) AND (IJG AND MIT) AND GPL-1.0-or-later AND (GPL-2.0-only AND Apache-2.0 AND LGPL-3.0-or-later) AND (GPL-2.0-only AND LGPL-2.0-or-later) AND LGPL-2.0-or-later",
233299
"license_detections": [
234300
{
235301
"license_expression": "lgpl-2.1-plus AND other-permissive AND gpl-2.0-plus",
@@ -448,41 +514,73 @@
448514
],
449515
"detection_log": [],
450516
"identifier": "gpl_2_0_and_apache_2_0_and_lgpl_3_0_plus-c2393e5a-e531-304f-58a9-a6431d46d214"
451-
}
452-
],
453-
"license_clues": [
517+
},
454518
{
455-
"license_expression": "gpl-2.0",
456-
"spdx_license_expression": "GPL-2.0-only",
457-
"from_file": "ffmpeg-LICENSE.md",
458-
"start_line": 100,
459-
"end_line": 100,
460-
"matcher": "2-aho",
461-
"score": 100.0,
462-
"matched_length": 1,
463-
"match_coverage": 100.0,
464-
"rule_relevance": 100,
465-
"rule_identifier": "gpl-2.0_bare_single_word.RULE",
466-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE",
467-
"matched_text": "are incompatible with the GPLv2 and v3. We do not know for certain if their",
468-
"matched_text_diagnostics": "GPLv2"
519+
"license_expression": "gpl-2.0 AND lgpl-2.0-plus",
520+
"license_expression_spdx": "GPL-2.0-only AND LGPL-2.0-or-later",
521+
"matches": [
522+
{
523+
"license_expression": "gpl-2.0",
524+
"spdx_license_expression": "GPL-2.0-only",
525+
"from_file": "ffmpeg-LICENSE.md",
526+
"start_line": 100,
527+
"end_line": 100,
528+
"matcher": "2-aho",
529+
"score": 100.0,
530+
"matched_length": 1,
531+
"match_coverage": 100.0,
532+
"rule_relevance": 100,
533+
"rule_identifier": "gpl-2.0_bare_single_word.RULE",
534+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE",
535+
"matched_text": "are incompatible with the GPLv2 and v3. We do not know for certain if their",
536+
"matched_text_diagnostics": "GPLv2"
537+
},
538+
{
539+
"license_expression": "lgpl-2.0-plus",
540+
"spdx_license_expression": "LGPL-2.0-or-later",
541+
"from_file": "ffmpeg-LICENSE.md",
542+
"start_line": 101,
543+
"end_line": 101,
544+
"matcher": "2-aho",
545+
"score": 60.0,
546+
"matched_length": 1,
547+
"match_coverage": 100.0,
548+
"rule_relevance": 60,
549+
"rule_identifier": "lgpl_bare_single_word.RULE",
550+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
551+
"matched_text": "licenses are compatible with the LGPL.",
552+
"matched_text_diagnostics": "LGPL."
553+
}
554+
],
555+
"detection_log": [],
556+
"identifier": "gpl_2_0_and_lgpl_2_0_plus-e597690d-3d55-0948-8697-914f460389e8"
469557
},
470558
{
471559
"license_expression": "lgpl-2.0-plus",
472-
"spdx_license_expression": "LGPL-2.0-or-later",
473-
"from_file": "ffmpeg-LICENSE.md",
474-
"start_line": 101,
475-
"end_line": 101,
476-
"matcher": "2-aho",
477-
"score": 75.0,
478-
"matched_length": 1,
479-
"match_coverage": 100.0,
480-
"rule_relevance": 75,
481-
"rule_identifier": "lgpl_bare_single_word.RULE",
482-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
483-
"matched_text": "licenses are compatible with the LGPL.",
484-
"matched_text_diagnostics": "LGPL."
485-
},
560+
"license_expression_spdx": "LGPL-2.0-or-later",
561+
"matches": [
562+
{
563+
"license_expression": "lgpl-2.0-plus",
564+
"spdx_license_expression": "LGPL-2.0-or-later",
565+
"from_file": "ffmpeg-LICENSE.md",
566+
"start_line": 104,
567+
"end_line": 104,
568+
"matcher": "2-aho",
569+
"score": 60.0,
570+
"matched_length": 1,
571+
"match_coverage": 100.0,
572+
"rule_relevance": 60,
573+
"rule_identifier": "lgpl_bare_single_word.RULE",
574+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
575+
"matched_text": "be under a complex license mix that is more restrictive than the LGPL and that",
576+
"matched_text_diagnostics": "LGPL"
577+
}
578+
],
579+
"detection_log": [],
580+
"identifier": "lgpl_2_0_plus-e66c5b24-33ce-ea1b-0e3b-28952361ec32"
581+
}
582+
],
583+
"license_clues": [
486584
{
487585
"license_expression": "proprietary-license",
488586
"spdx_license_expression": "LicenseRef-scancode-proprietary-license",
@@ -498,22 +596,6 @@
498596
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/proprietary-license_490.RULE",
499597
"matched_text": "If you wish to enable these libraries, pass --enable-nonfree to configure.",
500598
"matched_text_diagnostics": "enable-nonfree"
501-
},
502-
{
503-
"license_expression": "lgpl-2.0-plus",
504-
"spdx_license_expression": "LGPL-2.0-or-later",
505-
"from_file": "ffmpeg-LICENSE.md",
506-
"start_line": 104,
507-
"end_line": 104,
508-
"matcher": "2-aho",
509-
"score": 75.0,
510-
"matched_length": 1,
511-
"match_coverage": 100.0,
512-
"rule_relevance": 75,
513-
"rule_identifier": "lgpl_bare_single_word.RULE",
514-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl_bare_single_word.RULE",
515-
"matched_text": "be under a complex license mix that is more restrictive than the LGPL and that",
516-
"matched_text_diagnostics": "LGPL"
517599
}
518600
],
519601
"percentage_of_license_text": 34.78,

tests/licensedcode/test_detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ def test_match_has_correct_line_positions_in_automake_perl_file(self):
10621062
# detected, match.lines(), match.qspan,
10631063
('gpl-2.0-plus', (12, 25), Span(48, 157)),
10641064
('fsf-unlimited-no-warranty', (231, 238), Span(964, 1027)),
1065-
('warranty-disclaimer', (306, 307), Span(1335, 1357)),
1065+
('warranty-disclaimer', (306, 307), Span(1336, 1358)),
10661066
]
10671067
self.check_position('positions/automake.pl', expected)
10681068

0 commit comments

Comments
 (0)