scanoss 1.12.2__py3-none-any.whl → 1.43.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. protoc_gen_swagger/__init__.py +13 -13
  2. protoc_gen_swagger/options/__init__.py +13 -13
  3. protoc_gen_swagger/options/annotations_pb2.py +18 -12
  4. protoc_gen_swagger/options/annotations_pb2.pyi +48 -0
  5. protoc_gen_swagger/options/annotations_pb2_grpc.py +20 -0
  6. protoc_gen_swagger/options/openapiv2_pb2.py +110 -99
  7. protoc_gen_swagger/options/openapiv2_pb2.pyi +1317 -0
  8. protoc_gen_swagger/options/openapiv2_pb2_grpc.py +20 -0
  9. scanoss/__init__.py +18 -18
  10. scanoss/api/__init__.py +17 -17
  11. scanoss/api/common/__init__.py +17 -17
  12. scanoss/api/common/v2/__init__.py +17 -17
  13. scanoss/api/common/v2/scanoss_common_pb2.py +49 -20
  14. scanoss/api/common/v2/scanoss_common_pb2_grpc.py +25 -0
  15. scanoss/api/components/__init__.py +17 -17
  16. scanoss/api/components/v2/__init__.py +17 -17
  17. scanoss/api/components/v2/scanoss_components_pb2.py +68 -43
  18. scanoss/api/components/v2/scanoss_components_pb2_grpc.py +83 -22
  19. scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py +136 -21
  20. scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py +766 -13
  21. scanoss/api/dependencies/__init__.py +17 -17
  22. scanoss/api/dependencies/v2/__init__.py +17 -17
  23. scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py +56 -29
  24. scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py +94 -8
  25. scanoss/api/geoprovenance/__init__.py +23 -0
  26. scanoss/api/geoprovenance/v2/__init__.py +23 -0
  27. scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py +92 -0
  28. scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py +381 -0
  29. scanoss/api/licenses/__init__.py +23 -0
  30. scanoss/api/licenses/v2/__init__.py +23 -0
  31. scanoss/api/licenses/v2/scanoss_licenses_pb2.py +84 -0
  32. scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py +302 -0
  33. scanoss/api/scanning/__init__.py +17 -17
  34. scanoss/api/scanning/v2/__init__.py +17 -17
  35. scanoss/api/scanning/v2/scanoss_scanning_pb2.py +42 -13
  36. scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py +86 -7
  37. scanoss/api/semgrep/__init__.py +17 -17
  38. scanoss/api/semgrep/v2/__init__.py +17 -17
  39. scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py +50 -23
  40. scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py +151 -16
  41. scanoss/api/vulnerabilities/__init__.py +17 -17
  42. scanoss/api/vulnerabilities/v2/__init__.py +17 -17
  43. scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py +78 -31
  44. scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py +282 -18
  45. scanoss/cli.py +2359 -370
  46. scanoss/components.py +187 -94
  47. scanoss/constants.py +22 -0
  48. scanoss/cryptography.py +308 -0
  49. scanoss/csvoutput.py +91 -58
  50. scanoss/cyclonedx.py +221 -63
  51. scanoss/data/build_date.txt +1 -1
  52. scanoss/data/osadl-copyleft.json +133 -0
  53. scanoss/data/scanoss-settings-schema.json +254 -0
  54. scanoss/delta.py +197 -0
  55. scanoss/export/__init__.py +23 -0
  56. scanoss/export/dependency_track.py +227 -0
  57. scanoss/file_filters.py +582 -0
  58. scanoss/filecount.py +75 -69
  59. scanoss/gitlabqualityreport.py +214 -0
  60. scanoss/header_filter.py +563 -0
  61. scanoss/inspection/__init__.py +23 -0
  62. scanoss/inspection/policy_check/__init__.py +0 -0
  63. scanoss/inspection/policy_check/dependency_track/__init__.py +0 -0
  64. scanoss/inspection/policy_check/dependency_track/project_violation.py +479 -0
  65. scanoss/inspection/policy_check/policy_check.py +222 -0
  66. scanoss/inspection/policy_check/scanoss/__init__.py +0 -0
  67. scanoss/inspection/policy_check/scanoss/copyleft.py +243 -0
  68. scanoss/inspection/policy_check/scanoss/undeclared_component.py +309 -0
  69. scanoss/inspection/summary/__init__.py +0 -0
  70. scanoss/inspection/summary/component_summary.py +170 -0
  71. scanoss/inspection/summary/license_summary.py +191 -0
  72. scanoss/inspection/summary/match_summary.py +341 -0
  73. scanoss/inspection/utils/file_utils.py +44 -0
  74. scanoss/inspection/utils/license_utils.py +123 -0
  75. scanoss/inspection/utils/markdown_utils.py +63 -0
  76. scanoss/inspection/utils/scan_result_processor.py +417 -0
  77. scanoss/osadl.py +125 -0
  78. scanoss/results.py +275 -0
  79. scanoss/scancodedeps.py +87 -38
  80. scanoss/scanner.py +431 -539
  81. scanoss/scanners/__init__.py +23 -0
  82. scanoss/scanners/container_scanner.py +476 -0
  83. scanoss/scanners/folder_hasher.py +358 -0
  84. scanoss/scanners/scanner_config.py +73 -0
  85. scanoss/scanners/scanner_hfh.py +252 -0
  86. scanoss/scanoss_settings.py +337 -0
  87. scanoss/scanossapi.py +140 -101
  88. scanoss/scanossbase.py +59 -22
  89. scanoss/scanossgrpc.py +799 -251
  90. scanoss/scanpostprocessor.py +294 -0
  91. scanoss/scantype.py +22 -21
  92. scanoss/services/dependency_track_service.py +132 -0
  93. scanoss/spdxlite.py +532 -174
  94. scanoss/threadeddependencies.py +148 -47
  95. scanoss/threadedscanning.py +53 -37
  96. scanoss/utils/__init__.py +23 -0
  97. scanoss/utils/abstract_presenter.py +103 -0
  98. scanoss/utils/crc64.py +96 -0
  99. scanoss/utils/file.py +84 -0
  100. scanoss/utils/scanoss_scan_results_utils.py +41 -0
  101. scanoss/utils/simhash.py +198 -0
  102. scanoss/winnowing.py +241 -63
  103. {scanoss-1.12.2.dist-info → scanoss-1.43.1.dist-info}/METADATA +18 -9
  104. scanoss-1.43.1.dist-info/RECORD +110 -0
  105. {scanoss-1.12.2.dist-info → scanoss-1.43.1.dist-info}/WHEEL +1 -1
  106. scanoss-1.12.2.dist-info/RECORD +0 -58
  107. {scanoss-1.12.2.dist-info → scanoss-1.43.1.dist-info}/entry_points.txt +0 -0
  108. {scanoss-1.12.2.dist-info → scanoss-1.43.1.dist-info/licenses}/LICENSE +0 -0
  109. {scanoss-1.12.2.dist-info → scanoss-1.43.1.dist-info}/top_level.txt +0 -0
