Commit Graph

7 Commits

Author SHA1 Message Date
Kazuki Yamada
3a10a9f255 fix(core): Use proper hostname validation for Azure DevOps URLs
Replace substring matching with proper URL parsing to fix CodeQL security alert.

Previously, the code used `includes()` for substring matching which could
incorrectly identify malicious URLs like `https://evil.com/dev.azure.com/`
as Azure DevOps URLs.

Changes:
- Extract Azure DevOps URL detection into a dedicated function
- Use URL constructor to parse and validate the hostname
- For SSH URLs, use `startsWith()` for exact prefix matching
- For HTTP(S) URLs, check the hostname property exactly
- Add security tests to ensure malicious URLs are not incorrectly identified

This resolves the "Incomplete URL substring sanitization" alert from CodeQL.
2025-10-07 23:43:38 +09:00
Kazuki Yamada
179ca6fba4 fix(core): Improve Azure DevOps URL parsing support
Address PR review feedback by expanding Azure DevOps URL support:

- Add support for SSH URLs (ssh.dev.azure.com)
- Add support for legacy Visual Studio Team Services (*.visualstudio.com)
- Remove invalid azure.com case
- Add test coverage for legacy VSTS URLs
- Move Azure DevOps detection before git-url-parse to avoid parsing issues

This ensures compatibility with all Azure DevOps URL formats including modern and legacy domains.
2025-10-07 23:28:36 +09:00
Kazuki Yamada
a2edd58e60 feat(core): Add support for Azure DevOps remote repository URLs
This commit adds support for Azure DevOps repository URLs in both SSH and HTTPS formats.

Azure DevOps uses a special URL structure that differs from standard Git hosting services:
- SSH: git@ssh.dev.azure.com:v3/organization/project/repo
- HTTPS: https://dev.azure.com/organization/project/_git/repo

The git-url-parse library can parse these URLs but its toString() method doesn't preserve
the full path structure (e.g., v3/organization/ part is lost in SSH URLs). To address this,
we now detect Azure DevOps URLs by checking the source field and use the original URL
as-is instead of reconstructing it.

Changes:
- Modified parseRemoteValue() to use switch statement for source-based URL handling
- Added Azure DevOps cases ('dev.azure.com' and 'azure.com') to preserve original URLs
- Added test cases for both Azure DevOps SSH and HTTPS URL formats
- All existing tests continue to pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 23:05:36 +09:00
Kazuki Yamada
9e81c8926d security(git): Fix URL substring sanitization vulnerability
User reported security issue with incomplete URL validation:
- `remoteValue.includes('github.com')` could match malicious URLs like 'https://evil.com/github.com/user/repo'
- Replaced substring check with proper hostname validation using URL.hostname
- Added allowlist of legitimate GitHub hosts: ['github.com', 'www.github.com']
- Added comprehensive test cases to verify malicious URLs are rejected
- Ensures only legitimate GitHub domains are processed for archive download

This prevents URL spoofing attacks where arbitrary hosts could be treated as GitHub repositories.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-15 21:31:52 +09:00
Kazuki Yamada
2914ce5e0e feat(remote): Implement GitHub archive download with git clone fallback
User requested performance optimization for remote repository processing:
- User asked: "archive zipをダウンロードしてくれば良い気もしています"
- User wanted: Archive download as primary method with git clone fallback
- User specified: Keep "cloning" display message for consistency

Implementation provides ~70% performance improvement for GitHub repositories
by downloading archive zip instead of full git clone when possible.

Key features:
- GitHub repository auto-detection from various URL formats
- Archive download priority with real-time progress tracking
- Seamless git clone fallback on archive download failure
- Comprehensive error handling with retry logic
- Support for branches, tags, and commit-specific downloads

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-15 20:13:23 +09:00
Kazuki Yamada
8f9b307ffa refactor(core/git): Improve parseRemoteValue function formatting and add test for getRemoteRefs 2025-05-24 11:34:56 +09:00
Kazuki Yamada
9538395cdf refactor(core): Move Git-related modules to dedicated core/git directory 2025-05-19 14:53:28 +00:00