Skip to content

Conversation

@sallyom
Copy link
Collaborator

@sallyom sallyom commented Dec 10, 2025

No description provided.

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sallyom sallyom force-pushed the simple-upload-files branch 4 times, most recently from ff0b24e to 8a7769e Compare December 10, 2025 18:34
@github-actions

This comment was marked as outdated.

@sallyom sallyom force-pushed the simple-upload-files branch from 8a7769e to bca02c1 Compare December 11, 2025 22:01
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 11, 2025
@github-actions

This comment was marked as outdated.

@sallyom sallyom force-pushed the simple-upload-files branch from bca02c1 to c527be6 Compare December 11, 2025 22:08
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@sallyom sallyom force-pushed the simple-upload-files branch from 09d900e to 0a0b091 Compare December 12, 2025 05:47
@github-actions

This comment was marked as outdated.

@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@ambient-code ambient-code deleted a comment from github-actions bot Dec 12, 2025
@github-actions
Copy link
Contributor

See full review in next comment due to character limits

@github-actions

This comment was marked as outdated.

@bobbravo2 bobbravo2 added this to the v0.0.14 milestone Dec 15, 2025
@sallyom sallyom force-pushed the simple-upload-files branch from 5ad21df to 6d2492e Compare December 15, 2025 18:43
@github-actions

This comment was marked as outdated.

sallyom and others added 9 commits December 15, 2025 20:31
Add file upload functionality to sessions, allowing users to upload files
from local machine or URL to the workspace. Files are uploaded to the
file-uploads directory and accessible to Claude Code runners.

- Backend: Auto-spawn temp-content pod when service unavailable (202 Accepted)
- Operator: Support temp pods for Pending sessions, prevent PVC mount conflicts
- Frontend: Upload modal with local/URL tabs, integrated in File Explorer and Add Context modal
- Files uploaded to /workspace/file-uploads/ directory

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: sallyom <somalley@redhat.com>
Add "File Uploads" option to the directory selector dropdown so users can
navigate to the file-uploads directory and see their uploaded files.

- Add file-uploads option to directoryOptions array
- Add CloudUpload icon for file-uploads type in dropdown
- Files will appear even if directory is empty (shows empty state)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: sallyom <somalley@redhat.com>
This commit adds comprehensive file upload and management capabilities:

## Upload Functionality
- Users can upload files from local machine or URL via upload modal
- Files stored in workspace/file-uploads/ directory
- Modal accessible from Add Context window and File Explorer
- Auto-retry logic when content service is starting (202 Accepted)
- Temp pod spawning for Pending sessions to enable pre-upload

## Context Visualization
- Context accordion shows combined repos + uploaded files
- Badge displays total context count (repos + files)
- Repos: GitBranch icon with URL
- Files: CloudUpload icon with size
- Files can be removed via X button

## File Explorer Integration
- File Uploads directory visible in directory selector dropdown
- Always shown even when empty
- Same browsing/viewing as other directories

