Conversation
Add files.info API wrapper for efficient single-file metadata retrieval. Add downloadFile method that fetches url_private with auth headers, removing the need to manually extract credentials and curl. Store token and cookie as private fields alongside the WebClient instance to support authenticated file downloads via native fetch.
Add `file download <file-id> [output-path]` subcommand that downloads files shared in Slack using extracted credentials. Supports optional output path with automatic directory detection. Falls back to original filename in current directory when no path is specified. Also improves file info command to use getFileInfo() directly instead of listing all files then filtering by ID.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
3 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/platforms/slack/commands/file.ts">
<violation number="1" location="src/platforms/slack/commands/file.ts:133">
P1: Sanitize `file.name` before using it in filesystem paths to prevent path traversal/arbitrary overwrite via crafted filenames.</violation>
</file>
<file name="e2e/slack.e2e.test.ts">
<violation number="1" location="e2e/slack.e2e.test.ts:374">
P2: This test uploads a Slack file but never deletes it, so each run leaves orphaned remote test files in the workspace.</violation>
</file>
<file name="src/platforms/slack/commands/file.test.ts">
<violation number="1" location="src/platforms/slack/commands/file.test.ts:193">
P2: This test is tautological for `path` and does not exercise real download-command path handling, so it can pass even when command behavior is broken.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Prevent path traversal by running file.name through basename() with backslash normalization before using it in filesystem paths. Replace tautological unit test with one that verifies the sanitization logic. Delete uploaded Slack files in e2e test cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
file download <file-id> [output-path]command that downloads Slack files using extracted credentials. Previously, downloading files shared in Slack required manually extracting the token and cookie from credentials and curlingurl_privatewith the correct auth headers — this automates the entire flow.Changes
SlackClient (
client.ts)getFileInfo()— wrapsfiles.infoAPI for efficient single-file metadata retrieval instead of listing all files and filtering.downloadFile()— fetchesurl_privatewith Bearer token + cookie auth headers, returns the file buffer and metadata.tokenandcookieas private fields alongside theWebClientinstance to support authenticated downloads via nativefetch.File command (
commands/file.ts)file download <file-id> [output-path]subcommand with optional output path. Defaults to original filename in the current directory. Detects when the output path is a directory and appends the original filename automatically.file infoto callgetFileInfo()directly instead of listing all files then filtering by ID — faster and avoids the file count limit.Tests
getFileInfo(),downloadFile()(happy path, missing URL, download failure, auth header verification), and command mock.Testing
Summary by cubic
Adds
file download <file-id> [output-path]to fetch Slack files using extracted credentials. Speeds upfile infoby callingfiles.infodirectly, and sanitizes filenames before writing to disk.New Features
file download <file-id> [output-path]. Defaults to original filename; detects directories; outputs JSON with id, name, mimetype, size, path.SlackClient.downloadFile()downloadsurl_privatewith Bearer token and cookie, returning a buffer and metadata.Bug Fixes
basename()with backslash normalization to prevent path traversal.Written for commit bff5a39. Summary will update on new commits.