Skip to content

Commit b5aef8d

Browse files
committed
feat: ES-213 Fix wfp scanoss settings bug
1 parent 470c127 commit b5aef8d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Add `--container` flag to `dependency` subcommand to scan dependencies in container images.
1616
### Modified
1717
- Refactor CLI argument handling for output and format options.
18+
### Fixed
19+
- Fixed issue with wfp command where settings file was being loaded from the cwd instead of the scan root directory
1820

1921
## [1.21.0] - 2025-03-27
2022
### Added

src/scanoss/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def wfp(parser, args):
844844
if not args.skip_settings_file:
845845
scan_settings = ScanossSettings(debug=args.debug, trace=args.trace, quiet=args.quiet)
846846
try:
847-
scan_settings.load_json_file(args.settings)
847+
scan_settings.load_json_file(args.settings, args.scan_dir)
848848
except ScanossSettingsError as e:
849849
print_stderr(f'Error: {e}')
850850
sys.exit(1)

src/scanoss/scanoss_settings.py

Lines changed: 9 additions & 5 deletions
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,7 +100,7 @@ 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
@@ -118,7 +122,7 @@ def load_json_file(self, filepath: 'str | None' = None, scan_root: 'str | None'
118122

119123
result = validate_json_file(json_file)
120124
if not result.is_valid:
121-
if result.error_code == JSON_ERROR_FILE_NOT_FOUND or result.error_code == JSON_ERROR_FILE_EMPTY:
125+
if result.error_code in (JSON_ERROR_FILE_NOT_FOUND, JSON_ERROR_FILE_EMPTY):
122126
self.print_msg(
123127
f'WARNING: The supplied settings file "{filepath}" was not found or is empty. Skipping...'
124128
)
@@ -235,7 +239,7 @@ def _get_sbom_assets(self):
235239
include_bom_entries = self._remove_duplicates(self.normalize_bom_entries(self.get_bom_include()))
236240
replace_bom_entries = self._remove_duplicates(self.normalize_bom_entries(self.get_bom_replace()))
237241
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"
242+
f"Scan type set to 'identify'. Adding {len(include_bom_entries) + len(replace_bom_entries)} components as context to the scan. \n" # noqa: E501
239243
f'From Include list: {[entry["purl"] for entry in include_bom_entries]} \n'
240244
f'From Replace list: {[entry["purl"] for entry in replace_bom_entries]} \n'
241245
)

0 commit comments

Comments
 (0)