|
1 | 1 | # UCD: Undocumented Change Detector
|
2 | 2 |
|
| 3 | +UCD helps security teams detect hidden code changes between software versions using Google's Gemini AI. |
| 4 | + |
3 | 5 | [](https://goreportcard.com/report/github.com/tstromberg/ucd)
|
4 | 6 | [](https://pkg.go.dev/github.com/tstromberg/ucd)
|
5 | 7 |
|
6 |
| -UCD is an experimental AI-powered tool that identifies hidden code changes between software versions. It helps security teams detect undocumented modifications that might introduce security risks. |
7 |
| - |
8 |
| -> **Note:** This is an experimental project. Analysis results may vary in accuracy and should be manually verified. |
9 |
| -
|
10 |
| -## Features |
11 |
| - |
12 |
| -* Detects hidden code changes missed in documentation |
13 |
| -* Assesses risk for potential malware and silent security patches |
14 |
| -* Supports Git repositories and diff files |
15 |
| -* Uses Google's Gemini AI for analysis |
16 |
| -* Provides JSON output for integration with other tools |
| 8 | +> **Note:** Experimental project. Results should be manually verified. |
17 | 9 |
|
18 |
| -## Quick Start |
| 10 | +## Install |
19 | 11 |
|
20 | 12 | ```bash
|
21 | 13 | go install github.com/tstromberg/ucd@latest
|
22 |
| -export GEMINI_API_KEY=YOUR_API_KEY # From Google AI Studio |
23 |
| -ucd --a v1.0.0 --b v1.1.0 git https://github.com/repo/example.git |
24 | 14 | ```
|
25 | 15 |
|
26 | 16 | ## Usage
|
27 | 17 |
|
28 | 18 | ```bash
|
29 |
| -# Analyze Git repository |
30 |
| -ucd --a v0.25.3 --b v0.25.4 git https://github.com/org/repo.git |
| 19 | +# Set API key |
| 20 | +export GEMINI_API_KEY=YOUR_API_KEY |
31 | 21 |
|
32 |
| -# Analyze diff file |
33 |
| -ucd diff changes.patch |
| 22 | +# Analyze a Git repository |
| 23 | +ucd git https://github.com/org/repo.git |
34 | 24 |
|
35 |
| -# Use with additional options |
36 |
| -ucd --json --model gemini-2.0-flash git --a v1.0 --b v1.1 https://github.com/org/repo.git |
37 |
| -``` |
| 25 | +# Compare specific versions |
| 26 | +ucd -a v0.25.3 -b v0.25.4 git https://github.com/org/repo.git |
38 | 27 |
|
39 |
| -## Key Options |
| 28 | +# Analyze a local diff file |
| 29 | +ucd file changes.patch |
40 | 30 |
|
| 31 | +# Output in JSON format |
| 32 | +ucd -json git https://github.com/org/repo.git |
41 | 33 | ```
|
42 |
| ---a string Old version (default "v0") |
43 |
| ---b string New version (default "v1") |
44 |
| ---diff string Unified diff file |
45 |
| ---commit-messages Commit messages file |
46 |
| ---changelog Changelog file |
47 |
| ---api-key string Gemini API key |
48 |
| ---model string AI model (default "gemini-2.0-flash") |
49 |
| ---json Output as JSON |
50 |
| ---debug Enable debug output |
| 34 | + |
| 35 | +## Go API Example |
| 36 | + |
| 37 | +```go |
| 38 | +package main |
| 39 | + |
| 40 | +import ( |
| 41 | + "context" |
| 42 | + "fmt" |
| 43 | + "log" |
| 44 | + |
| 45 | + "github.com/google/generative-ai-go/genai" |
| 46 | + "github.com/tstromberg/ucd/pkg/ucd" |
| 47 | + "google.golang.org/api/option" |
| 48 | +) |
| 49 | + |
| 50 | +func main() { |
| 51 | + // Collect data |
| 52 | + data, err := ucd.Collect(ucd.Config{ |
| 53 | + RepoURL: "https://github.com/example/repo", |
| 54 | + VersionA: "v1.0.0", |
| 55 | + VersionB: "v1.1.0", |
| 56 | + }) |
| 57 | + if err != nil { |
| 58 | + log.Fatal(err) |
| 59 | + } |
| 60 | + |
| 61 | + // Analyze changes |
| 62 | + ctx := context.Background() |
| 63 | + client, err := genai.NewClient(ctx, option.WithAPIKey("YOUR_API_KEY")) |
| 64 | + if err != nil { |
| 65 | + log.Fatal(err) |
| 66 | + } |
| 67 | + defer client.Close() |
| 68 | + |
| 69 | + result, err := ucd.AnalyzeChanges(ctx, client, data, "gemini-2.0-flash") |
| 70 | + if err != nil { |
| 71 | + log.Fatal(err) |
| 72 | + } |
| 73 | + |
| 74 | + // Process results |
| 75 | + fmt.Printf("Found %d undocumented changes\n", len(result.UndocumentedChanges)) |
| 76 | +} |
51 | 77 | ```
|
52 | 78 |
|
53 | 79 | ## Requirements
|
54 | 80 |
|
55 | 81 | * Go 1.18+
|
56 | 82 | * Gemini API Key
|
57 | 83 | * Git (for repository analysis)
|
58 |
| - |
59 |
| -## Contributing |
60 |
| - |
61 |
| -Contributions welcome! As this is an experimental tool, we value feedback and improvements. |
|
0 commit comments