Add File Preview Support to HostFile Entity#1912
Conversation
- Updated HostFile ent schema to include `preview` and `preview_type` fields. - Implemented server-side file type detection (text vs image) in the ReportFile gRPC endpoint. - Added logic to cap text previews at 512KB and image previews at <512KB. - Exposed preview fields via GraphQL with a custom resolver for Base64/String encoding. - Added comprehensive tests covering various file types and size constraints. Co-authored-by: hulto <7121375+hulto@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary
Previous Results
Insights
Slowest Tests
🎉 No failed tests in this run. | 🍂 No flaky tests in this run. Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
| Comment("The type of preview available for the file"), | ||
| field.Bytes("preview"). | ||
| Optional(). | ||
| SchemaType(map[string]string{ |
There was a problem hiding this comment.
nit: We can probably use Longtext here since the max size is in kb
This change adds support for file previews to the
HostFileentity. The server now automatically detects if a reported file is a text file (using UTF-8 validation) or an image (using magic numbers).For text files, the first 512KB of content is stored as a preview. For images, the full content is stored as a preview only if the file size is less than 512KB. Otherwise, no preview is stored.
The new fields are exposed via GraphQL, with a custom resolver that ensures text previews are returned as strings and image previews are returned as Base64-encoded strings.
New tests were added to
tavern/internal/c2/api_report_file_test.goto verify the detection logic and preview constraints.PR created automatically by Jules for task 14321818820613450316 started by @hulto