Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/januskey-cli/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl KeyManager {

fn load_store_raw(&self) -> Result<KeyStoreData> {
let path = self.store_path.join("keystore.jks");
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
let store: KeyStoreData = serde_json::from_str(&content)?;
Ok(store)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/januskey-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Config {
pub fn load(dir: &std::path::Path) -> Self {
let config_path = dir.join(".januskey").join("config.json");
if config_path.exists() {
if let Ok(content) = std::fs::read_to_string(&config_path) {
if let Ok(content) = ({ use std::io::Read; std::fs::File::open(&config_path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }) {
if let Ok(config) = serde_json::from_str(&content) {
return config;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/januskey-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ fn cmd_modify(
// Preview changes
let mut changes = Vec::new();
for file in &files {
let content = fs::read_to_string(file)?;
let content = ({ use std::io::Read; std::fs::File::open(file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
let new_content = if global {
content.replace(&search, &replace)
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/januskey-cli/src/obliteration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ObliterationManager {
/// Create or open an obliteration manager
pub fn new(log_path: PathBuf) -> Result<Self> {
let log = if log_path.exists() {
let content = fs::read_to_string(&log_path)?;
let content = ({ use std::io::Read; std::fs::File::open(&log_path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content)
.map_err(|e| JanusError::MetadataCorrupted(e.to_string()))?
} else {
Expand Down
6 changes: 3 additions & 3 deletions crates/januskey-cli/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod tests {
executor.undo(&delete_meta.id).unwrap();

assert!(test_file.exists());
assert_eq!(fs::read_to_string(&test_file).unwrap(), "hello world");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "hello world");
}

#[test]
Expand All @@ -533,13 +533,13 @@ mod tests {
})
.unwrap();

assert_eq!(fs::read_to_string(&test_file).unwrap(), "modified content");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "modified content");

// Undo the modify
let mut executor = OperationExecutor::new(&content_store, &mut metadata_store);
executor.undo(&modify_meta.id).unwrap();

assert_eq!(fs::read_to_string(&test_file).unwrap(), "original content");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "original content");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/januskey-cli/tests/aspect_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn obliterated_key_record_marked_revoked() {

// Verify key record reflects revocation
let key_content =
fs::read_to_string(base.join(".jk/keys").join(format!("{}.json", key_id)))
({ use std::io::Read; std::fs::File::open(base.join(".jk/keys").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).join(format!("{}.json", key_id)))
.expect("Read key record");
assert!(
key_content.contains("revoked"),
Expand Down
4 changes: 2 additions & 2 deletions crates/januskey-cli/tests/concurrency_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn transaction_isolation_uncommitted_invisible() {

// Reader may see the file (filesystem is not transactional),
// but we verify the transaction itself is still "active" not "committed"
let tx_read = fs::read_to_string(base.join(".jk/transactions/001.json"))
let tx_read = ({ use std::io::Read; std::fs::File::open(base.join(".jk/transactions/001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))
.expect("Read transaction");
assert!(
tx_read.contains("\"active\""),
Expand Down Expand Up @@ -404,7 +404,7 @@ fn concurrent_commit_rollback_no_corruption() {
// Verify each transaction is in a valid terminal state
for entry in fs::read_dir(base.join(".jk/transactions")).expect("Read dir") {
let entry = entry.expect("Dir entry");
let content = fs::read_to_string(entry.path()).expect("Read tx file");
let content = ({ use std::io::Read; std::fs::File::open(entry.path().and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })).expect("Read tx file");
let is_valid = content.contains("\"committed\"") || content.contains("\"rolled_back\"");
assert!(
is_valid,
Expand Down
8 changes: 4 additions & 4 deletions crates/januskey-cli/tests/e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ fn full_key_lifecycle_single_key() {
assert_eq!(retrieved, key_material, "Retrieved content must match original");

// Step 5: Verify attestation references the key
let attest_read = fs::read_to_string(base.join(".jk/attestation/0001.json"))
let attest_read = ({ use std::io::Read; std::fs::File::open(base.join(".jk/attestation/0001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))
.expect("Read attestation");
assert!(attest_read.contains(key_id), "Attestation must contain key ID");
assert!(attest_read.contains(&key_hash), "Attestation must contain content hash");

// Verify key record exists
let key_read = fs::read_to_string(base.join(".jk/keys/001.json"))
let key_read = ({ use std::io::Read; std::fs::File::open(base.join(".jk/keys/001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))
.expect("Read key record");
assert!(key_read.contains(key_id), "Key record must contain ID");
}
Expand Down Expand Up @@ -167,7 +167,7 @@ fn full_key_lifecycle_multi_key_transaction() {

// Verify transaction is committed
let tx_read =
fs::read_to_string(base.join(".jk/transactions/001.json")).expect("Read tx");
({ use std::io::Read; std::fs::File::open(base.join(".jk/transactions/001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })).expect("Read tx");
assert!(tx_read.contains("committed"), "Transaction must be committed");
}

Expand Down Expand Up @@ -359,7 +359,7 @@ fn corrupted_attestation_entry_detected() {
.expect("Write malformed entry");

// Attempt to read and parse
let read_result = fs::read_to_string(base.join(".jk/attestation/0001.json"))
let read_result = ({ use std::io::Read; std::fs::File::open(base.join(".jk/attestation/0001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))
.expect("Read file");
let parse_result = serde_json::from_str::<serde_json::Value>(&read_result);

Expand Down
4 changes: 2 additions & 2 deletions crates/januskey-cli/tests/p2p_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn key_operation_creates_attestation_entry() {
std::fs::write(attest_path.join("0001.json"), &entry).unwrap();

// Verify attestation references the key
let read_back = std::fs::read_to_string(attest_path.join("0001.json")).unwrap();
let read_back = ({ use std::io::Read; std::fs::File::open(attest_path.join("0001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })).unwrap();
assert!(
read_back.contains(key_id),
"Attestation must reference key ID"
Expand Down Expand Up @@ -132,7 +132,7 @@ fn attestation_chain_integrity() {

// Verify chain: each entry's content hashes to the next's prev_hash
let entries: Vec<String> = (0..3)
.map(|i| std::fs::read_to_string(attest_path.join(format!("{:04}.json", i))).unwrap())
.map(|i| ({ use std::io::Read; std::fs::File::open(attest_path.join(format!("{:04}.json", i).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))).unwrap())
.collect();

for i in 1..entries.len() {
Expand Down
2 changes: 1 addition & 1 deletion crates/reversible-core/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl MetadataStore {
/// Create or open a metadata store
pub fn new(path: PathBuf) -> Result<Self> {
let log = if path.exists() {
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content)
.map_err(|e| ReversibleError::MetadataCorrupted(e.to_string()))?
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/reversible-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl TransactionManager {
/// Create or open a transaction manager
pub fn new(path: PathBuf) -> Result<Self> {
let log = if path.exists() {
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content)
.map_err(|e| ReversibleError::MetadataCorrupted(e.to_string()))?
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl KeyManager {

fn load_store_raw(&self) -> Result<KeyStoreData> {
let path = self.store_path.join("keystore.jks");
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
let store: KeyStoreData = serde_json::from_str(&content)?;
Ok(store)
}
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Config {
pub fn load(dir: &std::path::Path) -> Self {
let config_path = dir.join(".januskey").join("config.json");
if config_path.exists() {
if let Ok(content) = std::fs::read_to_string(&config_path) {
if let Ok(content) = ({ use std::io::Read; std::fs::File::open(&config_path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }) {
if let Ok(config) = serde_json::from_str(&content) {
return config;
}
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn cmd_modify(
// Preview changes
let mut changes = Vec::new();
for file in &files {
let content = fs::read_to_string(file)?;
let content = ({ use std::io::Read; std::fs::File::open(file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
let new_content = if global {
content.replace(&search, &replace)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl MetadataStore {
/// Create or open a metadata store
pub fn new(path: PathBuf) -> Result<Self> {
let log = if path.exists() {
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content).map_err(|e| JanusError::MetadataCorrupted(e.to_string()))?
} else {
OperationLog::default()
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/obliteration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ObliterationManager {
/// Create or open an obliteration manager
pub fn new(log_path: PathBuf) -> Result<Self> {
let log = if log_path.exists() {
let content = fs::read_to_string(&log_path)?;
let content = ({ use std::io::Read; std::fs::File::open(&log_path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content)
.map_err(|e| JanusError::MetadataCorrupted(e.to_string()))?
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/januskey/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod tests {
executor.undo(&delete_meta.id).unwrap();

assert!(test_file.exists());
assert_eq!(fs::read_to_string(&test_file).unwrap(), "hello world");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "hello world");
}

#[test]
Expand All @@ -533,13 +533,13 @@ mod tests {
})
.unwrap();

assert_eq!(fs::read_to_string(&test_file).unwrap(), "modified content");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "modified content");

// Undo the modify
let mut executor = OperationExecutor::new(&content_store, &mut metadata_store);
executor.undo(&modify_meta.id).unwrap();

assert_eq!(fs::read_to_string(&test_file).unwrap(), "original content");
assert_eq!(({ use std::io::Read; std::fs::File::open(&test_file).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }).unwrap(), "original content");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/januskey/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl TransactionManager {
/// Create or open a transaction manager
pub fn new(path: PathBuf) -> Result<Self> {
let log = if path.exists() {
let content = fs::read_to_string(&path)?;
let content = ({ use std::io::Read; std::fs::File::open(&path).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })?;
serde_json::from_str(&content)
.map_err(|e| JanusError::MetadataCorrupted(e.to_string()))?
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/p2p/component_p2p_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod p2p_tests {
std::fs::write(attest_path.join("0001.json"), &entry).unwrap();

// Verify attestation references the key
let read_back = std::fs::read_to_string(attest_path.join("0001.json")).unwrap();
let read_back = ({ use std::io::Read; std::fs::File::open(attest_path.join("0001.json").and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) })).unwrap();
assert!(read_back.contains(key_id), "Attestation must reference key ID");
}

Expand All @@ -108,7 +108,7 @@ mod p2p_tests {
// Verify chain: each entry's content hashes to the next's prev_hash
let entries: Vec<String> = (0..3)
.map(|i| {
std::fs::read_to_string(attest_path.join(format!("{:04}.json", i))).unwrap()
({ use std::io::Read; std::fs::File::open(attest_path.join(format!("{:04}.json", i).and_then(|mut f| { let mut buf = String::new(); f.take(10 * 1024 * 1024).read_to_string(&mut buf)?; Ok(buf) }) }))).unwrap()
})
.collect();

Expand Down
Loading