Skip to content

Commit

Permalink
fix: Migrate from tempdir to tempfile crate
Browse files Browse the repository at this point in the history
tempdir is obsolete and relies on remove_dir_all 0.5.3 which has a
security vulnerability. Migrate to using tempfile crate instead.
References:
- [RUSTSEC-2018-0017](https://rustsec.org/advisories/RUSTSEC-2018-0017)
- [RUSTSEC-2013-0018](https://rustsec.org/advisories/RUSTSEC-2023-0018)
  • Loading branch information
cdaudt committed Nov 13, 2023
1 parent 28d7006 commit 68913bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ serde_bytes = "0.11.8"
serde_derive = "^1.0"
serde_json = "^1.0"
serde_repr = "0.1.16"
tempdir = "0.3"
tempfile = "3.8"
tokio = { version = "1", features = ["macros"] }
typed-builder = "^0.18"
url = "2"
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ uuid = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
tempdir = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true }
10 changes: 5 additions & 5 deletions crates/iceberg/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ mod tests {
use futures::io::AllowStdIo;
use futures::{AsyncReadExt, AsyncWriteExt};

use tempdir::TempDir;
use tempfile::TempDir;

use super::{FileIO, FileIOBuilder};

Expand All @@ -415,7 +415,7 @@ mod tests {

#[tokio::test]
async fn test_local_input_file() {
let tmp_dir = TempDir::new("test").unwrap();
let tmp_dir = TempDir::new().unwrap();

let file_name = "a.txt";
let content = "Iceberg loves rust.";
Expand All @@ -436,7 +436,7 @@ mod tests {

#[tokio::test]
async fn test_delete_local_file() {
let tmp_dir = TempDir::new("test").unwrap();
let tmp_dir = TempDir::new().unwrap();

let file_name = "a.txt";
let content = "Iceberg loves rust.";
Expand All @@ -452,7 +452,7 @@ mod tests {

#[tokio::test]
async fn test_delete_non_exist_file() {
let tmp_dir = TempDir::new("test").unwrap();
let tmp_dir = TempDir::new().unwrap();

let file_name = "a.txt";
let full_path = format!("{}/{}", tmp_dir.path().to_str().unwrap(), file_name);
Expand All @@ -464,7 +464,7 @@ mod tests {

#[tokio::test]
async fn test_local_output_file() {
let tmp_dir = TempDir::new("test").unwrap();
let tmp_dir = TempDir::new().unwrap();

let file_name = "a.txt";
let content = "Iceberg loves rust.";
Expand Down
6 changes: 3 additions & 3 deletions crates/iceberg/src/spec/manifest_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ pub(super) mod _serde {
mod test {
use std::{fs, sync::Arc};

use tempdir::TempDir;
use tempfile::TempDir;

use crate::{
io::FileIOBuilder,
Expand Down Expand Up @@ -1091,7 +1091,7 @@ mod test {
}]
};

let temp_dir = TempDir::new("manifest_list_v1").unwrap();
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path().join("manifest_list_v1.avro");
let io = FileIOBuilder::new_fs_io().build().unwrap();
let output_file = io.new_output(path.to_str().unwrap()).unwrap();
Expand Down Expand Up @@ -1140,7 +1140,7 @@ mod test {
}]
};

let temp_dir = TempDir::new("manifest_list_v2").unwrap();
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path().join("manifest_list_v2.avro");
let io = FileIOBuilder::new_fs_io().build().unwrap();
let output_file = io.new_output(path.to_str().unwrap()).unwrap();
Expand Down

0 comments on commit 68913bb

Please sign in to comment.