Skip to content

Commit 40b40da

Browse files
fix: add missing file/line fields to WeakPoint initializers (#16)
The WeakPoint struct gained file and line fields (for GitHub Actions annotations), but several test helpers and benchmarks were not updated, causing compilation failures. https://claude.ai/code/session_01HTks5HmV7XHW6ZtiEfp9dN Co-authored-by: Claude <noreply@anthropic.com>
1 parent 36c7599 commit 40b40da

7 files changed

Lines changed: 28 additions & 0 deletions

File tree

benches/scan_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ fn bench_location_extraction(c: &mut Criterion) {
9696
category: panic_attack::types::WeakPointCategory::UnsafeCode,
9797
severity: panic_attack::types::Severity::High,
9898
location: Some("test.rs:10".to_string()),
99+
file: None,
100+
line: None,
99101
description: "test".to_string(),
100102
recommended_attack: vec![],
101103
};

src/a2ml/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ mod tests {
827827
weak_points: vec![WeakPoint {
828828
category: WeakPointCategory::UncheckedError,
829829
location: Some("src/main.rs:10".to_string()),
830+
file: Some("src/main.rs".to_string()),
831+
line: Some(10),
830832
severity: Severity::Medium,
831833
description: "unchecked result".to_string(),
832834
recommended_attack: vec![AttackAxis::Concurrency],

src/kanren/core.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,8 @@ mod tests {
10521052
WeakPoint {
10531053
category,
10541054
location: Some(location.to_string()),
1055+
file: None,
1056+
line: None,
10551057
severity: Severity::Medium,
10561058
description: description.to_string(),
10571059
recommended_attack: vec![],

tests/panll_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ fn test_panll_export_summary_reflects_report() {
6868
vec![WeakPoint {
6969
category: WeakPointCategory::UnsafeCode,
7070
location: Some("src/lib.rs".to_string()),
71+
file: None,
72+
line: None,
7173
severity: Severity::Critical,
7274
description: "unsafe block".to_string(),
7375
recommended_attack: vec![],
@@ -93,13 +95,17 @@ fn test_panll_export_constraints_from_critical_wp() {
9395
WeakPoint {
9496
category: WeakPointCategory::UnsafeCode,
9597
location: Some("src/danger.rs".to_string()),
98+
file: None,
99+
line: None,
96100
severity: Severity::Critical,
97101
description: "transmute usage".to_string(),
98102
recommended_attack: vec![AttackAxis::Memory],
99103
},
100104
WeakPoint {
101105
category: WeakPointCategory::PanicPath,
102106
location: Some("src/safe.rs".to_string()),
107+
file: None,
108+
line: None,
103109
severity: Severity::Medium,
104110
description: "unwrap call".to_string(),
105111
recommended_attack: vec![],

tests/property_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ fn prop_weak_point_location_validity() {
180180
category: WeakPointCategory::UnsafeCode,
181181
severity: Severity::High,
182182
location: None,
183+
file: None,
184+
line: None,
183185
description: "test".to_string(),
184186
recommended_attack: vec![],
185187
};
@@ -233,13 +235,17 @@ fn prop_no_duplicate_weak_points_at_same_location() {
233235
category: WeakPointCategory::UnsafeCode,
234236
severity: Severity::High,
235237
location: Some("test.rs:10".to_string()),
238+
file: None,
239+
line: None,
236240
description: "unsafe block 1".to_string(),
237241
recommended_attack: vec![],
238242
},
239243
WeakPoint {
240244
category: WeakPointCategory::UnsafeCode,
241245
severity: Severity::High,
242246
location: Some("test.rs:10".to_string()),
247+
file: None,
248+
line: None,
243249
description: "unsafe block 2".to_string(),
244250
recommended_attack: vec![],
245251
},

tests/report_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ fn make_assail_report() -> AssailReport {
1616
WeakPoint {
1717
category: WeakPointCategory::UnsafeCode,
1818
location: Some("src/main.rs".to_string()),
19+
file: None,
20+
line: None,
1921
severity: Severity::Critical,
2022
description: "2 unsafe blocks in src/main.rs".to_string(),
2123
recommended_attack: vec![AttackAxis::Memory, AttackAxis::Concurrency],
2224
},
2325
WeakPoint {
2426
category: WeakPointCategory::PanicPath,
2527
location: Some("src/lib.rs".to_string()),
28+
file: None,
29+
line: None,
2630
severity: Severity::Medium,
2731
description: "5 unwrap/expect calls in src/lib.rs".to_string(),
2832
recommended_attack: vec![AttackAxis::Memory],
@@ -132,6 +136,8 @@ fn test_robustness_score_clamped_to_zero() {
132136
assail.weak_points.push(WeakPoint {
133137
category: WeakPointCategory::UnsafeCode,
134138
location: Some(format!("src/file{}.rs", i)),
139+
file: None,
140+
line: None,
135141
severity: Severity::Critical,
136142
description: format!("critical issue {}", i),
137143
recommended_attack: vec![],

tests/sarif_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ fn make_test_report() -> AssailReport {
1818
severity: Severity::Critical,
1919
description: "unsafe block found".to_string(),
2020
location: Some("src/main.rs:10".to_string()),
21+
file: Some("src/main.rs".to_string()),
22+
line: Some(10),
2123
recommended_attack: vec![AttackAxis::Memory],
2224
},
2325
WeakPoint {
2426
category: WeakPointCategory::PanicPath,
2527
severity: Severity::Medium,
2628
description: "unwrap on Option".to_string(),
2729
location: Some("src/lib.rs:42".to_string()),
30+
file: Some("src/lib.rs".to_string()),
31+
line: Some(42),
2832
recommended_attack: vec![],
2933
},
3034
],

0 commit comments

Comments
 (0)