mirror of
https://github.com/dragonheim/gagent.git
synced 2025-06-27 20:58:17 -07:00
fix: changed db destination to programatic instead of hardcoded.
fix: minor cleanup. feat: cleaned up agent hint collection.
This commit is contained in:
parent
13d18d7714
commit
2b0975b30a
3 changed files with 16 additions and 9 deletions
|
@ -69,13 +69,21 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
|||
*/
|
||||
func getTagsFromHints(agent gstructs.AgentDetails) []string {
|
||||
var tags []string
|
||||
re := regexp.MustCompile(`\s*set\s+GHINT\s*\[\s*split\s*"(?P<Hints>.+)"\s*\,\s*\]`)
|
||||
|
||||
// Use named capture groups to extract the hints
|
||||
re := regexp.MustCompile(`^*set\s+GHINT\s*\[\s*split\s*"(?P<Hints>[^"]+)"\s*,\s*\]`)
|
||||
res := re.FindStringSubmatch(string(agent.ScriptCode))
|
||||
if len(res) < 1 {
|
||||
|
||||
// If we don't have at least 2 matches, we have no hints
|
||||
if len(res) < 2 {
|
||||
log.Printf("[ERROR] Agent is missing GHINT tags")
|
||||
os.Exit(4)
|
||||
}
|
||||
tags = strings.Split(res[1], ",")
|
||||
|
||||
// Use named capturing group index
|
||||
hintsIndex := re.SubexpIndex("Hints")
|
||||
tags = strings.Split(res[hintsIndex], ",")
|
||||
|
||||
log.Printf("[DEBUG] G'Agent hints: %v\n", tags)
|
||||
|
||||
return tags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue