108 Commits

Author SHA1 Message Date
Julian Brost
4023128be4 VerifyCertificate: Work around issue in OpenSSL < 1.1.0 causing invalid certifcates being treated as valid
Old versions of OpenSSL stored a valid flag in the certificate (see inline code
comment for details) that if already set, causes parts of the verification to
be skipped and return that the certificate is valid, even if it's not actually
signed by the CA in the trust store.

This issue was assigned CVE-2025-48057.
2025-05-21 10:50:12 +02:00
Julian Brost
5404143dee Ensure consistent mktime() DST behavior across different implementations
There are inputs to mktime() where the behavior is not specified and there's
also no single obviously correct behavior. In particular, this affects how
auto-detection of whether DST is in effect is done when tm_isdst = -1 is set
and the time specified does not exist at all or exists twice on that day.

If different implementations are used within an Icinga 2 cluster, that can lead
to inconsistent behavior because different nodes may interpret the same
TimePeriod differently.

This commit introduces a wrapper to mktime(), namely Utility::NormalizeTm()
that implements the behavior provided by glibc. The choice for glibc's behavior
is pretty arbitrary, it was simply picked because most systems that are
officially/fully supported use it (with the only exception being Windows), so
this should give the least possible amount of user-visible changes.

As part of this commit, the closely related helper function mktime_const() is
also moved to Utility::TmToTimestamp() and made a wrapper around the newly
introduced NormalizeTm().
2025-04-28 13:38:55 +02:00
Julian Brost
de4b58a04f tests: Move make_tm helper function to utils file
Preparation to be able to use the function from different test files later on.
2025-04-28 13:38:32 +02:00
Yonas Habteab
b462028b4f Add basic unittests for bulk group registration 2025-03-19 16:28:00 +01:00
Yonas Habteab
2616c99891 tests: Add unittests for the redundancy groups registry 2025-03-12 16:32:01 +01:00
Yonas Habteab
3e9292a349 Value: Add a specialized rvalue reference of Get()
The move `String(Value&&)` constructor tries to partially move `String`
values from a `Value` type. However, since there was no an appropriate
`Value::Get<T>()` implementation that binds to the requested move
operation, the compiler will actually not move the value but copy it
instead as the only available implementation of `Value::Get<T>()`
returns a const reference `const T&`. This commit adds a new overload
that returns a non-const reference and allows to optionally move the string
value of a Value type.
2025-03-07 10:16:31 +01:00
Julian Brost
e308552ecc Add test that std::vector<icinga::String> uses move overloads 2025-03-06 13:02:40 +01:00
Alexander A. Klimov
8cdbea303b Test Timeout 2025-01-07 18:18:39 +01:00
Yonas Habteab
eb97676d69 Add basic test cases for Type::GetConfigTypesSortedByLoadDependencies() 2024-09-20 16:18:12 +02:00
Julian Brost
090dcfd70f Add tests for Utility::FormatDateTime() 2024-08-22 12:23:22 +02:00
Julian Brost
4c83d793a6
Merge pull request #9983 from Icinga/broken-timeperiod
Fix broken `TimePeriod/ScheduledDowntime`s
2024-08-20 10:05:59 +02:00
Julian Brost
c45829b59f Timeperiods: fix off by one when calculating n-th last weekday of the month
A day specification like "monday -1" refers to the last Monday of the month.
However, there was an off by one if the first day of the next month is the same
day of the week, i.e. a Monday in this example.

LegacyTimePeriod::FindNthWeekday() picks a day to start the search for the day
in question. When given a negative n to search for the n-th last day, it
wrongly used the first day of the following month as the start and counted it
as if it was within the current month. This resulted in a 1/7 chance that the
result was one week too late.

