Skip to content

Commit bd4bfa6

Browse files
committed
Integrate undercover skill and update AI, remediation, and output logic
1 parent ffcaa3d commit bd4bfa6

9 files changed

Lines changed: 239 additions & 258 deletions

File tree

README.md

Lines changed: 76 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,66 @@
1-
# FlutterGuard CLI 🔍
1+
# FlutterGuard CLI
22

3-
<div align="center">
4-
<img src="https://flutterguard.dev/logo.png" alt="FlutterGuard Logo" width="200" height="200">
5-
</div>
3+
**FlutterGuard CLI** is a professional, AI-powered command-line utility for comprehensive security and compliance analysis of Flutter Android applications. Designed for engineering teams, security professionals, and agencies, FlutterGuard delivers actionable, human-quality remediation guidance and compliance insights for every scan finding.
64

7-
A powerful command-line tool for analyzing Flutter Android apps to discover security issues, secrets, API endpoints, and more. FlutterGuard runs completely offline on your machine—no cloud services, no tracking, just local analysis.
5+
## Key Features
86

9-
## What It Does
7+
- **AI-Powered Remediation**: Integrates with leading AI providers (OpenAI, Gemini, Claude, xAI, and more) to generate professional, actionable remediation steps and compliance explanations for every security or privacy finding.
8+
- **Comprehensive Static Analysis**: Detects hardcoded secrets, API endpoints, permissions, SDKs, third-party services, and more.
9+
- **Privacy & Compliance Checks**: Flags risks related to GDPR, COPPA, Play Store, and other regulatory requirements, with clear, human-readable explanations.
10+
- **CI/CD Integration**: Ready for automation in pipelines, with structured output and machine-readable formats.
11+
- **Professional Reports**: Generates detailed Markdown and JSON reports suitable for audits, client delivery, and internal review.
12+
- **Offline-First**: All analysis runs locally by default. No data is sent to the cloud unless you explicitly enable AI or network features.
1013

11-
FlutterGuard CLI analyzes Flutter app APK files and extracts:
14+
---
15+
16+
## AI Setup and Usage
17+
18+
FlutterGuard CLI supports multiple AI providers for remediation and compliance guidance. You can configure the AI engine via environment variables or CLI flags.
19+
20+
### Supported Providers
21+
22+
- OpenAI
23+
- Google Gemini
24+
- Anthropic Claude
25+
- xAI
26+
- OpenRouter
27+
28+
### Configuration
29+
30+
Set the following environment variables or use equivalent CLI flags:
31+
32+
- `FLUTTERGUARD_AI_ENABLED=1` — Enable AI-powered remediation
33+
- `FLUTTERGUARD_AI_PROVIDER=openai|gemini|claude|xai|openrouter` — Select provider
34+
- `FLUTTERGUARD_AI_KEY=...` — API key for the selected provider
35+
- `FLUTTERGUARD_AI_BASEURL=...` — (Optional) Custom API endpoint
36+
37+
**Example:**
38+
39+
```bash
40+
export FLUTTERGUARD_AI_ENABLED=1
41+
export FLUTTERGUARD_AI_PROVIDER=openai
42+
export FLUTTERGUARD_AI_KEY=sk-...
43+
flutterguard-cli --apk app.apk --outDir ./results --enable-ai-remediation
44+
```
45+
46+
When enabled, all findings in the report will include a dedicated "Remediation Guidance" section with professional, human-like explanations and actionable steps.
47+
48+
---
49+
50+
## What FlutterGuard CLI Analyzes
1251

13-
- 🔑 **Secrets & API Keys** — Finds hardcoded passwords, tokens, and credentials
14-
- 🌐 **Network Details** — Extracts URLs, domains, API endpoints, and Firebase configs
15-
- 📦 **Dependencies** — Lists all Flutter packages with direct links to pub.dev
16-
- 📋 **App Metadata** — Package name, version, SDK info, and permissions
17-
- 🔍 **Third-Party Services** — Detects bundled SDKs, CDNs, and analytics libraries
18-
- 📜 **Certificate Info** — Analyzes signing certificates and flags self-signed ones
19-
- 📁 **Complete Breakdown** — Organized assets, resources, and full decompiled source code
52+
- **Secrets & API Keys**: Detects hardcoded credentials and sensitive tokens
53+
- **Network & API Endpoints**: Extracts all URLs, domains, and backend endpoints
54+
- **Dependencies**: Lists all Flutter/Dart packages and third-party SDKs
55+
- **App Metadata**: Reports package name, version, SDK targets, and permissions
56+
- **Third-Party Services**: Identifies analytics, ad networks, and bundled SDKs
57+
- **Certificate Information**: Analyzes signing certificates for trust and compliance
58+
- **Assets & Resources**: Catalogs all embedded files, assets, and resources
59+
- **Decompiled Source**: Optionally provides full decompiled APK contents for audit
60+
61+
## Installation
62+
63+
...existing code...
2064

2165
## Installation
2266