scanoss/utils/file.py ADDED
@@ -0,0 +1,84 @@
1
+ """
2
+ SPDX-License-Identifier: MIT
3
+
4
+ Copyright (c) 2024, SCANOSS
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ """
24
+
25
+ import json
26
+ import os
27
+ from dataclasses import dataclass
28
+ from typing import Optional
29
+
30
+ JSON_ERROR_PARSE = 1
31
+ JSON_ERROR_FILE_NOT_FOUND = 2
32
+ JSON_ERROR_FILE_EMPTY = 3
33
+ JSON_ERROR_FILE_SIZE = 4
34
+
35
+
36
+ @dataclass
37
+ class JsonValidation:
38
+ is_valid: bool
39
+ data: Optional[dict] = None
40
+ error: Optional[str] = None
41
+ error_code: Optional[int] = None
42
+
43
+
44
+ def validate_json_file(json_file_path: str) -> JsonValidation:
45
+ """
46
+ Validate if the specified file is indeed a valid JSON file
47
+
48
+ Args:
49
+ json_file_path (str): The JSON file to validate
50
+
51
+ Returns:
52
+ JsonValidation: A JsonValidation object containing a boolean indicating if the file is valid, the data, error, and error code
53
+ """ # noqa: E501
54
+ if not json_file_path:
55
+ return JsonValidation(is_valid=False, error='No JSON file specified')
56
+ if not os.path.isfile(json_file_path):
57
+ return JsonValidation(
58
+ is_valid=False,
59
+ error=f'File not found: {json_file_path}',
60
+ error_code=JSON_ERROR_FILE_NOT_FOUND,
61
+ )
62
+ try:
63
+ if os.stat(json_file_path).st_size == 0:
64
+ return JsonValidation(
65
+ is_valid=False,
66
+ error=f'File is empty: {json_file_path}',
67
+ error_code=JSON_ERROR_FILE_EMPTY,
68
+ )
69
+ except OSError as e:
70
+ return JsonValidation(
71
+ is_valid=False,
72
+ error=f'Problem checking file size: {json_file_path}: {e}',
73
+ error_code=JSON_ERROR_FILE_SIZE,
74
+ )
75
+ try:
76
+ with open(json_file_path) as f:
77
+ data = json.load(f)
78
+ return JsonValidation(is_valid=True, data=data)
79
+ except json.JSONDecodeError as e:
80
+ return JsonValidation(
81
+ is_valid=False,
82
+ error=f'Problem parsing JSON file: "{json_file_path}": {e}',
83
+ error_code=JSON_ERROR_PARSE,
84
+ )
@@ -0,0 +1,41 @@
1
+ """
2
+ SPDX-License-Identifier: MIT
3
+
4
+ Copyright (c) 2025, SCANOSS
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ """
24
+
25
+ def get_lines(lines: str) -> list:
26
+ """
27
+ Parse line range string into a list of line numbers.
28
+
29
+ Converts SCANOSS line notation (e.g., '10-20,25-30') into a flat list
30
+ of individual line numbers for processing.
31
+
32
+ :param lines: Comma-separated line ranges in SCANOSS format (e.g., '10-20,25-30')
33
+ :return: Flat list of all line numbers extracted from the ranges
34
+ """
35
+ lines_list = []
36
+ lines = lines.split(',')
37
+ for line in lines:
38
+ line_parts = line.split('-')
39
+ for part in line_parts:
40
+ lines_list.append(int(part))
41
+ return lines_list
@@ -0,0 +1,198 @@
1
+ """
2
+ SPDX-License-Identifier: MIT
3
+
4
+ Copyright (c) 2025, SCANOSS
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ """
24
+
25
+ import re
26
+ import unicodedata
27
+
28
+ FNV64_OFFSET_BASIS = 14695981039346656037
29
+ FNV64_PRIME = 1099511628211
30
+ MASK64 = 0xFFFFFFFFFFFFFFFF
31
+
32
+
33
+ def fnv1_64(data: bytes) -> int:
34
+ """Compute the 64‐bit FNV‑1 hash of data."""
35
+ h = FNV64_OFFSET_BASIS
36
+ for b in data:
37
+ h = (h * FNV64_PRIME) & MASK64
38
+ h = h ^ b
39
+ return h
40
+
41
+
42
+ class SimhashFeature:
43
+ def __init__(self, hash_value: int, weight: int = 1):
44
+ self.hash_value = hash_value
45
+ self.weight = weight
46
+
47
+ def sum(self) -> int:
48
+ """Return the 64-bit hash (sum) of this feature."""
49
+ return self.hash_value
50
+
51
+ def get_weight(self) -> int:
52
+ """Return the weight of this feature."""
53
+ return self.weight
54
+
55
+
56
+ def new_feature(f: bytes) -> SimhashFeature:
57
+ """Return a new feature for the given byte slice with weight 1."""
58
+ return SimhashFeature(fnv1_64(f), 1)
59
+
60
+
61
+ def new_feature_with_weight(f: bytes, weight: int) -> SimhashFeature:
62
+ """Return a new feature for the given byte slice with the given weight."""
63
+ return SimhashFeature(fnv1_64(f), weight)
64
+
65
+
66
+ def vectorize(features: list) -> list:
67
+ """
68
+ Given a list of features, return a 64-element vector.
69
+ Each feature contributes its weight to each coordinate,
70
+ added if that bit is set and subtracted otherwise.
71
+ """
72
+ v = [0] * 64
73
+ for feature in features:
74
+ h = feature.sum()
75
+ w = feature.get_weight()
76
+ for i in range(64):
77
+ if ((h >> i) & 1) == 1:
78
+ v[i] += w
79
+ else:
80
+ v[i] -= w
81
+ return v
82
+
83
+
84
+ def vectorize_bytes(features: list) -> list:
85
+ """
86
+ Given a list of byte slices, treat each as a feature (with weight 1)
87
+ by computing its FNV-1 hash.
88
+ """
89
+ v = [0] * 64
90
+ for feat in features:
91
+ h = fnv1_64(feat)
92
+ for i in range(64):
93
+ if ((h >> i) & 1) == 1:
94
+ v[i] += 1
95
+ else:
96
+ v[i] -= 1
97
+ return v
98
+
99
+
100
+ def fingerprint(v: list) -> int:
101
+ """
102
+ Given a 64-element vector, return a 64-bit fingerprint.
103
+ For each bit i, if v[i] >= 0, set bit i to 1; otherwise leave it 0.
104
+ """
105
+ f = 0
106
+ for i in range(64):
107
+ if v[i] >= 0:
108
+ f |= 1 << i
109
+ return f
110
+
111
+
112
+ def compare(a: int, b: int) -> int:
113
+ """
114
+ Calculate the Hamming distance between two 64-bit integers.
115
+ (The number of differing bits.)
116
+ """
117
+ v = a ^ b
118
+ c = 0
119
+ while v:
120
+ v &= v - 1
121
+ c += 1
122
+ return c
123
+
124
+
125
+ def simhash(fs) -> int:
126
+ """
127
+ Given a feature set (an object with a get_features() method),
128
+ return its 64-bit simhash.
129
+ """
130
+ return fingerprint(vectorize(fs.get_features()))
131
+
132
+
133
+ def simhash_bytes(b: list) -> int:
134
+ """
135
+ Given a list of byte slices, return the simhash.
136
+ """
137
+ return fingerprint(vectorize_bytes(b))
138
+
139
+
140
+ boundaries = re.compile(rb"[\w']+(?:\://[\w\./]+){0,1}")
141
+ unicode_boundaries = re.compile(r"[\w'-]+", re.UNICODE)
142
+
143
+
144
+ # --- Helper Functions for Feature Extraction ---
145
+ def _get_features_bytes(b: bytes, pattern: re.Pattern) -> list:
146
+ """
147
+ Split the given byte string using the given regex pattern,
148
+ and return a list of features (each created with new_feature).
149
+ """
150
+ words = pattern.findall(b)
151
+ return [new_feature(word) for word in words]
152
+
153
+
154
+ def _get_features_str(s: str, pattern) -> list:
155
+ """
156
+ Split the given string using the given regex pattern,
157
+ and return a list of features (each created by encoding to UTF-8).
158
+ """
159
+ words = pattern.findall(s)
160
+ return [new_feature(word.encode('utf-8')) for word in words]
161
+
162
+
163
+ class WordFeatureSet:
164
+ def __init__(self, b: bytes):
165
+ # Normalize the input to lowercase.
166
+ self.b = b.lower()
167
+
168
+ def get_features(self) -> list:
169
+ return _get_features_bytes(self.b, boundaries)
170
+
171
+
172
+ class UnicodeWordFeatureSet:
173
+ def __init__(self, b: bytes, norm_form: str = 'NFC'):
174
+ # Decode, normalize (using the provided form), and lowercase.
175
+ text = b.decode('utf-8')
176
+ normalized = unicodedata.normalize(norm_form, text)
177
+ self.text = normalized.lower()
178
+
179
+ def get_features(self) -> list:
180
+ return _get_features_str(self.text, unicode_boundaries)
181
+
182
+
183
+ def shingle(w: int, b: list) -> list:
184
+ """
185
+ Return the w-shingling of the given set of byte slices.
186
+ For example, if b is [b"this", b"is", b"a", b"test"]
187
+ and w == 2, the result is [b"this is", b"is a", b"a test"].
188
+ """
189
+ if w < 1:
190
+ raise ValueError('simhash.shingle(): k must be a positive integer')
191
+ if w == 1:
192
+ return b
193
+ w = min(w, len(b))
194
+ count = len(b) - w + 1
195
+ shingles = []
196
+ for i in range(count):
197
+ shingles.append(b' '.join(b[i : i + w]))
198
+ return shingles