refactor(server): replace custom remote clients with macro-based implementation
- Replaced manual remote client functions with remote_client! macro for archive, blame, branch, commit, and diff services - Simplified remote client creation logic using declarative macro approach - Maintained same functionality while reducing code duplication across services security(bare): enhance path traversal protection with comprehensive validation - Added early relative_path validation to prevent path traversal attacks - Implemented unified path validation to avoid TOCTOU race conditions - Enhanced canonicalization checks for both existing and non-existent paths - Added detailed logging for path traversal detection attempts feat(cache): migrate from CLruCache to Moka with TTL and invalidation support - Replaced clru dependency with moka for improved caching capabilities - Added 300-second time-to-live for cache entries - Implemented repository-specific cache invalidation mechanism - Enhanced cache operations with thread-safe async support refactor(commit): improve security validation for commit operations - Added ref name validation to prevent command injection in cherry_pick_commit - Implemented revision validation for commit selectors - Added comprehensive input validation for create_commit parameters - Enhanced file path validation to prevent traversal
This commit is contained in:
@@ -2,7 +2,8 @@ use crate::bare::GitBare;
|
||||
use crate::commit::list_commits::read_commit_from_repo;
|
||||
use crate::diff::get_diff_stats::diff_stats_for_range;
|
||||
use crate::error::{GitError, GitResult};
|
||||
use crate::pb::{CommitStats, CompareCommitsRequest, CompareCommitsResponse, object_selector};
|
||||
use crate::pb::{CommitStats, CompareCommitsRequest, CompareCommitsResponse};
|
||||
use crate::resolve_revision;
|
||||
|
||||
impl GitBare {
|
||||
pub fn compare_commits(
|
||||
@@ -10,16 +11,8 @@ impl GitBare {
|
||||
request: CompareCommitsRequest,
|
||||
) -> GitResult<CompareCommitsResponse> {
|
||||
let repo = self.gix_repo()?;
|
||||
let base = match request.base.clone().and_then(|s| s.selector) {
|
||||
Some(object_selector::Selector::Oid(oid)) => oid.hex,
|
||||
Some(object_selector::Selector::Revision(name)) => name.revision,
|
||||
None => "HEAD".into(),
|
||||
};
|
||||
let head = match request.head.clone().and_then(|s| s.selector) {
|
||||
Some(object_selector::Selector::Oid(oid)) => oid.hex,
|
||||
Some(object_selector::Selector::Revision(name)) => name.revision,
|
||||
None => "HEAD".into(),
|
||||
};
|
||||
let base = resolve_revision!(request.base.clone());
|
||||
let head = resolve_revision!(request.head.clone());
|
||||
|
||||
let base_id = repo.rev_parse_single(base.as_str())?;
|
||||
let head_id = repo.rev_parse_single(head.as_str())?;
|
||||
|
||||
Reference in New Issue
Block a user