Skip to content

[SP-2874] feat: add licenses sub-command, add support for ingesting CDX, add CDX input validation #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

matiasdaloia
Copy link
Contributor

@matiasdaloia matiasdaloia commented Jul 10, 2025

Summary by CodeRabbit

  • New Features

    • Added a new CLI sub-command to display license details for components.
    • Introduced support for CycloneDX (CDX) input validation and ingestion across all relevant commands.
    • Added the ability to retrieve license information for supplied PURLs.
  • Dependency Updates

    • Updated and added dependencies to support new features, including CycloneDX validation.
  • Improvements

    • Enhanced compatibility checks for required Python and gRPC/protobuf versions.
    • Improved internal validation and handling of input files and formats.
  • Documentation

    • Updated changelog to reflect new features and enhancements.
  • Chores

    • Updated CI workflows to use Python 3.9.

@matiasdaloia matiasdaloia self-assigned this Jul 10, 2025
@matiasdaloia matiasdaloia added the enhancement New feature or request label Jul 10, 2025
Copy link

coderabbitai bot commented Jul 10, 2025

Walkthrough

This update introduces a new licenses sub-command to the CLI, enabling license detail retrieval for components via a new gRPC service and protobuf API. CycloneDX (CDX) input is now supported and validated across decoration commands. Numerous protobuf and gRPC files were regenerated to enforce runtime version checks, update OpenAPI annotation imports, and support the new license functionality. Several dependencies and CI Python versions were updated.

Changes

