【substack-mcp】サムネ付き記事投稿CLIを整備する#2
Conversation
Refs #1
There was a problem hiding this comment.
Review Summary
This PR adds a CLI tool for creating Substack articles with cover images, along with supporting infrastructure and tests. The implementation is well-structured with proper validation and safety mechanisms.
Critical Issue Found (1)
A security vulnerability in the exception handling that could leak sensitive information through error messages. The bare except Exception handler needs to be replaced with specific exception types to prevent exposing credentials or internal system details.
Code Quality Observations
The PR includes solid defensive programming practices such as blocked path prefixes for image uploads and proper validation of arguments. The test coverage demonstrates correct behavior for the main workflow and validation rules.
Action Required: Address the exception handling security issue before merging.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| except Exception as exc: | ||
| print(f"error: {exc}", file=sys.stderr) | ||
| return 1 |
There was a problem hiding this comment.
🛑 Security Vulnerability: Replace generic exception handler with specific exceptions to prevent leaking sensitive information. The current bare except Exception can expose credentials or internal system details if SubstackClient.from_env() or client methods fail with unexpected errors. Handle credential loading failures separately from API errors to provide safe error messages.
| except Exception as exc: | |
| print(f"error: {exc}", file=sys.stderr) | |
| return 1 | |
| except RuntimeError as exc: | |
| # Credential loading or API initialization errors | |
| print(f"error: {exc}", file=sys.stderr) | |
| return 1 | |
| except (ValueError, FileNotFoundError) as exc: | |
| # Validation or file errors | |
| print(f"error: {exc}", file=sys.stderr) | |
| return 1 | |
| except Exception as exc: | |
| # Unexpected errors - don't expose details | |
| print(f"error: An unexpected error occurred during article processing", file=sys.stderr) | |
| return 1 |
Closes #1
概要
substack-publish-articleCLIを追加--publish指定時のみ公開し、--send-email/--share-automaticallyは--publishなしでは拒否する安全設計にしたarticles/fable5.mdを追加し、実際にSubstack下書き作成とサムネ設定まで実行test-board.yamlとユニットテストを追加実運用結果
204559799--publishを付けて実行する。検証
.venv/bin/python -m unittest discover -s tests→ 成功(2 tests).venv/bin/python -m compileall src→ 成功test-board once --board test-board.yaml→status=done:1リスク
.gitignoreのthumbnails/*.png対象のためコミットしていない。下書きにはSubstack CDNアップロード済み画像を設定済み