Skip to content

Commit e1320cc

Browse files
authored
Added catch for empty results file in dependency track (#146)
* Added catch for empty results file in dependency track
1 parent 3900859 commit e1320cc

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
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.31.4] - 2025-08-20
13+
### Added
14+
- Added support for empty dependency track project policy checks
15+
1216
## [1.31.3] - 2025-08-19
1317
### Fixed
1418
- Added handling for empty results files
@@ -642,4 +646,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
642646
[1.31.0]: https://github.com/scanoss/scanoss.py/compare/v1.30.0...v1.31.0
643647
[1.31.1]: https://github.com/scanoss/scanoss.py/compare/v1.31.0...v1.31.1
644648
[1.31.2]: https://github.com/scanoss/scanoss.py/compare/v1.31.1...v1.31.2
645-
[1.31.2]: https://github.com/scanoss/scanoss.py/compare/v1.31.2...v1.31.3
649+
[1.31.3]: https://github.com/scanoss/scanoss.py/compare/v1.31.2...v1.31.3
650+
[1.31.4]: https://github.com/scanoss/scanoss.py/compare/v1.31.3...v1.31.4

src/scanoss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
THE SOFTWARE.
2323
"""
2424

25-
__version__ = '1.31.3'
25+
__version__ = '1.31.4'

src/scanoss/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,8 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
803803
p_inspect_dt_project_violation.add_argument(
804804
'--timeout', '-M',
805805
required=False,
806-
default='300',
806+
default=300,
807+
type=float,
807808
help='Timeout (in seconds) for API communication (optional - default 300 sec)'
808809
)
809810

src/scanoss/inspection/dependency_track/project_violation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# Constants
3333
PROCESSING_RETRY_DELAY = 5 # seconds
34-
DEFAULT_TIME_OUT = 300
34+
DEFAULT_TIME_OUT = 300.0
3535
MILLISECONDS_TO_SECONDS = 1000
3636

3737

@@ -257,6 +257,12 @@ def _safe_timestamp(field, value=None, default=0) -> float:
257257
self.print_msg(f'last_occurrence: {last_occurrence}')
258258
self.print_msg(f'last_vulnerability_analysis is updated: {last_vulnerability_analysis >= last_import}')
259259
self.print_msg(f'last_occurrence is updated: {last_occurrence >= last_import}')
260+
# Catches case where vulnerability analysis is skipped for empty SBOMs
261+
if 0 < last_import <= last_occurrence:
262+
component_count = metrics.get('components', 0) if isinstance(metrics, dict) else 0
263+
if component_count < 1:
264+
self.print_msg('Notice: Empty SBOM detected. Assuming no violations.')
265+
return True
260266
# If all timestamps are zero, this indicates no processing has occurred
261267
if last_vulnerability_analysis == 0 or last_occurrence == 0 or last_import == 0:
262268
self.print_stderr(f'Warning: Some project data appears to be unset. Returning False: {dt_project}')

0 commit comments

Comments
 (0)