Cargo.toml: Dependencies renamed using the package key yield incorrect package name and purl

オープン
#5,476 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@patelshivani2283-lab がすでに取り組んでいます。

2026年11月13日 から。

  • #5477 @patelshivani2283-lab による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, rust
領域
backend

調査の方向性

Start with CargoTomlHandler and the dependency_mapper it uses, where the dictionary key is taken as the package name. Read the package key handling first, since the issue says it is left unhandled in extra_data. Pull request #5477 is already open against this issue, so check its state before starting. Done means purl is pkg:cargo/regex for the example and the alias is kept in extra_data['alias'].

索引モデルが issue の本文から書いたものです。

説明

Description

In Rust Cargo.toml, dependencies can be renamed using the package key as documented in the Cargo Reference on Renaming Dependencies:

[dependencies]
my_regex = { version = "1.5.0", package = "regex" }

In this case, my_regex is only the local alias used in code, while the actual crate published on crates.io is regex.

Currently, scancode-toolkit's CargoTomlHandler / dependency_mapper takes the dictionary key (my_regex) as the package name:

  • Generated purl: pkg:cargo/my_regex (incorrect)
  • Expected purl: pkg:cargo/regex (correct)

Because pkg:cargo/my_regex does not point to the actual dependency crate, downstream package and vulnerability lookups on crates.io fail or look up the wrong package. The package key also remains unhandled in extra_data.

How To Reproduce
  1. Create a Cargo.toml with a renamed dependency:
    [package]
    name = "test-pkg"
    version = "0.1.0"
    
    [dependencies]
    my_regex = { version = "1.5.0", package = "regex" }
    
  2. Scan the file with ScanCode:
    ./scancode --package --json - Cargo.toml
    
  3. Observe dependencies:
    • It outputs purl: "pkg:cargo/my_regex" instead of pkg:cargo/regex.
Expected Behavior
  • purl should reflect the target package name (pkg:cargo/regex).
  • The local alias (my_regex) should be preserved in extra_data['alias'].
System configuration
  • OS: macOS / Linux
  • ScanCode version: 33.0.0rc1 / develop branch
  • Python version: 3.10+
主要言語
Python
スター
2.7k
フォーク
871
平均マージ
1日 10時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/scancode-toolkit のほかの issue

aboutcode-org/scancode-toolkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。