Skip to content

Commit 448557f

Browse files
authored
Merge pull request #147 from syncable-dev/develop
Added further improvements and refactor, specifically for the vulnerabilities command
2 parents de1a78d + 76d2c1d commit 448557f

44 files changed

Lines changed: 6057 additions & 2570 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.qoder/quests/bun-audit-integration.md

Lines changed: 615 additions & 0 deletions
Large diffs are not rendered by default.

.qoder/quests/vulnerability-scanning-setup.md

Lines changed: 1229 additions & 0 deletions
Large diffs are not rendered by default.

.qoder/rules/project-rules.md

Lines changed: 959 additions & 0 deletions
Large diffs are not rendered by default.

.qoder/rules/rust-rules.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
trigger: model_decision
3+
description: It is triggered whenever rust code is being developed.
4+
---
5+
6+
You are an expert Rust developer with extensive experience in building high-performance CLI tools. Your task is to provide guidance and best practices for Rust development, focusing on code organization, performance optimization, and CLI-specific considerations.
7+
8+
When answering Rust-related questions, adhere to the following guidelines:
9+
10+
1. Code Organization:
11+
- Break down code into smaller, reusable functions and modules
12+
- Use traits and generics for abstraction when appropriate
13+
- Implement design patterns that promote scalability and maintainability
14+
- Favor composition over inheritance
15+
16+
2. Performance Optimization:
17+
- Utilize Rust's zero-cost abstractions
18+
- Consider using parallel processing with rayon when applicable
19+
- Implement efficient error handling without excessive allocations
20+
- Use appropriate data structures for fast lookups and iterations
21+
22+
3. CLI Development:
23+
- Prioritize startup time and memory usage
24+
- Implement efficient argument parsing (e.g., using clap)
25+
- Provide clear and concise error messages
26+
- Consider implementing a progress bar for long-running operations
27+
28+
4. Rust Best Practices:
29+
- Follow the Rust API Guidelines
30+
- Use strong typing and leverage the type system
31+
- Implement proper error handling with custom error types
32+
- Write comprehensive unit and integration tests
33+
34+
35+
Provide a detailed answer to the question, including code examples where appropriate. Ensure your response addresses the specific concerns raised in the question while adhering to the best practices outlined above.
36+
37+
In your response:
38+
1. Explain the rationale behind your approach
39+
2. Provide code snippets demonstrating the solution
40+
3. Discuss any trade-offs or alternative approaches
41+
4. Mention any relevant Rust features or crates that could be beneficial
42+
43+
Your final output should be structured as follows:
44+
45+
<answer>
46+
[Your detailed explanation and code examples here]
47+
</answer>
48+
49+
<best_practices>
50+
[List 3-5 key best practices that are particularly relevant to the question]
51+
</best_practices>
52+
<performance_considerations>
53+
[Briefly discuss any performance implications or optimizations related to the solution]
54+
</performance_considerations>
55+
56+
Ensure that your response is comprehensive, yet focused on the specific question asked. Do not include any additional commentary or notes outside of the specified XML tags.
57+

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- 🧄 **Bun Runtime Integration**: Complete support for Bun JavaScript runtime and package manager
12+
- Automatic Bun project detection via `bun.lockb`, `bunfig.toml`, and package.json configuration
13+
- Multi-runtime vulnerability scanning with priority-based package manager detection (Bun > pnpm > yarn > npm)
14+
- Cross-platform Bun installation support (Windows PowerShell, Unix curl/bash)
15+
- Runtime detection with confidence levels and fallback mechanisms
16+
- Comprehensive unit and integration tests (34+ tests covering all scenarios)
17+
- Enhanced ToolDetector with caching and alternative command support
18+
- Updated documentation with Bun examples and migration guides
19+
1020
## [0.13.6](https://github.com/syncable-dev/syncable-cli/compare/v0.13.5...v0.13.6) - 2025-09-03
1121

1222
### Other

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ sync-ctl security --fail-on-findings # Exit with error code if issues found
373373
- **Rust** (20) - Actix-web, Axum, Rocket, Tokio, SeaORM, and more
374374

375375
### Package Managers
376-
- npm, yarn, pnpm, bun (JavaScript)
376+
- npm, yarn, pnpm, bun (JavaScript/TypeScript)
377377
- pip, poetry, pipenv, conda (Python)
378378
- Maven, Gradle (Java)
379379
- Cargo (Rust)

