scanoss 1.20.0__py3-none-any.whl → 1.20.2__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.
- protoc_gen_swagger/__init__.py +13 -13
- protoc_gen_swagger/options/__init__.py +13 -13
- protoc_gen_swagger/options/annotations_pb2.py +12 -9
- protoc_gen_swagger/options/annotations_pb2_grpc.py +1 -1
- protoc_gen_swagger/options/openapiv2_pb2.py +98 -96
- protoc_gen_swagger/options/openapiv2_pb2_grpc.py +1 -1
- scanoss/__init__.py +18 -18
- scanoss/api/__init__.py +17 -17
- scanoss/api/common/__init__.py +17 -17
- scanoss/api/common/v2/__init__.py +17 -17
- scanoss/api/common/v2/scanoss_common_pb2.py +18 -18
- scanoss/api/common/v2/scanoss_common_pb2_grpc.py +1 -1
- scanoss/api/components/__init__.py +17 -17
- scanoss/api/components/v2/__init__.py +17 -17
- scanoss/api/components/v2/scanoss_components_pb2.py +48 -38
- scanoss/api/components/v2/scanoss_components_pb2_grpc.py +142 -96
- scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py +22 -16
- scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py +75 -49
- scanoss/api/dependencies/__init__.py +17 -17
- scanoss/api/dependencies/v2/__init__.py +17 -17
- scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py +30 -24
- scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py +75 -49
- scanoss/api/scanning/__init__.py +17 -17
- scanoss/api/scanning/v2/__init__.py +17 -17
- scanoss/api/scanning/v2/scanoss_scanning_pb2.py +10 -8
- scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py +40 -32
- scanoss/api/semgrep/__init__.py +17 -17
- scanoss/api/semgrep/v2/__init__.py +17 -17
- scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py +22 -18
- scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py +71 -49
- scanoss/api/vulnerabilities/__init__.py +17 -17
- scanoss/api/vulnerabilities/v2/__init__.py +17 -17
- scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py +37 -27
- scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py +109 -72
- scanoss/cli.py +664 -356
- scanoss/components.py +67 -45
- scanoss/csvoutput.py +83 -56
- scanoss/cyclonedx.py +48 -46
- scanoss/data/build_date.txt +1 -1
- scanoss/file_filters.py +13 -15
- scanoss/filecount.py +43 -36
- scanoss/inspection/__init__.py +17 -17
- scanoss/inspection/copyleft.py +71 -58
- scanoss/inspection/policy_check.py +76 -53
- scanoss/inspection/undeclared_component.py +98 -75
- scanoss/inspection/utils/license_utils.py +66 -44
- scanoss/results.py +51 -60
- scanoss/scancodedeps.py +61 -38
- scanoss/scanner.py +203 -135
- scanoss/scanoss_settings.py +5 -3
- scanoss/scanossapi.py +98 -69
- scanoss/scanossbase.py +19 -19
- scanoss/scanossgrpc.py +73 -51
- scanoss/scanpostprocessor.py +9 -6
- scanoss/scantype.py +22 -21
- scanoss/spdxlite.py +265 -171
- scanoss/threadeddependencies.py +91 -61
- scanoss/threadedscanning.py +37 -31
- scanoss/utils/file.py +4 -4
- scanoss/winnowing.py +111 -47
- {scanoss-1.20.0.dist-info → scanoss-1.20.2.dist-info}/METADATA +1 -1
- scanoss-1.20.2.dist-info/RECORD +74 -0
- {scanoss-1.20.0.dist-info → scanoss-1.20.2.dist-info}/WHEEL +1 -1
- scanoss-1.20.0.dist-info/RECORD +0 -74
- {scanoss-1.20.0.dist-info → scanoss-1.20.2.dist-info}/LICENSE +0 -0
- {scanoss-1.20.0.dist-info → scanoss-1.20.2.dist-info}/entry_points.txt +0 -0
- {scanoss-1.20.0.dist-info → scanoss-1.20.2.dist-info}/top_level.txt +0 -0
scanoss/scancodedeps.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Copyright (c) 2021, SCANOSS
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
23
|
"""
|
|
24
24
|
|
|
25
25
|
import json
|
|
@@ -33,8 +33,17 @@ class ScancodeDeps(ScanossBase):
|
|
|
33
33
|
"""
|
|
34
34
|
SCANOSS dependency scanning class
|
|
35
35
|
"""
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
debug: bool = False,
|
|
40
|
+
quiet: bool = False,
|
|
41
|
+
trace: bool = False,
|
|
42
|
+
output_file: str = None,
|
|
43
|
+
scan_output: str = None,
|
|
44
|
+
timeout: int = 600,
|
|
45
|
+
sc_command: str = None,
|
|
46
|
+
):
|
|
38
47
|
"""
|
|
39
48
|
Initialise ScancodeDeps class
|
|
40
49
|
"""
|
|
@@ -54,12 +63,11 @@ class ScancodeDeps(ScanossBase):
|
|
|
54
63
|
if not outfile and self.scan_output:
|
|
55
64
|
outfile = self.scan_output
|
|
56
65
|
if outfile:
|
|
57
|
-
with open(outfile,
|
|
66
|
+
with open(outfile, 'a') as rf:
|
|
58
67
|
rf.write(string + '\n')
|
|
59
68
|
else:
|
|
60
69
|
print(string)
|
|
61
70
|
|
|
62
|
-
|
|
63
71
|
def remove_interim_file(self, output_file: str = None):
|
|
64
72
|
"""
|
|
65
73
|
Remove the temporary Scancode interim file
|
|
@@ -86,7 +94,7 @@ class ScancodeDeps(ScanossBase):
|
|
|
86
94
|
self.print_debug(f'Processing Scancode results into Dependency data...')
|
|
87
95
|
files = []
|
|
88
96
|
for t in data:
|
|
89
|
-
if t == 'files':
|
|
97
|
+
if t == 'files': # Only interested in 'files' details
|
|
90
98
|
files_details = data.get(t)
|
|
91
99
|
if not files_details or files_details == '':
|
|
92
100
|
continue
|
|
@@ -121,7 +129,7 @@ class ScancodeDeps(ScanossBase):
|
|
|
121
129
|
dp_data = {'purl': dp}
|
|
122
130
|
rq = d.get('extracted_requirement') # scancode format 2.0
|
|
123
131
|
if not rq or rq == '':
|
|
124
|
-
rq = d.get('requirement')
|
|
132
|
+
rq = d.get('requirement') # scancode format 1.0
|
|
125
133
|
# skip requirement if it ends with the purl (i.e. exact version) or if it's local (file)
|
|
126
134
|
if rq and rq != '' and not dp.endswith(rq) and not rq.startswith('file:'):
|
|
127
135
|
dp_data['requirement'] = rq
|
|
@@ -206,17 +214,32 @@ class ScancodeDeps(ScanossBase):
|
|
|
206
214
|
output_file = self.output_file
|
|
207
215
|
try:
|
|
208
216
|
open(output_file, 'w').close()
|
|
209
|
-
self.print_trace(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
self.print_trace(
|
|
218
|
+
f'About to execute {self.sc_command} -p --only-findings --quiet --json {output_file} {what_to_scan}'
|
|
219
|
+
)
|
|
220
|
+
result = subprocess.run(
|
|
221
|
+
[
|
|
222
|
+
self.sc_command,
|
|
223
|
+
'-p',
|
|
224
|
+
'--only-findings',
|
|
225
|
+
'--quiet',
|
|
226
|
+
'--strip-root',
|
|
227
|
+
'--json',
|
|
228
|
+
output_file,
|
|
229
|
+
what_to_scan,
|
|
230
|
+
],
|
|
231
|
+
cwd=os.getcwd(),
|
|
232
|
+
stdout=subprocess.PIPE,
|
|
233
|
+
stderr=subprocess.STDOUT,
|
|
234
|
+
text=True,
|
|
235
|
+
timeout=self.timeout,
|
|
236
|
+
)
|
|
216
237
|
self.print_trace(f'Subprocess return: {result}')
|
|
217
238
|
if result.returncode:
|
|
218
|
-
self.print_stderr(
|
|
219
|
-
|
|
239
|
+
self.print_stderr(
|
|
240
|
+
f'ERROR: Scancode dependency scan of {what_to_scan} failed with exit code'
|
|
241
|
+
f' {result.returncode}:\n{result.stdout}'
|
|
242
|
+
)
|
|
220
243
|
return False
|
|
221
244
|
except subprocess.TimeoutExpired as e:
|
|
222
245
|
self.print_stderr(f'ERROR: Timed out attempting to run scancode dependency scan on {what_to_scan}: {e}')
|
|
@@ -245,21 +268,21 @@ class ScancodeDeps(ScanossBase):
|
|
|
245
268
|
self.print_stderr(f'ERROR: Problem loading input JSON: {e}')
|
|
246
269
|
return None
|
|
247
270
|
|
|
248
|
-
|
|
249
271
|
@staticmethod
|
|
250
|
-
def __remove_dep_scope(deps: json)->json:
|
|
272
|
+
def __remove_dep_scope(deps: json) -> json:
|
|
251
273
|
"""
|
|
252
274
|
:param deps: dependencies with scopes
|
|
253
275
|
:return dependencies without scopes
|
|
254
276
|
"""
|
|
255
|
-
files = deps.get(
|
|
277
|
+
files = deps.get('files')
|
|
256
278
|
for file in files:
|
|
257
279
|
if 'purls' in file:
|
|
258
|
-
purls = file.get(
|
|
280
|
+
purls = file.get('purls')
|
|
259
281
|
for purl in purls:
|
|
260
|
-
purl.pop(
|
|
282
|
+
purl.pop('scope', None)
|
|
283
|
+
|
|
284
|
+
return {'files': files}
|
|
261
285
|
|
|
262
|
-
return {"files": files }
|
|
263
286
|
|
|
264
287
|
#
|
|
265
288
|
# End of ScancodeDeps Class
|