Skip to content

Commit 9c3b77f

Browse files
committed
Add regression test for single Cargo.toml file scan
Signed-off-by: Om Santosh Suneri <[email protected]>
1 parent aaea989 commit 9c3b77f

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
name = "constant_time_eq"
3+
version = "0.4.2"
4+
edition = "2024"
5+
authors = ["Cesar Eduardo Barros <[email protected]>"]
6+
description = "Compares two equal-sized byte strings in constant time."
7+
documentation = "https://docs.rs/constant_time_eq"
8+
repository = "https://github.com/cesarb/constant_time_eq"
9+
readme = "README"
10+
keywords = ["constant_time"]
11+
categories = ["cryptography", "no-std"]
12+
license = "CC0-1.0 OR MIT-0 OR Apache-2.0"
13+
rust-version = "1.85.0"
14+
15+
[dev-dependencies]
16+
criterion = { version = "0.5.1", features = ["cargo_bench_support", "html_reports"] }
17+
count_instructions = "0.2.0"
18+
19+
[features]
20+
default = ["std"]
21+
22+
# Necessary to detect at runtime whether DIT is available on aarch64.
23+
std = []
24+
25+
# Enables tests which depend on the count_instructions crate.
26+
count_instructions_test = []
27+
28+
[[bench]]
29+
name = "bench"
30+
harness = false
31+
32+
[[bench]]
33+
name = "bench_generic"
34+
harness = false
35+
36+
[[bench]]
37+
name = "bench_classic"
38+
harness = false
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
[
2+
{
3+
"type": "cargo",
4+
"namespace": null,
5+
"name": "constant_time_eq",
6+
"version": "0.4.2",
7+
"qualifiers": {},
8+
"subpath": null,
9+
"primary_language": "Rust",
10+
"description": "Compares two equal-sized byte strings in constant time.",
11+
"release_date": null,
12+
"parties": [
13+
{
14+
"type": "person",
15+
"role": "author",
16+
"name": "Cesar Eduardo Barros",
17+
"email": "[email protected]",
18+
"url": null
19+
}
20+
],
21+
"keywords": [
22+
"constant_time",
23+
"cryptography",
24+
"no-std"
25+
],
26+
"homepage_url": null,
27+
"download_url": null,
28+
"size": null,
29+
"sha1": null,
30+
"md5": null,
31+
"sha256": null,
32+
"sha512": null,
33+
"bug_tracking_url": null,
34+
"code_view_url": null,
35+
"vcs_url": "https://github.com/cesarb/constant_time_eq",
36+
"copyright": null,
37+
"holder": null,
38+
"declared_license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
39+
"declared_license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
40+
"license_detections": [
41+
{
42+
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
43+
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
44+
"matches": [
45+
{
46+
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
47+
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
48+
"from_file": null,
49+
"start_line": 1,
50+
"end_line": 1,
51+
"matcher": "1-spdx-id",
52+
"score": 100.0,
53+
"matched_length": 10,
54+
"match_coverage": 100.0,
55+
"rule_relevance": 100,
56+
"rule_identifier": "spdx-license-identifier-cc0_1_0_or_mit_0_or_apache_2_0-f44a2ec174eb034bd3c662f728664281e507b20d",
57+
"rule_url": null,
58+
"matched_text": "CC0-1.0 OR MIT-0 OR Apache-2.0"
59+
}
60+
],
61+
"identifier": "cc0_1_0_or_mit_0_or_apache_2_0-3f14dd48-7cd8-cf28-d4e1-3b0174a587ee"
62+
}
63+
],
64+
"other_license_expression": null,
65+
"other_license_expression_spdx": null,
66+
"other_license_detections": [],
67+
"extracted_license_statement": "CC0-1.0 OR MIT-0 OR Apache-2.0",
68+
"notice_text": null,
69+
"source_packages": [],
70+
"file_references": [],
71+
"is_private": false,
72+
"is_virtual": false,
73+
"extra_data": {
74+
"documentation_url": "https://docs.rs/constant_time_eq",
75+
"rust_version": "1.85.0",
76+
"rust_edition": "2024"
77+
},
78+
"dependencies": [
79+
{
80+
"purl": "pkg:cargo/criterion",
81+
"extracted_requirement": "0.5.1",
82+
"scope": "dev-dependencies",
83+
"is_runtime": false,
84+
"is_optional": false,
85+
"is_pinned": false,
86+
"is_direct": true,
87+
"resolved_package": {},
88+
"extra_data": {
89+
"version": "0.5.1",
90+
"features": [
91+
"cargo_bench_support",
92+
"html_reports"
93+
]
94+
}
95+
},
96+
{
97+
"purl": "pkg:cargo/count_instructions",
98+
"extracted_requirement": "0.2.0",
99+
"scope": "dev-dependencies",
100+
"is_runtime": false,
101+
"is_optional": false,
102+
"is_pinned": false,
103+
"is_direct": true,
104+
"resolved_package": {},
105+
"extra_data": {}
106+
}
107+
],
108+
"repository_homepage_url": "https://crates.io/crates/constant_time_eq",
109+
"repository_download_url": "https://crates.io/api/v1/crates/constant_time_eq/0.4.2/download",
110+
"api_data_url": "https://crates.io/api/v1/crates/constant_time_eq",
111+
"datasource_id": "cargo_toml",
112+
"purl": "pkg:cargo/[email protected]"
113+
}
114+
]

tests/packagedcode/test_cargo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def test_parse_cargo_toml_workspace_with_dependencies_child(self):
8383
packages_data = cargo.CargoTomlHandler.parse(test_file)
8484
self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES)
8585

86+
def test_parse_cargo_toml_single_file_no_crash(self):
87+
test_file = self.get_test_loc('cargo/cargo_toml/single-file-scan/Cargo.toml')
88+
expected_loc = self.get_test_loc('cargo/cargo_toml/single-file-scan/Cargo.toml.expected')
89+
packages_data = cargo.CargoTomlHandler.parse(test_file)
90+
self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES)
91+
8692
def test_parse_cargo_toml_tauri_workspace_in_version(self):
8793
test_file = self.get_test_loc('cargo/cargo_toml/tauri-examples/Cargo.toml')
8894
expected_loc = self.get_test_loc('cargo/cargo_toml/tauri-examples/Cargo.toml.expected')

0 commit comments

Comments
 (0)