docs/BUN_INTEGRATION.md

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# 🧄 Bun Integration Guide
2+
3+
This document covers the new Bun runtime and package manager integration in Syncable CLI.
4+
5+
## Overview
6+
7+
Syncable CLI now fully supports Bun, the all-in-one JavaScript runtime & toolkit. The integration includes:
8+
9+
- **Runtime Detection**: Automatically detects Bun projects via lock files, package.json configuration, and Bun-specific files
10+
- **Vulnerability Scanning**: Uses `bun audit` to check for vulnerabilities in Bun projects
11+
- **Tool Installation**: Auto-installs Bun when needed across all platforms
12+
- **Multi-Runtime Support**: Prioritizes Bun when multiple package managers are present
13+
14+
## How Bun Projects Are Detected
15+
16+
Syncable CLI uses a priority-based detection system:
17+
18+
### 1. Lock File Detection (Highest Priority)
19+
```bash
20+
# If bun.lockb exists, project is detected as Bun
21+
bun.lockb
22+
```
23+
24+
### 2. Package.json Configuration
25+
```json
26+
{
27+
"name": "my-app",
28+
"packageManager": "bun@1.0.0",
29+
"engines": {
30+
"bun": ">=1.0.0"
31+
}
32+
}
33+
```
34+
35+
### 3. Bun Configuration Files
36+
```bash
37+
bunfig.toml # Bun configuration file
38+
.bunfig.toml # Alternative config name
39+
```
40+
41+
### 4. Bun Scripts in package.json
42+
```json
43+
{
44+
"scripts": {
45+
"start": "bun run index.js",
46+
"dev": "bun --watch server.ts"
47+
}
48+
}
49+
```
50+
51+
## Priority Order
52+
53+
When multiple package managers are detected, Syncable CLI uses this priority:
54+
55+
1. **Bun** (bun.lockb, packageManager: "bun@*")
56+
2. **pnpm** (pnpm-lock.yaml, packageManager: "pnpm@*")
57+
3. **Yarn** (yarn.lock, packageManager: "yarn@*")
58+
4. **npm** (package-lock.json, packageManager: "npm@*")
59+
60+
## Vulnerability Scanning
61+
62+
### Automatic Runtime Detection
63+
```bash
64+
# Automatically detects Bun and uses 'bun audit'
65+
sync-ctl vulnerabilities /path/to/bun-project
66+
67+
# Shows runtime detection in output
68+
Runtime: Bun
69+
Package Manager: bun
70+
Audit Command: bun audit
71+
```
72+
73+
### Example Output
74+
```bash
75+
$ sync-ctl vulnerabilities ./my-bun-app
76+
77+
🔍 Vulnerability Analysis Report
78+
═══════════════════════════════════════════════════════════════════════
79+
80+
┌─ Project Information ────────────────────────────────────────────────┐
81+
│ Runtime: Bun │
82+
│ Package Manager: bun │
83+
│ Dependencies: 42 total (38 production, 4 development) │
84+
│ Lock File: bun.lockb │
85+
└──────────────────────────────────────────────────────────────────────┘
86+
87+
┌─ Vulnerability Summary ──────────────────────────────────────────────┐
88+
│ Total Vulnerabilities: 3 │
89+
│ Critical: 1 | High: 1 | Medium: 1 | Low: 0 │
90+
│ Checked at: 2024-01-15 14:30:22 UTC │
91+
└──────────────────────────────────────────────────────────────────────┘
92+
```
93+
94+
## Installation Integration
95+
96+
### Automatic Installation
97+
If Bun is not installed but detected as the project's package manager:
98+
99+
```bash
100+
$ sync-ctl vulnerabilities ./bun-project
101+
102+
⚙️ Bun not found but required for this project
103+
🔧 Installing Bun automatically...
104+
105+
# On Windows
106+
> powershell -c "irm bun.sh/install.ps1 | iex"
107+
108+
# On Unix/Linux/macOS
109+
> curl -fsSL https://bun.sh/install | bash
110+
111+
✅ Bun v1.0.3 installed successfully
112+
🔍 Running vulnerability scan with bun audit...
113+
```
114+
115+
### Manual Installation
116+
```bash
117+
# Check tool status
118+
sync-ctl tools status
119+
120+
# Install all missing tools (including Bun if needed)
121+
sync-ctl tools install
122+
123+
# Get installation guide
124+
sync-ctl tools guide --bun
125+
```
126+
127+
## Cross-Platform Support
128+
129+
### Windows Installation
130+
```powershell
131+
# PowerShell (Administrator recommended)
132+
irm bun.sh/install.ps1 | iex
133+
134+
# Or via Scoop
135+
scoop install bun
136+
```
137+
138+
### Unix/Linux/macOS Installation
139+
```bash
140+
# Official installer
141+
curl -fsSL https://bun.sh/install | bash
142+
143+
# Homebrew (macOS)
144+
brew install bun
145+
146+
# Manual download
147+
wget https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip
148+
```
149+
150+
## Multi-Runtime Projects
151+
152+
For projects with multiple package managers, Bun takes priority:
153+
154+
```bash
155+
# Project structure
156+
my-project/
157+
├── package.json # Shared dependencies
158+
├── bun.lockb # Bun lock file (highest priority)
159+
├── yarn.lock # Yarn lock file
160+
├── package-lock.json # npm lock file
161+
└── pnpm-lock.yaml # pnpm lock file
162+
163+
# Result: Detected as Bun project
164+
Runtime: Bun
165+
Package Manager: bun
166+
Confidence: High
167+
```
168+
169+
## Configuration Options
170+
171+
### .syncable.toml Configuration
172+
```toml
173+
[javascript]
174+
# Force specific package manager
175+
preferred_package_manager = "bun"
176+
177+
# Skip auto-installation
178+
auto_install_tools = false
179+
180+
[vulnerability]
181+
# Custom audit commands
182+
bun_audit_command = "bun audit --json"
183+
```
184+
185+
### Command Line Options
186+
```bash
187+
# Force specific package manager for vulnerability scanning
188+
sync-ctl vulnerabilities . --package-manager bun
189+
190+
# Skip missing tool installation
191+
sync-ctl vulnerabilities . --no-install
192+
```
193+
194+
## Troubleshooting
195+
196+
### Common Issues
197+
198+
1. **Bun not found in PATH**
199+
```bash
200+
# Add Bun to PATH (Unix/Linux/macOS)
201+
echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.bashrc
202+
source ~/.bashrc
203+
204+
# Windows: Add %USERPROFILE%\.bun\bin to PATH
205+
```
206+
207+
2. **Permission issues during installation**
208+
```bash
209+
# Run with elevated permissions or use package manager
210+
sudo curl -fsSL https://bun.sh/install | bash
211+
```
212+
213+
3. **Lock file conflicts**
214+
```bash
215+
# Clean conflicting lock files
216+
rm package-lock.json yarn.lock pnpm-lock.yaml
217+
bun install # Recreate bun.lockb
218+
```
219+
220+
### Debug Information
221+
```bash
222+
# Enable debug logging
223+
RUST_LOG=debug sync-ctl vulnerabilities .
224+
225+
# View runtime detection details
226+
sync-ctl analyze . --display detailed
227+
```
228+
229+
## Best Practices
230+
231+
1. **Use explicit packageManager field** in package.json for clarity
232+
2. **Remove conflicting lock files** when switching to Bun
233+
3. **Keep bunfig.toml** for project-specific Bun configuration
234+
4. **Use bun scripts** in package.json for consistency
235+
236+
## Migration from Other Package Managers
237+
238+
### From npm
239+
```bash
240+
# Remove npm artifacts
241+
rm package-lock.json node_modules/ -rf
242+
243+
# Install with Bun
244+
bun install
245+
246+
# Update package.json
247+
{
248+
"packageManager": "bun@1.0.0"
249+
}
250+
```
251+
252+
### From Yarn
253+
```bash
254+
# Remove Yarn artifacts
255+
rm yarn.lock node_modules/ -rf
256+
257+
# Install with Bun
258+
bun install
259+
260+
# Update scripts if needed
261+
{
262+
"scripts": {
263+
"start": "bun run index.js"
264+
}
265+
}
266+
```
267+
268+
## Examples
269+
270+
See `examples/` directory for sample Bun projects and usage patterns.
271+
272+
---
273+
274+
For more information, see the [main documentation](../README.md) or [file an issue](https://github.com/syncable-dev/syncable-cli/issues).

docs/command-overview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ sync-ctl security . --fail-on-findings
8989
### 4. Vulnerability Scanning
9090

9191
```bash
92-
# Scan all dependencies for vulnerabilities
92+
# Scan all dependencies for vulnerabilities across all supported package managers
93+
# Supports: npm, yarn, pnpm, bun (JavaScript), pip (Python), cargo (Rust), go mod (Go)
9394
sync-ctl vulnerabilities .
9495

9596
# Filter by severity

examples/check_vulnerabilities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use syncable_cli::analyzer::dependency_parser::{DependencyParser};
2-
use syncable_cli::analyzer::vulnerability_checker::VulnerabilityChecker;
2+
use syncable_cli::analyzer::vulnerability::VulnerabilityChecker;
33
use std::path::Path;
44

55
#[tokio::main]

0 commit comments

Comments
 (0)