File(s) Change Summary
CHANGELOG.md Added version 1.29.0 with new features: licenses sub-command, CycloneDX input support, and CDX validation. Updated version links.
.github/workflows/*.yml Updated all GitHub Actions workflows to use Python 3.9.x instead of 3.8 or 3.10.x.
requirements.txt, setup.cfg Updated grpcio minimum version to 1.70.0, added protoc-gen-openapiv2 and cyclonedx-python-lib[validation] dependencies.
src/scanoss/cli.py Added licenses sub-command under component, implemented handler comp_licenses, and ensured consistent argument parsing.
src/scanoss/components.py Refactored to support CycloneDX input: added CycloneDx usage, refactored load_purls, and implemented new get_licenses method for license retrieval.
src/scanoss/cyclonedx.py Added methods to validate CycloneDX JSON (is_cyclonedx_json) and extract PURLs from CycloneDX data (get_purls_request_from_cdx).
src/scanoss/cryptography.py Refactored input processing into _process_input_file to support CycloneDX and PurlRequest validation. Simplified _build_purls_request signature.
src/scanoss/scanossgrpc.py Added license gRPC stub initialization and get_licenses method for license-related RPCs.
src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py, scanoss_licenses_pb2_grpc.py Added new protobuf and gRPC files for the License API, including message types, enums, and service stubs for license queries.
src/scanoss/api/common/v2/scanoss_common_pb2.py Added new protobuf messages: ComponentBatchRequest and ComponentRequest. Improved runtime version validation and descriptor handling.
src/scanoss/api/components/v2/scanoss_components_pb2.py, scanoss_components_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, and improved method registration.
src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py, scanoss_cryptography_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py, scanoss_dependencies_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py, scanoss_geoprovenance_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py, scanoss_scanning_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py, scanoss_semgrep_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py, scanoss_vulnerabilities_pb2_grpc.py Regenerated protobuf and gRPC code: enforced grpc/protobuf version checks, updated OpenAPI annotation imports, improved method registration.
src/protoc_gen_swagger/options/annotations_pb2.py, openapiv2_pb2.py Updated protobuf code: enforced runtime version validation, improved import order, and descriptor handling.
src/protoc_gen_swagger/options/annotations_pb2.pyi, openapiv2_pb2.pyi Added new mypy-protobuf type stubs for OpenAPI v2 annotations and objects.
src/protoc_gen_swagger/options/annotations_pb2_grpc.py, openapiv2_pb2_grpc.py Added grpc version compatibility checks in generated gRPC code.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Components
    participant CycloneDx
    participant ScanossGrpc
    participant LicenseService

    User->>CLI: scanoss component licenses --purl/--input
    CLI->>Components: comp_licenses(args)
    Components->>CycloneDx: is_cyclonedx_json(input)
    alt CycloneDX input
        CycloneDx-->>Components: get_purls_request_from_cdx(input)
    end
    Components->>ScanossGrpc: get_licenses(purls)
    ScanossGrpc->>LicenseService: GetLicenses(ComponentBatchRequest)
    LicenseService-->>ScanossGrpc: BasicResponse
    ScanossGrpc-->>Components: response
    Components-->>CLI: output license details
    CLI-->>User: display/write output
Loading

Poem

🐇✨
A new command hops into view,
"Licenses" brings the facts to you!
CycloneDX now checked with care,
Protobufs fresh, with stubs to spare.
Version checks keep bugs at bay,
Hopping forward, clear the way—
ScanOSS grows stronger every day!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b167952 and 4c37f13.

📒 Files selected for processing (39)
  • .github/workflows/container-local-test.yml (1 hunks)
  • .github/workflows/container-publish-ghcr.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/python-local-test.yml (1 hunks)
  • .github/workflows/python-publish-pypi.yml (2 hunks)
  • .github/workflows/python-publish-testpypi.yml (2 hunks)
  • .github/workflows/version-tag.yml (1 hunks)
  • CHANGELOG.md (2 hunks)
  • requirements.txt (2 hunks)
  • setup.cfg (2 hunks)
  • src/protoc_gen_swagger/options/annotations_pb2.py (2 hunks)
  • src/protoc_gen_swagger/options/annotations_pb2.pyi (1 hunks)
  • src/protoc_gen_swagger/options/annotations_pb2_grpc.py (1 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2.py (2 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2.pyi (1 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py (1 hunks)
  • src/scanoss/api/common/v2/scanoss_common_pb2.py (1 hunks)
  • src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py (1 hunks)
  • src/scanoss/api/components/v2/scanoss_components_pb2.py (1 hunks)
  • src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py (7 hunks)
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py (1 hunks)
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py (9 hunks)
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py (1 hunks)
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py (6 hunks)
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py (1 hunks)
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py (6 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py (1 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py (1 hunks)
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py (2 hunks)
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py (5 hunks)
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py (1 hunks)
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py (5 hunks)
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py (1 hunks)
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py (6 hunks)
  • src/scanoss/cli.py (8 hunks)
  • src/scanoss/components.py (4 hunks)
  • src/scanoss/cryptography.py (4 hunks)
  • src/scanoss/cyclonedx.py (2 hunks)
  • src/scanoss/scanossgrpc.py (4 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .github/workflows/container-local-test.yml
  • .github/workflows/version-tag.yml
🚧 Files skipped from review as they are similar to previous changes (37)
  • .github/workflows/lint.yml
  • .github/workflows/container-publish-ghcr.yml
  • .github/workflows/python-local-test.yml
  • .github/workflows/python-publish-pypi.yml
  • requirements.txt
  • setup.cfg
  • CHANGELOG.md
  • .github/workflows/python-publish-testpypi.yml
  • src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py
  • src/protoc_gen_swagger/options/annotations_pb2_grpc.py
  • src/protoc_gen_swagger/options/annotations_pb2.py
  • src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py
  • src/scanoss/cryptography.py
  • src/scanoss/api/common/v2/scanoss_common_pb2.py
  • src/scanoss/scanossgrpc.py
  • src/protoc_gen_swagger/options/openapiv2_pb2.py
  • src/scanoss/components.py
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py
  • src/protoc_gen_swagger/options/annotations_pb2.pyi
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py
  • src/scanoss/cyclonedx.py
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py
  • src/scanoss/cli.py
  • src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py
  • src/scanoss/api/components/v2/scanoss_components_pb2.py
  • src/protoc_gen_swagger/options/openapiv2_pb2.pyi
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93b2475 and 3ae3dfd.

📒 Files selected for processing (12)
  • CHANGELOG.md (2 hunks)
  • requirements.txt (1 hunks)
  • setup.cfg (1 hunks)
  • src/scanoss/__init__.py (1 hunks)
  • src/scanoss/api/common/v2/scanoss_common_pb2.py (1 hunks)
  • src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py (1 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py (1 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py (1 hunks)
  • src/scanoss/cli.py (8 hunks)
  • src/scanoss/components.py (4 hunks)
  • src/scanoss/cyclonedx.py (2 hunks)
  • src/scanoss/scanossgrpc.py (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/scanoss/scanossgrpc.py (2)
src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py (3)
  • LicenseStub (29-59)
  • GetLicenses (74-79)
  • GetLicenses (159-183)
src/scanoss/components.py (1)
  • get_licenses (373-403)
src/scanoss/components.py (1)
src/scanoss/scanossgrpc.py (1)
  • get_licenses (668-683)
🪛 GitHub Actions: Build/Test Local Python Package
src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py

[error] 27-27: ModuleNotFoundError: No module named 'protoc_gen_openapiv2'. The scanoss-py command failed with exit code 1.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (27)
setup.cfg (1)

42-42: LGTM: CycloneDX dependency addition is appropriate.

The addition of cyclonedx-python-lib[validation] supports the new CycloneDX JSON validation and processing features. The [validation] extra ensures JSON schema validation capabilities are available.

src/scanoss/__init__.py (1)

25-25: LGTM: Version bump aligns with new feature additions.

The version increment from 1.27.1 to 1.28.0 is appropriate for a minor release introducing new license sub-command and CycloneDX support features.

requirements.txt (1)

16-16: LGTM: Dependency addition is consistent with setup.cfg.

The cyclonedx-python-lib[validation] dependency addition matches the setup.cfg configuration and supports the new CycloneDX functionality.

CHANGELOG.md (2)

12-17: LGTM: Changelog entry is well-formatted and comprehensive.

The version 1.28.0 changelog entry clearly documents the three main additions: licenses sub-command, CycloneDX ingestion support, and CDX input validation. The format follows the existing changelog structure.


592-592: LGTM: Version comparison link is consistent.

The version comparison link for 1.28.0 follows the established pattern and maintains consistency with existing entries.

src/scanoss/scanossgrpc.py (5)

39-39: LGTM: License stub import added correctly.

The import follows the same pattern as other gRPC stub imports in the file.


45-45: LGTM: ComponentBatchRequest import added correctly.

This import is needed for the new license functionality and follows the existing import pattern.


175-175: LGTM: License stub initialization for insecure channels.

The initialization follows the same pattern as other stubs in the class.


188-188: LGTM: License stub initialization for secure channels.

The initialization follows the same pattern as other stubs in the class.


668-683: LGTM: Well-implemented get_licenses method.

The method follows the established patterns in the class:

  • Uses the _call_rpc helper for consistent error handling
  • Proper type hints with Optional[Dict] return type
  • Appropriate debug message template
  • Correct usage of ComponentBatchRequest type

The implementation is consistent with other gRPC methods in the class.

src/scanoss/cyclonedx.py (3)

31-32: LGTM: Required imports for CycloneDX validation.

The imports are necessary for the new validation functionality and follow the existing import pattern.


311-329: LGTM: Well-implemented CycloneDX validation method.

The method provides proper validation functionality:

  • Uses CycloneDX schema v1.6 for validation
  • Includes comprehensive error handling with try-catch
  • Consistent error messaging using print_stderr
  • Returns boolean indicating validation success
  • Follows the existing class patterns

The implementation is robust and handles validation errors appropriately.


331-349: LGTM: Effective PURL extraction from CycloneDX.

The method correctly extracts PURL requests from CycloneDX components:

  • Properly handles optional version requirements
  • Creates appropriate request structure with 'purls' key
  • Handles both cases (with and without version) correctly
  • Returns the expected dictionary format

The implementation aligns with the expected input format for the license API.

src/scanoss/cli.py (3)

309-316: LGTM: Licenses sub-command properly defined

The new licenses sub-command follows the established pattern for other component sub-commands. The alias lics and handler function assignment are correctly implemented.


419-427: LGTM: Licenses sub-command properly included in common options

The c_licenses parser is correctly added to the list of parsers that receive common purl and input options, maintaining consistency with other component sub-commands.


1888-1920: LGTM: Licenses handler function correctly implemented

The comp_licenses function follows the established pattern for other component handlers:

  • Proper input validation (purl XOR input)
  • Certificate file existence check
  • PAC file processing
  • Components instance creation with all necessary parameters
  • Error handling with appropriate exit codes

The implementation is consistent with similar handlers like comp_vulns and comp_semgrep.

src/scanoss/api/common/v2/scanoss_common_pb2.py (2)

12-19: LGTM: Runtime version validation added

The protobuf runtime version validation ensures compatibility with protobuf version 5.29.0, which is a good practice for generated code.


49-52: LGTM: New message types properly defined

The serialization offsets for the new ComponentBatchRequest and ComponentRequest message types are correctly generated and will be used by the licenses API.

src/scanoss/components.py (4)

32-33: LGTM: Proper imports for CycloneDX support

The imports for CycloneDx and validate_json_file are correctly added to support CycloneDX input validation and processing.


89-89: LGTM: CycloneDx instance properly initialized

The CycloneDx instance is correctly initialized with the debug flag from the parent class, enabling CycloneDX processing capabilities.


100-108: LGTM: Enhanced load_purls method with CycloneDX support

The updated load_purls method properly:

  • Uses validate_json_file for robust JSON validation
  • Detects CycloneDX format using self.cdx.is_cyclonedx_json
  • Converts CycloneDX data to PURL request format via self.cdx.get_purls_request_from_cdx
  • Falls back to direct JSON data usage for non-CycloneDX inputs

This implementation maintains backward compatibility while adding CycloneDX support.


373-403: LGTM: get_licenses method correctly implemented

The new get_licenses method follows the established pattern of other get_* methods in the class:

  • Proper input validation and loading
  • File/stdout handling with error checking
  • Correct construction of ComponentBatchRequest dictionary
  • Appropriate gRPC API call to self.grpc_api.get_licenses
  • JSON output formatting and success handling
  • Consistent error handling and file cleanup

The method integrates well with the existing codebase architecture.

src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py (5)

1-27: Well-implemented version compatibility checking.

The version checking logic is robust and follows gRPC best practices. It gracefully handles import errors and provides clear upgrade/downgrade instructions for version mismatches.


29-60: Correctly implemented client-side gRPC stub.

The LicenseStub class properly implements all four RPC methods with correct endpoint paths, serialization, and deserialization. The implementation follows standard gRPC client patterns.


62-94: Appropriate placeholder implementations for server-side servicer.

The LicenseServicer class correctly implements placeholder methods that raise NotImplementedError with UNIMPLEMENTED status. This is the expected pattern for generated gRPC servicers, allowing developers to provide actual implementations by subclassing or overriding these methods.


96-123: Correctly implemented server registration function.

The add_LicenseServicer_to_server function properly registers all RPC method handlers with appropriate serialization/deserialization configuration. The implementation follows standard gRPC server setup patterns.


125-238: Well-implemented experimental gRPC API.

The License experimental class provides static methods for direct RPC calls with full parameter support. The implementation correctly uses grpc.experimental.unary_unary and follows the expected patterns for experimental gRPC APIs.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ae3dfd and fc12bd2.

📒 Files selected for processing (1)
  • src/scanoss/cryptography.py (3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Lint
src/scanoss/cryptography.py

[error] 30-30: Ruff: Too many branches (14 > 12) in function 'post_init' (PLR0912)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (2)
src/scanoss/cryptography.py (2)

5-5: LGTM: Clean import addition.

The import of CycloneDx is properly placed and follows the existing import structure.


193-193: LGTM: Method signature formatting improvement.

The single-line method signature is cleaner and more consistent with Python conventions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py (1)

7-24: Version mismatch issue persists and has worsened.

The generated code now requires grpcio>=1.73.1, but based on previous review comments, the project dependencies only specify grpcio>=1.70.0. This creates a version mismatch where users with grpcio versions 1.70.0-1.73.0 will encounter a RuntimeError.

This is a continuation of the issue flagged in previous reviews, but it has worsened as the required version has increased from 1.70.0 to 1.73.1.

Please ensure the project dependencies are updated to align with the generated code requirement:

# In setup.cfg and requirements.txt
-grpcio>=1.70.0
+grpcio>=1.73.1

Or alternatively, regenerate the gRPC stubs with a lower version threshold that matches the current project dependencies.

🧹 Nitpick comments (1)
src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings import is not used in the code and should be removed.

-import warnings
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 918a615 and 3eda2f9.

📒 Files selected for processing (4)
  • src/scanoss/api/common/v2/scanoss_common_pb2.py (1 hunks)
  • src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py (1 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py (1 hunks)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py
  • src/scanoss/api/common/v2/scanoss_common_pb2.py
  • src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (6)
src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py (3)

1-1: Manual modifications to generated code may be lost.

This file is marked as generated code with "DO NOT EDIT!" but contains changes. Ensure these modifications are made in the source proto files or generation scripts to prevent loss during regeneration.


4-4: Remove unused import.

The warnings module is imported but never used in the code.


9-27: Version check may be overly restrictive.

The runtime version check enforces exactly grpcio>=1.73.1, which could cause issues for users with newer compatible versions.

src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py (3)

1-1: Manual modifications to generated code may be lost.

This file is marked as generated code with "DO NOT EDIT!" but contains changes. Ensure these modifications are made in the source proto files or generation scripts to prevent loss during regeneration.


4-4: Remove unused import.

The warnings module is imported but never used in the code.


9-27: Version check may be overly restrictive.

The runtime version check enforces exactly grpcio>=1.73.1, which could cause issues for users with newer compatible versions.

🧹 Nitpick comments (6)
src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but never used in the code.

-import warnings
src/protoc_gen_swagger/options/annotations_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but not used in this generated file.

-import warnings
src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but not used in this generated file.

-import warnings
src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but not used in this generated file.

-import warnings
src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but not used in this generated file.

-import warnings
src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py (1)

4-4: Remove unused import.

The warnings module is imported but not used in this generated file.

-import warnings
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eda2f9 and b167952.

📒 Files selected for processing (20)
  • src/protoc_gen_swagger/options/annotations_pb2.py (2 hunks)
  • src/protoc_gen_swagger/options/annotations_pb2.pyi (1 hunks)
  • src/protoc_gen_swagger/options/annotations_pb2_grpc.py (1 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2.py (2 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2.pyi (1 hunks)
  • src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py (1 hunks)
  • src/scanoss/api/components/v2/scanoss_components_pb2.py (1 hunks)
  • src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py (7 hunks)
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py (1 hunks)
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py (9 hunks)
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py (1 hunks)
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py (6 hunks)
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py (1 hunks)
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py (6 hunks)
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py (2 hunks)
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py (5 hunks)
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py (1 hunks)
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py (5 hunks)
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py (1 hunks)
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py (6 hunks)
✅ Files skipped from review due to trivial changes (11)
  • src/protoc_gen_swagger/options/annotations_pb2.py
  • src/scanoss/api/components/v2/scanoss_components_pb2.py
  • src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py
  • src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py
  • src/protoc_gen_swagger/options/openapiv2_pb2.py
  • src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py
  • src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py
  • src/protoc_gen_swagger/options/annotations_pb2.pyi
  • src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py
  • src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py
  • src/protoc_gen_swagger/options/openapiv2_pb2.pyi
🔇 Additional comments (11)
src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py (2)

7-10: LGTM: Version constants are properly defined.

The version constants and initialization are correctly implemented for version compatibility checking.


11-24: LGTM: Robust version compatibility checking.

The version checking logic is well-implemented with proper error handling:

  • Uses try-except to handle cases where first_version_is_lower utility might not be available
  • Provides a comprehensive error message with actionable guidance
  • Gracefully falls back to marking version as unsupported if the utility is unavailable

This ensures that users are informed about version incompatibilities and know how to resolve them.

src/protoc_gen_swagger/options/annotations_pb2_grpc.py (1)

7-24: LGTM: Version compatibility check is well implemented.

The version compatibility check correctly handles both the case where first_version_is_lower is available and when it's not, providing clear error messages to guide users on how to resolve version conflicts.

src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py (2)

44-69: LGTM: Explicit method registration is properly implemented.

The addition of _registered_method=True flags to all unary-unary RPC method calls in the stub class correctly implements explicit method registration as per the updated gRPC Python API.


156-156: LGTM: Server-side method registration is correctly added.

The call to server.add_registered_method_handlers complements the existing generic handler registration, ensuring methods are properly registered on the server side.

src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py (1)

44-49: LGTM: Method registration flags are properly added.

The _registered_method=True flags are correctly added to all RPC method calls in the stub class.

src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py (1)

44-49: LGTM: Method registration is correctly implemented.

The explicit method registration flags are properly added to all RPC methods in the stub class.

src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py (2)

44-59: LGTM: Method registration flags are consistently applied.

All RPC method calls in the stub class correctly include the _registered_method=True flag for explicit method registration.


122-122: LGTM: Server method registration is properly implemented.

The server-side method registration call is correctly added to ensure methods are properly registered.

src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py (2)

1-1: Manual modifications to generated code may be lost.

This file is marked as generated code with "DO NOT EDIT!" but contains changes. Ensure these modifications are made in the source proto files or generation scripts to prevent loss during regeneration.


9-27: Keep the strict gRPC version check as-is

The gRPC Python team intentionally added a runtime enforcement (since v1.65.0) to ensure that generated stubs run against the same—or a newer—grpcio release. This prevents subtle incompatibilities (e.g. Protobuf runtime updates in v1.73.0+) and avoids runtime errors caused by mismatched code and library versions. Feel free to retain the current grpcio>=1.73.1 check and accompanying error message.

Likely an incorrect or invalid review comment.

@@ -1,10 +1,30 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unused import.

The warnings module is imported but never used in the code.

 import grpc
-import warnings
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import warnings
import grpc
🤖 Prompt for AI Agents
In src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py at line 4,
the warnings module is imported but not used anywhere in the file. Remove the
import statement for warnings to clean up unused imports.

@matiasdaloia matiasdaloia force-pushed the feature/mdaloia/SP-2874-Add-support-for-ingesting-CDX-to-all-scanoss-py-decoration-comamnds branch from b167952 to 4c37f13 Compare July 11, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant