mirror of
https://github.com/anotherhadi/iknowyou.git
synced 2026-04-11 16:37:25 +02:00
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package config
|
|
|
|
import "gopkg.in/yaml.v3"
|
|
|
|
// BuiltinProfile is a hardcoded, read-only profile with optional tool config overrides.
|
|
type BuiltinProfile struct {
|
|
Notes string
|
|
Profile Profile
|
|
Tools map[string]map[string]any
|
|
}
|
|
|
|
var BuiltinProfiles = map[string]BuiltinProfile{
|
|
"default": {
|
|
Notes: "Standard profile. All tools are active with default settings.",
|
|
Profile: Profile{},
|
|
},
|
|
"hard": {
|
|
Notes: "Aggressive profile. All tools are active, including those that may send notifications to the target.",
|
|
Profile: Profile{},
|
|
Tools: map[string]map[string]any{
|
|
"user-scanner": {"allow_loud": true},
|
|
"github-recon": {"deepscan": true},
|
|
},
|
|
},
|
|
}
|
|
|
|
func ApplyBuiltinToolOverride(profileName, toolName string, dst any) error {
|
|
builtin, ok := BuiltinProfiles[profileName]
|
|
if !ok || builtin.Tools == nil {
|
|
return nil
|
|
}
|
|
overrides, hasOverride := builtin.Tools[toolName]
|
|
if !hasOverride {
|
|
return nil
|
|
}
|
|
b, err := yaml.Marshal(overrides)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return yaml.Unmarshal(b, dst)
|
|
}
|
|
|
|
func ActiveToolsForProfile(p Profile, allToolNames []string) []string {
|
|
active := allToolNames
|
|
if len(p.Enabled) > 0 {
|
|
active = p.Enabled
|
|
}
|
|
if len(p.Disabled) > 0 {
|
|
blacklist := make(map[string]struct{}, len(p.Disabled))
|
|
for _, n := range p.Disabled {
|
|
blacklist[n] = struct{}{}
|
|
}
|
|
var filtered []string
|
|
for _, n := range active {
|
|
if _, skip := blacklist[n]; !skip {
|
|
filtered = append(filtered, n)
|
|
}
|
|
}
|
|
active = filtered
|
|
}
|
|
return active
|
|
}
|