Repository navigation
Conversation
larsewi
left a comment
There was a problem hiding this comment.
Please separate each bug fix into their own commits with a changelog.
Covers the current behaviour, before refactoring them. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FuzzySetMatch() now returns -1 instead of the strncmp() result when a prefix does not match. All callers only compare the result to 0. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FuzzySetMatch() now determines the notation of the pattern (prefix, CIDR or range) and calls the matching helper. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| (address[len] == '\0' || address[len] == '.'); | ||
| } | ||
|
|
||
| static bool MatchIPv4CIDR(const char *pattern, const char *address) |
craigcomstock
left a comment
There was a problem hiding this comment.
some comments, but looks good to me!
larsewi
left a comment
There was a problem hiding this comment.
Lot's of great improvements. And it's much more digestible with smaller commits. Great work! 🚀
I'm a little bit uncertain if these functions should spam the error log. A normal use case could be to check is something is an IP address. In that case, I don't want to see a bunch of errors spammed to the logs if it's not. It would make me think that something is wrong. And also it would probably spam the system log. Maybe LOG_LEVEL_VERBOSE would be better option here?
I think the change log entries can also be phrased a bit better.
It now splits host and port first and determines the address type afterwards, instead of doing both in each branch. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was never defined. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Groups without a range, e.g. "fe80", were parsed as decimal, so "fe80:1-3:0:0:0:0:0:1" matched "fe81:2:0:0:0:0:0:1". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"2001:10-20:0:0:0:0:0:1" did not match "2001:10:0:0:0:0:0:1". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Neither in the pattern nor in the address, so "2001:db8:1-5::1" never matched "2001:db8:3::1". Invalid groups are now rejected too. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ctet When an octet failed to parse, the value of the previous octet was compared instead, so "10.x.0.1-50" matched "10.10.0.25". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re now rejected The address was never validated, so an uninitialized address was compared, and e.g. "bogus/0" matched every address. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ranges FuzzyMatchParse() always returned true. It now uses the same parsers as FuzzySetMatch(), including for CIDR patterns. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FuzzyHostMatch() read before the start of its buffer when the host name was empty or only digits. Only visible with ASan/valgrind. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d32863c to
b864e94
Compare
There was a problem hiding this comment.
- Host names starting with a digit are no longer being parsed as IPv4 addresses
- Invalid IP addresses and ranges are now logged at verbose level
Probably need some more context here in the change log. These are policy functions right? Maybe mention which ones. It's better to do this proper now, then the release manager having to figure this out. Sorry I did not mention this before.
Otherwise looks great!
… digit It contained the host name, e.g. "1password.com", instead of its IP address. ParseHostPort() now uses inet_pton() to detect IPv4. Changelog: Title Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There is nothing fuzzy about them. IPRangeMatch() and HostRangeMatch() now return true on match, like StringMatch(), instead of 0. Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The acl argument is always dereferenced. Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… level
E.g. isipinsubnet("10.0.0.0/8", "not-an-ip-address") logged an error.
The same applies to IP lists in cf-serverd, e.g. admit_ips and allowconnects.
Changelog: Commit
Ticket: ENT-14276
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@cf-bottom Jenkins please :) |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/15155/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-15155/ |
No description provided.