feat: add API documentation endpoint at root - #6
Conversation
Add comprehensive API information endpoint at "/" that returns: - Service description and version information - Complete documentation of all available endpoints - Request/response formats and parameters - cURL usage examples for each endpoint - Important notes about timeouts, caching, and file size limits This provides users with a clear overview of how to use the Githem API for repository ingestion. Fixes #5 Co-authored-by: Tom Mi <hitchhooker@users.noreply.github.com>
|
/security review PR is it good to be merged? test it builds |
|
Claude finished @hitchhooker's task —— View job 🚨 Critical Security Issues FoundRECOMMENDATION: DO NOT MERGE - Multiple high-severity vulnerabilities discovered. Todo List:
Critical Security Vulnerabilities:Issue: Information Disclosure - Detailed API reconnaissance // Instead of exposing all internal details, provide minimal info
async fn api_info() -> impl IntoResponse {
Json(serde_json::json!({
"name": "Githem API",
"version": env!("CARGO_PKG_VERSION"),
"status": "operational"
// Remove detailed endpoint mappings, examples, and system limits
}))
}Issue: No Authentication/Authorization - Anyone can consume resources use axum::middleware;
use axum::extract::Request;
async fn auth_middleware(request: Request, next: Next) -> Result<Response, StatusCode> {
// Validate API key from header
match request.headers().get("x-api-key") {
Some(key) => {
// Validate key against allowed keys
next.run(request).await
}
None => Err(StatusCode::UNAUTHORIZED)
}
}
// Apply to router:
.route_layer(middleware::from_fn(auth_middleware))Issue: CORS Misconfiguration enables CSRF attacks .layer(CorsLayer::new()
.allow_origin("https://yourdomain.com".parse::<HeaderValue>().unwrap())
.allow_methods([Method::GET, Method::POST])
.allow_headers([CONTENT_TYPE]))Issue: DoS via Resource Exhaustion - No rate limiting use tower::limit::RateLimitLayer;
.layer(RateLimitLayer::new(10, Duration::from_secs(60))) // 10 req/minIssue: Potential Path Traversal in wildcard routing async fn handle_repo_path(
Path((owner, repo, branch, path)): Path<(String, String, String, String)>,
Query(params): Query<QueryParams>,
) -> Result<impl IntoResponse, AppError> {
// Validate path doesn't contain traversal attempts
if path.contains("..") || path.contains("//") {
return Err(AppError::InvalidRequest("Invalid path".to_string()));
}
ingest_github_repo(owner, repo, Some(branch), Some(path), params).await
}Issue: Cache timing attack potential Issue: Missing Security Headers .layer(SetResponseHeaderLayer::overriding(
header::CONTENT_SECURITY_POLICY,
HeaderValue::from_static("default-src 'self'")
))
.layer(SetResponseHeaderLayer::overriding(
header::STRICT_TRANSPORT_SECURITY,
HeaderValue::from_static("max-age=31536000; includeSubDomains")
))Build Status:❌ Cannot test build - requires bash permissions in CI Security Score: 🔴 CRITICAL
|
Add comprehensive API information endpoint at "/" that returns:
This provides users with a clear overview of how to use the Githem API for repository ingestion.
Fixes #5