Skip to content

Commit f4ae9c2

Browse files
Alex HolmbergAlex Holmberg
authored andcommitted
feat: improved small vulnerability scan within java, and framework detections.
1 parent 76ef277 commit f4ae9c2

13 files changed

Lines changed: 1276 additions & 147 deletions

.cursor/rules/project-rules.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ use predicates::prelude::*;
646646

647647
#[test]
648648
fn test_analyze_node_project() {
649-
let mut cmd = Command::cargo_bin("iac-generator").unwrap();
649+
let mut cmd = Command::cargo_bin("sync-ctl").unwrap();
650650
cmd.arg("analyze")
651651
.arg("tests/fixtures/node_express_app")
652652
.assert()
@@ -789,7 +789,7 @@ Include output values
789789
rustCopyuse clap::{Parser, Subcommand};
790790

791791
#[derive(Parser)]
792-
#[command(name = "iac-gen")]
792+
#[command(name = "sync-ctl")]
793793
#[command(about = "Generate Infrastructure as Code from your codebase")]
794794
struct Cli {
795795
#[command(subcommand)]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ use assert_cmd::Command;
159159

160160
#[test]
161161
fn test_cli_analyze() {
162-
let mut cmd = Command::cargo_bin("iac-gen").unwrap();
162+
let mut cmd = Command::cargo_bin("sync-ctl").unwrap();
163163
cmd.arg("analyze")
164164
.arg("tests/fixtures/sample_project")
165165
.assert()

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["iac", "infrastructure", "docker", "terraform", "cli"]
1010
categories = ["command-line-utilities", "development-tools"]
1111

1212
[[bin]]
13-
name = "iac-gen"
13+
name = "sync-ctl"
1414
path = "src/main.rs"
1515

1616
[dependencies]

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cd syncable-cli
4444
cargo install --path .
4545

4646
# Verify installation
47-
iac-gen --version
47+
sync-ctl --version
4848
```
4949

5050
### Pre-built Binaries
@@ -57,31 +57,31 @@ Coming soon! Check the [releases page](https://github.com/yourusername/syncable-
5757

5858
```bash
5959
# Analyze current directory
60-
iac-gen analyze
60+
sync-ctl analyze
6161

6262
# Analyze specific project
63-
iac-gen analyze /path/to/your/project
63+
sync-ctl analyze /path/to/your/project
6464

6565
# Get JSON output
66-
iac-gen analyze --json > analysis.json
66+
sync-ctl analyze --json > analysis.json
6767
```
6868

6969
### Check for Vulnerabilities
7070

7171
```bash
7272
# Run vulnerability scan
73-
iac-gen vuln-check /path/to/project
73+
sync-ctl vuln-check /path/to/project
7474

7575
# Check only high severity and above
76-
iac-gen vuln-check --severity high
76+
sync-ctl vuln-check --severity high
7777
```
7878

7979
## 📖 Usage Examples
8080

8181
### Example: Node.js Express Application
8282

8383
```bash
84-
$ iac-gen analyze ./my-express-app
84+
$ sync-ctl analyze ./my-express-app
8585

8686
🔍 Analyzing project at: ./my-express-app
8787
============================================================
@@ -113,7 +113,7 @@ $ iac-gen analyze ./my-express-app
113113
### Example: Python FastAPI Service
114114

115115
```bash
116-
$ iac-gen analyze ./fastapi-service --json
116+
$ sync-ctl analyze ./fastapi-service --json
117117
```
118118

119119
```json

TUTORIAL.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,33 @@ Welcome to the Syncable Infrastructure-as-Code CLI! This tool analyzes your code
2828
# Build the project
2929
cargo build --release
3030

31-
# The binary will be at ./target/release/iac-gen
31+
# The binary will be at ./target/release/sync-ctl
3232
```
3333

3434
3. **Install Globally**
3535
```bash
3636
# Install to your system
3737
cargo install --path .
3838

39-
# Now you can use 'iac-gen' from anywhere
40-
iac-gen --version
39+
# Now you can use 'sync-ctl' from anywhere
40+
sync-ctl --version
4141
```
4242

4343
### Option 2: Download Pre-built Binary (Coming Soon)
4444

4545
```bash
4646
# macOS
47-
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/iac-gen-macos -o iac-gen
48-
chmod +x iac-gen
49-
sudo mv iac-gen /usr/local/bin/
47+
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/sync-ctl-macos -o sync-ctl
48+
chmod +x sync-ctl
49+
sudo mv sync-ctl /usr/local/bin/
5050

5151
# Linux
52-
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/iac-gen-linux -o iac-gen
53-
chmod +x iac-gen
54-
sudo mv iac-gen /usr/local/bin/
52+
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/sync-ctl-linux -o sync-ctl
53+
chmod +x sync-ctl
54+
sudo mv sync-ctl /usr/local/bin/
5555

5656
# Windows
57-
# Download iac-gen-windows.exe from releases page
57+
# Download sync-ctl-windows.exe from releases page
5858
```
5959

6060
## 🏁 Quick Start
@@ -63,23 +63,23 @@ sudo mv iac-gen /usr/local/bin/
6363

6464
```bash
6565
# Analyze the current directory
66-
iac-gen analyze
66+
sync-ctl analyze
6767

6868
# Analyze a specific project
69-
iac-gen analyze /path/to/your/project
69+
sync-ctl analyze /path/to/your/project
7070

7171
# Get JSON output for scripting
72-
iac-gen analyze --json
72+
sync-ctl analyze --json
7373
```
7474

7575
### Vulnerability Scanning
7676

7777
```bash
7878
# Check for vulnerabilities in dependencies
79-
iac-gen vuln-check /path/to/project
79+
sync-ctl vuln-check /path/to/project
8080

8181
# Check with specific severity threshold
82-
iac-gen vuln-check --severity high /path/to/project
82+
sync-ctl vuln-check --severity high /path/to/project
8383
```
8484

8585
## 🎯 Core Features
@@ -118,7 +118,7 @@ The CLI automatically detects:
118118
### Example 1: Analyzing a Node.js Express App
119119

120120
```bash
121-
$ iac-gen analyze ~/projects/my-express-app
121+
$ sync-ctl analyze ~/projects/my-express-app
122122

123123
🔍 Analyzing project at: /Users/john/projects/my-express-app
124124
============================================================
@@ -167,7 +167,7 @@ $ iac-gen analyze ~/projects/my-express-app
167167
### Example 2: Vulnerability Check
168168

169169
```bash
170-
$ iac-gen vuln-check ~/projects/my-express-app
170+
$ sync-ctl vuln-check ~/projects/my-express-app
171171

172172
🔍 Checking vulnerabilities for: /Users/john/projects/my-express-app
173173
============================================================
@@ -204,7 +204,7 @@ Run 'npm update' to fix most issues.
204204
### Example 3: Analyzing a Python FastAPI Project
205205

206206
```bash
207-
$ iac-gen analyze ~/projects/fastapi-app --json
207+
$ sync-ctl analyze ~/projects/fastapi-app --json
208208
```
209209

210210
```json
@@ -314,16 +314,16 @@ jobs:
314314

315315
- name: Install Syncable CLI
316316
run: |
317-
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/iac-gen-linux -o iac-gen
318-
chmod +x iac-gen
319-
sudo mv iac-gen /usr/local/bin/
317+
curl -L https://github.com/yourusername/syncable-cli/releases/latest/download/sync-ctl-linux -o sync-ctl
318+
chmod +x sync-ctl
319+
sudo mv sync-ctl /usr/local/bin/
320320
321321
- name: Run Analysis
322-
run: iac-gen analyze --json > analysis.json
322+
run: sync-ctl analyze --json > analysis.json
323323

324324
- name: Check Vulnerabilities
325325
run: |
326-
iac-gen vuln-check --severity high
326+
sync-ctl vuln-check --severity high
327327
if [ $? -ne 0 ]; then
328328
echo "High severity vulnerabilities found!"
329329
exit 1
@@ -356,10 +356,10 @@ jobs:
356356
Run with verbose logging:
357357
```bash
358358
# Show debug information
359-
RUST_LOG=debug iac-gen analyze /path/to/project
359+
RUST_LOG=debug sync-ctl analyze /path/to/project
360360
361361
# Show only warnings and errors
362-
RUST_LOG=warn iac-gen analyze /path/to/project
362+
RUST_LOG=warn sync-ctl analyze /path/to/project
363363
```
364364

365365
## 🚧 Upcoming Features (Phase 2)

VULNERABILITY_CHECKING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@ The CLI can check vulnerabilities for dependencies in the following languages:
1616

1717
### Check vulnerabilities in the current directory:
1818
```bash
19-
iac-gen vulnerabilities
19+
sync-ctl vulnerabilities
2020
```
2121

2222
### Check vulnerabilities in a specific project:
2323
```bash
24-
iac-gen vulnerabilities /path/to/project
24+
sync-ctl vulnerabilities /path/to/project
2525
```
2626

2727
### Filter by severity:
2828
```bash
29-
iac-gen vulnerabilities --severity high
29+
sync-ctl vulnerabilities --severity high
3030
```
3131

3232
Available severity levels: `low`, `medium`, `high`, `critical`
3333

3434
### Export results:
3535
```bash
3636
# Export as JSON
37-
iac-gen vulnerabilities --format json --output report.json
37+
sync-ctl vulnerabilities --format json --output report.json
3838

3939
# Export as table (default)
40-
iac-gen vulnerabilities --output report.txt
40+
sync-ctl vulnerabilities --output report.txt
4141
```
4242

4343
### Check vulnerabilities as part of dependency analysis:
4444
```bash
45-
iac-gen dependencies --vulnerabilities /path/to/project
45+
sync-ctl dependencies --vulnerabilities /path/to/project
4646
```
4747

4848
## Required Tools
@@ -153,7 +153,7 @@ This makes it easy to integrate into CI/CD pipelines:
153153
```yaml
154154
# GitHub Actions example
155155
- name: Check vulnerabilities
156-
run: iac-gen vulnerabilities --severity high
156+
run: sync-ctl vulnerabilities --severity high
157157
```
158158
159159
## Limitations
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
use env_logger;
2+
use log::{info, debug, error};
3+
use syncable_cli::analyzer::dependency_parser::{DependencyParser, Language};
4+
use syncable_cli::analyzer::vulnerability_checker::VulnerabilityChecker;
5+
use std::path::Path;
6+
use std::env;
7+
8+
#[tokio::main]
9+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
10+
// Enable debug logging
11+
env::set_var("RUST_LOG", "debug");
12+
env_logger::init();
13+
14+
// Get project path from command line args or use current directory
15+
let args: Vec<String> = env::args().collect();
16+
let project_path = if args.len() > 1 {
17+
Path::new(&args[1])
18+
} else {
19+
Path::new(".")
20+
};
21+
22+
info!("🔍 Debug Java vulnerability scanning in: {}", project_path.display());
23+
24+
// Parse dependencies
25+
let parser = DependencyParser::new();
26+
info!("📦 Parsing dependencies...");
27+
let dependencies = parser.parse_all_dependencies(project_path)?;
28+
29+
if dependencies.is_empty() {
30+
error!("❌ No dependencies found!");
31+
info!("Make sure you're in a Java project directory with:");
32+
info!(" - pom.xml (Maven project)");
33+
info!(" - build.gradle or build.gradle.kts (Gradle project)");
34+
return Ok(());
35+
}
36+
37+
// Show detailed dependency information
38+
info!("📊 Found dependencies in {} languages:", dependencies.len());
39+
for (lang, deps) in &dependencies {
40+
info!(" {:?}: {} dependencies", lang, deps.len());
41+
if *lang == Language::Java {
42+
info!(" Java dependencies details:");
43+
for dep in deps.iter().take(10) {
44+
info!(" - {} v{} (source: {:?})", dep.name, dep.version, dep.source);
45+
}
46+
if deps.len() > 10 {
47+
info!(" ... and {} more", deps.len() - 10);
48+
}
49+
}
50+
}
51+
52+
// Check if Java dependencies were found
53+
if !dependencies.contains_key(&Language::Java) {
54+
error!("❌ No Java dependencies detected!");
55+
info!("Troubleshooting steps:");
56+
info!("1. Make sure you're in a Java project directory");
57+
info!("2. For Maven projects: ensure pom.xml exists and has <dependencies> section");
58+
info!("3. For Gradle projects: ensure build.gradle exists with dependency declarations");
59+
info!("4. Run 'mvn dependency:resolve' or 'gradle build' to ensure dependencies are resolved");
60+
return Ok(());
61+
}
62+
63+
// Check vulnerabilities
64+
info!("🛡️ Checking for vulnerabilities...");
65+
let checker = VulnerabilityChecker::new();
66+
67+
match checker.check_all_dependencies(&dependencies, project_path).await {
68+
Ok(report) => {
69+
info!("✅ Vulnerability scan completed successfully!");
70+
info!("📊 Results:");
71+
info!(" Total vulnerabilities: {}", report.total_vulnerabilities);
72+
info!(" Critical: {}", report.critical_count);
73+
info!(" High: {}", report.high_count);
74+
info!(" Medium: {}", report.medium_count);
75+
info!(" Low: {}", report.low_count);
76+
77+
if report.total_vulnerabilities > 0 {
78+
info!("🚨 Vulnerable dependencies:");
79+
for vuln_dep in &report.vulnerable_dependencies {
80+
info!(" - {} v{} ({} vulnerabilities)",
81+
vuln_dep.name, vuln_dep.version, vuln_dep.vulnerabilities.len());
82+
for vuln in &vuln_dep.vulnerabilities {
83+
info!(" • {} [{:?}] - {}", vuln.id, vuln.severity, vuln.title);
84+
}
85+
}
86+
} else {
87+
info!("✅ No vulnerabilities found!");
88+
info!("This could mean:");
89+
info!(" - Your dependencies are up to date and secure");
90+
info!(" - The vulnerability scanner (grype) didn't find any issues");
91+
info!(" - The dependency versions couldn't be matched with vulnerability databases");
92+
}
93+
}
94+
Err(e) => {
95+
error!("❌ Vulnerability scanning failed: {}", e);
96+
info!("Common issues:");
97+
info!(" - grype not installed: brew install grype");
98+
info!(" - Project not built: run 'mvn compile' or 'gradle build'");
99+
info!(" - Dependencies not resolved: run 'mvn dependency:resolve'");
100+
}
101+
}
102+
103+
Ok(())
104+
}

install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ echo ""
4444
echo "✅ Installation complete!"
4545
echo ""
4646
echo "🎯 Quick Start:"
47-
echo " iac-gen --help # Show help"
48-
echo " iac-gen analyze . # Analyze current directory"
49-
echo " iac-gen vuln-check . # Check for vulnerabilities"
47+
echo " sync-ctl --help # Show help"
48+
echo " sync-ctl analyze . # Analyze current directory"
49+
echo " sync-ctl vuln-check . # Check for vulnerabilities"
5050
echo ""
5151
echo "📚 For more information, see TUTORIAL.md"
5252
echo ""

0 commit comments

Comments
 (0)