Skip to content

Commit 82f0ec2

Browse files
committed
fix: SP-2339 Fix wfp command loading settings file from cwd
fix: SP-2339 Lint fix: SP-2339 Lint
1 parent 8af0416 commit 82f0ec2

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Diff for: CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [1.20.7] - 2025-04-11
13+
### Fixed
14+
- Fixed issue with wfp command where settings file was being loaded from the cwd instead of the scan root directory
15+
1216
## [1.20.6] - 2025-03-19
1317
### Added
1418
- Added HTTP/gRPC generic headers feature using --header flag
@@ -490,4 +494,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
490494
[1.20.3]: https://github.com/scanoss/scanoss.py/compare/v1.20.2...v1.20.3
491495
[1.20.4]: https://github.com/scanoss/scanoss.py/compare/v1.20.3...v1.20.4
492496
[1.20.5]: https://github.com/scanoss/scanoss.py/compare/v1.20.4...v1.20.5
493-
[1.20.6]: https://github.com/scanoss/scanoss.py/compare/v1.20.5...v1.20.6
497+
[1.20.6]: https://github.com/scanoss/scanoss.py/compare/v1.20.5...v1.20.6
498+
[1.20.7]: https://github.com/scanoss/scanoss.py/compare/v1.20.6...v1.20.7

Diff for: src/scanoss/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
THE SOFTWARE.
2323
"""
2424

25-
__version__ = '1.20.6'
25+
__version__ = '1.20.7'

Diff for: src/scanoss/cli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import os
2727
import sys
2828
from pathlib import Path
29+
from typing import List
2930

3031
import pypac
31-
from typing import List
3232

3333
from . import __version__
3434
from .components import Components
@@ -691,7 +691,7 @@ def wfp(parser, args):
691691
if not args.skip_settings_file:
692692
scan_settings = ScanossSettings(debug=args.debug, trace=args.trace, quiet=args.quiet)
693693
try:
694-
scan_settings.load_json_file(args.settings)
694+
scan_settings.load_json_file(args.settings, args.scan_dir)
695695
except ScanossSettingsError as e:
696696
print_stderr(f'Error: {e}')
697697
sys.exit(1)
@@ -1204,7 +1204,7 @@ def get_pac_file(pac: str):
12041204
if pac == 'auto':
12051205
pac_file = pypac.get_pac() # try to determine the PAC file
12061206
elif pac.startswith('file://'):
1207-
pac_local = pac.strip('file://')
1207+
pac_local = pac[7:] # Remove 'file://' prefix
12081208
if not os.path.exists(pac_local):
12091209
print_stderr(f'Error: PAC file does not exist: {pac_local}.')
12101210
sys.exit(1)

Diff for: src/scanoss/scanoss_settings.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424

2525
import json
2626
from pathlib import Path
27-
from typing import List, TypedDict
27+
from typing import List, Optional, TypedDict
2828

2929
import importlib_resources
3030
from jsonschema import validate
3131

3232
from .scanossbase import ScanossBase
33-
from .utils.file import JSON_ERROR_FILE_NOT_FOUND, JSON_ERROR_FILE_EMPTY, validate_json_file
33+
from .utils.file import (
34+
JSON_ERROR_FILE_EMPTY,
35+
JSON_ERROR_FILE_NOT_FOUND,
36+
validate_json_file,
37+
)
3438

3539
DEFAULT_SCANOSS_JSON_FILE = Path('scanoss.json')
3640

@@ -96,12 +100,13 @@ def __init__(
96100
if filepath:
97101
self.load_json_file(filepath)
98102

99-
def load_json_file(self, filepath: 'str | None' = None, scan_root: 'str | None' = None) -> 'ScanossSettings':
103+
def load_json_file(self, filepath: Optional[str] = None, scan_root: Optional[str] = None) -> 'ScanossSettings':
100104
"""
101105
Load the scan settings file. If no filepath is provided, scanoss.json will be used as default.
102106
103107
Args:
104108
filepath (str): Path to the SCANOSS settings file
109+
scan_root (str): Path to the scan root directory
105110
"""
106111

107112
if not filepath:
@@ -118,7 +123,7 @@ def load_json_file(self, filepath: 'str | None' = None, scan_root: 'str | None'
118123

119124
result = validate_json_file(json_file)
120125
if not result.is_valid:
121-
if result.error_code == JSON_ERROR_FILE_NOT_FOUND or result.error_code == JSON_ERROR_FILE_EMPTY:
126+
if result.error_code in (JSON_ERROR_FILE_NOT_FOUND, JSON_ERROR_FILE_EMPTY):
122127
self.print_msg(
123128
f'WARNING: The supplied settings file "{filepath}" was not found or is empty. Skipping...'
124129
)
@@ -235,7 +240,7 @@ def _get_sbom_assets(self):
235240
include_bom_entries = self._remove_duplicates(self.normalize_bom_entries(self.get_bom_include()))
236241
replace_bom_entries = self._remove_duplicates(self.normalize_bom_entries(self.get_bom_replace()))
237242
self.print_debug(
238-
f"Scan type set to 'identify'. Adding {len(include_bom_entries) + len(replace_bom_entries)} components as context to the scan. \n"
243+
f"Scan type set to 'identify'. Adding {len(include_bom_entries) + len(replace_bom_entries)} components as context to the scan. \n" # noqa: E501
239244
f'From Include list: {[entry["purl"] for entry in include_bom_entries]} \n'
240245
f'From Replace list: {[entry["purl"] for entry in replace_bom_entries]} \n'
241246
)

0 commit comments

Comments
 (0)