-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
102 lines (92 loc) · 1.99 KB
/
Copy pathconfig.go
File metadata and controls
102 lines (92 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package main
import (
"encoding/json"
"os"
)
type Config struct {
Version int `json:"version"`
Scan ScanConfig `json:"scan"`
Allowlist []AllowlistEntry `json:"allowlist"`
Notify NotifyConfig `json:"notify"`
AI AIConfig `json:"ai"`
}
type ScanConfig struct {
Paths []string `json:"paths"`
ExcludePaths []string `json:"exclude_paths"`
ExcludeFiles []string `json:"exclude_files"`
MaxFileSize int64 `json:"max_file_size_kb"`
}
type AllowlistEntry struct {
Hash string `json:"hash,omitempty"`
Pattern string `json:"pattern,omitempty"`
File string `json:"file,omitempty"`
Reason string `json:"reason,omitempty"`
}
type NotifyConfig struct {
SlackWebhook string `json:"slack_webhook"`
DiscordWebhook string `json:"discord_webhook"`
}
type AIConfig struct {
Provider string `json:"provider"`
KeyEnv string `json:"api_key_env"`
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
}
var DefaultConfig = `{
"version": 1,
"scan": {
"paths": ["."],
"exclude_paths": [
"vendor/",
"node_modules/",
".git/",
"dist/",
"build/"
],
"exclude_files": [
"*.min.js",
"*.min.css",
"*.lock",
"go.sum"
],
"max_file_size_kb": 1024
},
"allowlist": [
{
"pattern": "EXAMPLE_.*",
"reason": "Placeholder values"
}
],
"notify": {
"slack_webhook": "",
"discord_webhook": ""
},
"ai": {
"provider": "anthropic",
"api_key_env": "ANTHROPIC_API_KEY",
"model": "claude-sonnet-4-20250514",
"max_tokens": 512
}
}
`
func LoadConfig(path string) *Config {
cfg := &Config{
Version: 1,
Scan: ScanConfig{
Paths: []string{"."},
MaxFileSize: 1024,
},
AI: AIConfig{
Provider: "anthropic",
KeyEnv: "ANTHROPIC_API_KEY",
Model: "claude-sonnet-4-20250514",
MaxTokens: 512,
},
}
data, err := os.ReadFile(path)
if err != nil {
return cfg
}
json.Unmarshal(data, cfg)
return cfg
}