refactor(bare): enhance security and performance optimizations
- Remove unnecessary sorting in advertise_refs for deterministic output - Add path traversal detection and validation in bare_dir construction - Implement symlink resolution checks to prevent security vulnerabilities - Refactor cache system with CRC validation and improved metrics - Integrate repo-specific cache invalidation using indexed keys - Add comprehensive unit tests for commit operations and diff functionality - Move configuration constants to centralized config module - Optimize string operations in disk cache random value generation - Enhance license detection algorithm with cleaner matching logic - Streamline argument processing in various git operations - Update dependencies including crc32fast and flate2 for performance - Add signal handling capability to tokio runtime configuration
This commit is contained in:
@@ -18,7 +18,6 @@ impl GitBare {
|
||||
let pack_dir = self.bare_dir.join("objects").join("pack");
|
||||
std::fs::create_dir_all(&pack_dir).map_err(GitError::Io)?;
|
||||
|
||||
// Stream pack data to a temp file instead of accumulating in memory
|
||||
let mut tmp_file = tempfile::Builder::new()
|
||||
.prefix("tmp_index_pack_")
|
||||
.tempfile_in(&pack_dir)
|
||||
@@ -41,7 +40,6 @@ impl GitBare {
|
||||
return Err(GitError::InvalidArgument("empty pack data".into()));
|
||||
}
|
||||
|
||||
// Flush and get the path before we pass it to git
|
||||
tmp_file.flush().map_err(GitError::Io)?;
|
||||
let tmp_path = tmp_file.path().to_path_buf();
|
||||
|
||||
@@ -64,7 +62,6 @@ impl GitBare {
|
||||
.unchecked()
|
||||
.run()?;
|
||||
|
||||
// Drop the temp file handle — git index-pack has processed it
|
||||
drop(tmp_file);
|
||||
|
||||
if !result.status.success() {
|
||||
@@ -74,7 +71,6 @@ impl GitBare {
|
||||
});
|
||||
}
|
||||
|
||||
// Parse the output to extract the pack hash
|
||||
let output = String::from_utf8_lossy(&result.stdout);
|
||||
let stderr = String::from_utf8_lossy(&result.stderr);
|
||||
let all_output = format!("{output}\n{stderr}");
|
||||
@@ -96,7 +92,6 @@ impl GitBare {
|
||||
})
|
||||
.next();
|
||||
|
||||
// Try to get object count from .idx if it exists
|
||||
let mut object_count = 0u64;
|
||||
if let Some(ref hash) = pack_hash {
|
||||
let idx_path = pack_dir.join(format!("pack-{hash}.idx"));
|
||||
|
||||
Reference in New Issue
Block a user