scanoss 1.22.0__py3-none-any.whl → 1.24.0__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.
- scanoss/__init__.py +1 -1
- scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py +49 -0
- scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py +142 -0
- scanoss/cli.py +206 -40
- scanoss/components.py +21 -11
- scanoss/constants.py +2 -0
- scanoss/cryptography.py +274 -0
- scanoss/data/build_date.txt +1 -1
- scanoss/scanners/scanner_hfh.py +2 -1
- scanoss/scanossgrpc.py +115 -47
- scanoss/utils/file.py +2 -2
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/METADATA +1 -1
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/RECORD +19 -18
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/WHEEL +1 -1
- scanoss/api/provenance/v2/scanoss_provenance_pb2.py +0 -41
- scanoss/api/provenance/v2/scanoss_provenance_pb2_grpc.py +0 -108
- /scanoss/api/{provenance → geoprovenance}/__init__.py +0 -0
- /scanoss/api/{provenance → geoprovenance}/v2/__init__.py +0 -0
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/entry_points.txt +0 -0
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/licenses/LICENSE +0 -0
- {scanoss-1.22.0.dist-info → scanoss-1.24.0.dist-info}/top_level.txt +0 -0
scanoss/__init__.py
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: scanoss/api/geoprovenance/v2/scanoss-geoprovenance.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf.internal import builder as _builder
|
|
6
|
+
from google.protobuf import descriptor as _descriptor
|
|
7
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
8
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
9
|
+
# @@protoc_insertion_point(imports)
|
|
10
|
+
|
|
11
|
+
_sym_db = _symbol_database.Default()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from scanoss.api.common.v2 import scanoss_common_pb2 as scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2
|
|
15
|
+
from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
|
|
16
|
+
from protoc_gen_swagger.options import annotations_pb2 as protoc__gen__swagger_dot_options_dot_annotations__pb2
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n8scanoss/api/geoprovenance/v2/scanoss-geoprovenance.proto\x12\x1cscanoss.api.geoprovenance.v2\x1a*scanoss/api/common/v2/scanoss-common.proto\x1a\x1cgoogle/api/annotations.proto\x1a,protoc-gen-swagger/options/annotations.proto\"\xd1\x03\n\x13\x43ontributorResponse\x12\x46\n\x05purls\x18\x01 \x03(\x0b\x32\x37.scanoss.api.geoprovenance.v2.ContributorResponse.Purls\x12\x35\n\x06status\x18\x02 \x01(\x0b\x32%.scanoss.api.common.v2.StatusResponse\x1a\x32\n\x10\x44\x65\x63laredLocation\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08location\x18\x02 \x01(\t\x1a\x31\n\x0f\x43uratedLocation\x12\x0f\n\x07\x63ountry\x18\x01 \x01(\t\x12\r\n\x05\x63ount\x18\x02 \x01(\x05\x1a\xd3\x01\n\x05Purls\x12\x0c\n\x04purl\x18\x01 \x01(\t\x12^\n\x12\x64\x65\x63lared_locations\x18\x02 \x03(\x0b\x32\x42.scanoss.api.geoprovenance.v2.ContributorResponse.DeclaredLocation\x12\\\n\x11\x63urated_locations\x18\x03 \x03(\x0b\x32\x41.scanoss.api.geoprovenance.v2.ContributorResponse.CuratedLocation\"\x99\x02\n\x0eOriginResponse\x12\x41\n\x05purls\x18\x01 \x03(\x0b\x32\x32.scanoss.api.geoprovenance.v2.OriginResponse.Purls\x12\x35\n\x06status\x18\x02 \x01(\x0b\x32%.scanoss.api.common.v2.StatusResponse\x1a,\n\x08Location\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\npercentage\x18\x02 \x01(\x02\x1a_\n\x05Purls\x12\x0c\n\x04purl\x18\x01 \x01(\t\x12H\n\tlocations\x18\x02 \x03(\x0b\x32\x35.scanoss.api.geoprovenance.v2.OriginResponse.Location2\xb9\x03\n\rGeoProvenance\x12v\n\x04\x45\x63ho\x12\".scanoss.api.common.v2.EchoRequest\x1a#.scanoss.api.common.v2.EchoResponse\"%\x82\xd3\xe4\x93\x02\x1f\"\x1a/api/v2/geoprovenance/echo:\x01*\x12\x9d\x01\n\x18GetComponentContributors\x12\".scanoss.api.common.v2.PurlRequest\x1a\x31.scanoss.api.geoprovenance.v2.ContributorResponse\"*\x82\xd3\xe4\x93\x02$\"\x1f/api/v2/geoprovenance/countries:\x01*\x12\x8f\x01\n\x12GetComponentOrigin\x12\".scanoss.api.common.v2.PurlRequest\x1a,.scanoss.api.geoprovenance.v2.OriginResponse\"\'\x82\xd3\xe4\x93\x02!\"\x1c/api/v2/geoprovenance/origin:\x01*B\xa4\x02Z;github.com/scanoss/papi/api/geoprovenancev2;geoprovenancev2\x92\x41\xe3\x01\x12}\n\x1eSCANOSS GEO Provenance Service\"V\n\x15scanoss-geoprovenance\x12(https://github.com/scanoss/geoprovenance\x1a\x13support@scanoss.com2\x03\x32.0*\x01\x01\x32\x10\x61pplication/json:\x10\x61pplication/jsonR;\n\x03\x34\x30\x34\x12\x34\n*Returned when the resource does not exist.\x12\x06\n\x04\x9a\x02\x01\x07\x62\x06proto3')
|
|
20
|
+
|
|
21
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
|
22
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'scanoss.api.geoprovenance.v2.scanoss_geoprovenance_pb2', globals())
|
|
23
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
24
|
+
|
|
25
|
+
DESCRIPTOR._options = None
|
|
26
|
+
DESCRIPTOR._serialized_options = b'Z;github.com/scanoss/papi/api/geoprovenancev2;geoprovenancev2\222A\343\001\022}\n\036SCANOSS GEO Provenance Service\"V\n\025scanoss-geoprovenance\022(https://github.com/scanoss/geoprovenance\032\023support@scanoss.com2\0032.0*\001\0012\020application/json:\020application/jsonR;\n\003404\0224\n*Returned when the resource does not exist.\022\006\n\004\232\002\001\007'
|
|
27
|
+
_GEOPROVENANCE.methods_by_name['Echo']._options = None
|
|
28
|
+
_GEOPROVENANCE.methods_by_name['Echo']._serialized_options = b'\202\323\344\223\002\037\"\032/api/v2/geoprovenance/echo:\001*'
|
|
29
|
+
_GEOPROVENANCE.methods_by_name['GetComponentContributors']._options = None
|
|
30
|
+
_GEOPROVENANCE.methods_by_name['GetComponentContributors']._serialized_options = b'\202\323\344\223\002$\"\037/api/v2/geoprovenance/countries:\001*'
|
|
31
|
+
_GEOPROVENANCE.methods_by_name['GetComponentOrigin']._options = None
|
|
32
|
+
_GEOPROVENANCE.methods_by_name['GetComponentOrigin']._serialized_options = b'\202\323\344\223\002!\"\034/api/v2/geoprovenance/origin:\001*'
|
|
33
|
+
_CONTRIBUTORRESPONSE._serialized_start=211
|
|
34
|
+
_CONTRIBUTORRESPONSE._serialized_end=676
|
|
35
|
+
_CONTRIBUTORRESPONSE_DECLAREDLOCATION._serialized_start=361
|
|
36
|
+
_CONTRIBUTORRESPONSE_DECLAREDLOCATION._serialized_end=411
|
|
37
|
+
_CONTRIBUTORRESPONSE_CURATEDLOCATION._serialized_start=413
|
|
38
|
+
_CONTRIBUTORRESPONSE_CURATEDLOCATION._serialized_end=462
|
|
39
|
+
_CONTRIBUTORRESPONSE_PURLS._serialized_start=465
|
|
40
|
+
_CONTRIBUTORRESPONSE_PURLS._serialized_end=676
|
|
41
|
+
_ORIGINRESPONSE._serialized_start=679
|
|
42
|
+
_ORIGINRESPONSE._serialized_end=960
|
|
43
|
+
_ORIGINRESPONSE_LOCATION._serialized_start=819
|
|
44
|
+
_ORIGINRESPONSE_LOCATION._serialized_end=863
|
|
45
|
+
_ORIGINRESPONSE_PURLS._serialized_start=865
|
|
46
|
+
_ORIGINRESPONSE_PURLS._serialized_end=960
|
|
47
|
+
_GEOPROVENANCE._serialized_start=963
|
|
48
|
+
_GEOPROVENANCE._serialized_end=1404
|
|
49
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
from scanoss.api.common.v2 import scanoss_common_pb2 as scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2
|
|
6
|
+
from scanoss.api.geoprovenance.v2 import scanoss_geoprovenance_pb2 as scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GeoProvenanceStub(object):
|
|
10
|
+
"""*
|
|
11
|
+
Expose all of the SCANOSS Geo Provenance RPCs here
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, channel):
|
|
15
|
+
"""Constructor.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
channel: A grpc.Channel.
|
|
19
|
+
"""
|
|
20
|
+
self.Echo = channel.unary_unary(
|
|
21
|
+
'/scanoss.api.geoprovenance.v2.GeoProvenance/Echo',
|
|
22
|
+
request_serializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoRequest.SerializeToString,
|
|
23
|
+
response_deserializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoResponse.FromString,
|
|
24
|
+
)
|
|
25
|
+
self.GetComponentContributors = channel.unary_unary(
|
|
26
|
+
'/scanoss.api.geoprovenance.v2.GeoProvenance/GetComponentContributors',
|
|
27
|
+
request_serializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.SerializeToString,
|
|
28
|
+
response_deserializer=scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.ContributorResponse.FromString,
|
|
29
|
+
)
|
|
30
|
+
self.GetComponentOrigin = channel.unary_unary(
|
|
31
|
+
'/scanoss.api.geoprovenance.v2.GeoProvenance/GetComponentOrigin',
|
|
32
|
+
request_serializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.SerializeToString,
|
|
33
|
+
response_deserializer=scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.OriginResponse.FromString,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class GeoProvenanceServicer(object):
|
|
38
|
+
"""*
|
|
39
|
+
Expose all of the SCANOSS Geo Provenance RPCs here
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def Echo(self, request, context):
|
|
43
|
+
"""Standard echo
|
|
44
|
+
"""
|
|
45
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
46
|
+
context.set_details('Method not implemented!')
|
|
47
|
+
raise NotImplementedError('Method not implemented!')
|
|
48
|
+
|
|
49
|
+
def GetComponentContributors(self, request, context):
|
|
50
|
+
"""Get component-level Geo Provenance based on contributor declared location
|
|
51
|
+
"""
|
|
52
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
53
|
+
context.set_details('Method not implemented!')
|
|
54
|
+
raise NotImplementedError('Method not implemented!')
|
|
55
|
+
|
|
56
|
+
def GetComponentOrigin(self, request, context):
|
|
57
|
+
"""Get component-level Geo Provenance based on contributor origin commit times
|
|
58
|
+
"""
|
|
59
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
60
|
+
context.set_details('Method not implemented!')
|
|
61
|
+
raise NotImplementedError('Method not implemented!')
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def add_GeoProvenanceServicer_to_server(servicer, server):
|
|
65
|
+
rpc_method_handlers = {
|
|
66
|
+
'Echo': grpc.unary_unary_rpc_method_handler(
|
|
67
|
+
servicer.Echo,
|
|
68
|
+
request_deserializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoRequest.FromString,
|
|
69
|
+
response_serializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoResponse.SerializeToString,
|
|
70
|
+
),
|
|
71
|
+
'GetComponentContributors': grpc.unary_unary_rpc_method_handler(
|
|
72
|
+
servicer.GetComponentContributors,
|
|
73
|
+
request_deserializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.FromString,
|
|
74
|
+
response_serializer=scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.ContributorResponse.SerializeToString,
|
|
75
|
+
),
|
|
76
|
+
'GetComponentOrigin': grpc.unary_unary_rpc_method_handler(
|
|
77
|
+
servicer.GetComponentOrigin,
|
|
78
|
+
request_deserializer=scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.FromString,
|
|
79
|
+
response_serializer=scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.OriginResponse.SerializeToString,
|
|
80
|
+
),
|
|
81
|
+
}
|
|
82
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
83
|
+
'scanoss.api.geoprovenance.v2.GeoProvenance', rpc_method_handlers)
|
|
84
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# This class is part of an EXPERIMENTAL API.
|
|
88
|
+
class GeoProvenance(object):
|
|
89
|
+
"""*
|
|
90
|
+
Expose all of the SCANOSS Geo Provenance RPCs here
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def Echo(request,
|
|
95
|
+
target,
|
|
96
|
+
options=(),
|
|
97
|
+
channel_credentials=None,
|
|
98
|
+
call_credentials=None,
|
|
99
|
+
insecure=False,
|
|
100
|
+
compression=None,
|
|
101
|
+
wait_for_ready=None,
|
|
102
|
+
timeout=None,
|
|
103
|
+
metadata=None):
|
|
104
|
+
return grpc.experimental.unary_unary(request, target, '/scanoss.api.geoprovenance.v2.GeoProvenance/Echo',
|
|
105
|
+
scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoRequest.SerializeToString,
|
|
106
|
+
scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.EchoResponse.FromString,
|
|
107
|
+
options, channel_credentials,
|
|
108
|
+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def GetComponentContributors(request,
|
|
112
|
+
target,
|
|
113
|
+
options=(),
|
|
114
|
+
channel_credentials=None,
|
|
115
|
+
call_credentials=None,
|
|
116
|
+
insecure=False,
|
|
117
|
+
compression=None,
|
|
118
|
+
wait_for_ready=None,
|
|
119
|
+
timeout=None,
|
|
120
|
+
metadata=None):
|
|
121
|
+
return grpc.experimental.unary_unary(request, target, '/scanoss.api.geoprovenance.v2.GeoProvenance/GetComponentContributors',
|
|
122
|
+
scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.SerializeToString,
|
|
123
|
+
scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.ContributorResponse.FromString,
|
|
124
|
+
options, channel_credentials,
|
|
125
|
+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
126
|
+
|
|
127
|
+
@staticmethod
|
|
128
|
+
def GetComponentOrigin(request,
|
|
129
|
+
target,
|
|
130
|
+
options=(),
|
|
131
|
+
channel_credentials=None,
|
|
132
|
+
call_credentials=None,
|
|
133
|
+
insecure=False,
|
|
134
|
+
compression=None,
|
|
135
|
+
wait_for_ready=None,
|
|
136
|
+
timeout=None,
|
|
137
|
+
metadata=None):
|
|
138
|
+
return grpc.experimental.unary_unary(request, target, '/scanoss.api.geoprovenance.v2.GeoProvenance/GetComponentOrigin',
|
|
139
|
+
scanoss_dot_api_dot_common_dot_v2_dot_scanoss__common__pb2.PurlRequest.SerializeToString,
|
|
140
|
+
scanoss_dot_api_dot_geoprovenance_dot_v2_dot_scanoss__geoprovenance__pb2.OriginResponse.FromString,
|
|
141
|
+
options, channel_credentials,
|
|
142
|
+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
scanoss/cli.py
CHANGED
|
@@ -31,6 +31,7 @@ from typing import List
|
|
|
31
31
|
|
|
32
32
|
import pypac
|
|
33
33
|
|
|
34
|
+
from scanoss.cryptography import Cryptography, create_cryptography_config_from_args
|
|
34
35
|
from scanoss.scanners.container_scanner import (
|
|
35
36
|
DEFAULT_SYFT_COMMAND,
|
|
36
37
|
DEFAULT_SYFT_TIMEOUT,
|
|
@@ -50,6 +51,7 @@ from scanoss.scanossgrpc import (
|
|
|
50
51
|
from . import __version__
|
|
51
52
|
from .components import Components
|
|
52
53
|
from .constants import (
|
|
54
|
+
DEFAULT_API_TIMEOUT,
|
|
53
55
|
DEFAULT_POST_SIZE,
|
|
54
56
|
DEFAULT_RETRY,
|
|
55
57
|
DEFAULT_TIMEOUT,
|
|
@@ -292,15 +294,6 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
292
294
|
help='component sub-commands',
|
|
293
295
|
)
|
|
294
296
|
|
|
295
|
-
# Component Sub-command: component crypto
|
|
296
|
-
c_crypto = comp_sub.add_parser(
|
|
297
|
-
'crypto',
|
|
298
|
-
aliases=['cr'],
|
|
299
|
-
description=f'Show Cryptographic algorithms: {__version__}',
|
|
300
|
-
help='Retrieve cryptographic algorithms for the given components',
|
|
301
|
-
)
|
|
302
|
-
c_crypto.set_defaults(func=comp_crypto)
|
|
303
|
-
|
|
304
297
|
# Component Sub-command: component vulns
|
|
305
298
|
c_vulns = comp_sub.add_parser(
|
|
306
299
|
'vulns',
|
|
@@ -323,8 +316,13 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
323
316
|
c_provenance = comp_sub.add_parser(
|
|
324
317
|
'provenance',
|
|
325
318
|
aliases=['prov', 'prv'],
|
|
326
|
-
description=f'Show Provenance findings: {__version__}',
|
|
327
|
-
help='Retrieve
|
|
319
|
+
description=f'Show GEO Provenance findings: {__version__}',
|
|
320
|
+
help='Retrieve geoprovenance for the given components',
|
|
321
|
+
)
|
|
322
|
+
c_provenance.add_argument(
|
|
323
|
+
'--origin',
|
|
324
|
+
action='store_true',
|
|
325
|
+
help='Retrieve geoprovenance using contributors origin (default: declared origin)',
|
|
328
326
|
)
|
|
329
327
|
c_provenance.set_defaults(func=comp_provenance)
|
|
330
328
|
|
|
@@ -356,18 +354,76 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
356
354
|
c_versions.add_argument('--limit', '-l', type=int, help='Generic component search')
|
|
357
355
|
c_versions.set_defaults(func=comp_versions)
|
|
358
356
|
|
|
357
|
+
# Sub-command: crypto
|
|
358
|
+
p_crypto = subparsers.add_parser(
|
|
359
|
+
'crypto',
|
|
360
|
+
aliases=['cr'],
|
|
361
|
+
description=f'SCANOSS Crypto commands: {__version__}',
|
|
362
|
+
help='Crypto support commands',
|
|
363
|
+
)
|
|
364
|
+
crypto_sub = p_crypto.add_subparsers(
|
|
365
|
+
title='Crypto Commands',
|
|
366
|
+
dest='subparsercmd',
|
|
367
|
+
description='crypto sub-commands',
|
|
368
|
+
help='crypto sub-commands',
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
# GetAlgorithms and GetAlgorithmsInRange gRPC APIs
|
|
372
|
+
p_crypto_algorithms = crypto_sub.add_parser(
|
|
373
|
+
'algorithms',
|
|
374
|
+
aliases=['alg'],
|
|
375
|
+
description=f'Show Cryptographic algorithms: {__version__}',
|
|
376
|
+
help='Retrieve cryptographic algorithms for the given components',
|
|
377
|
+
)
|
|
378
|
+
p_crypto_algorithms.add_argument(
|
|
379
|
+
'--with-range',
|
|
380
|
+
action='store_true',
|
|
381
|
+
help='Returns the list of versions in the specified range that contains cryptographic algorithms',
|
|
382
|
+
)
|
|
383
|
+
p_crypto_algorithms.set_defaults(func=crypto_algorithms)
|
|
384
|
+
|
|
385
|
+
# GetEncryptionHints and GetHintsInRange gRPC APIs
|
|
386
|
+
p_crypto_hints = crypto_sub.add_parser(
|
|
387
|
+
'hints',
|
|
388
|
+
description=f'Show Encryption hints: {__version__}',
|
|
389
|
+
help='Retrieve encryption hints for the given components',
|
|
390
|
+
)
|
|
391
|
+
p_crypto_hints.add_argument(
|
|
392
|
+
'--with-range',
|
|
393
|
+
action='store_true',
|
|
394
|
+
help='Returns the list of versions in the specified range that contains encryption hints',
|
|
395
|
+
)
|
|
396
|
+
p_crypto_hints.set_defaults(func=crypto_hints)
|
|
397
|
+
|
|
398
|
+
p_crypto_versions_in_range = crypto_sub.add_parser(
|
|
399
|
+
'versions-in-range',
|
|
400
|
+
aliases=['vr'],
|
|
401
|
+
description=f'Show versions in range: {__version__}',
|
|
402
|
+
help="Given a list of PURLS and version ranges, get a list of versions that do/don't contain crypto algorithms",
|
|
403
|
+
)
|
|
404
|
+
p_crypto_versions_in_range.set_defaults(func=crypto_versions_in_range)
|
|
405
|
+
|
|
359
406
|
# Common purl Component sub-command options
|
|
360
|
-
for p in [
|
|
407
|
+
for p in [c_vulns, c_semgrep, c_provenance, p_crypto_algorithms, p_crypto_hints, p_crypto_versions_in_range]:
|
|
361
408
|
p.add_argument('--purl', '-p', type=str, nargs='*', help='Package URL - PURL to process.')
|
|
362
409
|
p.add_argument('--input', '-i', type=str, help='Input file name')
|
|
363
410
|
|
|
364
411
|
# Common Component sub-command options
|
|
365
|
-
for p in [
|
|
412
|
+
for p in [
|
|
413
|
+
c_vulns,
|
|
414
|
+
c_search,
|
|
415
|
+
c_versions,
|
|
416
|
+
c_semgrep,
|
|
417
|
+
c_provenance,
|
|
418
|
+
p_crypto_algorithms,
|
|
419
|
+
p_crypto_hints,
|
|
420
|
+
p_crypto_versions_in_range,
|
|
421
|
+
]:
|
|
366
422
|
p.add_argument(
|
|
367
423
|
'--timeout',
|
|
368
424
|
'-M',
|
|
369
425
|
type=int,
|
|
370
|
-
default=
|
|
426
|
+
default=DEFAULT_API_TIMEOUT,
|
|
371
427
|
help='Timeout (in seconds) for API communication (optional - default 600)',
|
|
372
428
|
)
|
|
373
429
|
|
|
@@ -583,7 +639,6 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
583
639
|
p_dep,
|
|
584
640
|
p_fc,
|
|
585
641
|
p_cnv,
|
|
586
|
-
c_crypto,
|
|
587
642
|
c_vulns,
|
|
588
643
|
c_search,
|
|
589
644
|
c_versions,
|
|
@@ -592,6 +647,9 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
592
647
|
p_c_dwnld,
|
|
593
648
|
p_folder_scan,
|
|
594
649
|
p_folder_hash,
|
|
650
|
+
p_crypto_algorithms,
|
|
651
|
+
p_crypto_hints,
|
|
652
|
+
p_crypto_versions_in_range,
|
|
595
653
|
]:
|
|
596
654
|
p.add_argument('--output', '-o', type=str, help='Output result file name (optional - default stdout).')
|
|
597
655
|
|
|
@@ -669,7 +727,6 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
669
727
|
# Global Scan/GRPC options
|
|
670
728
|
for p in [
|
|
671
729
|
p_scan,
|
|
672
|
-
c_crypto,
|
|
673
730
|
c_vulns,
|
|
674
731
|
c_search,
|
|
675
732
|
c_versions,
|
|
@@ -677,6 +734,9 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
677
734
|
c_provenance,
|
|
678
735
|
p_folder_scan,
|
|
679
736
|
p_cs,
|
|
737
|
+
p_crypto_algorithms,
|
|
738
|
+
p_crypto_hints,
|
|
739
|
+
p_crypto_versions_in_range,
|
|
680
740
|
]:
|
|
681
741
|
p.add_argument(
|
|
682
742
|
'--key', '-k', type=str, help='SCANOSS API Key token (optional - not required for default OSSKB URL)'
|
|
@@ -703,7 +763,19 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
703
763
|
)
|
|
704
764
|
|
|
705
765
|
# Global GRPC options
|
|
706
|
-
for p in [
|
|
766
|
+
for p in [
|
|
767
|
+
p_scan,
|
|
768
|
+
c_vulns,
|
|
769
|
+
c_search,
|
|
770
|
+
c_versions,
|
|
771
|
+
c_semgrep,
|
|
772
|
+
c_provenance,
|
|
773
|
+
p_folder_scan,
|
|
774
|
+
p_cs,
|
|
775
|
+
p_crypto_algorithms,
|
|
776
|
+
p_crypto_hints,
|
|
777
|
+
p_crypto_versions_in_range,
|
|
778
|
+
]:
|
|
707
779
|
p.add_argument(
|
|
708
780
|
'--api2url', type=str, help='SCANOSS gRPC API 2.0 URL (optional - default: https://api.osskb.org)'
|
|
709
781
|
)
|
|
@@ -746,7 +818,6 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
746
818
|
p_c_loc,
|
|
747
819
|
p_c_dwnld,
|
|
748
820
|
p_p_proxy,
|
|
749
|
-
c_crypto,
|
|
750
821
|
c_vulns,
|
|
751
822
|
c_search,
|
|
752
823
|
c_versions,
|
|
@@ -758,6 +829,9 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
758
829
|
p_folder_scan,
|
|
759
830
|
p_folder_hash,
|
|
760
831
|
p_cs,
|
|
832
|
+
p_crypto_algorithms,
|
|
833
|
+
p_crypto_hints,
|
|
834
|
+
p_crypto_versions_in_range,
|
|
761
835
|
]:
|
|
762
836
|
p.add_argument('--debug', '-d', action='store_true', help='Enable debug messages')
|
|
763
837
|
p.add_argument('--trace', '-t', action='store_true', help='Enable trace messages, including API posts')
|
|
@@ -770,7 +844,9 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
770
844
|
if not args.subparser:
|
|
771
845
|
parser.print_help() # No sub command subcommand, print general help
|
|
772
846
|
sys.exit(1)
|
|
773
|
-
elif (
|
|
847
|
+
elif (
|
|
848
|
+
args.subparser in ('utils', 'ut', 'component', 'comp', 'inspect', 'insp', 'ins', 'crypto', 'cr')
|
|
849
|
+
) and not args.subparsercmd:
|
|
774
850
|
parser.parse_args([args.subparser, '--help']) # Force utils helps to be displayed
|
|
775
851
|
sys.exit(1)
|
|
776
852
|
args.func(parser, args) # Execute the function associated with the sub-command
|
|
@@ -1388,9 +1464,9 @@ def get_pac_file(pac: str):
|
|
|
1388
1464
|
return pac_file
|
|
1389
1465
|
|
|
1390
1466
|
|
|
1391
|
-
def
|
|
1467
|
+
def crypto_algorithms(parser, args):
|
|
1392
1468
|
"""
|
|
1393
|
-
Run the "
|
|
1469
|
+
Run the "crypto algorithms" sub-command
|
|
1394
1470
|
Parameters
|
|
1395
1471
|
----------
|
|
1396
1472
|
parser: ArgumentParser
|
|
@@ -1405,22 +1481,112 @@ def comp_crypto(parser, args):
|
|
|
1405
1481
|
if args.ca_cert and not os.path.exists(args.ca_cert):
|
|
1406
1482
|
print_stderr(f'Error: Certificate file does not exist: {args.ca_cert}.')
|
|
1407
1483
|
sys.exit(1)
|
|
1408
|
-
pac_file = get_pac_file(args.pac)
|
|
1409
1484
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1485
|
+
try:
|
|
1486
|
+
config = create_cryptography_config_from_args(args)
|
|
1487
|
+
grpc_config = create_grpc_config_from_args(args)
|
|
1488
|
+
if args.pac:
|
|
1489
|
+
grpc_config.pac = get_pac_file(args.pac)
|
|
1490
|
+
if args.header:
|
|
1491
|
+
grpc_config.req_headers = process_req_headers(args.header)
|
|
1492
|
+
client = ScanossGrpc(**asdict(grpc_config))
|
|
1493
|
+
|
|
1494
|
+
cryptography = Cryptography(config=config, client=client)
|
|
1495
|
+
cryptography.get_algorithms()
|
|
1496
|
+
cryptography.present(output_file=args.output)
|
|
1497
|
+
except ScanossGrpcError as e:
|
|
1498
|
+
print_stderr(f'API ERROR: {e}')
|
|
1499
|
+
sys.exit(1)
|
|
1500
|
+
except Exception as e:
|
|
1501
|
+
if args.debug:
|
|
1502
|
+
import traceback
|
|
1503
|
+
|
|
1504
|
+
traceback.print_exc()
|
|
1505
|
+
print_stderr(f'ERROR: {e}')
|
|
1506
|
+
sys.exit(1)
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
def crypto_hints(parser, args):
|
|
1510
|
+
"""
|
|
1511
|
+
Run the "crypto hints" sub-command
|
|
1512
|
+
Parameters
|
|
1513
|
+
----------
|
|
1514
|
+
parser: ArgumentParser
|
|
1515
|
+
command line parser object
|
|
1516
|
+
args: Namespace
|
|
1517
|
+
Parsed arguments
|
|
1518
|
+
"""
|
|
1519
|
+
if (not args.purl and not args.input) or (args.purl and args.input):
|
|
1520
|
+
print_stderr('Please specify an input file or purl to decorate (--purl or --input)')
|
|
1521
|
+
parser.parse_args([args.subparser, args.subparsercmd, '-h'])
|
|
1522
|
+
sys.exit(1)
|
|
1523
|
+
if args.ca_cert and not os.path.exists(args.ca_cert):
|
|
1524
|
+
print_stderr(f'Error: Certificate file does not exist: {args.ca_cert}.')
|
|
1525
|
+
sys.exit(1)
|
|
1526
|
+
|
|
1527
|
+
try:
|
|
1528
|
+
config = create_cryptography_config_from_args(args)
|
|
1529
|
+
grpc_config = create_grpc_config_from_args(args)
|
|
1530
|
+
if args.pac:
|
|
1531
|
+
grpc_config.pac = get_pac_file(args.pac)
|
|
1532
|
+
if args.header:
|
|
1533
|
+
grpc_config.req_headers = process_req_headers(args.header)
|
|
1534
|
+
client = ScanossGrpc(**asdict(grpc_config))
|
|
1535
|
+
|
|
1536
|
+
cryptography = Cryptography(config=config, client=client)
|
|
1537
|
+
cryptography.get_encryption_hints()
|
|
1538
|
+
cryptography.present(output_file=args.output)
|
|
1539
|
+
except ScanossGrpcError as e:
|
|
1540
|
+
print_stderr(f'API ERROR: {e}')
|
|
1541
|
+
sys.exit(1)
|
|
1542
|
+
except Exception as e:
|
|
1543
|
+
if args.debug:
|
|
1544
|
+
import traceback
|
|
1545
|
+
|
|
1546
|
+
traceback.print_exc()
|
|
1547
|
+
print_stderr(f'ERROR: {e}')
|
|
1548
|
+
sys.exit(1)
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
def crypto_versions_in_range(parser, args):
|
|
1552
|
+
"""
|
|
1553
|
+
Run the "crypto versions-in-range" sub-command
|
|
1554
|
+
Parameters
|
|
1555
|
+
----------
|
|
1556
|
+
parser: ArgumentParser
|
|
1557
|
+
command line parser object
|
|
1558
|
+
args: Namespace
|
|
1559
|
+
Parsed arguments
|
|
1560
|
+
"""
|
|
1561
|
+
if (not args.purl and not args.input) or (args.purl and args.input):
|
|
1562
|
+
print_stderr('Please specify an input file or purl to decorate (--purl or --input)')
|
|
1563
|
+
parser.parse_args([args.subparser, args.subparsercmd, '-h'])
|
|
1564
|
+
sys.exit(1)
|
|
1565
|
+
if args.ca_cert and not os.path.exists(args.ca_cert):
|
|
1566
|
+
print_stderr(f'Error: Certificate file does not exist: {args.ca_cert}.')
|
|
1567
|
+
sys.exit(1)
|
|
1568
|
+
|
|
1569
|
+
try:
|
|
1570
|
+
config = create_cryptography_config_from_args(args)
|
|
1571
|
+
grpc_config = create_grpc_config_from_args(args)
|
|
1572
|
+
if args.pac:
|
|
1573
|
+
grpc_config.pac = get_pac_file(args.pac)
|
|
1574
|
+
if args.header:
|
|
1575
|
+
grpc_config.req_headers = process_req_headers(args.header)
|
|
1576
|
+
client = ScanossGrpc(**asdict(grpc_config))
|
|
1577
|
+
|
|
1578
|
+
cryptography = Cryptography(config=config, client=client)
|
|
1579
|
+
cryptography.get_versions_in_range()
|
|
1580
|
+
cryptography.present(output_file=args.output)
|
|
1581
|
+
except ScanossGrpcError as e:
|
|
1582
|
+
print_stderr(f'API ERROR: {e}')
|
|
1583
|
+
sys.exit(1)
|
|
1584
|
+
except Exception as e:
|
|
1585
|
+
if args.debug:
|
|
1586
|
+
import traceback
|
|
1587
|
+
|
|
1588
|
+
traceback.print_exc()
|
|
1589
|
+
print_stderr(f'ERROR: {e}')
|
|
1424
1590
|
sys.exit(1)
|
|
1425
1591
|
|
|
1426
1592
|
|
|
@@ -1579,7 +1745,7 @@ def comp_versions(parser, args):
|
|
|
1579
1745
|
|
|
1580
1746
|
def comp_provenance(parser, args):
|
|
1581
1747
|
"""
|
|
1582
|
-
Run the "component
|
|
1748
|
+
Run the "component provenance" sub-command
|
|
1583
1749
|
Parameters
|
|
1584
1750
|
----------
|
|
1585
1751
|
parser: ArgumentParser
|
|
@@ -1608,7 +1774,7 @@ def comp_provenance(parser, args):
|
|
|
1608
1774
|
timeout=args.timeout,
|
|
1609
1775
|
req_headers=process_req_headers(args.header),
|
|
1610
1776
|
)
|
|
1611
|
-
if not comps.get_provenance_details(args.input, args.purl, args.output):
|
|
1777
|
+
if not comps.get_provenance_details(args.input, args.purl, args.output, args.origin):
|
|
1612
1778
|
sys.exit(1)
|
|
1613
1779
|
|
|
1614
1780
|
|
|
@@ -1711,8 +1877,8 @@ def folder_hashing_scan(parser, args):
|
|
|
1711
1877
|
scanner.best_match = args.best_match
|
|
1712
1878
|
scanner.threshold = args.threshold
|
|
1713
1879
|
|
|
1714
|
-
scanner.scan()
|
|
1715
|
-
|
|
1880
|
+
if scanner.scan():
|
|
1881
|
+
scanner.present(output_file=args.output, output_format=args.format)
|
|
1716
1882
|
except ScanossGrpcError as e:
|
|
1717
1883
|
print_stderr(f'ERROR: {e}')
|
|
1718
1884
|
sys.exit(1)
|
scanoss/components.py
CHANGED
|
@@ -39,7 +39,7 @@ class Components(ScanossBase):
|
|
|
39
39
|
Class for Component functionality
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
|
-
def __init__(
|
|
42
|
+
def __init__( # noqa: PLR0913, PLR0915
|
|
43
43
|
self,
|
|
44
44
|
debug: bool = False,
|
|
45
45
|
trace: bool = False,
|
|
@@ -244,7 +244,7 @@ class Components(ScanossBase):
|
|
|
244
244
|
self._close_file(output_file, file)
|
|
245
245
|
return success
|
|
246
246
|
|
|
247
|
-
def search_components(
|
|
247
|
+
def search_components( # noqa: PLR0913, PLR0915
|
|
248
248
|
self,
|
|
249
249
|
output_file: str = None,
|
|
250
250
|
json_file: str = None,
|
|
@@ -330,14 +330,20 @@ class Components(ScanossBase):
|
|
|
330
330
|
self._close_file(output_file, file)
|
|
331
331
|
return success
|
|
332
332
|
|
|
333
|
-
def get_provenance_details(
|
|
333
|
+
def get_provenance_details(
|
|
334
|
+
self, json_file: str = None, purls: [] = None, output_file: str = None, origin: bool = False
|
|
335
|
+
) -> bool:
|
|
334
336
|
"""
|
|
335
|
-
Retrieve the
|
|
337
|
+
Retrieve the provenance details for the supplied PURLs
|
|
336
338
|
|
|
337
|
-
:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
Args:
|
|
340
|
+
json_file (str, optional): Input JSON file. Defaults to None.
|
|
341
|
+
purls (None, optional): PURLs to retrieve provenance details for. Defaults to None.
|
|
342
|
+
output_file (str, optional): Output file. Defaults to None.
|
|
343
|
+
origin (bool, optional): Retrieve origin details. Defaults to False.
|
|
344
|
+
|
|
345
|
+
Returns:
|
|
346
|
+
bool: True on success, False otherwise
|
|
341
347
|
"""
|
|
342
348
|
success = False
|
|
343
349
|
purls_request = self.load_purls(json_file, purls)
|
|
@@ -346,12 +352,16 @@ class Components(ScanossBase):
|
|
|
346
352
|
file = self._open_file_or_sdtout(output_file)
|
|
347
353
|
if file is None:
|
|
348
354
|
return False
|
|
349
|
-
|
|
350
|
-
|
|
355
|
+
if origin:
|
|
356
|
+
self.print_msg('Sending PURLs to Geo Provenance Origin API for decoration...')
|
|
357
|
+
response = self.grpc_api.get_provenance_origin(purls_request)
|
|
358
|
+
else:
|
|
359
|
+
self.print_msg('Sending PURLs to Geo Provenance Declared API for decoration...')
|
|
360
|
+
response = self.grpc_api.get_provenance_json(purls_request)
|
|
351
361
|
if response:
|
|
352
362
|
print(json.dumps(response, indent=2, sort_keys=True), file=file)
|
|
353
363
|
success = True
|
|
354
364
|
if output_file:
|
|
355
365
|
self.print_msg(f'Results written to: {output_file}')
|
|
356
366
|
self._close_file(output_file, file)
|
|
357
|
-
return success
|
|
367
|
+
return success
|