Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle blank AgentLastRuleUpdate #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jeremy-cxf
Copy link
Contributor

@jeremy-cxf jeremy-cxf commented Sep 4, 2024

Ran into some issues today running a debug util that uses ListAgents failed each time when the site contained an EdgeWAF. This is because the agents endpoint is returning:

      "agent.last_rule_update": "",

In the JSON response, which we try to unmarshal via:

AgentLastRuleUpdate         time.Time  `json:"agent.last_rule_update"`

Which results in:

2024/09/04 19:17:12 parsing time "" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "2006"

Could probably handle this from the API, but easier to just implement a custom Unmarshal() to handle the empty "" value in this scenario. I don't believe any other keys need to be changed, as AgentLastSeen is always updated.

	agents, err := sc.ListAgents("xxxx", "xxxxx")
	if err != nil {
		log.Fatal(err)
	}

	for _, agent := range agents {
		fmt.Println(agent.AgentName)
		fmt.Println(agent.AgentLastRuleUpdate)
	}

Now returns:

Site ID:  xxxxx
EdgeSecurity
0001-01-01 00:00:00 +0000 UTC
waf-lab-demo-cf9fcf48-gd6zt
2024-09-04 10:58:05 +0000 UTC

@jeremy-cxf jeremy-cxf requested a review from shawnps September 4, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant