scanoss 1.19.4__py3-none-any.whl → 1.19.6__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 CHANGED
@@ -22,4 +22,4 @@
22
22
  THE SOFTWARE.
23
23
  """
24
24
 
25
- __version__ = "1.19.4"
25
+ __version__ = "1.19.6"
scanoss/cli.py CHANGED
@@ -575,11 +575,11 @@ def scan(parser, args):
575
575
  scan_settings = ScanossSettings(debug=args.debug, trace=args.trace, quiet=args.quiet)
576
576
  try:
577
577
  if args.identify:
578
- scan_settings.load_json_file(args.identify).set_file_type('legacy').set_scan_type('identify')
578
+ scan_settings.load_json_file(args.identify, args.scan_dir).set_file_type('legacy').set_scan_type('identify')
579
579
  elif args.ignore:
580
- scan_settings.load_json_file(args.ignore).set_file_type('legacy').set_scan_type('blacklist')
580
+ scan_settings.load_json_file(args.ignore, args.scan_dir).set_file_type('legacy').set_scan_type('blacklist')
581
581
  else:
582
- scan_settings.load_json_file(args.settings).set_file_type('new').set_scan_type('identify')
582
+ scan_settings.load_json_file(args.settings, args.scan_dir).set_file_type('new').set_scan_type('identify')
583
583
  except ScanossSettingsError as e:
584
584
  print_stderr(f'Error: {e}')
585
585
  exit(1)
scanoss/cyclonedx.py CHANGED
@@ -197,12 +197,12 @@ class CycloneDx(ScanossBase):
197
197
  'name': 'scanoss-py',
198
198
  'version': __version__,
199
199
  }
200
- ]
201
- },
202
- 'component': {
203
- 'type': 'application',
204
- 'name': 'NOASSERTION',
205
- 'version': 'NOASSERTION'
200
+ ],
201
+ 'component': {
202
+ 'type': 'application',
203
+ 'name': 'NOASSERTION',
204
+ 'version': 'NOASSERTION'
205
+ }
206
206
  },
207
207
  'components': [],
208
208
  'vulnerabilities': []
@@ -1 +1 @@
1
- date: 20250108144949, utime: 1736347789
1
+ date: 20250130190618, utime: 1738263978
@@ -30,9 +30,9 @@ import importlib_resources
30
30
  from jsonschema import validate
31
31
 
32
32
  from .scanossbase import ScanossBase
33
- from .utils.file import validate_json_file
33
+ from .utils.file import JSON_ERROR_FILE_NOT_FOUND, JSON_ERROR_FILE_EMPTY, validate_json_file
34
34
 
35
- DEFAULT_SCANOSS_JSON_FILE = 'scanoss.json'
35
+ DEFAULT_SCANOSS_JSON_FILE = Path('scanoss.json')
36
36
 
37
37
 
38
38
  class BomEntry(TypedDict, total=False):
@@ -96,16 +96,20 @@ class ScanossSettings(ScanossBase):
96
96
  if filepath:
97
97
  self.load_json_file(filepath)
98
98
 
99
- def load_json_file(self, filepath: 'str | None' = None) -> 'ScanossSettings':
99
+ def load_json_file(self, filepath: 'str | None' = None, scan_root: 'str | None' = None) -> 'ScanossSettings':
100
100
  """
101
101
  Load the scan settings file. If no filepath is provided, scanoss.json will be used as default.
102
102
 
103
103
  Args:
104
104
  filepath (str): Path to the SCANOSS settings file
105
105
  """
106
+
106
107
  if not filepath:
107
108
  filepath = DEFAULT_SCANOSS_JSON_FILE
108
- json_file = Path(filepath).resolve()
109
+
110
+ filepath = Path(scan_root) / filepath if scan_root else Path(filepath)
111
+
112
+ json_file = filepath.resolve()
109
113
 
110
114
  if filepath == DEFAULT_SCANOSS_JSON_FILE and not json_file.exists():
111
115
  self.print_debug(f'Default settings file "{filepath}" not found. Skipping...')
@@ -114,7 +118,11 @@ class ScanossSettings(ScanossBase):
114
118
 
115
119
  result = validate_json_file(json_file)
116
120
  if not result.is_valid:
117
- raise ScanossSettingsError(f'Problem with settings file. {result.error}')
121
+ if result.error_code == JSON_ERROR_FILE_NOT_FOUND or result.error_code == JSON_ERROR_FILE_EMPTY:
122
+ self.print_msg(f'WARNING: The supplied settings file "{filepath}" was not found or is empty. Skipping...')
123
+ return self
124
+ else:
125
+ raise ScanossSettingsError(f'Problem with settings file. {result.error}')
118
126
  try:
119
127
  validate(result.data, self.schema)
120
128
  except Exception as e:
scanoss/utils/file.py CHANGED
@@ -21,18 +21,24 @@ SPDX-License-Identifier: MIT
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  THE SOFTWARE.
23
23
  """
24
+
24
25
  import json
25
26
  import os
26
- import sys
27
27
  from dataclasses import dataclass
28
28
  from typing import Optional
29
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
+
30
35
 
31
36
  @dataclass
32
37
  class JsonValidation:
33
38
  is_valid: bool
34
39
  data: Optional[dict] = None
35
40
  error: Optional[str] = None
41
+ error_code: Optional[int] = None
36
42
 
37
43
 
38
44
  def validate_json_file(json_file_path: str) -> JsonValidation:
@@ -46,12 +52,33 @@ def validate_json_file(json_file_path: str) -> JsonValidation:
46
52
  Tuple[bool, str]: A tuple containing a boolean indicating if the file is valid and a message
47
53
  """
48
54
  if not json_file_path:
49
- return JsonValidation(is_valid=False, error='No JSON file specified')
55
+ return JsonValidation(is_valid=False, error="No JSON file specified")
50
56
  if not os.path.isfile(json_file_path):
51
- return JsonValidation(is_valid=False, error=f'File not found: {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
+ )
52
75
  try:
53
76
  with open(json_file_path) as f:
54
77
  data = json.load(f)
55
78
  return JsonValidation(is_valid=True, data=data)
56
79
  except json.JSONDecodeError as e:
57
- return JsonValidation(is_valid=False, error=f'Problem parsing JSON file: "{json_file_path}": {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
+ )
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: scanoss
3
- Version: 1.19.4
3
+ Version: 1.19.6
4
4
  Summary: Simple Python library to leverage the SCANOSS APIs
5
5
  Home-page: https://scanoss.com
6
6
  Author: SCANOSS
@@ -4,17 +4,17 @@ protoc_gen_swagger/options/annotations_pb2.py,sha256=b25EDD6gssUWnFby9gxgcpLIROT
4
4
  protoc_gen_swagger/options/annotations_pb2_grpc.py,sha256=1oboBPFxaTEXt9Aw7EAj8gXHDCNMhZD2VXqocC9l_gk,159
5
5
  protoc_gen_swagger/options/openapiv2_pb2.py,sha256=vYElGp8E1vGHszvWqX97zNG9GFJ7u2QcdK9ouq0XdyI,14939
6
6
  protoc_gen_swagger/options/openapiv2_pb2_grpc.py,sha256=1oboBPFxaTEXt9Aw7EAj8gXHDCNMhZD2VXqocC9l_gk,159
7
- scanoss/__init__.py,sha256=lzQZL-XMupclTvPVGCfZB-UAGfik20RjvISPAt1i9Fo,1163
8
- scanoss/cli.py,sha256=eJB6s1DVKJd3FPO7wVea8ggeAfua_-7CC8I10uSmdDc,51509
7
+ scanoss/__init__.py,sha256=DKQ4C2kCmfEN06YVkz4aiecv2uhkktLk14P24tTMmJ8,1163
8
+ scanoss/cli.py,sha256=6mAO8bBFiQ8DVEsWNs45x8luT51FxnxfE8GT_jQWWNE,51554
9
9
  scanoss/components.py,sha256=ZHZ1KA69shxOASZK7USD9yPTITpAc_RXL5q5zpDK23o,12590
10
10
  scanoss/csvoutput.py,sha256=hBwr_Fc6mBdOdXgyQcdFrockYH-PJ0jblowlExJ6OPg,9925
11
- scanoss/cyclonedx.py,sha256=ZbFNinMz_R68ko4-ZPo2w4bBORpASh271VCmYYRTUCg,12746
11
+ scanoss/cyclonedx.py,sha256=QWDNvn6o_Y6xWYEr0-qDgDtNOTaHccxPeHFoNZLx0is,12766
12
12
  scanoss/file_filters.py,sha256=HGGECJ-P0LL8pg8YVO4BP8ql24tCnanx0_S2wA8EWis,16642
13
13
  scanoss/filecount.py,sha256=o7xb6m387ucnsU4H1OXGzf_AdWsudhAHe49T8uX4Ieo,6660
14
14
  scanoss/results.py,sha256=7G33QAYYI9qI61TCzXjSLYXMmg5CDtZS5e2QhnQfE74,9883
15
15
  scanoss/scancodedeps.py,sha256=_9d7MAV20-FrET7mF7gW-BZiz2eHrtwudgrEcSX0oZQ,11321
16
16
  scanoss/scanner.py,sha256=hF8N8XXSwYw93htpqv0h0t-IqswG_bcxH7awe4JA5Aw,45374
17
- scanoss/scanoss_settings.py,sha256=AJKMJeLoPVLO15vb9Pd12b5tVCa3ALP5sOXeWR6KCb0,10144
17
+ scanoss/scanoss_settings.py,sha256=VwcvbUYjhPv6svBhtOlxULrY3TnUZgLOlcmaU_f2jTk,10590
18
18
  scanoss/scanossapi.py,sha256=TJxPctr-0DTn_26LfM__OAMfntaXzvheFTbdmU-5pnM,11953
19
19
  scanoss/scanossbase.py,sha256=zMDRCLbrcoRvYEKQRuZXnBiVY4_Vsplmg_APbB65oaU,3084
20
20
  scanoss/scanossgrpc.py,sha256=ythZkr6F0P0hl_KPYoHkos_IL97TxLKeYfAouX_CUnM,20491
@@ -51,7 +51,7 @@ scanoss/api/vulnerabilities/__init__.py,sha256=FLQtiDiv85Q1Chk-sJ9ky9WOV1mulZhEK
51
51
  scanoss/api/vulnerabilities/v2/__init__.py,sha256=FLQtiDiv85Q1Chk-sJ9ky9WOV1mulZhEKjiBihlwiaM,1139
52
52
  scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py,sha256=CFhF80av8tenGvn9AIsGEtRJPuV2dC_syA5JLZb2lDw,5464
53
53
  scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py,sha256=HlS4k4Zmx6RIAqaO9I96jD-eyF5yU6Xx04pVm7pdqOg,6864
54
- scanoss/data/build_date.txt,sha256=I2tiS4Cw-x-eVSPBx4mOEQefstESmGedPYeWtb6B5W4,40
54
+ scanoss/data/build_date.txt,sha256=pY9qGh_8jGdbdRkRMjlqers462ORg9vEPvGq8Vk2PPU,40
55
55
  scanoss/data/scanoss-settings-schema.json,sha256=ClkRYAkjAN0Sk704G8BE_Ok006oQ6YnIGmX84CF8h9w,8798
56
56
  scanoss/data/spdx-exceptions.json,sha256=s7UTYxC7jqQXr11YBlIWYCNwN6lRDFTR33Y8rpN_dA4,17953
57
57
  scanoss/data/spdx-licenses.json,sha256=A6Z0q82gaTLtnopBfzeIVZjJFxkdRW1g2TuumQc-lII,228794
@@ -61,10 +61,10 @@ scanoss/inspection/policy_check.py,sha256=mbtNwDydf2aBUCz9n2yNG6DV6rc7HH_ZaQuK2C
61
61
  scanoss/inspection/undeclared_component.py,sha256=QvlBgYpytQhaWlVqrz3p8JPIGbsX8v8U59n-4Q2llLc,9951
62
62
  scanoss/inspection/utils/license_utils.py,sha256=mIaoVWXMA6shkRQmgmiP2mWchjxX4ex8LWs91Nf6rq4,5093
63
63
  scanoss/utils/__init__.py,sha256=0hjb5ktavp7utJzFhGMPImPaZiHWgilM2HwvTp5lXJE,1122
64
- scanoss/utils/file.py,sha256=W-XFLgaTM_td31Y5rzd5DimO4_qXafQhBtKtY_p3JIQ,2184
65
- scanoss-1.19.4.dist-info/LICENSE,sha256=LLUaXoiyOroIbr5ubAyrxBOwSRLTm35ETO2FmLpy8QQ,1074
66
- scanoss-1.19.4.dist-info/METADATA,sha256=aodKN8xCOP_yUP5w9Ey4SCrIoXVAIBDjbVBk-xZcNl0,6019
67
- scanoss-1.19.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
68
- scanoss-1.19.4.dist-info/entry_points.txt,sha256=Uy28xnaDL5KQ7V77sZD5VLDXPNxYYzSr5tsqtiXVzAs,48
69
- scanoss-1.19.4.dist-info/top_level.txt,sha256=V11PrQ6Pnrc-nDF9xnisnJ8e6-i7HqSIKVNqduRWcL8,27
70
- scanoss-1.19.4.dist-info/RECORD,,
64
+ scanoss/utils/file.py,sha256=0Dv0Si8qVOGjauOboqos_caZhLR6qc6qEyKZDNwG3VA,2933
65
+ scanoss-1.19.6.dist-info/LICENSE,sha256=LLUaXoiyOroIbr5ubAyrxBOwSRLTm35ETO2FmLpy8QQ,1074
66
+ scanoss-1.19.6.dist-info/METADATA,sha256=J5Gz8LczPYkxOAQrJuheiw2vIprpOtxx1arxKoEX5QU,6019
67
+ scanoss-1.19.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
68
+ scanoss-1.19.6.dist-info/entry_points.txt,sha256=Uy28xnaDL5KQ7V77sZD5VLDXPNxYYzSr5tsqtiXVzAs,48
69
+ scanoss-1.19.6.dist-info/top_level.txt,sha256=V11PrQ6Pnrc-nDF9xnisnJ8e6-i7HqSIKVNqduRWcL8,27
70
+ scanoss-1.19.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.7.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5