Skip to content

Commit e72110b

Browse files
authored
Merge pull request #3163 from nexB/3162-wurfl-license
Detect wurfl commercial license
2 parents d64acdd + 2ec4f63 commit e72110b

File tree

12 files changed

+91
-29
lines changed

12 files changed

+91
-29
lines changed

etc/scripts/licenses/buildrules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def load_data(location="00-new-licenses.txt"):
7979
Load rules metadata and text from file at ``location``. Return a list of
8080
RuleData.
8181
"""
82-
with io.open(location, encoding="utf-8") as o:
82+
with open(location) as o:
8383
lines = o.read().splitlines(False)
8484

8585
rules = []
@@ -262,7 +262,7 @@ def cli(licenses_file):
262262
print(existing_msg.format(**locals()))
263263
continue
264264
else:
265-
print(f"Adding new rule: {identifier}")
265+
print(f"Adding new rule: file://{identifier}")
266266
rl = models.update_ignorables(rulerec, verbose=False)
267267
rl.dump(rules_data_dir=models.rules_data_dir)
268268

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
5+
---
6+
7+
This software package is the property of ScientiaMobile Inc. and is licensed
8+
commercially according to a contract between the Licensee and ScientiaMobile Inc. (Licensor).
9+
If you represent the Licensee, please refer to the licensing agreement which has been signed
10+
between the two parties. If you do not represent the Licensee, you are not authorized to use
11+
this software in any way.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
software package is the property
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
licensed commercially
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
licensed commercially according to a contract
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
refer to the licensing agreement which has been signed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
you are not authorized to use this software in any way.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
license_expression: commercial-license
3+
is_license_notice: yes
4+
relevance: 100
5+
notes: Seen in wurfl.h https://github.com/haproxy/haproxy/commit/cd9b9bd3e47cb2814eaab6c07d1facf222f013a9#diff-be9afa6e330d524179c2f689a4858fd7645bb3d1f05e54871b962f829f2580e8
6+
---
7+
8+
not authorized to use this software

src/licensedcode/models.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -425,20 +425,13 @@ def dump(self, licenses_data_dir):
425425
- the license data as YAML frontmatter
426426
- the license text
427427
"""
428-
429-
def write(location, byte_string):
430-
# we write as binary because rules and licenses texts and data are
431-
# UTF-8-encoded bytes
432-
with io.open(location, 'wb') as of:
433-
of.write(byte_string)
434-
435428
metadata = self.to_dict()
436-
content = self.text.encode('utf-8')
429+
content = self.text
437430
rule_post = FrontmatterPost(content=content, handler=SaneYAMLHandler(), **metadata)
438-
output_string = dumps_frontmatter(post=rule_post)
439-
431+
output = dumps_frontmatter(post=rule_post)
440432
license_file = self.license_file(licenses_data_dir=licenses_data_dir)
441-
write(license_file, output_string.encode('utf-8'))
433+
with open(license_file, 'w') as of:
434+
of.write(output)
442435

443436
def load(self, license_file, check_consistency=True):
444437
"""
@@ -2078,19 +2071,14 @@ def dump(self, rules_data_dir):
20782071
if self.is_from_license or self.is_synthetic:
20792072
return
20802073

2081-
def write(location, byte_string):
2082-
# we write as binary because rules and licenses texts and data are
2083-
# UTF-8-encoded bytes
2084-
with io.open(location, 'wb') as of:
2085-
of.write(byte_string)
2086-
20872074
rule_file = self.rule_file(rules_data_dir=rules_data_dir)
20882075

20892076
metadata = self.to_dict()
2090-
content = self.text.encode('utf-8')
2077+
content = self.text
20912078
rule_post = FrontmatterPost(content=content, handler=SaneYAMLHandler(), **metadata)
2092-
output_string = dumps_frontmatter(post=rule_post)
2093-
write(rule_file, output_string.encode('utf-8'))
2079+
output = dumps_frontmatter(post=rule_post)
2080+
with open(rule_file, 'w') as of:
2081+
of.write(output)
20942082

20952083
def load(self, rule_file, with_checks=True):
20962084
"""

src/scancode/cli_test_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,8 @@ def run_scan_click(
137137

138138

139139
def get_opts(options):
140-
try:
141-
return ' '.join(options)
142-
except:
143-
try:
144-
return b' '.join(options)
145-
except:
146-
return b' '.join(map(repr, options))
140+
opts = [o if isinstance(o, str) else repr(o) for o in options]
141+
return ' '.join(opts)
147142

148143

149144
WINDOWS_CI_TIMEOUT = '222.2'

0 commit comments

Comments
 (0)