## Backend Architecture
- Added DeleteSessionWorkspaceFile handler in sessions.go
- Added ContentDelete handler in new content.go for content service
- DELETE route: /workspace/*path
- Proper JSON responses for frontend compatibility

## Frontend Architecture
- New workspace API route with GET/PUT/DELETE support
- Upload modal with local file and URL tabs
- Remove file mutation with proper refetch logic
- TypeScript types updated for file-uploads directory

## Operator Changes
- Support for temp pods in Pending sessions
- Critical fix: Delete temp pod before Job to avoid PVC mount conflicts
- TerminationGracePeriodSeconds=0 for instant cleanup

Co-authored-by: Claude Code Runner

Signed-off-by: Sally O'Malley <somalley@redhat.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Detect binary content via Content-Type header or UTF-8 validation
- Auto-encode binary files (images, PDFs, zips) as base64
- Keep text files as utf8 for readability
- Content service already supports base64 decoding
- Fixes PNG upload corruption issue

Supported binary types:
- image/* (PNG, JPG, GIF, etc.)
- application/octet-stream
- application/pdf
- application/zip
- Any non-UTF-8 content

Signed-off-by: Sally O'Malley <somalley@redhat.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: sallyom <somalley@redhat.com>
Signed-off-by: sallyom <somalley@redhat.com>
Signed-off-by: sallyom <somalley@redhat.com>
Signed-off-by: sallyom <somalley@redhat.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add path traversal validation with explicit .. checks and path.Clean()
- Move authentication validation to happen immediately before any operations
- Verify all errors are properly handled (no ignored error values)

Fixes path traversal vulnerability in PutSessionWorkspaceFile and
DeleteSessionWorkspaceFile by validating paths stay within workspace
directory. Corrects authentication check order to validate user tokens
before RBAC checks or service lookups.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: sallyom <somalley@redhat.com>
@sallyom sallyom force-pushed the simple-upload-files branch from 6d2492e to 0ddd633 Compare December 16, 2025 01:33
@github-actions

This comment was marked as outdated.

Signed-off-by: sallyom <somalley@redhat.com>
@github-actions

This comment was marked as outdated.

Sanitize backend error messages before returning to client to prevent
potential token or sensitive data leakage. Following defense-in-depth
security principles:

- Log full error details server-side for debugging
- Return generic error messages to client
- Remove 'details' field from error responses

This addresses PR review feedback identifying risk of exposing
sensitive backend error content (including tokens) to the client.

Changes:
- Upload endpoint (local): Log errors server-side, return generic message
- Upload endpoint (URL): Log errors server-side, return generic message
- Catch-all handler: Remove error details from response

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions

This comment was marked as outdated.

sallyom and others added 2 commits December 16, 2025 15:24
Expand allowed file types when magic byte detection fails to support
common text-based formats that don't have detectable magic bytes:
- JSON (application/json)
- XML (application/xml)
- YAML (application/yaml, application/x-yaml, text/yaml)
- CSV (text/csv, application/csv)
- JavaScript (application/javascript)

Previously, files like JSON, XML, CSV, and YAML would be rejected with
"Unable to verify file type" because they lack magic bytes for the
file-type library to detect. This fix allows these common developer
file types while still maintaining security by validating their
claimed MIME types against an allowlist.

Security: Still prevents binary file type spoofing by only allowing
safe text-based MIME types when detection fails.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Two security and debuggability improvements:

1. Remove sensitive details from file validation error responses
   - Remove 'details' field that exposed internal error messages
   - Log full error server-side for debugging
   - Return generic "File type validation failed" to client
   - Prevents information leakage about file content mismatches

2. Log compression errors before throwing
   - Empty catch block was swallowing error details
   - Now logs "Image compression failed:" with full error
   - Maintains debuggability while still returning user-friendly message
   - Critical for troubleshooting compression issues

Both changes follow defense-in-depth principles: full logging
server-side, generic messages client-side.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Claude Code Review

Summary

This PR implements file upload functionality for AgenticSession workspaces with strong security measures. The implementation adds path traversal protection, RBAC validation, magic byte content-type verification, SSRF prevention, automatic image compression, and proper error handling. Overall, the code quality is excellent with robust security patterns and comprehensive validation.

Issues by Severity

🚫 Blocker Issues

None - No blocking issues found.

🔴 Critical Issues

None - No critical issues found. All security patterns are correctly implemented.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions
Copy link
Contributor

🌟 Excellent Code Quality

1. Error Handling

  • ✅ All io.ReadAll calls check errors
  • ✅ All http.NewRequestWithContext calls check errors
  • ✅ All json.Marshal calls check errors
  • ✅ Proper error wrapping with %w
  • ✅ Generic user-facing messages, detailed internal logs

2. User Token Authentication

  • ✅ GetK8sClientsForRequest called FIRST in all handlers
  • ✅ 401 Unauthorized returned immediately if token invalid
  • ✅ Backend service account used ONLY for privileged operations
  • ✅ Perfect adherence to k8s-client-usage patterns

3. Frontend Implementation

  • ✅ Zero any types
  • ✅ All UI components use Shadcn UI
  • ✅ Proper loading states and disabled states
  • ✅ Clear user feedback for validation errors

4. Testing

  • ✅ Comprehensive path validation tests (pathutil_test.go)
  • ✅ Edge cases covered (Windows paths, trailing slashes)
  • ✅ Clear test names and expected outcomes

@github-actions

This comment was marked as outdated.

@github-actions
Copy link
Contributor

🌟 Architectural Excellence

1. Temp Content Pod Pattern

  • ✅ Graceful handling when content service doesn't exist
  • ✅ Annotation-based pod request (temp-content-requested)
  • ✅ Optimistic locking to prevent duplicate pod creation
  • ✅ 202 Accepted response with retry logic on frontend

2. Binary File Handling

  • ✅ UTF-8 validation BEFORE string conversion
  • ✅ Base64 encoding for binary content
  • ✅ Proper encoding detection using magic bytes

3. Path Sanitization

  • ✅ Consistent use of filepath.Join + pathutil.IsPathWithinBase
  • ✅ Platform-independent (works on Windows and Unix)

@github-actions

This comment was marked as outdated.

@bobbravo2 bobbravo2 merged commit 2420f2a into ambient-code:main Dec 16, 2025
22 checks passed
andybraren pushed a commit to andybraren/vTeam that referenced this pull request Dec 16, 2025
Signed-off-by: sallyom <somalley@redhat.com>
Signed-off-by: Sally O'Malley <somalley@redhat.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants