Skip to content

Commit 1850207

Browse files
authored
Merge pull request #152 from onSec-fr/main
Add a global flag to customize the User-Agent
2 parents 46bdb84 + f49fbb8 commit 1850207

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

client/rest/http.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,13 @@ func NewRequest(
128128
req.Header.Set("Accept", "application/json")
129129
}
130130

131-
// set azurehound as user-agent
132-
req.Header.Set("User-Agent", constants.UserAgent())
131+
// set azurehound as user-agent, use custom if set in config
132+
ua := config.UserAgent.Value()
133+
if s, ok := ua.(string); ok && s != "" {
134+
req.Header.Set("User-Agent", s)
135+
} else {
136+
req.Header.Set("User-Agent", constants.UserAgent())
137+
}
133138
return req, nil
134139
}
135140
}

config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ var (
354354
Default: "",
355355
}
356356

357+
UserAgent = Config{
358+
Name: "user-agent",
359+
Shorthand: "U",
360+
Usage: "Custom User-Agent header",
361+
Persistent: true,
362+
Default: "",
363+
}
364+
357365
GlobalConfig = []Config{
358366
ConfigFile,
359367
VerbosityLevel,
@@ -363,6 +371,7 @@ var (
363371
Proxy,
364372
RefreshToken,
365373
Pprof,
374+
UserAgent,
366375
}
367376

368377
AzureConfig = []Config{

0 commit comments

Comments
 (0)