Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The following organizations or individuals have contributed to ScanCode:
- Sebastian Schuberth @sschuberth
- Shankhadeep Dey @Iamshankhadeep
- Sharikzama @ZamaSharik
- Shrashti @Shrashti1234
- Shrijal Acharya @OctoPie23
- Shivam Chauhan @chashiv
- Shivam Sandbhor @sbs2001
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
Next release
--------------

- Preserve Cargo workspace members' own authors and inherit workspace authors
only when a member explicitly declares ``authors.workspace = true``.

- Fix the optional ``licenses`` extra dependency typo to install
``licensedcode-data``.
https://github.com/aboutcode-org/scancode-toolkit/pull/5056
Expand Down
2 changes: 1 addition & 1 deletion src/packagedcode/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def update_resource_package_data(cls, workspace, workspace_package_data, resourc
replace_by_value = workspace_package_data.get(replace_by_attribute)
if replace_by_value:
resource_package_data[attribute] = replace_by_value
elif attribute == "parties":
elif attribute == "parties" and "authors" in extra_data:
resource_package_data[attribute] = list(get_parties(
person_names=workspace_package_data.get("authors", []),
party_role='author',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@
"primary_language": "Rust",
"description": "BoringSSL bindings",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [
"crypto",
"tls",
Expand Down Expand Up @@ -91,7 +106,29 @@
"primary_language": "Rust",
"description": "FFI bindings to BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Alex Crichton",
"email": "alex@alexcrichton.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [
"cryptography",
"external-ffi-bindings"
Expand Down Expand Up @@ -168,7 +205,22 @@
"primary_language": "Rust",
"description": "An implementation of SSL streams for Tokio backed by BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Alex Crichton",
"email": "alex@alexcrichton.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [],
"homepage_url": "https://github.com/cloudflare/boring",
"download_url": null,
Expand Down Expand Up @@ -242,7 +294,22 @@
"primary_language": "Rust",
"description": "Hyper TLS support via BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
Expand Down Expand Up @@ -954,7 +1021,29 @@
"primary_language": "Rust",
"description": "FFI bindings to BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Alex Crichton",
"email": "alex@alexcrichton.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [
"cryptography",
"external-ffi-bindings"
Expand Down Expand Up @@ -1082,7 +1171,22 @@
"primary_language": "Rust",
"description": "BoringSSL bindings",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [
"crypto",
"tls",
Expand Down Expand Up @@ -1254,7 +1358,22 @@
"primary_language": "Rust",
"description": "Hyper TLS support via BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Steven Fackler",
"email": "sfackler@gmail.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
Expand Down Expand Up @@ -1501,7 +1620,22 @@
"primary_language": "Rust",
"description": "An implementation of SSL streams for Tokio backed by BoringSSL",
"release_date": null,
"parties": [],
"parties": [
{
"type": "person",
"role": "author",
"name": "Alex Crichton",
"email": "alex@alexcrichton.com",
"url": null
},
{
"type": "person",
"role": "author",
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
"url": null
}
],
"keywords": [],
"homepage_url": "https://github.com/cloudflare/boring",
"download_url": null,
Expand Down
38 changes: 38 additions & 0 deletions tests/packagedcode/test_cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# See https://aboutcode.org for more information about nexB OSS projects.
#

import json
import os
import pytest

Expand All @@ -17,6 +18,43 @@
from scancode.cli_test_utils import check_json_scan


@pytest.mark.parametrize('workspace_authors, member_authors, expected_names', [
('', 'authors = ["Member Author"]\n', ['Member Author']),
('authors = ["Workspace Author"]\n', 'authors = ["Member Author"]\n', ['Member Author']),
('authors = ["Workspace Author"]\n', 'authors.workspace = true\n', ['Workspace Author']),
('authors = ["Workspace Author"]\n', '', []),
('', '', []),
])
def test_workspace_preserves_member_authors(
workspace_authors, member_authors, expected_names, tmp_path,
):
workspace = tmp_path / 'workspace'
member = workspace / 'crates/member'
member.mkdir(parents=True)
(workspace / 'Cargo.toml').write_text(
'[workspace]\nmembers = ["crates/member"]\n'
'[workspace.package]\nversion = "1.2.3"\n'
'repository = "https://example.com/workspace"\n'
f'{workspace_authors}',
encoding='utf-8',
)
(member / 'Cargo.toml').write_text(
'[package]\nname = "workspace-member"\n'
'version.workspace = true\nrepository.workspace = true\n'
f'{member_authors}',
encoding='utf-8',
)
result_file = tmp_path / 'results.json'
run_scan_click(['--package', str(workspace), '--json', str(result_file)])
results = json.loads(result_file.read_text(encoding='utf-8'))
packages = results['packages']
assert len(packages) == 1
package = packages[0]
assert package['purl'] == 'pkg:cargo/workspace-member@1.2.3'
assert package['vcs_url'] == 'https://example.com/workspace'
assert [party['name'] for party in package['parties']] == expected_names


class TestCargo(PackageTester):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

Expand Down
Loading