This is fixed by using the last day of the current month instead.
2024-08-07 12:06:05 +02:00
Yonas Habteab
4f94891b52 Add advanced timeperiod range,include/exclude test cases 2024-08-02 11:12:51 +02:00
Yonas Habteab
ddf7143777 tests: Add some basic tests cases for LegacyTimePeriod::IsInTimeRange() 2024-08-02 11:12:51 +02:00
Maciej Dems
2bb5cc62e2 Fix missing values in PerfData normalization 2024-04-25 17:41:12 +02:00
Alexander Aleksandrovič Klimov
949d983a76
Merge pull request #9895 from Icinga/targeted-api-filter
FilterUtility::GetFilterTargets(): don't run filter for specific object(s) for all objects
2023-12-19 15:18:41 +01:00
Alexander Aleksandrovič Klimov
8b2e28a869
Merge pull request #9891 from Icinga/renew-the-ca-9890
ApiListener#Start(): auto-renew CA on its owner
2023-12-19 14:57:47 +01:00
Alexander A. Klimov
175153ce6a PluginNotificationTask::ScriptFunc(): on Linux truncate output and comment
not to run into an exec(3) error E2BIG due to a too long argument.
This sends a notification with truncated output instead of not sending.
2023-12-19 12:21:03 +01:00
Alexander A. Klimov
dc338a406a Test IsCertUptodate() and IsCaUptodate() 2023-12-18 15:28:11 +01:00
Alexander A. Klimov
191bf93f2e Test ApplyRule::GetTarget*s() 2023-12-18 13:07:31 +01:00
Alexander A. Klimov
97cd05db7a Notification#BeginExecuteNotification(): on recovery clear last_notified_state_per_user 2023-12-13 13:21:22 +01:00
Alexander A. Klimov
44e9c6f40d Notification#BeginExecuteNotification(): discard likely duplicate problem notifications 2023-12-13 13:21:19 +01:00
Yonas Habteab
e7c5554d87 Test: Add multiline PerfData test case 2023-04-05 15:44:13 +02:00
Julian Brost
90848f602b Checkable: Add test for state notifications after a suppression ends 2022-03-03 14:25:23 +01:00
Julian Brost
7b2667400b Add tests for LegacyTimePeriod::ScriptFunc when used by TimePeriod::IsInside 2021-11-17 13:09:10 +01:00
Noah Hilverling
10bde2075a Dictionary: Make sure underlaying map is ordered 2021-11-12 13:34:57 +01:00
Julian Brost
d07d48b169 Add tests for DST handling in TimePeriods and ScheduledDowntimes 2021-07-26 16:09:20 +02:00
Alexander A. Klimov
ea5411a6e0 PluginUtility::FormatPerfdata(): normalize UoMs if desired 2021-07-05 19:05:32 +02:00
Alexander Aleksandrovič Klimov
2cd9c1d902
Merge pull request #8835 from Icinga/bugfix/api-filename-truncation
Fix/restrict truncation of filenames for API-created objects
2021-06-23 12:06:31 +02:00
Julian Brost
97d6876803 Utility: add a function to truncate strings while avoiding collisions 2021-06-17 16:21:01 +02:00
Julian Brost
c40b18ef61 ConfigPackageUtility::ValidateName: replace broken regex
The old validation regex matched if the name consists only of invalid
character, not that it does not contain them, i.e. something like "foo/bar" was
considered valid.

This commit replaces the regex with a check that all characters in the name are
allowed characters.
2021-06-15 12:16:54 +02:00
Julian Brost
06999faf25 Allow using E in perfdata both as exponent and unit prefix 2021-06-08 12:37:13 +02:00
Julian Brost
62cbe72cdb
Merge pull request #8492 from Icinga/bugfix/perfdata-scientific-notation
Fix perfdata parser not recognize scientific notation
2021-06-07 15:29:52 +02:00
Julian Brost
49cfda833e Add tests for SHA1 function 2021-03-19 10:31:01 +01:00
Alexander Aleksandrovič Klimov
dbdfe189c0
Merge pull request #7092 from Icinga/bugfix/command-escape-windows-4849
Fix Windows command escape for \"
2021-02-01 11:20:44 +01:00
Julian Brost
56095b29f4 Add tests for Utility::EscapeCreateProcessArg 2021-01-29 15:15:43 +01:00
Michael Insel
e070651203 Add test-case for perfdata scientific notation 2020-11-27 11:40:10 +01:00
Michael Friedrich
3a4fb840d4 Tests: Add multi parent dependency test case 2020-02-11 15:13:25 +01:00
Michael Friedrich
da982c256b Add unit test for Utility::CompareVersion 2019-08-14 13:14:43 +02:00
Michael Friedrich
96f62d2d34 Add Utility::ParseVersion() and unit tests
This now uses a regex to extract the short version
similar to how Icinga Web 2 does it.

Additional unit tests prove the rule.
2019-08-14 11:22:55 +02:00
Michael Friedrich
9c5f280a85 Tests: Add Notification state/type to string cases 2019-07-16 13:46:22 +02:00
Michael Friedrich
5e931fe127 Tests: Add cases for LegacyTimePeriod::ProcessTimeRangeRaw() 2019-06-06 13:11:34 +02:00
Michael Friedrich
6ace8001d8
Merge pull request #7019 from Icinga/feature/new-json-library
Replace YAJL with nlohmann::json
2019-03-18 17:26:57 +01:00
Alexander A. Klimov
c4333b49f5 Test Json{En,De}code() 2019-03-18 15:07:57 +01:00
Alexander A. Klimov
60ec11de73 Test Utility::ValidateUTF8() 2019-03-15 13:34:20 +01:00
Michael Friedrich
458f997a18 Replace Copyright header with a short version, part II 2019-02-25 15:09:36 +01:00
Alexander A. Klimov
1b00331a88 Test Utility::ComparePasswords() 2019-02-22 16:59:36 +01:00
Michael Friedrich
9d73f0cf30 Implement unit tests for Dictionary initializers 2018-11-09 14:56:36 +01:00
Michael Friedrich
dea5ec614e icinga.com: Update CMakeLists.txt 2018-10-18 09:35:18 +02:00
Alexander A. Klimov
d21a218527 Test PackObject 2018-07-27 13:57:28 +02:00