From aa249b5721d2b7cf6abff45fdfc82473afbf4b77 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 20 Nov 2023 20:35:10 +0530 Subject: [PATCH 1/5] Add Cargo.toml with workspaces as a test Signed-off-by: Ayan Sinha Mahapatra --- .../data/cargo/cargo_toml/tauri/Cargo.toml | 52 ++++++++++++++ .../cargo_toml/tauri/Cargo.toml.expected | 72 +++++++++++++++++++ tests/packagedcode/test_cargo.py | 6 ++ 3 files changed, 130 insertions(+) create mode 100644 tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml new file mode 100644 index 0000000000..8c30ab13d5 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml @@ -0,0 +1,52 @@ +[package] +name = "tauri-runtime" +version = "1.0.0-alpha.4" +description = "Runtime for Tauri applications" +exclude = [ "CHANGELOG.md", "/target" ] +readme = "README.md" +authors = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +categories = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } + +[package.metadata.docs.rs] +all-features = true +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-linux-android", + "x86_64-apple-ios" +] + +[dependencies] +serde = { version = "1.0", features = [ "derive" ] } +serde_json = "1.0" +thiserror = "1.0" +tauri-utils = { version = "2.0.0-alpha.10", path = "../tauri-utils" } +http = "0.2.4" +raw-window-handle = "0.5" +url = { version = "2" } + +[target."cfg(windows)".dependencies.windows] +version = "0.51" +features = [ "Win32_Foundation" ] + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +gtk = { version = "0.18", features = [ "v3_24" ] } + +[target."cfg(target_os = \"android\")".dependencies] +jni = "0.21" + +[target."cfg(target_os = \"macos\")".dependencies] +url = "2" + +[features] +devtools = [ ] +macos-private-api = [ ] diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected new file mode 100644 index 0000000000..c1801c22e2 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected @@ -0,0 +1,72 @@ +[ + { + "type": "cargo", + "namespace": null, + "name": "rustup", + "version": "1.17.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "Manage multiple rust installations with ease", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Diggory Blake", + "email": "diggsey@googlemail.com", + "url": null + } + ], + "keywords": [], + "homepage_url": "https://github.com/rust-lang/rustup.rs", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/rust-lang/rustup.rs", + "copyright": null, + "holder": null, + "declared_license_expression": "mit OR apache-2.0", + "declared_license_expression_spdx": "MIT OR Apache-2.0", + "license_detections": [ + { + "license_expression": "mit OR apache-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "mit OR apache-2.0", + "rule_identifier": "mit_or_apache-2.0_15.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_apache-2.0_15.RULE", + "matched_text": "MIT OR Apache-2.0" + } + ], + "identifier": "mit_or_apache_2_0-480eec53-1a80-0150-7c7e-39cf79c9f3a8" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "MIT OR Apache-2.0", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/rustup", + "repository_download_url": "https://crates.io/api/v1/crates/rustup/1.17.0/download", + "api_data_url": "https://crates.io/api/v1/crates/rustup", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/rustup@1.17.0" + } +] \ No newline at end of file diff --git a/tests/packagedcode/test_cargo.py b/tests/packagedcode/test_cargo.py index 1184421262..e5077bd7c5 100644 --- a/tests/packagedcode/test_cargo.py +++ b/tests/packagedcode/test_cargo.py @@ -65,6 +65,12 @@ def test_parse_cargo_toml_rustup(self): packages_data = cargo.CargoTomlHandler.parse(test_file) self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES) + def test_parse_cargo_toml_rustup(self): + test_file = self.get_test_loc('cargo/cargo_toml/tauri/Cargo.toml') + expected_loc = self.get_test_loc('cargo/cargo_toml/tauri/Cargo.toml.expected') + packages_data = cargo.CargoTomlHandler.parse(test_file) + self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES) + def test_parse_cargo_lock_sample1(self): test_file = self.get_test_loc('cargo/cargo_lock/sample1/Cargo.lock') expected_loc = self.get_test_loc('cargo/cargo_lock/sample1/output.expected.json') From 853cef142b9448f296cb76acf81851e59ea24350 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Tue, 21 Nov 2023 17:28:33 +0530 Subject: [PATCH 2/5] Fix crash on cargo workspace Signed-off-by: Ayan Sinha Mahapatra --- src/packagedcode/licensing.py | 8 +- src/packagedcode/models.py | 5 +- .../cargo/cargo-with-workspace.expected.json | 1049 +++++++++++++++++ .../cargo/cargo-with-workspace/Cargo.toml | 27 + .../cargo/cargo-with-workspace/LICENSE.spdx | 20 + .../cargo-with-workspace/LICENSE_APACHE-2.0 | 1 + .../cargo/cargo-with-workspace/LICENSE_MIT | 3 + .../data/cargo/cargo-with-workspace/README.md | 21 + .../core/tauri-build/Cargo.toml | 51 + .../core/tauri-runtime/Cargo.toml | 52 + .../core/tauri/Cargo.toml | 194 +++ .../core/tests/restart/Cargo.toml | 12 + .../cargo/cargo-with-workspace/package.json | 26 + .../cargo_toml/tauri/Cargo.toml.expected | 48 +- .../data/plugin/com-package-expected.json | 14 +- .../data/plugin/mui-package-expected.json | 14 +- .../data/plugin/mun-package-expected.json | 14 +- .../data/plugin/sys-package-expected.json | 14 +- .../data/plugin/tlb-package-expected.json | 14 +- .../data/plugin/winmd-package-expected.json | 14 +- .../pypi/metadata/v10/PKG-INFO-expected.json | 8 +- ...eLibrary.Caching.dll.package-expected.json | 14 +- .../Moq.Silverlight.dll.package-expected.json | 14 +- .../Windows.AI.winmd.package-expected.json | 14 +- .../_ctypes_test.pyd.package-expected.json | 14 +- .../win_pe/chcp.com.package-expected.json | 14 +- .../win_pe/clfs.sys.mui.package-expected.json | 14 +- .../crypt32.dll.mun.package-expected.json | 14 +- .../win_pe/euc-jp.so.package-expected.json | 14 +- .../win_pe/stdole2.tlb.package-expected.json | 14 +- .../data/win_pe/tbs.sys.package-expected.json | 14 +- tests/packagedcode/test_cargo.py | 9 + 32 files changed, 1618 insertions(+), 140 deletions(-) create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace.expected.json create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE.spdx create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_APACHE-2.0 create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_MIT create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/README.md create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-build/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-runtime/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/core/tests/restart/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/package.json diff --git a/src/packagedcode/licensing.py b/src/packagedcode/licensing.py index daa53483a2..ce208f93c0 100644 --- a/src/packagedcode/licensing.py +++ b/src/packagedcode/licensing.py @@ -684,6 +684,12 @@ def get_normalized_license_detections( if detections: license_detections.extend(detections) + if not license_detections: + unknown_dict_object = repr(dict(extracted_license.items())) + unknown_detection = get_unknown_license_detection(query_string=unknown_dict_object) + license_detections.append(unknown_detection) + if TRACE: + logger_debug(f'get_normalized_license_detections: dict: unknown_dict_object: {unknown_dict_object}, unknown_detection: {saneyaml.dump(unknown_detection.to_dict())}') else: extracted_license_statement = saneyaml.dump(extracted_license) license_detections = get_license_detections_for_extracted_license_statement( @@ -728,7 +734,6 @@ def get_normalized_license_detections( else: extracted_license_statement = saneyaml.dump(extracted_license_item) - detections = get_license_detections_for_extracted_license_statement( extracted_license_statement=extracted_license_statement, try_as_expression=try_as_expression, @@ -794,6 +799,7 @@ def get_license_detections_and_expression( if not license_detections: if not isinstance(extracted_license_statement, str): extracted_license_statement = saneyaml.dump(extracted_license_statement) + license_detection = get_unknown_license_detection(query_string=extracted_license_statement) license_detections = [license_detection] diff --git a/src/packagedcode/models.py b/src/packagedcode/models.py index 1e304dc7e0..6b46e4c8fb 100644 --- a/src/packagedcode/models.py +++ b/src/packagedcode/models.py @@ -781,7 +781,10 @@ def populate_license_fields(self): ) if self.extracted_license_statement and not isinstance(self.extracted_license_statement, str): - self.extracted_license_statement = saneyaml.dump(self.extracted_license_statement) + if isinstance(self.extracted_license_statement, dict): + self.extracted_license_statement = saneyaml.dump(dict(self.extracted_license_statement.items())) + else: + self.extracted_license_statement = saneyaml.dump(self.extracted_license_statement) def to_dict(self, with_details=True, **kwargs): mapping = super().to_dict(with_details=with_details, **kwargs) diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json new file mode 100644 index 0000000000..5529d5c8dc --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json @@ -0,0 +1,1049 @@ +{ + "packages": [ + { + "type": "npm", + "namespace": null, + "name": "tauri-workspace", + "version": "0.0.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "contributor", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": null, + "download_url": "https://registry.npmjs.org/tauri-workspace/-/tauri-workspace-0.0.0.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "git+https://github.com/tauri-apps/tauri.git", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_36.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE", + "matched_text": "Apache-2.0 OR MIT" + } + ], + "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- Apache-2.0 OR MIT\n", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://www.npmjs.com/package/tauri-workspace", + "repository_download_url": "https://registry.npmjs.org/tauri-workspace/-/tauri-workspace-0.0.0.tgz", + "api_data_url": "https://registry.npmjs.org/tauri-workspace/0.0.0", + "package_uid": "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "cargo-with-workspace/package.json" + ], + "datasource_ids": [ + "npm_package_json" + ], + "purl": "pkg:npm/tauri-workspace@0.0.0" + } + ], + "dependencies": [ + { + "purl": "pkg:npm/typescript", + "extracted_requirement": "^4.5.4", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/typescript?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "cargo-with-workspace/package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/covector", + "extracted_requirement": "^0.9.0", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/covector?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "cargo-with-workspace/package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/husky", + "extracted_requirement": "^6.0.0", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/husky?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "cargo-with-workspace/package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/prettier", + "extracted_requirement": "^2.5.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/prettier?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "cargo-with-workspace/package.json", + "datasource_id": "npm_package_json" + } + ], + "license_detections": [ + { + "identifier": "mit_or_apache_2_0__and_cc_by_nc_nd_4_0-71efc9f6-0e5a-a573-25ad-cd1e32f50720", + "license_expression": "(mit OR apache-2.0) AND cc-by-nc-nd-4.0", + "detection_count": 1 + }, + { + "identifier": "apache_2_0-62ae3761-33a2-9012-c9ab-0dd8e74dae85", + "license_expression": "apache-2.0", + "detection_count": 1 + }, + { + "identifier": "apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8", + "license_expression": "apache-2.0", + "detection_count": 1 + }, + { + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9", + "license_expression": "apache-2.0 OR mit", + "detection_count": 4 + }, + { + "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef", + "license_expression": "apache-2.0 OR mit", + "detection_count": 2 + }, + { + "identifier": "cc0_1_0-309b9888-634d-163a-1eaa-15f7837d2907", + "license_expression": "cc0-1.0", + "detection_count": 1 + }, + { + "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929", + "license_expression": "mit", + "detection_count": 1 + }, + { + "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94", + "license_expression": "unknown", + "detection_count": 3 + } + ], + "files": [ + { + "path": "cargo-with-workspace", + "type": "directory", + "package_data": [], + "for_packages": [], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "cargo_toml", + "purl": null + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "apache-2.0 OR mit", + "detected_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "license_clues": [], + "percentage_of_license_text": 8.0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/LICENSE.spdx", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "cc0-1.0 AND apache-2.0", + "detected_license_expression_spdx": "CC0-1.0 AND Apache-2.0", + "license_detections": [ + { + "license_expression": "cc0-1.0", + "matches": [ + { + "score": 95.0, + "start_line": 2, + "end_line": 2, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "cc0-1.0", + "rule_identifier": "spdx_license_id_cc0-1.0_for_cc0-1.0.RULE", + "rule_relevance": 95, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_cc0-1.0_for_cc0-1.0.RULE" + } + ], + "identifier": "cc0_1_0-309b9888-634d-163a-1eaa-15f7837d2907" + }, + { + "license_expression": "apache-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 7, + "end_line": 7, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0", + "rule_identifier": "spdx_license_id_apache-2.0_for_apache-2.0.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE" + } + ], + "identifier": "apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8" + } + ], + "license_clues": [], + "percentage_of_license_text": 5.56, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/LICENSE_APACHE-2.0", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "apache-2.0", + "detected_license_expression_spdx": "Apache-2.0", + "license_detections": [ + { + "license_expression": "apache-2.0", + "matches": [ + { + "score": 75.0, + "start_line": 1, + "end_line": 1, + "matched_length": 4, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0", + "rule_identifier": "apache-2.0_3.RULE", + "rule_relevance": 75, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_3.RULE" + } + ], + "identifier": "apache_2_0-62ae3761-33a2-9012-c9ab-0dd8e74dae85" + } + ], + "license_clues": [], + "percentage_of_license_text": 100.0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/LICENSE_MIT", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "mit", + "detected_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_14.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_14.RULE" + } + ], + "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929" + } + ], + "license_clues": [], + "percentage_of_license_text": 22.22, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/README.md", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "(mit OR apache-2.0) AND cc-by-nc-nd-4.0", + "detected_license_expression_spdx": "(MIT OR Apache-2.0) AND CC-BY-NC-ND-4.0", + "license_detections": [ + { + "license_expression": "(mit OR apache-2.0) AND cc-by-nc-nd-4.0", + "matches": [ + { + "score": 99.0, + "start_line": 19, + "end_line": 19, + "matched_length": 4, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit OR apache-2.0", + "rule_identifier": "mit_or_apache-2.0_1.RULE", + "rule_relevance": 99, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_apache-2.0_1.RULE" + }, + { + "score": 100.0, + "start_line": 21, + "end_line": 21, + "matched_length": 4, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "cc-by-nc-nd-4.0", + "rule_identifier": "cc-by-nc-nd-4.0_27.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/cc-by-nc-nd-4.0_27.RULE" + } + ], + "identifier": "mit_or_apache_2_0__and_cc_by_nc_nd_4_0-71efc9f6-0e5a-a573-25ad-cd1e32f50720" + } + ], + "license_clues": [], + "percentage_of_license_text": 4.52, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri-build", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri-build/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": "tauri-build", + "version": "2.0.0-alpha.11", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "build time code to pair with https://crates.io/crates/tauri", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "workspace", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": { + "workspace": true + }, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": { + "workspace": true + }, + "copyright": null, + "holder": null, + "declared_license_expression": "unknown", + "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "license_detections": [ + { + "license_expression": "unknown", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "5-undetected", + "license_expression": "unknown", + "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matched_text": "license {'workspace': True}" + } + ], + "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "workspace: yes\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/tauri-build", + "repository_download_url": "https://crates.io/api/v1/crates/tauri-build/2.0.0-alpha.11/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri-build", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/tauri-build@2.0.0-alpha.11" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri-runtime", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri-runtime/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": "tauri-runtime", + "version": "1.0.0-alpha.4", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "Runtime for Tauri applications", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "workspace", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": { + "workspace": true + }, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": { + "workspace": true + }, + "copyright": null, + "holder": null, + "declared_license_expression": "unknown", + "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "license_detections": [ + { + "license_expression": "unknown", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "5-undetected", + "license_expression": "unknown", + "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matched_text": "license {'workspace': True}" + } + ], + "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "workspace: yes\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/tauri-runtime", + "repository_download_url": "https://crates.io/api/v1/crates/tauri-runtime/1.0.0-alpha.4/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri-runtime", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/tauri-runtime@1.0.0-alpha.4" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tauri/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": "tauri", + "version": "2.0.0-alpha.17", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "Make tiny, secure apps for all desktop platforms with Tauri", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "workspace", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": { + "workspace": true + }, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": { + "workspace": true + }, + "copyright": null, + "holder": null, + "declared_license_expression": "unknown", + "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "license_detections": [ + { + "license_expression": "unknown", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "5-undetected", + "license_expression": "unknown", + "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matched_text": "license {'workspace': True}" + } + ], + "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "workspace: yes\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/tauri", + "repository_download_url": "https://crates.io/api/v1/crates/tauri/2.0.0-alpha.17/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/tauri@2.0.0-alpha.17" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tests", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tests/restart", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/core/tests/restart/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": "restart", + "version": "0.1.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_36.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE", + "matched_text": "Apache-2.0 OR MIT" + } + ], + "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/restart", + "repository_download_url": "https://crates.io/api/v1/crates/restart/0.1.0/download", + "api_data_url": "https://crates.io/api/v1/crates/restart", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/restart@0.1.0" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "apache-2.0 OR mit", + "detected_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 5, + "end_line": 5, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "license_clues": [], + "percentage_of_license_text": 20.0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/package.json", + "type": "file", + "package_data": [ + { + "type": "npm", + "namespace": null, + "name": "tauri-workspace", + "version": "0.0.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "contributor", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": null, + "download_url": "https://registry.npmjs.org/tauri-workspace/-/tauri-workspace-0.0.0.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "git+https://github.com/tauri-apps/tauri.git", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_36.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE", + "matched_text": "Apache-2.0 OR MIT" + } + ], + "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- Apache-2.0 OR MIT\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:npm/typescript", + "extracted_requirement": "^4.5.4", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/covector", + "extracted_requirement": "^0.9.0", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/husky", + "extracted_requirement": "^6.0.0", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/prettier", + "extracted_requirement": "^2.5.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://www.npmjs.com/package/tauri-workspace", + "repository_download_url": "https://registry.npmjs.org/tauri-workspace/-/tauri-workspace-0.0.0.tgz", + "api_data_url": "https://registry.npmjs.org/tauri-workspace/0.0.0", + "datasource_id": "npm_package_json", + "purl": "pkg:npm/tauri-workspace@0.0.0" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "apache-2.0 OR mit", + "detected_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 4, + "end_line": 4, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "license_clues": [], + "percentage_of_license_text": 8.33, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/Cargo.toml new file mode 100644 index 0000000000..e95103f7eb --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/Cargo.toml @@ -0,0 +1,27 @@ +[workspace] +resolver = "2" +members = [ + # core + "core/tauri", + "core/tauri-runtime", + "core/tauri-build", + # integration tests + "core/tests/restart", +] + +[workspace.package] +authors = ["Tauri Programme within The Commons Conservancy"] +homepage = "https://tauri.app/" +repository = "https://github.com/tauri-apps/tauri" +categories = ["gui", "web-programming"] +license = "Apache-2.0 OR MIT" +edition = "2021" +rust-version = "1.70" + +# default to small, optimized workspace release binaries +[profile.release] +panic = "abort" +codegen-units = 1 +lto = true +incremental = false +opt-level = "s" diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE.spdx b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE.spdx new file mode 100644 index 0000000000..7e8f2bfad2 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_APACHE-2.0 b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_APACHE-2.0 new file mode 100644 index 0000000000..5410b6a11a --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_APACHE-2.0 @@ -0,0 +1 @@ +Apache License 2.0 \ No newline at end of file diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_MIT b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_MIT new file mode 100644 index 0000000000..0559474d69 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/LICENSE_MIT @@ -0,0 +1,3 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/README.md b/tests/packagedcode/data/cargo/cargo-with-workspace/README.md new file mode 100644 index 0000000000..3dceea4f3f --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/README.md @@ -0,0 +1,21 @@ +## Current Releases + +### Core + +| Component | Description | Version | Lin | Win | Mac | +| -------------------------------------------------------------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------- | --- | --- | --- | +| [**tauri**](https://github.com/tauri-apps/tauri/tree/dev/core/tauri) | runtime core | [![](https://img.shields.io/crates/v/tauri.svg)](https://crates.io/crates/tauri) | ✅ | ✅ | ✅ | +| [**tauri-build**](https://github.com/tauri-apps/tauri/tree/dev/core/tauri-build) | applies macros at build-time | [![](https://img.shields.io/crates/v/tauri-build.svg)](https://crates.io/crates/tauri-build) | ✅ | ✅ | ✅ | +| [**tauri-runtime**](https://github.com/tauri-apps/tauri/tree/dev/core/tauri-runtime) | layer between Tauri and webview libraries | [![](https://img.shields.io/crates/v/tauri-runtime.svg)](https://crates.io/crates/tauri-runtime) | ✅ | ✅ | ✅ | + +## Introduction + +Tauri is a framework for building tiny, blazingly fast binaries for all major desktop platforms. Developers can integrate any front-end framework that compiles to HTML, JS and CSS for building their user interface. The backend of the application is a rust-sourced binary with an API that the front-end can interact with. + +## Licenses + +Code: (c) 2015 - 2021 - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. + +Logo: CC-BY-NC-ND diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-build/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-build/Cargo.toml new file mode 100644 index 0000000000..a3725585b6 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-build/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "tauri-build" +version = "2.0.0-alpha.11" +description = "build time code to pair with https://crates.io/crates/tauri" +exclude = [ "CHANGELOG.md", "/target" ] +readme = "README.md" +authors = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +categories = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } + +[package.metadata.docs.rs] +all-features = true +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-linux-android", + "x86_64-apple-ios" +] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] + +[dependencies] +anyhow = "1" +quote = { version = "1", optional = true } +tauri-codegen = { version = "2.0.0-alpha.10", path = "../tauri-codegen", optional = true } +tauri-utils = { version = "2.0.0-alpha.10", path = "../tauri-utils", features = [ "build", "resources" ] } +cargo_toml = "0.17" +serde = "1" +serde_json = "1" +heck = "0.4" +json-patch = "1.2" +walkdir = "2" +tauri-winres = "0.1" +semver = "1" +dirs-next = "2" + +[target."cfg(target_os = \"macos\")".dependencies] +swift-rs = { version = "1.0.6", features = [ "build" ] } +plist = "1" + +[features] +codegen = [ "tauri-codegen", "quote" ] +isolation = [ "tauri-codegen/isolation", "tauri-utils/isolation" ] +config-json5 = [ "tauri-utils/config-json5" ] +config-toml = [ "tauri-utils/config-toml" ] diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-runtime/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-runtime/Cargo.toml new file mode 100644 index 0000000000..8c30ab13d5 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri-runtime/Cargo.toml @@ -0,0 +1,52 @@ +[package] +name = "tauri-runtime" +version = "1.0.0-alpha.4" +description = "Runtime for Tauri applications" +exclude = [ "CHANGELOG.md", "/target" ] +readme = "README.md" +authors = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +categories = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } + +[package.metadata.docs.rs] +all-features = true +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-linux-android", + "x86_64-apple-ios" +] + +[dependencies] +serde = { version = "1.0", features = [ "derive" ] } +serde_json = "1.0" +thiserror = "1.0" +tauri-utils = { version = "2.0.0-alpha.10", path = "../tauri-utils" } +http = "0.2.4" +raw-window-handle = "0.5" +url = { version = "2" } + +[target."cfg(windows)".dependencies.windows] +version = "0.51" +features = [ "Win32_Foundation" ] + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +gtk = { version = "0.18", features = [ "v3_24" ] } + +[target."cfg(target_os = \"android\")".dependencies] +jni = "0.21" + +[target."cfg(target_os = \"macos\")".dependencies] +url = "2" + +[features] +devtools = [ ] +macos-private-api = [ ] diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri/Cargo.toml new file mode 100644 index 0000000000..97ea27d464 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tauri/Cargo.toml @@ -0,0 +1,194 @@ +[package] +name = "tauri" +version = "2.0.0-alpha.17" +description = "Make tiny, secure apps for all desktop platforms with Tauri" +exclude = [ "/test", "/.scripts", "CHANGELOG.md", "/target" ] +readme = "README.md" +links = "Tauri" +authors = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +categories = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } + +[package.metadata.docs.rs] +no-default-features = true +features = [ + "wry", + "custom-protocol", + "tray-icon", + "devtools", + "icon-png", + "protocol-asset", + "test" +] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-linux-android", + "x86_64-apple-ios" +] + +[package.metadata.cargo-udeps.ignore] +normal = [ "reqwest" ] +build = [ "tauri-build" ] +development = [ "quickcheck_macros" ] + +[dependencies] +serde_json = { version = "1.0", features = [ "raw_value" ] } +serde = { version = "1.0", features = [ "derive", "rc" ] } +tokio = { version = "1", features = [ "rt", "rt-multi-thread", "sync", "fs", "io-util" ] } +futures-util = "0.3" +uuid = { version = "1", features = [ "v4" ], optional = true } +url = { version = "2.4" } +anyhow = "1.0" +thiserror = "1.0" +once_cell = "1" +tauri-runtime = { version = "1.0.0-alpha.4", path = "../tauri-runtime" } +tauri-macros = { version = "2.0.0-alpha.10", path = "../tauri-macros" } +tauri-utils = { version = "2.0.0-alpha.10", features = [ "resources" ], path = "../tauri-utils" } +tauri-runtime-wry = { version = "1.0.0-alpha.5", path = "../tauri-runtime-wry", optional = true } +getrandom = "0.2" +serde_repr = "0.1" +state = "0.6" +http = "0.2" +dirs-next = "2.0" +percent-encoding = "2.3" +reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] } +bytes = { version = "1", features = [ "serde" ] } +raw-window-handle = "0.5" +glob = "0.3" +mime = "0.3" +data-url = { version = "0.3", optional = true } +serialize-to-javascript = "=0.1.1" +infer = { version = "0.15", optional = true } +png = { version = "0.17", optional = true } +ico = { version = "0.3.0", optional = true } +http-range = { version = "0.1.5", optional = true } + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies] +muda = { version = "0.11", default-features = false, features = [ "serde" ] } +tray-icon = { version = "0.11", default-features = false, features = [ "serde" ], optional = true } + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +gtk = { version = "0.18", features = [ "v3_24" ] } +webkit2gtk = { version = "=2.0.1", features = [ "v2_38" ] } + +[target."cfg(target_os = \"macos\")".dependencies] +embed_plist = "1.2" +cocoa = "0.25" +objc = "0.2" +window-vibrancy = "0.4" + +[target."cfg(windows)".dependencies] +webview2-com = "0.27" +window-vibrancy = "0.4" + + [target."cfg(windows)".dependencies.windows] + version = "0.51" + features = [ "Win32_Foundation" ] + +[target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies] +log = "0.4" +heck = "0.4" + +[target."cfg(target_os = \"android\")".dependencies] +jni = "0.21" + +[target."cfg(target_os = \"ios\")".dependencies] +libc = "0.2" +objc = "0.2" +cocoa = "0.25" +swift-rs = "1.0.6" + +[build-dependencies] +heck = "0.4" +once_cell = "1" +tauri-build = { path = "../tauri-build/", version = "2.0.0-alpha.11" } + +[dev-dependencies] +proptest = "1.4.0" +quickcheck = "1.0.3" +quickcheck_macros = "1.0.0" +serde = { version = "1.0", features = [ "derive" ] } +serde_json = "1.0" +tauri = { path = ".", default-features = false, features = [ "wry" ] } +tokio = { version = "1", features = [ "full" ] } +cargo_toml = "0.17" +http-range = "0.1.5" + +[features] +default = [ + "wry", + "compression", + "objc-exception", + "tray-icon?/common-controls-v6", + "muda/common-controls-v6" +] +tray-icon = [ "dep:tray-icon" ] +test = [ ] +compression = [ "tauri-macros/compression", "tauri-utils/compression" ] +wry = [ "tauri-runtime-wry" ] +objc-exception = [ "tauri-runtime-wry/objc-exception" ] +linux-ipc-protocol = [ "tauri-runtime-wry/linux-protocol-body", "webkit2gtk/v2_40" ] +linux-libxdo = [ "tray-icon/libxdo", "muda/libxdo" ] +isolation = [ "tauri-utils/isolation", "tauri-macros/isolation", "uuid" ] +custom-protocol = [ "tauri-macros/custom-protocol" ] +native-tls = [ "reqwest/native-tls" ] +native-tls-vendored = [ "reqwest/native-tls-vendored" ] +rustls-tls = [ "reqwest/rustls-tls" ] +devtools = [ "tauri-runtime/devtools", "tauri-runtime-wry/devtools" ] +process-relaunch-dangerous-allow-symlink-macos = [ "tauri-utils/process-relaunch-dangerous-allow-symlink-macos" ] +macos-private-api = [ + "tauri-runtime/macos-private-api", + "tauri-runtime-wry/macos-private-api" +] +window-data-url = [ "data-url" ] +protocol-asset = [ "http-range" ] +config-json5 = [ "tauri-macros/config-json5" ] +config-toml = [ "tauri-macros/config-toml" ] +icon-ico = [ "infer", "ico" ] +icon-png = [ "infer", "png" ] + +[[example]] +name = "commands" +path = "../../examples/commands/main.rs" + +[[example]] +name = "helloworld" +path = "../../examples/helloworld/main.rs" + +[[example]] +name = "multiwindow" +path = "../../examples/multiwindow/main.rs" + +[[example]] +name = "parent-window" +path = "../../examples/parent-window/main.rs" + +[[example]] +name = "navigation" +path = "../../examples/navigation/main.rs" + +[[example]] +name = "splashscreen" +path = "../../examples/splashscreen/main.rs" + +[[example]] +name = "state" +path = "../../examples/state/main.rs" + +[[example]] +name = "streaming" +path = "../../examples/streaming/main.rs" + +[[example]] +name = "isolation" +path = "../../examples/isolation/main.rs" +required-features = [ "isolation" ] diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/core/tests/restart/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tests/restart/Cargo.toml new file mode 100644 index 0000000000..1d7036e986 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/core/tests/restart/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "restart" +version = "0.1.0" +authors = [ "Tauri Programme within The Commons Conservancy" ] +license = "Apache-2.0 OR MIT" +edition = "2021" + +[dependencies.tauri] +path = "../../tauri" + +[dev-dependencies] +tempfile = "3" diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/package.json b/tests/packagedcode/data/cargo/cargo-with-workspace/package.json new file mode 100644 index 0000000000..3c8d8351ca --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/package.json @@ -0,0 +1,26 @@ +{ + "name": "tauri-workspace", + "version": "0.0.0", + "license": "Apache-2.0 OR MIT", + "private": true, + "contributors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": { + "type": "git", + "url": "https://github.com/tauri-apps/tauri.git" + }, + "scripts": { + "format": "prettier --write . --config .prettierrc --ignore-path .prettierignore", + "format:check": "prettier --check . --config .prettierrc --ignore-path .prettierignore", + "postinstall": "husky install" + }, + "devDependencies": { + "covector": "^0.9.0", + "husky": "^6.0.0", + "prettier": "^2.5.1" + }, + "dependencies": { + "typescript": "^4.5.4" + } +} diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected index c1801c22e2..88a067bbed 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected @@ -2,24 +2,26 @@ { "type": "cargo", "namespace": null, - "name": "rustup", - "version": "1.17.0", + "name": "tauri-runtime", + "version": "1.0.0-alpha.4", "qualifiers": {}, "subpath": null, "primary_language": "Rust", - "description": "Manage multiple rust installations with ease", + "description": "Runtime for Tauri applications", "release_date": null, "parties": [ { "type": "person", "role": "author", - "name": "Diggory Blake", - "email": "diggsey@googlemail.com", + "name": "workspace", + "email": null, "url": null } ], "keywords": [], - "homepage_url": "https://github.com/rust-lang/rustup.rs", + "homepage_url": { + "workspace": true + }, "download_url": null, "size": null, "sha1": null, @@ -28,45 +30,47 @@ "sha512": null, "bug_tracking_url": null, "code_view_url": null, - "vcs_url": "https://github.com/rust-lang/rustup.rs", + "vcs_url": { + "workspace": true + }, "copyright": null, "holder": null, - "declared_license_expression": "mit OR apache-2.0", - "declared_license_expression_spdx": "MIT OR Apache-2.0", + "declared_license_expression": "unknown", + "declared_license_expression_spdx": "LicenseRef-scancode-unknown", "license_detections": [ { - "license_expression": "mit OR apache-2.0", + "license_expression": "unknown", "matches": [ { "score": 100.0, "start_line": 1, "end_line": 1, - "matched_length": 5, + "matched_length": 3, "match_coverage": 100.0, - "matcher": "1-hash", - "license_expression": "mit OR apache-2.0", - "rule_identifier": "mit_or_apache-2.0_15.RULE", + "matcher": "5-undetected", + "license_expression": "unknown", + "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_apache-2.0_15.RULE", - "matched_text": "MIT OR Apache-2.0" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matched_text": "license {'workspace': True}" } ], - "identifier": "mit_or_apache_2_0-480eec53-1a80-0150-7c7e-39cf79c9f3a8" + "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": "MIT OR Apache-2.0", + "extracted_license_statement": "workspace: yes\n", "notice_text": null, "source_packages": [], "file_references": [], "extra_data": {}, "dependencies": [], - "repository_homepage_url": "https://crates.io/crates/rustup", - "repository_download_url": "https://crates.io/api/v1/crates/rustup/1.17.0/download", - "api_data_url": "https://crates.io/api/v1/crates/rustup", + "repository_homepage_url": "https://crates.io/crates/tauri-runtime", + "repository_download_url": "https://crates.io/api/v1/crates/tauri-runtime/1.0.0-alpha.4/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri-runtime", "datasource_id": "cargo_toml", - "purl": "pkg:cargo/rustup@1.17.0" + "purl": "pkg:cargo/tauri-runtime@1.0.0-alpha.4" } ] \ No newline at end of file diff --git a/tests/packagedcode/data/plugin/com-package-expected.json b/tests/packagedcode/data/plugin/com-package-expected.json index 785c57ba07..ad686c6a13 100644 --- a/tests/packagedcode/data/plugin/com-package-expected.json +++ b/tests/packagedcode/data/plugin/com-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/plugin/mui-package-expected.json b/tests/packagedcode/data/plugin/mui-package-expected.json index 83ae8b8f69..3b289781d1 100644 --- a/tests/packagedcode/data/plugin/mui-package-expected.json +++ b/tests/packagedcode/data/plugin/mui-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/plugin/mun-package-expected.json b/tests/packagedcode/data/plugin/mun-package-expected.json index 0602ecff54..ea0706ddbe 100644 --- a/tests/packagedcode/data/plugin/mun-package-expected.json +++ b/tests/packagedcode/data/plugin/mun-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/plugin/sys-package-expected.json b/tests/packagedcode/data/plugin/sys-package-expected.json index e851355c05..bd3b6315a5 100644 --- a/tests/packagedcode/data/plugin/sys-package-expected.json +++ b/tests/packagedcode/data/plugin/sys-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/plugin/tlb-package-expected.json b/tests/packagedcode/data/plugin/tlb-package-expected.json index 544ee1e1dc..c429b23c1e 100644 --- a/tests/packagedcode/data/plugin/tlb-package-expected.json +++ b/tests/packagedcode/data/plugin/tlb-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/plugin/winmd-package-expected.json b/tests/packagedcode/data/plugin/winmd-package-expected.json index c87bc88f96..dd72994900 100644 --- a/tests/packagedcode/data/plugin/winmd-package-expected.json +++ b/tests/packagedcode/data/plugin/winmd-package-expected.json @@ -45,20 +45,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/pypi/metadata/v10/PKG-INFO-expected.json b/tests/packagedcode/data/pypi/metadata/v10/PKG-INFO-expected.json index 24816226e3..4a6cd87441 100644 --- a/tests/packagedcode/data/pypi/metadata/v10/PKG-INFO-expected.json +++ b/tests/packagedcode/data/pypi/metadata/v10/PKG-INFO-expected.json @@ -45,13 +45,13 @@ "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-623aa537047267a404620d70ae00f1448b424248", + "rule_identifier": "package-manifest-unknown-54cabbf9e6e2ad452085853f06d62077e9d72ddb", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-623aa537047267a404620d70ae00f1448b424248", - "matched_text": "license license: LICENSE.txt" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-54cabbf9e6e2ad452085853f06d62077e9d72ddb", + "matched_text": "license {'license': 'LICENSE.txt'}" } ], - "identifier": "unknown-083832d0-fb1a-f0bc-de38-c8d1cc1a3a8a" + "identifier": "unknown-d5d1ef26-6d73-51c2-0bd1-6551bb2e6e9c" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/Microsoft.Practices.EnterpriseLibrary.Caching.dll.package-expected.json b/tests/packagedcode/data/win_pe/Microsoft.Practices.EnterpriseLibrary.Caching.dll.package-expected.json index a7bb31b504..ad5c6928f7 100644 --- a/tests/packagedcode/data/win_pe/Microsoft.Practices.EnterpriseLibrary.Caching.dll.package-expected.json +++ b/tests/packagedcode/data/win_pe/Microsoft.Practices.EnterpriseLibrary.Caching.dll.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 75.0, + "score": 83.33, "start_line": 1, - "end_line": 3, - "matched_length": 3, + "end_line": 1, + "matched_length": 5, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", + "rule_identifier": "package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", - "matched_text": "license LegalCopyright:\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", + "matched_text": "license {'LegalCopyright': None, 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-d5e156bc-5560-c52a-28b9-d79ccb4407b2" + "identifier": "unknown-3a74427e-26a2-7b3f-eb84-9b610c013417" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/Moq.Silverlight.dll.package-expected.json b/tests/packagedcode/data/win_pe/Moq.Silverlight.dll.package-expected.json index 3f8dce3987..6381ad6f8e 100644 --- a/tests/packagedcode/data/win_pe/Moq.Silverlight.dll.package-expected.json +++ b/tests/packagedcode/data/win_pe/Moq.Silverlight.dll.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 75.0, + "score": 83.33, "start_line": 1, - "end_line": 3, - "matched_length": 3, + "end_line": 1, + "matched_length": 5, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", + "rule_identifier": "package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", - "matched_text": "license LegalCopyright:\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", + "matched_text": "license {'LegalCopyright': None, 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-d5e156bc-5560-c52a-28b9-d79ccb4407b2" + "identifier": "unknown-3a74427e-26a2-7b3f-eb84-9b610c013417" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/Windows.AI.winmd.package-expected.json b/tests/packagedcode/data/win_pe/Windows.AI.winmd.package-expected.json index 34b6fd1ed8..289eba3da2 100644 --- a/tests/packagedcode/data/win_pe/Windows.AI.winmd.package-expected.json +++ b/tests/packagedcode/data/win_pe/Windows.AI.winmd.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/_ctypes_test.pyd.package-expected.json b/tests/packagedcode/data/win_pe/_ctypes_test.pyd.package-expected.json index ccb14a0a74..dd1613c91c 100644 --- a/tests/packagedcode/data/win_pe/_ctypes_test.pyd.package-expected.json +++ b/tests/packagedcode/data/win_pe/_ctypes_test.pyd.package-expected.json @@ -30,20 +30,20 @@ "license_expression": "unknown", "matches": [ { - "score": 75.0, + "score": 83.33, "start_line": 1, - "end_line": 3, - "matched_length": 3, + "end_line": 1, + "matched_length": 5, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", + "rule_identifier": "package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", - "matched_text": "license LegalCopyright:\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", + "matched_text": "license {'LegalCopyright': None, 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-d5e156bc-5560-c52a-28b9-d79ccb4407b2" + "identifier": "unknown-3a74427e-26a2-7b3f-eb84-9b610c013417" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/chcp.com.package-expected.json b/tests/packagedcode/data/win_pe/chcp.com.package-expected.json index fc58940f8b..a3d039f8f5 100644 --- a/tests/packagedcode/data/win_pe/chcp.com.package-expected.json +++ b/tests/packagedcode/data/win_pe/chcp.com.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/clfs.sys.mui.package-expected.json b/tests/packagedcode/data/win_pe/clfs.sys.mui.package-expected.json index 22eca18d57..052928c89b 100644 --- a/tests/packagedcode/data/win_pe/clfs.sys.mui.package-expected.json +++ b/tests/packagedcode/data/win_pe/clfs.sys.mui.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/crypt32.dll.mun.package-expected.json b/tests/packagedcode/data/win_pe/crypt32.dll.mun.package-expected.json index 55ddfcff86..0801116c63 100644 --- a/tests/packagedcode/data/win_pe/crypt32.dll.mun.package-expected.json +++ b/tests/packagedcode/data/win_pe/crypt32.dll.mun.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/euc-jp.so.package-expected.json b/tests/packagedcode/data/win_pe/euc-jp.so.package-expected.json index ccb14a0a74..dd1613c91c 100644 --- a/tests/packagedcode/data/win_pe/euc-jp.so.package-expected.json +++ b/tests/packagedcode/data/win_pe/euc-jp.so.package-expected.json @@ -30,20 +30,20 @@ "license_expression": "unknown", "matches": [ { - "score": 75.0, + "score": 83.33, "start_line": 1, - "end_line": 3, - "matched_length": 3, + "end_line": 1, + "matched_length": 5, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", + "rule_identifier": "package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ad65678ddd5bed50985f1d896d812061269049b0", - "matched_text": "license LegalCopyright:\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce", + "matched_text": "license {'LegalCopyright': None, 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-d5e156bc-5560-c52a-28b9-d79ccb4407b2" + "identifier": "unknown-3a74427e-26a2-7b3f-eb84-9b610c013417" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/stdole2.tlb.package-expected.json b/tests/packagedcode/data/win_pe/stdole2.tlb.package-expected.json index 90c7e2696d..f987330cc6 100644 --- a/tests/packagedcode/data/win_pe/stdole2.tlb.package-expected.json +++ b/tests/packagedcode/data/win_pe/stdole2.tlb.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/win_pe/tbs.sys.package-expected.json b/tests/packagedcode/data/win_pe/tbs.sys.package-expected.json index 141004ae02..c7fbab0917 100644 --- a/tests/packagedcode/data/win_pe/tbs.sys.package-expected.json +++ b/tests/packagedcode/data/win_pe/tbs.sys.package-expected.json @@ -38,20 +38,20 @@ "license_expression": "unknown", "matches": [ { - "score": 88.89, + "score": 90.0, "start_line": 1, - "end_line": 3, - "matched_length": 8, + "end_line": 1, + "matched_length": 9, "match_coverage": 100.0, "matcher": "5-undetected", "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", + "rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-ac5b72bda2754025edd093f0f8161168689d3065", - "matched_text": "license LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225", + "matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}" } ], - "identifier": "unknown-11be580c-3254-29b5-4813-8b152eefbe71" + "identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7" } ], "other_license_expression": null, diff --git a/tests/packagedcode/test_cargo.py b/tests/packagedcode/test_cargo.py index e5077bd7c5..91b167b63f 100644 --- a/tests/packagedcode/test_cargo.py +++ b/tests/packagedcode/test_cargo.py @@ -110,6 +110,15 @@ def test_scan_cli_works(self): expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES ) + def test_scan_works_on_cargo_workspace(self): + test_file = self.get_test_loc('cargo/cargo-with-workspace') + expected_file = self.get_test_loc('cargo/cargo-with-workspace.expected.json', must_exist=False) + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', '--license', test_file, '--json', result_file]) + check_json_scan( + expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES + ) + PERSON_PARSER_TEST_TABLE = [ ('Barney Rubble ', ('Barney Rubble ', '')), From 2a2f5129487630b2c972aef851b60a3450015b37 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 22 Nov 2023 00:27:30 +0530 Subject: [PATCH 3/5] Support cargo workspaces in assembly Reference: https://github.com/nexB/scancode-toolkit/issues/3598 Signed-off-by: Ayan Sinha Mahapatra --- src/packagedcode/cargo.py | 98 +++- .../cargo/cargo-with-workspace.expected.json | 509 +++++++++++++++--- .../data/cargo/scan.expected.json | 18 +- .../score/no_license_ambiguity-expected.json | 22 +- 4 files changed, 551 insertions(+), 96 deletions(-) diff --git a/src/packagedcode/cargo.py b/src/packagedcode/cargo.py index ffe8dea515..fe955a279f 100644 --- a/src/packagedcode/cargo.py +++ b/src/packagedcode/cargo.py @@ -7,6 +7,7 @@ # See https://aboutcode.org for more information about nexB OSS projects. # +import os import re import saneyaml @@ -31,8 +32,8 @@ class CargoTomlHandler(models.DatafileHandler): @classmethod def parse(cls, location): package_data = toml.load(location, _dict=dict) - core_package_data = package_data.get('package', {}) + workspace = package_data.get('workspace', {}) name = core_package_data.get('name') version = core_package_data.get('version') @@ -66,6 +67,9 @@ def parse(cls, location): repository_homepage_url = name and f'https://crates.io/crates/{name}' repository_download_url = name and version and f'https://crates.io/api/v1/crates/{name}/{version}/download' api_data_url = name and f'https://crates.io/api/v1/crates/{name}' + extra_data = {} + if workspace: + extra_data["workspace"] = workspace yield models.PackageData( datasource_id=cls.datasource_id, @@ -82,20 +86,92 @@ def parse(cls, location): repository_download_url=repository_download_url, api_data_url=api_data_url, dependencies=dependencies, + extra_data=extra_data, ) @classmethod def assemble(cls, package_data, resource, codebase, package_adder): """ - Assemble Cargo.toml and possible Cargo.lock datafiles + Assemble Cargo.toml and possible Cargo.lock datafiles. Also + support cargo workspaces where we have multiple packages from + a repository and some shared information present at top-level. """ - yield from cls.assemble_from_many_datafiles( - datafile_name_patterns=('Cargo.toml', 'cargo.toml', 'Cargo.lock', 'cargo.lock'), - directory=resource.parent(codebase), - codebase=codebase, - package_adder=package_adder, - ) + workspace = package_data.extra_data.get("workspace", {}) + workspace_members = workspace.get("members", []) + workspace_package_data = workspace.get("package", {}) + attributes_to_copy = [ + "license_detections", + "declared_license_expression", + "declared_license_expression_spdx" + ] + if "license" in workspace_package_data: + for attribute in attributes_to_copy: + workspace_package_data[attribute] = getattr(package_data, attribute) + + workspace_root_path = resource.parent(codebase).path + if workspace_package_data and workspace_members: + for workspace_member_path in workspace_members: + workspace_directory_path = os.path.join(workspace_root_path, workspace_member_path) + workspace_directory = codebase.get_resource(path=workspace_directory_path) + if not workspace_directory: + continue + + # Update the package data for all members with the + # workspace package data + for resource in workspace_directory.children(codebase): + if cls.is_datafile(location=resource.location): + if not resource.package_data: + continue + + updated_package_data = cls.update_resource_package_data( + package_data=workspace_package_data, + old_package_data=resource.package_data.pop(), + mapping=CARGO_ATTRIBUTE_MAPPING, + ) + resource.package_data.append(updated_package_data) + resource.save(codebase) + + yield from cls.assemble_from_many_datafiles( + datafile_name_patterns=('Cargo.toml', 'cargo.toml', 'Cargo.lock', 'cargo.lock'), + directory=workspace_directory, + codebase=codebase, + package_adder=package_adder, + ) + else: + yield from cls.assemble_from_many_datafiles( + datafile_name_patterns=('Cargo.toml', 'cargo.toml', 'Cargo.lock', 'cargo.lock'), + directory=resource.parent(codebase), + codebase=codebase, + package_adder=package_adder, + ) + @classmethod + def update_resource_package_data(cls, package_data, old_package_data, mapping=None): + + for attribute in old_package_data.keys(): + if attribute in mapping: + replace_by_attribute = mapping.get(attribute) + old_package_data[attribute] = package_data.get(replace_by_attribute) + elif attribute == "parties": + old_package_data[attribute] = list(get_parties( + person_names=package_data.get("authors"), + party_role='author', + )) + + return old_package_data + + +CARGO_ATTRIBUTE_MAPPING = { + # Fields in PackageData model: Fields in cargo + "homepage_url": "homepage", + "vcs_url": "repository", + "keywords": "categories", + "extracted_license_statement": "license", + # These are fields carried over to avoid re-detection of licenses + "license_detections": "license_detections", + "declared_license_expression": "declared_license_expression", + "declared_license_expression_spdx": "declared_license_expression_spdx", +} class CargoLockHandler(models.DatafileHandler): datasource_id = 'cargo_lock' @@ -185,11 +261,13 @@ def dependency_mapper(dependencies, scope='dependencies'): ) -def get_parties(person_names, party_role): +def get_parties(person_names, party_role, debug=False): """ Yields Party of `party_role` given a list of ``person_names`` strings. https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional """ + if debug: + raise Exception(person_names) for person_name in person_names: name, email = parse_person(person_name) yield models.Party( @@ -197,7 +275,7 @@ def get_parties(person_names, party_role): name=name, role=party_role, email=email, - ) + ).to_dict() person_parser = re.compile( diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json index 5529d5c8dc..ed5264755e 100644 --- a/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json +++ b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json @@ -1,5 +1,309 @@ { "packages": [ + { + "type": "cargo", + "namespace": null, + "name": "tauri", + "version": "2.0.0-alpha.17", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "Make tiny, secure apps for all desktop platforms with Tauri", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/tauri-apps/tauri", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://crates.io/crates/tauri", + "repository_download_url": "https://crates.io/api/v1/crates/tauri/2.0.0-alpha.17/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri", + "package_uid": "pkg:cargo/tauri@2.0.0-alpha.17?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "cargo-with-workspace/core/tauri/Cargo.toml" + ], + "datasource_ids": [ + "cargo_toml" + ], + "purl": "pkg:cargo/tauri@2.0.0-alpha.17" + }, + { + "type": "cargo", + "namespace": null, + "name": "tauri-runtime", + "version": "1.0.0-alpha.4", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "Runtime for Tauri applications", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/tauri-apps/tauri", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://crates.io/crates/tauri-runtime", + "repository_download_url": "https://crates.io/api/v1/crates/tauri-runtime/1.0.0-alpha.4/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri-runtime", + "package_uid": "pkg:cargo/tauri-runtime@1.0.0-alpha.4?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "cargo-with-workspace/core/tauri-runtime/Cargo.toml" + ], + "datasource_ids": [ + "cargo_toml" + ], + "purl": "pkg:cargo/tauri-runtime@1.0.0-alpha.4" + }, + { + "type": "cargo", + "namespace": null, + "name": "tauri-build", + "version": "2.0.0-alpha.11", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "build time code to pair with https://crates.io/crates/tauri", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/tauri-apps/tauri", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://crates.io/crates/tauri-build", + "repository_download_url": "https://crates.io/api/v1/crates/tauri-build/2.0.0-alpha.11/download", + "api_data_url": "https://crates.io/api/v1/crates/tauri-build", + "package_uid": "pkg:cargo/tauri-build@2.0.0-alpha.11?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "cargo-with-workspace/core/tauri-build/Cargo.toml" + ], + "datasource_ids": [ + "cargo_toml" + ], + "purl": "pkg:cargo/tauri-build@2.0.0-alpha.11" + }, + { + "type": "cargo", + "namespace": null, + "name": "restart", + "version": "0.1.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Tauri Programme within The Commons Conservancy", + "email": null, + "url": null + } + ], + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/tauri-apps/tauri", + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://crates.io/crates/restart", + "repository_download_url": "https://crates.io/api/v1/crates/restart/0.1.0/download", + "api_data_url": "https://crates.io/api/v1/crates/restart", + "package_uid": "pkg:cargo/restart@0.1.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "cargo-with-workspace/core/tests/restart/Cargo.toml" + ], + "datasource_ids": [ + "cargo_toml" + ], + "purl": "pkg:cargo/restart@0.1.0" + }, { "type": "npm", "namespace": null, @@ -152,12 +456,12 @@ { "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9", "license_expression": "apache-2.0 OR mit", - "detection_count": 4 + "detection_count": 8 }, { "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef", "license_expression": "apache-2.0 OR mit", - "detection_count": 2 + "detection_count": 1 }, { "identifier": "cc0_1_0-309b9888-634d-163a-1eaa-15f7837d2907", @@ -168,11 +472,6 @@ "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929", "license_expression": "mit", "detection_count": 1 - }, - { - "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94", - "license_expression": "unknown", - "detection_count": 3 } ], "files": [ @@ -245,7 +544,53 @@ "notice_text": null, "source_packages": [], "file_references": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "resolver": "2", + "members": [ + "core/tauri", + "core/tauri-runtime", + "core/tauri-build", + "core/tests/restart" + ], + "package": { + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "homepage": "https://tauri.app/", + "repository": "https://github.com/tauri-apps/tauri", + "categories": [ + "gui", + "web-programming" + ], + "license": "Apache-2.0 OR MIT", + "edition": "2021", + "rust-version": "1.70", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 17, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT" + } + } + }, "dependencies": [], "repository_homepage_url": null, "repository_download_url": null, @@ -505,15 +850,16 @@ { "type": "person", "role": "author", - "name": "workspace", + "name": "Tauri Programme within The Commons Conservancy", "email": null, "url": null } ], - "keywords": [], - "homepage_url": { - "workspace": true - }, + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", "download_url": null, "size": null, "sha1": null, @@ -522,38 +868,35 @@ "sha512": null, "bug_tracking_url": null, "code_view_url": null, - "vcs_url": { - "workspace": true - }, + "vcs_url": "https://github.com/tauri-apps/tauri", "copyright": null, "holder": null, - "declared_license_expression": "unknown", - "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", "license_detections": [ { - "license_expression": "unknown", + "license_expression": "apache-2.0 OR mit", "matches": [ { "score": 100.0, - "start_line": 1, - "end_line": 1, - "matched_length": 3, + "start_line": 17, + "end_line": 17, + "matched_length": 6, "match_coverage": 100.0, - "matcher": "5-undetected", - "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", - "matched_text": "license {'workspace': True}" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" } ], - "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": "workspace: yes\n", + "extracted_license_statement": "Apache-2.0 OR MIT", "notice_text": null, "source_packages": [], "file_references": [], @@ -567,6 +910,7 @@ } ], "for_packages": [ + "pkg:cargo/tauri-build@2.0.0-alpha.11?uuid=fixed-uid-done-for-testing-5642512d1758", "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" ], "detected_license_expression": null, @@ -608,15 +952,16 @@ { "type": "person", "role": "author", - "name": "workspace", + "name": "Tauri Programme within The Commons Conservancy", "email": null, "url": null } ], - "keywords": [], - "homepage_url": { - "workspace": true - }, + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", "download_url": null, "size": null, "sha1": null, @@ -625,38 +970,35 @@ "sha512": null, "bug_tracking_url": null, "code_view_url": null, - "vcs_url": { - "workspace": true - }, + "vcs_url": "https://github.com/tauri-apps/tauri", "copyright": null, "holder": null, - "declared_license_expression": "unknown", - "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", "license_detections": [ { - "license_expression": "unknown", + "license_expression": "apache-2.0 OR mit", "matches": [ { "score": 100.0, - "start_line": 1, - "end_line": 1, - "matched_length": 3, + "start_line": 17, + "end_line": 17, + "matched_length": 6, "match_coverage": 100.0, - "matcher": "5-undetected", - "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", - "matched_text": "license {'workspace': True}" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" } ], - "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": "workspace: yes\n", + "extracted_license_statement": "Apache-2.0 OR MIT", "notice_text": null, "source_packages": [], "file_references": [], @@ -670,6 +1012,7 @@ } ], "for_packages": [ + "pkg:cargo/tauri-runtime@1.0.0-alpha.4?uuid=fixed-uid-done-for-testing-5642512d1758", "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" ], "detected_license_expression": null, @@ -697,15 +1040,16 @@ { "type": "person", "role": "author", - "name": "workspace", + "name": "Tauri Programme within The Commons Conservancy", "email": null, "url": null } ], - "keywords": [], - "homepage_url": { - "workspace": true - }, + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", "download_url": null, "size": null, "sha1": null, @@ -714,38 +1058,35 @@ "sha512": null, "bug_tracking_url": null, "code_view_url": null, - "vcs_url": { - "workspace": true - }, + "vcs_url": "https://github.com/tauri-apps/tauri", "copyright": null, "holder": null, - "declared_license_expression": "unknown", - "declared_license_expression_spdx": "LicenseRef-scancode-unknown", + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", "license_detections": [ { - "license_expression": "unknown", + "license_expression": "apache-2.0 OR mit", "matches": [ { "score": 100.0, - "start_line": 1, - "end_line": 1, - "matched_length": 3, + "start_line": 17, + "end_line": 17, + "matched_length": 6, "match_coverage": 100.0, - "matcher": "5-undetected", - "license_expression": "unknown", - "rule_identifier": "package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-06e9bf2862e301d2e03347936ee156170df84855", - "matched_text": "license {'workspace': True}" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" } ], - "identifier": "unknown-91d148c3-19ed-e6b1-0d37-5f588dcd6a94" + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": "workspace: yes\n", + "extracted_license_statement": "Apache-2.0 OR MIT", "notice_text": null, "source_packages": [], "file_references": [], @@ -759,6 +1100,7 @@ } ], "for_packages": [ + "pkg:cargo/tauri@2.0.0-alpha.17?uuid=fixed-uid-done-for-testing-5642512d1758", "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" ], "detected_license_expression": null, @@ -819,8 +1161,11 @@ "url": null } ], - "keywords": [], - "homepage_url": null, + "keywords": [ + "gui", + "web-programming" + ], + "homepage_url": "https://tauri.app/", "download_url": null, "size": null, "sha1": null, @@ -829,7 +1174,7 @@ "sha512": null, "bug_tracking_url": null, "code_view_url": null, - "vcs_url": null, + "vcs_url": "https://github.com/tauri-apps/tauri", "copyright": null, "holder": null, "declared_license_expression": "apache-2.0 OR mit", @@ -840,19 +1185,18 @@ "matches": [ { "score": 100.0, - "start_line": 1, - "end_line": 1, - "matched_length": 5, + "start_line": 17, + "end_line": 17, + "matched_length": 6, "match_coverage": 100.0, - "matcher": "1-hash", + "matcher": "2-aho", "license_expression": "apache-2.0 OR mit", - "rule_identifier": "apache-2.0_or_mit_36.RULE", + "rule_identifier": "apache-2.0_or_mit_37.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE", - "matched_text": "Apache-2.0 OR MIT" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" } ], - "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef" + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" } ], "other_license_expression": null, @@ -872,6 +1216,7 @@ } ], "for_packages": [ + "pkg:cargo/restart@0.1.0?uuid=fixed-uid-done-for-testing-5642512d1758", "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" ], "detected_license_expression": "apache-2.0 OR mit", diff --git a/tests/packagedcode/data/cargo/scan.expected.json b/tests/packagedcode/data/cargo/scan.expected.json index bf4c6c1c86..178914cfbb 100644 --- a/tests/packagedcode/data/cargo/scan.expected.json +++ b/tests/packagedcode/data/cargo/scan.expected.json @@ -142,7 +142,14 @@ "extracted_license_statement": "MIT OR Apache-2.0", "notice_text": null, "source_packages": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "members": [ + "bench", + "daacfind" + ] + } + }, "repository_homepage_url": "https://crates.io/crates/daachorse", "repository_download_url": "https://crates.io/api/v1/crates/daachorse/0.4.1/download", "api_data_url": "https://crates.io/api/v1/crates/daachorse", @@ -883,7 +890,14 @@ "notice_text": null, "source_packages": [], "file_references": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "members": [ + "bench", + "daacfind" + ] + } + }, "dependencies": [], "repository_homepage_url": "https://crates.io/crates/daachorse", "repository_download_url": "https://crates.io/api/v1/crates/daachorse/0.4.1/download", diff --git a/tests/summarycode/data/score/no_license_ambiguity-expected.json b/tests/summarycode/data/score/no_license_ambiguity-expected.json index baaa02dedf..b96b0ab5a2 100644 --- a/tests/summarycode/data/score/no_license_ambiguity-expected.json +++ b/tests/summarycode/data/score/no_license_ambiguity-expected.json @@ -80,7 +80,16 @@ "extracted_license_statement": "MIT OR Apache-2.0", "notice_text": null, "source_packages": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "members": [ + "rand_core", + "rand_distr", + "rand_chacha", + "rand_pcg" + ] + } + }, "repository_homepage_url": "https://crates.io/crates/rand", "repository_download_url": "https://crates.io/api/v1/crates/rand/0.8.5/download", "api_data_url": "https://crates.io/api/v1/crates/rand", @@ -365,7 +374,16 @@ "notice_text": null, "source_packages": [], "file_references": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "members": [ + "rand_core", + "rand_distr", + "rand_chacha", + "rand_pcg" + ] + } + }, "dependencies": [], "repository_homepage_url": "https://crates.io/crates/rand", "repository_download_url": "https://crates.io/api/v1/crates/rand/0.8.5/download", From ff84e1cc04903c6bbb9d1eaae3794fe61a718594 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 22 Nov 2023 02:05:36 +0530 Subject: [PATCH 4/5] Support more cargo workspace cases Signed-off-by: Ayan Sinha Mahapatra --- src/packagedcode/cargo.py | 161 ++++---- src/packagedcode/plugin_package.py | 24 +- .../cargo/cargo-with-workspace.expected.json | 378 +++++++++++++++++- .../examples/api/package.json | 25 ++ .../examples/api/src-tauri/Cargo.lock | 28 ++ .../examples/api/src-tauri/Cargo.toml | 57 +++ .../cargo_toml/rustup/Cargo.toml.expected | 8 +- .../cargo_toml/tauri-examples/Cargo.toml | 6 + .../tauri-examples/Cargo.toml.expected | 44 ++ tests/packagedcode/test_cargo.py | 8 +- 10 files changed, 641 insertions(+), 98 deletions(-) create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/package.json create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.lock create mode 100644 tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml create mode 100644 tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected diff --git a/src/packagedcode/cargo.py b/src/packagedcode/cargo.py index fe955a279f..415a19b965 100644 --- a/src/packagedcode/cargo.py +++ b/src/packagedcode/cargo.py @@ -21,74 +21,7 @@ """ -class CargoTomlHandler(models.DatafileHandler): - datasource_id = 'cargo_toml' - path_patterns = ('*/Cargo.toml', '*/cargo.toml',) - default_package_type = 'cargo' - default_primary_language = 'Rust' - description = 'Rust Cargo.toml package manifest' - documentation_url = 'https://doc.rust-lang.org/cargo/reference/manifest.html' - - @classmethod - def parse(cls, location): - package_data = toml.load(location, _dict=dict) - core_package_data = package_data.get('package', {}) - workspace = package_data.get('workspace', {}) - - name = core_package_data.get('name') - version = core_package_data.get('version') - description = core_package_data.get('description') or '' - description = description.strip() - - authors = core_package_data.get('authors') or [] - parties = list(get_parties(person_names=authors, party_role='author')) - - extracted_license_statement = core_package_data.get('license') - # TODO: load as a notice_text - license_file = core_package_data.get('license-file') - - keywords = core_package_data.get('keywords') or [] - categories = core_package_data.get('categories') or [] - keywords.extend(categories) - - # cargo dependencies are complex and can be overriden at multiple levels - dependencies = [] - for key, value in core_package_data.items(): - if key.endswith('dependencies'): - dependencies.extend(dependency_mapper(dependencies=value, scope=key)) - - # TODO: add file refs: - # - readme, include and exclude - # TODO: other URLs - # - documentation - - vcs_url = core_package_data.get('repository') - homepage_url = core_package_data.get('homepage') - repository_homepage_url = name and f'https://crates.io/crates/{name}' - repository_download_url = name and version and f'https://crates.io/api/v1/crates/{name}/{version}/download' - api_data_url = name and f'https://crates.io/api/v1/crates/{name}' - extra_data = {} - if workspace: - extra_data["workspace"] = workspace - - yield models.PackageData( - datasource_id=cls.datasource_id, - type=cls.default_package_type, - name=name, - version=version, - primary_language=cls.default_primary_language, - description=description, - parties=parties, - extracted_license_statement=extracted_license_statement, - vcs_url=vcs_url, - homepage_url=homepage_url, - repository_homepage_url=repository_homepage_url, - repository_download_url=repository_download_url, - api_data_url=api_data_url, - dependencies=dependencies, - extra_data=extra_data, - ) - +class CargoBaseHandler(models.DatafileHandler): @classmethod def assemble(cls, package_data, resource, codebase, package_adder): """ @@ -161,6 +94,79 @@ def update_resource_package_data(cls, package_data, old_package_data, mapping=No return old_package_data + +class CargoTomlHandler(CargoBaseHandler): + datasource_id = 'cargo_toml' + path_patterns = ('*/Cargo.toml', '*/cargo.toml',) + default_package_type = 'cargo' + default_primary_language = 'Rust' + description = 'Rust Cargo.toml package manifest' + documentation_url = 'https://doc.rust-lang.org/cargo/reference/manifest.html' + + @classmethod + def parse(cls, location): + package_data = toml.load(location, _dict=dict) + core_package_data = package_data.get('package', {}) + workspace = package_data.get('workspace', {}) + + name = core_package_data.get('name') + version = core_package_data.get('version') + if isinstance(version, dict) and "workspace" in version: + version = "workspace" + + description = core_package_data.get('description') or '' + description = description.strip() + + authors = core_package_data.get('authors') or [] + parties = list(get_parties(person_names=authors, party_role='author')) + + extracted_license_statement = core_package_data.get('license') + # TODO: load as a notice_text + license_file = core_package_data.get('license-file') + + keywords = core_package_data.get('keywords') or [] + categories = core_package_data.get('categories') or [] + keywords.extend(categories) + + # cargo dependencies are complex and can be overriden at multiple levels + dependencies = [] + for key, value in core_package_data.items(): + if key.endswith('dependencies'): + dependencies.extend(dependency_mapper(dependencies=value, scope=key)) + + # TODO: add file refs: + # - readme, include and exclude + # TODO: other URLs + # - documentation + + vcs_url = core_package_data.get('repository') + homepage_url = core_package_data.get('homepage') + repository_homepage_url = name and f'https://crates.io/crates/{name}' + repository_download_url = name and version and f'https://crates.io/api/v1/crates/{name}/{version}/download' + api_data_url = name and f'https://crates.io/api/v1/crates/{name}' + extra_data = {} + if workspace: + extra_data["workspace"] = workspace + + yield models.PackageData( + datasource_id=cls.datasource_id, + type=cls.default_package_type, + name=name, + version=version, + primary_language=cls.default_primary_language, + description=description, + parties=parties, + extracted_license_statement=extracted_license_statement, + vcs_url=vcs_url, + homepage_url=homepage_url, + repository_homepage_url=repository_homepage_url, + repository_download_url=repository_download_url, + api_data_url=api_data_url, + dependencies=dependencies, + extra_data=extra_data, + ) + + CARGO_ATTRIBUTE_MAPPING = { # Fields in PackageData model: Fields in cargo "homepage_url": "homepage", @@ -173,7 +179,8 @@ def update_resource_package_data(cls, package_data, old_package_data, mapping=No "declared_license_expression_spdx": "declared_license_expression_spdx", } -class CargoLockHandler(models.DatafileHandler): + +class CargoLockHandler(CargoBaseHandler): datasource_id = 'cargo_lock' path_patterns = ('*/Cargo.lock', '*/cargo.lock',) default_package_type = 'cargo' @@ -220,18 +227,6 @@ def parse(cls, location): dependencies=dependencies, ) - @classmethod - def assemble(cls, package_data, resource, codebase, package_adder): - """ - Assemble Cargo.toml and possible Cargo.lock datafiles - """ - yield from cls.assemble_from_many_datafiles( - datafile_name_patterns=('Cargo.toml', 'Cargo.lock',), - directory=resource.parent(codebase), - codebase=codebase, - package_adder=package_adder, - ) - def dependency_mapper(dependencies, scope='dependencies'): """ @@ -261,13 +256,11 @@ def dependency_mapper(dependencies, scope='dependencies'): ) -def get_parties(person_names, party_role, debug=False): +def get_parties(person_names, party_role): """ Yields Party of `party_role` given a list of ``person_names`` strings. https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional """ - if debug: - raise Exception(person_names) for person_name in person_names: name, email = parse_person(person_name) yield models.Party( diff --git a/src/packagedcode/plugin_package.py b/src/packagedcode/plugin_package.py index 2e1e4ad6e0..6af3186b4f 100644 --- a/src/packagedcode/plugin_package.py +++ b/src/packagedcode/plugin_package.py @@ -38,7 +38,8 @@ from packagedcode.models import PackageWithResources TRACE = os.environ.get('SCANCODE_DEBUG_PACKAGE_API', False) - +TRACE_DEEP = os.environ.get('SCANCODE_DEBUG_PACKAGE_API_DEEP', False) +TRACE_LICENSE = os.environ.get('SCANCODE_DEBUG_PACKAGE_LICENSE', False) def logger_debug(*args): pass @@ -207,7 +208,7 @@ def process_codebase(self, codebase, strip_root=False, **kwargs): # If we don't detect license in package_data but there is license detected in file # we add the license expression from the file to a package modified = add_license_from_file(resource, codebase) - if TRACE and modified: + if TRACE_LICENSE and modified: logger_debug(f'packagedcode: process_codebase: add_license_from_file: modified: {modified}') if codebase.has_single_resource: @@ -216,7 +217,7 @@ def process_codebase(self, codebase, strip_root=False, **kwargs): # If there is referenced files in a extracted license statement, we follow # the references, look for license detections and add them back modified = list(add_referenced_license_matches_for_package(resource, codebase)) - if TRACE and modified: + if TRACE_LICENSE and modified: logger_debug(f'packagedcode: process_codebase: add_referenced_license_matches_for_package: modified: {modified}') # If there is a LICENSE file on the same level as the manifest, and no license @@ -234,7 +235,7 @@ def process_codebase(self, codebase, strip_root=False, **kwargs): # If there is a unknown reference to a package we add the license # from the package license detection modified = list(add_referenced_license_detection_from_package(resource, codebase)) - if TRACE and modified: + if TRACE_LICENSE and modified: logger_debug(f'packagedcode: process_codebase: add_referenced_license_matches_from_package: modified: {modified}') @@ -244,7 +245,7 @@ def add_license_from_file(resource, codebase): and the file has license detections, and if so, populate the package_data license expression and detection fields from the file license. """ - if TRACE: + if TRACE_LICENSE: logger_debug(f'packagedcode.plugin_package: add_license_from_file: resource: {resource.path}') if not resource.is_file: @@ -252,7 +253,7 @@ def add_license_from_file(resource, codebase): license_detections_file = resource.license_detections - if TRACE: + if TRACE_LICENSE: logger_debug(f'add_license_from_file: license_detections_file: {license_detections_file}') if not license_detections_file: return @@ -263,7 +264,7 @@ def add_license_from_file(resource, codebase): for pkg in package_data: license_detections_pkg = pkg["license_detections"] - if TRACE: + if TRACE_LICENSE: logger_debug(f'add_license_from_file: license_detections_pkg: {license_detections_pkg}') if not license_detections_pkg: @@ -359,7 +360,7 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals package_data = PackageData.from_dict(mapping=package_data) if TRACE: - logger_debug(' get_package_and_deps: package_data:', package_data) + logger_debug(' get_package_and_deps: package_data.purl:', package_data.purl) # Find a handler for this package datasource to assemble collect # packages and deps @@ -375,8 +376,6 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals ) for item in items: - if TRACE: - logger_debug(' get_package_and_deps: item:', item) if isinstance(item, Package): if strip_root and not has_single_resource: @@ -385,6 +384,8 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals for dfp in item.datafile_paths ] packages.append(item) + if TRACE: + logger_debug(' get_package_and_deps: Package:', item.purl) elif isinstance(item, Dependency): if strip_root and not has_single_resource: @@ -395,6 +396,9 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals seen_resource_paths.add(item.path) if TRACE: + logger_debug(' get_package_and_deps: Resource:', item.path) + + if TRACE_DEEP: logger_debug( ' get_package_and_deps: seen_resource_path:', seen_resource_paths, diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json index ed5264755e..8611b5d58d 100644 --- a/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json +++ b/tests/packagedcode/data/cargo/cargo-with-workspace.expected.json @@ -456,12 +456,12 @@ { "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9", "license_expression": "apache-2.0 OR mit", - "detection_count": 8 + "detection_count": 9 }, { "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef", "license_expression": "apache-2.0 OR mit", - "detection_count": 1 + "detection_count": 2 }, { "identifier": "cc0_1_0-309b9888-634d-163a-1eaa-15f7837d2907", @@ -1245,6 +1245,380 @@ "percentage_of_license_text": 20.0, "scan_errors": [] }, + { + "path": "cargo-with-workspace/examples", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/examples/api", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/examples/api/package.json", + "type": "file", + "package_data": [ + { + "type": "npm", + "namespace": null, + "name": "api", + "version": "1.0.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": "https://registry.npmjs.org/api/-/api-1.0.0.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": null, + "declared_license_expression_spdx": null, + "license_detections": [], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:npm/%40tauri-apps/api", + "extracted_requirement": "../../tooling/api/dist", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/%40zerodevx/svelte-json-view", + "extracted_requirement": "0.2.1", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/%40iconify-json/codicon", + "extracted_requirement": "^1.1.10", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/%40iconify-json/ph", + "extracted_requirement": "^1.1.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/internal-ip", + "extracted_requirement": "^7.0.0", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/unocss", + "extracted_requirement": "^0.39.3", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/%40sveltejs/vite-plugin-svelte", + "extracted_requirement": "^2.4.6", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/svelte", + "extracted_requirement": "^4.2.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/vite", + "extracted_requirement": "^4.4.9", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://www.npmjs.com/package/api", + "repository_download_url": "https://registry.npmjs.org/api/-/api-1.0.0.tgz", + "api_data_url": "https://registry.npmjs.org/api/1.0.0", + "datasource_id": "npm_package_json", + "purl": "pkg:npm/api@1.0.0" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/examples/api/src-tauri", + "type": "directory", + "package_data": [], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/examples/api/src-tauri/Cargo.lock", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": null, + "declared_license_expression_spdx": null, + "license_detections": [], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:cargo/addr2line@0.21.0", + "extracted_requirement": "0.21.0", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:cargo/adler@1.0.2", + "extracted_requirement": "1.0.2", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:cargo/aead@0.5.2", + "extracted_requirement": "0.5.2", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "cargo_lock", + "purl": null + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "cargo-with-workspace/examples/api/src-tauri/Cargo.toml", + "type": "file", + "package_data": [ + { + "type": "cargo", + "namespace": null, + "name": "api", + "version": "0.1.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "An example Tauri Application showcasing the api", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "apache-2.0 OR mit", + "declared_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_36.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE", + "matched_text": "Apache-2.0 OR MIT" + } + ], + "identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "Apache-2.0 OR MIT", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/api", + "repository_download_url": "https://crates.io/api/v1/crates/api/0.1.0/download", + "api_data_url": "https://crates.io/api/v1/crates/api", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/api@0.1.0" + } + ], + "for_packages": [ + "pkg:npm/tauri-workspace@0.0.0?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "apache-2.0 OR mit", + "detected_license_expression_spdx": "Apache-2.0 OR MIT", + "license_detections": [ + { + "license_expression": "apache-2.0 OR mit", + "matches": [ + { + "score": 100.0, + "start_line": 7, + "end_line": 7, + "matched_length": 6, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0 OR mit", + "rule_identifier": "apache-2.0_or_mit_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_37.RULE" + } + ], + "identifier": "apache_2_0_or_mit-8028b724-ab19-ab66-3288-312e7edc4fd9" + } + ], + "license_clues": [], + "percentage_of_license_text": 3.28, + "scan_errors": [] + }, { "path": "cargo-with-workspace/package.json", "type": "file", diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/package.json b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/package.json new file mode 100644 index 0000000000..b1ab687345 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/package.json @@ -0,0 +1,25 @@ +{ + "name": "api", + "private": true, + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "tauri": "node ../../tooling/cli/node/tauri.js" + }, + "dependencies": { + "@tauri-apps/api": "../../tooling/api/dist", + "@zerodevx/svelte-json-view": "0.2.1" + }, + "devDependencies": { + "@iconify-json/codicon": "^1.1.10", + "@iconify-json/ph": "^1.1.1", + "internal-ip": "^7.0.0", + "unocss": "^0.39.3", + "@sveltejs/vite-plugin-svelte": "^2.4.6", + "svelte": "^4.2.1", + "vite": "^4.4.9" + } +} diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.lock b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.lock new file mode 100644 index 0000000000..5e47801481 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.lock @@ -0,0 +1,28 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] diff --git a/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.toml b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.toml new file mode 100644 index 0000000000..c83ce5c1ce --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo-with-workspace/examples/api/src-tauri/Cargo.toml @@ -0,0 +1,57 @@ +[package] +name = "api" +version = "0.1.0" +description = "An example Tauri Application showcasing the api" +edition = "2021" +rust-version = "1.70" +license = "Apache-2.0 OR MIT" + +[lib] +name = "api_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { path = "../../../core/tauri-build", features = ["codegen", "isolation"] } + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = [ "derive" ] } +tiny_http = "0.11" +log = "0.4" +tauri-plugin-sample = { path = "./tauri-plugin-sample/" } + +[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +tauri-plugin-cli = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } + +[patch.crates-io] +tauri = { path = "../../../core/tauri" } +tauri-build = { path = "../../../core/tauri-build" } + +[dependencies.tauri] +path = "../../../core/tauri" +features = [ + "protocol-asset", + "icon-ico", + "icon-png", + "isolation", + "macos-private-api", + "tray-icon" +] + +[dev-dependencies.tauri] +path = "../../../core/tauri" +features = ["test"] + +[target."cfg(target_os = \"windows\")".dependencies] +window-shadows= "0.2" + +[features] +custom-protocol = [ "tauri/custom-protocol" ] + +# default to small, optimized release binaries +[profile.release] +panic = "abort" +codegen-units = 1 +lto = true +incremental = false +opt-level = "s" diff --git a/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected index c1801c22e2..575cd3a296 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected @@ -61,7 +61,13 @@ "notice_text": null, "source_packages": [], "file_references": [], - "extra_data": {}, + "extra_data": { + "workspace": { + "members": [ + "src/download" + ] + } + }, "dependencies": [], "repository_homepage_url": "https://crates.io/crates/rustup", "repository_download_url": "https://crates.io/api/v1/crates/rustup/1.17.0/download", diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml new file mode 100644 index 0000000000..ee27b9b393 --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "core-api" +version = { workspace = true } +edition = "2021" + +[dependencies] diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected new file mode 100644 index 0000000000..ba154dd20a --- /dev/null +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected @@ -0,0 +1,44 @@ +[ + { + "type": "cargo", + "namespace": null, + "name": "core-api", + "version": "workspace", + "qualifiers": {}, + "subpath": null, + "primary_language": "Rust", + "description": "", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": null, + "declared_license_expression_spdx": null, + "license_detections": [], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [], + "repository_homepage_url": "https://crates.io/crates/core-api", + "repository_download_url": "https://crates.io/api/v1/crates/core-api/workspace/download", + "api_data_url": "https://crates.io/api/v1/crates/core-api", + "datasource_id": "cargo_toml", + "purl": "pkg:cargo/core-api@workspace" + } +] \ No newline at end of file diff --git a/tests/packagedcode/test_cargo.py b/tests/packagedcode/test_cargo.py index 91b167b63f..5c25f13502 100644 --- a/tests/packagedcode/test_cargo.py +++ b/tests/packagedcode/test_cargo.py @@ -65,12 +65,18 @@ def test_parse_cargo_toml_rustup(self): packages_data = cargo.CargoTomlHandler.parse(test_file) self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES) - def test_parse_cargo_toml_rustup(self): + def test_parse_cargo_toml_tauri_workspace(self): test_file = self.get_test_loc('cargo/cargo_toml/tauri/Cargo.toml') expected_loc = self.get_test_loc('cargo/cargo_toml/tauri/Cargo.toml.expected') packages_data = cargo.CargoTomlHandler.parse(test_file) self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES) + def test_parse_cargo_toml_tauri_workspace_in_version(self): + test_file = self.get_test_loc('cargo/cargo_toml/tauri-examples/Cargo.toml') + expected_loc = self.get_test_loc('cargo/cargo_toml/tauri-examples/Cargo.toml.expected') + packages_data = cargo.CargoTomlHandler.parse(test_file) + self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES) + def test_parse_cargo_lock_sample1(self): test_file = self.get_test_loc('cargo/cargo_lock/sample1/Cargo.lock') expected_loc = self.get_test_loc('cargo/cargo_lock/sample1/output.expected.json') From 50d2afe35e7f916ba10998cbc02be35390c4d130 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 6 Dec 2023 19:42:53 +0530 Subject: [PATCH 5/5] Add version case to extra_data Signed-off-by: Ayan Sinha Mahapatra --- src/packagedcode/cargo.py | 5 +++-- .../cargo_toml/tauri-examples/Cargo.toml.expected | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/packagedcode/cargo.py b/src/packagedcode/cargo.py index 415a19b965..18e19e5521 100644 --- a/src/packagedcode/cargo.py +++ b/src/packagedcode/cargo.py @@ -108,11 +108,13 @@ def parse(cls, location): package_data = toml.load(location, _dict=dict) core_package_data = package_data.get('package', {}) workspace = package_data.get('workspace', {}) + extra_data = {} name = core_package_data.get('name') version = core_package_data.get('version') if isinstance(version, dict) and "workspace" in version: - version = "workspace" + version = None + extra_data["version"] = "workspace" description = core_package_data.get('description') or '' description = description.strip() @@ -144,7 +146,6 @@ def parse(cls, location): repository_homepage_url = name and f'https://crates.io/crates/{name}' repository_download_url = name and version and f'https://crates.io/api/v1/crates/{name}/{version}/download' api_data_url = name and f'https://crates.io/api/v1/crates/{name}' - extra_data = {} if workspace: extra_data["workspace"] = workspace diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected index ba154dd20a..32ee8a491c 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected @@ -3,7 +3,7 @@ "type": "cargo", "namespace": null, "name": "core-api", - "version": "workspace", + "version": null, "qualifiers": {}, "subpath": null, "primary_language": "Rust", @@ -33,12 +33,14 @@ "notice_text": null, "source_packages": [], "file_references": [], - "extra_data": {}, + "extra_data": { + "version": "workspace" + }, "dependencies": [], "repository_homepage_url": "https://crates.io/crates/core-api", - "repository_download_url": "https://crates.io/api/v1/crates/core-api/workspace/download", + "repository_download_url": null, "api_data_url": "https://crates.io/api/v1/crates/core-api", "datasource_id": "cargo_toml", - "purl": "pkg:cargo/core-api@workspace" + "purl": "pkg:cargo/core-api" } ] \ No newline at end of file