Skip to content

Commit 8483e43

Browse files
Address CodeRabbit review round 5: pin deps, DetectionMethod::as_str()
- Pin dependency versions to match millhone for workspace consistency - Add DetectionMethod::as_str() for parity with Primitive::as_str() - Replace serde round-trip for DetectionMethod in cyclonedx.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 418924a commit 8483e43

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

extlib/cryptoscan/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ name = "cryptoscan"
1010
path = "src/main.rs"
1111

1212
[dependencies]
13-
serde = { version = "1", features = ["derive"] }
14-
serde_json = "1"
13+
serde = { version = "1.0.183", features = ["derive"] }
14+
serde_json = "1.0.107"
1515
regex = "1"
16-
walkdir = "2"
17-
clap = { version = "4", features = ["derive"] }
18-
uuid = { version = "1", features = ["v4"] }
16+
walkdir = "2.4.0"
17+
clap = { version = "4.3.21", features = ["derive"] }
18+
uuid = { version = "1.4.1", features = ["v4"] }
1919

2020
[dev-dependencies]
2121
tempfile = "3"

extlib/cryptoscan/src/crypto_algorithm.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ pub enum DetectionMethod {
103103
StringLiteral,
104104
}
105105

106+
impl DetectionMethod {
107+
pub fn as_str(&self) -> &'static str {
108+
match self {
109+
DetectionMethod::DependencyManifest => "dependency-manifest",
110+
DetectionMethod::ImportStatement => "import-statement",
111+
DetectionMethod::ApiCall => "api-call",
112+
DetectionMethod::ConfigFile => "config-file",
113+
DetectionMethod::StringLiteral => "string-literal",
114+
}
115+
}
116+
}
117+
106118
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
107119
#[serde(rename_all = "lowercase")]
108120
pub enum Confidence {

extlib/cryptoscan/src/cyclonedx.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ pub fn to_cyclonedx_bom(findings: &[CryptoFinding]) -> CycloneDxBom {
170170
});
171171
}
172172

173-
let method_str = serde_json::to_value(&finding.detection_method)
174-
.ok()
175-
.and_then(|v| v.as_str().map(|s| s.to_string()))
176-
.unwrap_or_default();
173+
let method_str = finding.detection_method.as_str().to_string();
177174
if seen_methods.insert(method_str.clone()) {
178175
properties.push(BomProperty {
179176
name: "fossa:detection-method".to_string(),

0 commit comments

Comments
 (0)