mirror of https://github.com/smithy-lang/smithy-rs
lots more fixes (some more cleanup still required)
This commit is contained in:
parent
829e51e481
commit
3af6c333af
|
@ -102,6 +102,7 @@ class FuzzHarnessBuildPlugin : SmithyBuildPlugin {
|
|||
target
|
||||
}
|
||||
|
||||
println("creating the driver...")
|
||||
createDriver(model, context.fileManifest, fuzzSettings)
|
||||
|
||||
targets.forEach {
|
||||
|
@ -133,11 +134,12 @@ fun corpus(
|
|||
val protocolTests = operations.flatMap { it.getTrait<HttpRequestTestsTrait>()?.testCases ?: listOf() }
|
||||
val out = ArrayNode.builder()
|
||||
protocolTests.forEach { testCase ->
|
||||
println(testCase.bodyMediaType)
|
||||
val body: List<NumberNode> =
|
||||
when (testCase.bodyMediaType.orNull()) {
|
||||
"application/cbor" -> {
|
||||
println("base64 decoding first")
|
||||
Base64.getDecoder().decode(testCase.body.orNull())?.map { NumberNode.from(it) }
|
||||
println("base64 decoding first (v2)")
|
||||
Base64.getDecoder().decode(testCase.body.orNull())?.map { NumberNode.from(it.toUByte().toInt()) }
|
||||
}
|
||||
else -> testCase.body.orNull()?.chars()?.toList()?.map { c -> NumberNode.from(c) }
|
||||
} ?: listOf()
|
||||
|
|
|
@ -7,8 +7,8 @@ AWS Smithy fuzz contains a set of utilities for writing fuzz tests against smith
|
|||
2. Install the AFL runtime: `cargo afl config --build`
|
||||
2. Install the smithy CLI:
|
||||
2. Install aws-smithy-fuzz:
|
||||
3. Locally: `cargo afl install --path .`
|
||||
4. From crates.io: cargo afl install aws-smithy-fuzz
|
||||
- Locally: `cargo afl install --path .`
|
||||
- From crates.io: cargo afl install aws-smithy-fuzz
|
||||
|
||||
## Usage
|
||||
This contains a library + a CLI tool to fuzz smithy servers. The library allows setting up a given Smithy server implementation as a `cdylib`. This allows two different versions two by dynamically linked at runtime and executed by the fuzzer.
|
||||
|
|
|
@ -164,7 +164,6 @@ fn assert_ready<F: Future>(mut future: F) -> F::Output {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::types::FuzzResult;
|
||||
use crate::{make_target, Body};
|
||||
use http::Request;
|
||||
use std::error::Error;
|
||||
|
|
|
@ -643,6 +643,21 @@ fn replay(
|
|||
FuzzResult { result: String },
|
||||
}
|
||||
|
||||
impl Display for CrashResult {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
CrashResult::Panic { message } => {
|
||||
f.pad("The process paniced!\n")?;
|
||||
for line in message.lines() {
|
||||
write!(f, " {}\n", line)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
CrashResult::FuzzResult { result } => f.pad(result),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for library in &config.targets {
|
||||
let result = Command::new(env::current_exe().unwrap())
|
||||
.arg("invoke-test-case")
|
||||
|
@ -667,17 +682,24 @@ fn replay(
|
|||
test_case: String,
|
||||
results: HashMap<String, CrashResult>,
|
||||
}
|
||||
impl Display for Results {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let test_case = &self.test_case;
|
||||
write!(f, "Test case: {test_case}\n")?;
|
||||
for (target, result) in &self.results {
|
||||
write!(f, " target: {target}\n{:>2}", result)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
let results = Results {
|
||||
test_case: format!("{:#?}", http_request.unwrap()),
|
||||
results,
|
||||
};
|
||||
if json {
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string(&Results {
|
||||
test_case: format!("{:#?}", http_request.unwrap()),
|
||||
results
|
||||
})
|
||||
.unwrap()
|
||||
);
|
||||
println!("{}", serde_json::to_string(&results).unwrap());
|
||||
} else {
|
||||
println!("{:#?}\n----", results);
|
||||
println!("{}\n----", results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,10 @@ impl Debug for TryString<'_> {
|
|||
let try_cbor = cbor_diag::parse_bytes(self.0);
|
||||
let str_rep = match try_cbor {
|
||||
Ok(repr) => repr.to_diag_pretty(),
|
||||
Err(e) => String::from_utf8_lossy(self.0).to_string(),
|
||||
Err(e) => {
|
||||
eprintln!("not cbor: {}", e);
|
||||
String::from_utf8_lossy(self.0).to_string()
|
||||
}
|
||||
};
|
||||
write!(f, "\"{}\"", str_rep)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue