Repository navigation
exprhelpers: LookupHost goes through the DNS cache - #4741
Conversation
LookupHost called net.LookupHost on every evaluation. In a parser whitelist that is one DNS query per log line and name. It now uses dnscache.ForwardIPs, as MatchKnownBot does.
|
@twiesing: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository. |
|
@twiesing: There are no area labels on this PR. You can add as many areas as you see fit.
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository. |
|
/kind enhancement |
dnscache keeps the error of a failed forward lookup with its empty result, and ForwardLookup returns both. LookupHost logs it at error level, as it did before it used the cache. ForwardIPs is unchanged. The subtests of TestLookupHost each have a resolver and a cache of their own.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4741 +/- ##
==========================================
+ Coverage 71.25% 71.27% +0.01%
==========================================
Files 542 542
Lines 36737 36743 +6
==========================================
+ Hits 26178 26189 +11
+ Misses 10558 10553 -5
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…pHost caching (#1191) Document the optional scenario argument of GetDecisionsSinceCount (crowdsecurity/crowdsec#4756) and LookupHost going through the DNS cache (crowdsecurity/crowdsec#4741). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… ➔ v1.8.2) (#1487) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1` → `v1.8.2` | | [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1-debian` → `v1.8.2-debian` | --- ### Release Notes <details> <summary>crowdsecurity/crowdsec (docker.io/crowdsecurity/crowdsec)</summary> ### [`v1.8.2`](https://github.com/crowdsecurity/crowdsec/releases/tag/v1.8.2) [Compare Source](crowdsecurity/crowdsec@v1.8.1...v1.8.2) ##### Version 1.8.2 - Brings [custom JS fingerprinting capabilities](https://docs.crowdsec.net/docs/next/appsec/bot_detection/custom_js/) to the bot detection feature, allowing both users and us to distribute detection rules directly via the hub. - Brings [rate limiting feature](https://docs.crowdsec.net/docs/next/appsec/rate_limiting/) to the WAF. - Brings performance improvements to the Security Engine, optimizing both memory copy behaviors and relying on static analysis to avoid processing unnecessary regular expressions. - Brings performance improvements to the WAF, optimizing out-of-band rules processing. - Brings performance improvements to the Bot Detection, optimizing memory usage. ##### New Features & Major improvements - \[WAF] Add RateLimiting feature ([#​4721](crowdsecurity/crowdsec#4721)) [@​blotus](https://github.com/blotus) - \[bot-detection] Add custom JS fingerprinting capabilities ([#​4657](crowdsecurity/crowdsec#4657)) [@​buixor](https://github.com/buixor) - \[bot-detection] Add cscli bot subcommand ([#​4666](crowdsecurity/crowdsec#4666)) [@​blotus](https://github.com/blotus) - \[WAF] Improve out-of-band rules performances ([#​4722](crowdsecurity/crowdsec#4722)) [@​blotus](https://github.com/blotus) - \[Security Engine] Run postoverflows in a separate goroutine to avoid blocking on slow enrichments ([#​4672](crowdsecurity/crowdsec#4672)) [@​blotus](https://github.com/blotus) - \[bot-detection] Improve memory usage ([#​4674](crowdsecurity/crowdsec#4674)) [@​blotus](https://github.com/blotus) - \[Security Engine] Various performance improvements to regular expression processing ([#​4736](crowdsecurity/crowdsec#4736)) ([#​4731](crowdsecurity/crowdsec#4731)) ([#​4729](crowdsecurity/crowdsec#4729)) [@​blotus](https://github.com/blotus) [@​buixor](https://github.com/buixor) ##### Improvements - Add `cs_features` metric ([#​4770](crowdsecurity/crowdsec#4770)) [@​blotus](https://github.com/blotus) - bot detection: add an option to set SameSite=None + Partitioned flag on cookie ([#​4764](crowdsecurity/crowdsec#4764)) [@​blotus](https://github.com/blotus) - exprhelpers: add GetDecisionsSinceCountByScenario ([#​4756](crowdsecurity/crowdsec#4756)) [@​tommy-ng0](https://github.com/tommy-ng0) - lapi: optionally limit concurrent decision stream requests ([#​4747](crowdsecurity/crowdsec#4747)) [@​tommy-ng0](https://github.com/tommy-ng0) - exprhelpers: LookupHost goes through the DNS cache ([#​4741](crowdsecurity/crowdsec#4741)) [@​twiesing](https://github.com/twiesing) - metrics: add CAPI last pull timestamp and error counter ([#​4749](crowdsecurity/crowdsec#4749)) [@​NazarkinRoman](https://github.com/NazarkinRoman) - prometheus: add kind label to cs_alerts ([#​4742](crowdsecurity/crowdsec#4742)) [@​blotus](https://github.com/blotus) - lapi: make decisions stream page size configurable ([#​4733](crowdsecurity/crowdsec#4733)) [@​tommy-ng0](https://github.com/tommy-ng0) - Fix ValidateChallengeResponse ([#​4737](crowdsecurity/crowdsec#4737)) [@​buixor](https://github.com/buixor) - bot-detection: add new FlagSubmission() helper ([#​4727](crowdsecurity/crowdsec#4727)) [@​blotus](https://github.com/blotus) - appsec: add an optional category to the request score ([#​4715](crowdsecurity/crowdsec#4715)) [@​buixor](https://github.com/buixor) - apiserver: reload the TLS server certificate when its files change ([#​4709](crowdsecurity/crowdsec#4709)) [@​ohartwig](https://github.com/ohartwig) - fix image link ([#​4702](crowdsecurity/crowdsec#4702)) [@​buixor](https://github.com/buixor) - waf: add SkipProcessing() helper ([#​4667](crowdsecurity/crowdsec#4667)) [@​blotus](https://github.com/blotus) - \[bot-detection] drop the URI from the cookie ([#​4656](crowdsecurity/crowdsec#4656)) [@​buixor](https://github.com/buixor) ##### Bug Fixes - acquisition/file: don't send half-written lines, or skip the lines after them ([#​4678](crowdsecurity/crowdsec#4678)) [@​n1koo](https://github.com/n1koo), [@​blotus](https://github.com/blotus), [@​claude](https://github.com/claude) - fix(cscli): display human-readable timestamps in local time ([#​4759](crowdsecurity/crowdsec#4759)) [@​sep2](https://github.com/sep2) - remove runtime Fatalf calls ([#​4760](crowdsecurity/crowdsec#4760)) [@​blotus](https://github.com/blotus) - waf: fix log spam when usin unix socket on freebsd ([#​4745](crowdsecurity/crowdsec#4745)) [@​blotus](https://github.com/blotus) - docker: read from now if container restarts ([#​4605](crowdsecurity/crowdsec#4605)) [@​blotus](https://github.com/blotus) - splunk-notification: add an option to configure InsecureSkipVerify ([#​4720](crowdsecurity/crowdsec#4720)) [@​blotus](https://github.com/blotus) - victorialogs: move the datasource to RestartableStreamer interface ([#​4738](crowdsecurity/crowdsec#4738)) [@​blotus](https://github.com/blotus) - metrics: remove series of deleted machines and bouncers ([#​4712](crowdsecurity/crowdsec#4712)) [@​somaz94](https://github.com/somaz94) - buckets: make a copy of all event maps before pouring the event to a bucket ([#​4481](crowdsecurity/crowdsec#4481)) [@​blotus](https://github.com/blotus) - fix(database): keep simulated decisions from suppressing real bans ([#​4679](crowdsecurity/crowdsec#4679)) [@​4erdenko](https://github.com/4erdenko), [@​blotus](https://github.com/blotus) - fix a nasty bug in transfrom where the effective uuid for a datasource ([#​4697](crowdsecurity/crowdsec#4697)) [@​sabban](https://github.com/sabban) - hubtest: add a tiebreaker based on the alert date to have a consistent order ([#​4699](crowdsecurity/crowdsec#4699)) [@​blotus](https://github.com/blotus) - syslog: copy buffer before handing it to the datasource ([#​4690](crowdsecurity/crowdsec#4690)) [@​blotus](https://github.com/blotus) - Expand env vars in online_api_credentials.yaml ([#​4677](crowdsecurity/crowdsec#4677)) [@​kushiemoon-dev](https://github.com/kushiemoon-dev) ##### Chore / Deps - build(deps): bump the gomod group with 5 updates ([#​4778](crowdsecurity/crowdsec#4778)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the github-actions group with 2 updates ([#​4777](crowdsecurity/crowdsec#4777)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump certifi from 2026.1.4 to 2026.10.19 in /build/docker/test ([#​4780](crowdsecurity/crowdsec#4780)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the github-actions group across 1 directory with 8 updates ([#​4766](crowdsecurity/crowdsec#4766)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 16 updates ([#​4767](crowdsecurity/crowdsec#4767)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 8 updates ([#​4753](crowdsecurity/crowdsec#4753)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - fpscanner: use fork ([#​4761](crowdsecurity/crowdsec#4761)) [@​blotus](https://github.com/blotus) - waf: update to coraza 3.8.0 ([#​4724](crowdsecurity/crowdsec#4724)) [@​blotus](https://github.com/blotus), [@​buixor](https://github.com/buixor) - build(deps): bump the gomod group across 1 directory with 19 updates ([#​4730](crowdsecurity/crowdsec#4730)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - CI: skip more docker tests on windows ([#​4728](crowdsecurity/crowdsec#4728)) [@​blotus](https://github.com/blotus) - grok: embed grok library instead of having it as a dep ([#​4725](crowdsecurity/crowdsec#4725)) [@​blotus](https://github.com/blotus) - docker datasource: skip tests on windows ([#​4719](crowdsecurity/crowdsec#4719)) [@​blotus](https://github.com/blotus) - agents.md: keep comments to a reasonable level ([#​4716](crowdsecurity/crowdsec#4716)) [@​blotus](https://github.com/blotus) - build(deps): bump the github-actions group with 7 updates ([#​4693](crowdsecurity/crowdsec#4693)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 11 updates ([#​4694](crowdsecurity/crowdsec#4694)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump github.com/go-openapi/validate from 0.26.5 to 1.0.0 ([#​4682](crowdsecurity/crowdsec#4682)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group with 19 updates ([#​4681](crowdsecurity/crowdsec#4681)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump cryptography from 48.0.1 to 50.0.0 in /build/docker/test ([#​4591](crowdsecurity/crowdsec#4591)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - bump to go 1.27 ([#​4675](crowdsecurity/crowdsec#4675)) [@​blotus](https://github.com/blotus) - build(deps): bump the github-actions group across 1 directory with 3 updates ([#​4658](crowdsecurity/crowdsec#4658)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - build(deps): bump the gomod group across 1 directory with 21 updates ([#​4659](crowdsecurity/crowdsec#4659)) [@​dependabot\[bot\]](https://github.com/apps/dependabot) - AGENTS.md: clearer guidance on tests ([#​4713](crowdsecurity/crowdsec#4713)) [@​blotus](https://github.com/blotus) - pimp readme ([#​4701](crowdsecurity/crowdsec#4701)) [@​buixor](https://github.com/buixor) ##### Geolite2 notice This product includes GeoLite2 data created by MaxMind, available from <a href="https://www.maxmind.com"><https://www.maxmind.com></a>. ##### Installation Take a look at the [installation instructions](https://doc.crowdsec.net/docs/getting_started/install_crowdsec). </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/Berlin) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.xcd.dev/gabrielcosi/home-ops/pulls/1487
What and why
LookupHostcallednet.LookupHoston every evaluation, so a parser whitelist likeevt.Meta.source_ip in LookupHost("home.example.com")did one DNS query per log line and name. It now goes throughdnscache.ForwardIPs, asMatchKnownBotdoes.Behaviour changes:
crowdsec_service.dns_cache), not at the next call.ForwardIPslowercases the name and drops a trailing dot, soLookupHost("host.example.com.")is resolved ashost.example.comand the resolver's search domains apply to it. I leftForwardIPsas it is (TestForwardIPsKeyNormalizationwants that); say ifLookupHostshould keep the dot.Fixes #4740
How it was tested
The new test fails on master (no call reaches the resolver of the cache) and passes with the change.
The whole suite (
TEST_LOCAL_ONLY=1 go test -tags=... ./...) on my Mac fails inpkg/acquisition,acquisition/modules/file,acquisition/modules/http,apiclient,csconfigandcsplugin, with the same tests on master, so I leave that to CI.Checklist
cscli -o json|rawoutput.AI assistance used: mostly