@@ -140,98 +184,38 @@ FlutterGuard works standalone, but these tools provide richer analysis:
140184

141185
### Basic Analysis
142186

143-
Analyze a Flutter app APK and save organized results to a directory:
187+
Run a full security and compliance scan on a Flutter APK:
144188

145189
```bash
146190
flutterguard-cli --apk app.apk --outDir ./results
147191
```
148192

149-
This creates a folder named after the app's package (e.g., `results/com.example.app/`) containing all findings, assets, and decompiled code.
150-
151-
### Show Progress
193+
This creates a results directory with all findings, assets, and a professional Markdown report.
152194

153-
Add `--verbose` to see real-time progress updates:
195+
### Enabling AI Remediation
154196

155-
```bash
156-
flutterguard-cli --apk app.apk --outDir ./results --verbose
157-
```
197+
Add the `--enable-ai-remediation` flag (or set `FLUTTERGUARD_AI_ENABLED=1`) to include AI-generated remediation and compliance guidance in your reports.
158198

159199
### Output Formats
160200

161-
**JSON format** (default, good for automation):
162-
163-
```bash
164-
flutterguard-cli --apk app.apk --format json
165-
```
166-
167-
**Text format** (human-readable summary):
168-
169-
```bash
170-
flutterguard-cli --apk app.apk --format text
171-
```
172-
173-
**Structured directory** (most comprehensive):
174-
175-
```bash
176-
flutterguard-cli --apk app.apk --outDir ~/my-analysis
177-
```
178-
179-
### Network Features (Opt-In)
180-
181-
By default, FlutterGuard runs completely offline. Enable network features for:
182-
183-
- Domain DNS validation
184-
- pub.dev package information enrichment
185-
186-
```bash
187-
flutterguard-cli --apk app.apk --outDir ./results --enable-network-and-dns-checks
188-
```
189-
190-
## Output Structure
191-
192-
When using `--outDir`, FlutterGuard creates an organized directory structure:
193-
194-
```
195-
results/
196-
└── com.example.app/
197-
├── summary.md ← Start here! Overview with clickable links
198-
├── analysis.json ← Full structured data (JSON)
199-
├── emails.txt ← Email addresses found
200-
├── domains.txt ← Domain names and hosts
201-
├── urls.txt ← All URLs discovered
202-
├── api_endpoints.txt ← API endpoints with HTTP methods
203-
├── packages.txt ← Flutter packages with pub.dev links
204-
├── permissions.txt ← Android permissions (⚠️ = dangerous)
205-
├── services.txt ← Third-party SDKs detected
206-
├── hardcoded_keys.txt ← Potential secrets and API keys
207-
├── assets/ ← App resources by file type
208-
│ ├── json/
209-
│ ├── png/
210-
│ ├── xml/
211-
│ ├── ttf/
212-
│ └── ...
213-
└── decompiled/ ← Complete APK contents
214-
├── AndroidManifest.xml
215-
├── classes.dex
216-
├── lib/ ← Native libraries (.so files)
217-
├── res/ ← App resources
218-
├── assets/ ← Embedded assets
219-
└── META-INF/ ← Signing certificates
220-
```
201+
- `summary.md`: Human-readable, professional Markdown report with remediation guidance
202+
- `analysis.json`: Full structured data for automation and audit
203+
- `*.txt`: Raw lists of emails, domains, endpoints, etc.
204+
- `assets/`: All extracted resources, organized by type
205+
- `decompiled/`: Decompiled APK contents (optional)
221206

222-
**Tip:** Open `summary.md` in any markdown viewer—it includes a table of contents with links to all findings.
207+
### Example Output Structure
223208

224-
## Why Go instead of Dart?
209+
...existing code...
225210

226-
FlutterGuard is written in Go rather than Dart because:
211+
## Why FlutterGuard CLI?
227212

228-
- **Single Compiled Binary**: Users get a standalone executable with zero dependencies—just download and run, no runtime required.
229-
- **Cross-Platform Distribution**: Go compiles easily to Windows, macOS, and Linux with a single codebase, making it simpler for users across different systems.
230-
- **Performance**: Go offers native compilation speed and efficiency ideal for analyzing large APK files and intensive security scanning operations.
231-
- **CLI Excellence**: Go is purpose-built for command-line tools with strong standard library support for file I/O, process execution, and signal handling.
232-
- **Ecosystem**: Direct access to powerful tools like JADX and aapt2 without the overhead of a UI framework designed for mobile apps.
213+
- **Professional, Human-Quality Guidance**: All AI-generated remediation is reviewed for clarity, accuracy, and professionalism.
214+
- **No Vendor Lock-In**: Choose your preferred AI provider or run fully offline.
215+
- **Enterprise-Ready**: Designed for security teams, agencies, and regulated environments.
216+
- **Transparent and Auditable**: All findings and AI guidance are saved locally for review and compliance.
233217

234-
While Dart excels at building Flutter mobile and web apps, Go is the better choice for a developer tool that needs to be lightweight, fast, and dependency-free.
218+
FlutterGuard CLI is written in Go for maximum portability, performance, and ease of deployment. No dependencies, no runtime, just a single binary.
235219

236220
## Contributing
237221

@@ -301,4 +285,4 @@ MIT License - see the [LICENSE](LICENSE) file for details.
301285

302286
---
303287

304-
**Built for the Flutter and Android security community**
288+
_FlutterGuard CLI: Professional AI-powered security and compliance for Flutter applications._

ai/ai.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ai
2+
3+
// ProviderType represents a supported AI provider.
4+
type ProviderType string
5+
6+
const (
7+
ProviderOpenAI ProviderType = "openai"
8+
ProviderGemini ProviderType = "gemini"
9+
ProviderClaude ProviderType = "claude"
10+
ProviderOpenRouter ProviderType = "openrouter"
11+
ProviderXAI ProviderType = "xai"
12+
)
13+
14+
// AIProviderConfig holds configuration for an AI provider.
15+
type AIProviderConfig struct {
16+
Provider ProviderType
17+
APIKey string
18+
BaseURL string // Optional, for custom endpoints
19+
}
20+
21+
// AIClient is the interface for all AI providers.
22+
type AIClient interface {
23+
ExplainFinding(finding string, context string) (string, error)
24+
}
25+
26+
// SystemPrompt returns the system prompt for remediation guidance.
27+
func SystemPrompt() string {
28+
return `You are a professional Flutter and Android security expert. For each finding, provide a clear, actionable, and human-like remediation guide. Include code snippets, links to best practices, and explain the risk in simple terms. Be concise, accurate, and friendly. Assume the reader is a developer or security engineer.`
29+
}

ai/config.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ai
2+
3+
import (
4+
"os"
5+
)
6+
7+
// AIConfig holds global AI integration settings.
8+
type AIConfig struct {
9+
Enabled bool
10+
Provider ProviderType
11+
APIKey string
12+
BaseURL string
13+
}
14+
15+
// LoadAIConfig loads AI config from environment variables or flags.
16+
func LoadAIConfig() *AIConfig {
17+
return &AIConfig{
18+
Enabled: os.Getenv("FLUTTERGUARD_AI_ENABLED") == "1",
19+
Provider: ProviderType(os.Getenv("FLUTTERGUARD_AI_PROVIDER")),
20+
APIKey: os.Getenv("FLUTTERGUARD_AI_KEY"),
21+
BaseURL: os.Getenv("FLUTTERGUARD_AI_BASEURL"),
22+
}
23+
}

ai/dummy.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ai
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// DummyAIClient is a placeholder AI client for development/testing.
8+
type DummyAIClient struct{}
9+
10+
func (d *DummyAIClient) ExplainFinding(finding string, context string) (string, error) {
11+
return fmt.Sprintf("[AI Remediation for: %s]\n- This is a placeholder. Configure a real AI provider for actionable guidance.\n- Context: %s", finding, context), nil
12+
}

ai/engine.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ai
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// NewAIClient returns an AIClient for the given config.
8+
func NewAIClient(cfg *AIConfig) AIClient {
9+
switch cfg.Provider {
10+
case ProviderOpenAI:
11+
// return &OpenAIClient{...} // To be implemented
12+
case ProviderGemini:
13+
// return &GeminiClient{...} // To be implemented
14+
case ProviderClaude:
15+
// return &ClaudeClient{...} // To be implemented
16+
case ProviderOpenRouter:
17+
// return &OpenRouterClient{...} // To be implemented
18+
case ProviderXAI:
19+
// return &XAIClient{...} // To be implemented
20+
}
21+
return &DummyAIClient{}
22+
}
23+
24+
// ExplainWithAI runs AI remediation for a finding.
25+
func ExplainWithAI(client AIClient, finding, context string) string {
26+
msg, err := client.ExplainFinding(finding, context)
27+
if err != nil {
28+
return fmt.Sprintf("[AI Error] %v", err)
29+
}
30+
return msg
31+
}

analyzer/remediation.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package analyzer
22

3+
import (
4+
"github.com/flutterguard/flutterguard-cli/ai"
5+
)
6+
37
// RemediationGuide contains guidance for addressing security findings
48
type RemediationGuide struct {
59
Title string `json:"title"`
@@ -160,3 +164,18 @@ func GetRemediationGuide(findingType string) RemediationGuide {
160164
}
161165
return guides["default"]
162166
}
167+
168+
// RemediationEngine provides AI-powered remediation for findings.
169+
type RemediationEngine struct {
170+
AI ai.AIClient
171+
}
172+
173+
// NewRemediationEngine creates a new RemediationEngine with the given AI client.
174+
func NewRemediationEngine(client ai.AIClient) *RemediationEngine {
175+
return &RemediationEngine{AI: client}
176+
}
177+
178+
// ExplainFinding returns an AI-generated remediation for a finding.
179+
func (r *RemediationEngine) ExplainFinding(finding, context string) string {
180+
return ai.ExplainWithAI(r.AI, finding, context)
181+
}

0 commit comments

Comments
 (0)