You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7ee15b1
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,7 +179,8 @@ They offer a free tier that allows for a limited number of queries per month, wh
179
179
180
180
> [!NOTE]
181
181
> The free account (as of April 2026) allows a single concurrent request and 100 requests per month.
182
-
> Once you've used all your credits, the `censys:` annotation will be empty for any following IPs until your credits refill the following month.
182
+
> Once you've used all your credits, the Censys API will return an error upon further requests until your credits reset at the beginning of the next month or you purchase additional credits.
183
+
> ZAnnotate will quit with an error if this occurs to prevent silent errors, so if you have a large dataset to annotate, be mindful of your credit usage and prioritize only annotating the IPs you have credits for.
183
184
> With the free account only offering a single concurrent request, you'll want to leave `--censys-threads=1` unless you pay for a higher tier.
184
185
185
186
1. Create an account at [Censys.io](https://censys.io) and get a Personal Access Token (PAT) from Personal Settings > Personal Access Tokens.
log.Debugf("failed to close response body: %v", err)
104
105
}
105
106
}(res.Body)
106
-
ifres.StatusCode!=http.StatusOK {
107
-
log.Debugf("failed to annotate ip %s with censys: %s", ip.String(), res.Status)
107
+
body, _:=io.ReadAll(res.Body)
108
+
ifres.StatusCode>=400&&res.StatusCode<500 {
109
+
// From https://docs.censys.com/reference/get-started#step-6-handle-http-response-codes
110
+
// 4XX errors are not transient and so we'll abort and report to the user
111
+
log.Fatalf("censys api returned an http status '%s' with message: '%s'. "+
112
+
"Cannot continue to annotate, please check that you have sufficient API credits and your PAT is correct", res.Status, strings.TrimSpace(string(body)))
113
+
114
+
} elseifres.StatusCode!=http.StatusOK {
115
+
// Should be a transient error, log and move on
116
+
log.Debugf("censys api returned an http %s status with message: '%s'. Skipping Censys annotation for this IP: %s", res.Status, strings.TrimSpace(string(body)), ip.String())
108
117
returnnil
109
118
}
110
-
body, _:=io.ReadAll(res.Body)
111
-
varresultany
119
+
// We have a successful response, unmarshall it.
120
+
// Struct taken from v1.1 of Censys API docs
121
+
varresultstruct {
122
+
Resultstruct {
123
+
Resourceany`json:"resource"`
124
+
} `json:"result"`
125
+
}
112
126
err=json.Unmarshal(body, &result)
113
127
iferr!=nil {
114
128
log.Debugf("failed to parse censys response for ip %s: %v", ip.String(), err)
115
129
returnnil
116
130
}
117
-
// By default, Censys' result is wrapped in a result[resource[real_data]]. We'll unwrap that here
0 commit comments