Skip to content

Commit

Permalink
CM-41380 - Fix SBOM report creation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Oct 22, 2024
1 parent 68ad6c8 commit 2006977
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ python cycode/cli/main.py

### Code linting and formatting

We use `ruff` and `ruff format`.
We use `ruff`.
It is configured well, so you don’t need to do anything.
You can see all enabled rules in the `pyproject.toml` file.
Both tests and the main codebase are checked.
Expand All @@ -63,7 +63,7 @@ GitHub Actions will check that your code is formatted well. You can run it local

```shell
# lint
poetry run ruff .
poetry run ruff check .
# format
poetry run ruff format .
```
Expand Down
43 changes: 22 additions & 21 deletions cycode/cli/files_collector/sca/sca_code_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,28 @@ def try_restore_dependencies(
restore_dependencies: 'BaseRestoreDependencies',
document: Document,
) -> None:
if restore_dependencies.is_project(document):
restore_dependencies_document = restore_dependencies.restore(document)
if restore_dependencies_document is None:
logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
return

if restore_dependencies_document.content is None:
logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
restore_dependencies_document.content = ''
else:
is_monitor_action = context.obj['monitor']

project_path = get_path_from_context(context)

manifest_file_path = get_manifest_file_path(document, is_monitor_action, project_path)
logger.debug('Succeeded to generate dependencies tree on path: %s', manifest_file_path)

if restore_dependencies_document.path in documents_to_add:
logger.debug('Duplicate document on restore for path: %s', restore_dependencies_document.path)
else:
documents_to_add[restore_dependencies_document.path] = restore_dependencies_document
if not restore_dependencies.is_project(document):
return

restore_dependencies_document = restore_dependencies.restore(document)
if restore_dependencies_document is None:
logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
return

if restore_dependencies_document.content is None:
logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
restore_dependencies_document.content = ''
else:
is_monitor_action = context.obj.get('monitor', False)
project_path = get_path_from_context(context)

manifest_file_path = get_manifest_file_path(document, is_monitor_action, project_path)
logger.debug('Succeeded to generate dependencies tree on path: %s', manifest_file_path)

if restore_dependencies_document.path in documents_to_add:
logger.debug('Duplicate document on restore for path: %s', restore_dependencies_document.path)
else:
documents_to_add[restore_dependencies_document.path] = restore_dependencies_document


def add_dependencies_tree_document(
Expand Down

0 comments on commit 2006977

Please sign in to comment.