339 Commits

Author SHA1 Message Date
Alexey Sokolov e7919287fe Merge pull request #2021 from dxbjavid/copy-preserve-mode
fileutils: open Copy() destination at the source's mode
2026-06-09 23:24:33 +01:00
dxbjavid 01678166a8 fileutils: force owner write while copying read-only sources
Opening the destination at the source's exact mode breaks when the
source lacks owner write (e.g. r-xr-xr-x): the create still works but
the overwrite path can't reopen such a destination for writing. Force
owner read+write while copying and let the trailing Chmod() put the
source mode back, which only ever adds owner bits so the group/other
bits stay as restrictive as the source throughout. Add a regression
test covering the restricted-mode and read-only-source cases.
2026-06-09 09:53:57 +05:30
Alexey Sokolov 53ffcc909b add include 2026-06-08 22:43:13 +01:00
Alexey Sokolov 2a9359d1fb Merge branch 'nossl' of github.com:DarthGandalf/znc into nossl 2026-06-08 22:07:34 +01:00
Alexey Sokolov ad12a6011d Skip tests which require SSL 2026-06-08 22:07:11 +01:00
Alexey Sokolov 14846166c6 Update test/integration/framework/znctest.cpp
Co-authored-by: dgw <dgw@technobabbl.es>
2026-06-08 22:00:37 +01:00
Alexey Sokolov 197a235764 test: Don't wait for SSL question if built without SSL
And don't hardcode 6667 in preparation for #2022
2026-06-08 21:54:34 +01:00
Alexey Sokolov a80cf49f5e Merge pull request #2018 from MarkLee131/fix/http-hardening-headers
HTTPSock: emit standard hardening response headers
2026-05-05 00:26:58 +01:00
Alexey Sokolov 663699b617 Merge pull request #2015 from MarkLee131/fix/cstring-empty-input-guards
ZNCString: guard Replace/Split against empty-width arguments
2026-05-04 22:05:49 +01:00
MarkLee131 80699c4178 test: use EXPECT_THAT matchers for Split assertions
Pull in gmock so the empty-delimiter Split assertions can keep using
EXPECT_THAT(..., ElementsAre(...)) and IsEmpty(). On failure the matcher
prints the actual vector contents, which EXPECT_TRUE(vempty.empty())
hides behind a bare 'not true'.
2026-05-04 20:51:56 +08:00
MarkLee131 83e7eefc21 HTTPSock: tighten hardening header defaults
Switch the default Referrer-Policy from same-origin to no-referrer so the
webadmin URL (which can carry user/network names in the path) does not
leak to outbound clicks either.

Drop Pragma: no-cache; it is deprecated and modern intermediaries honor
Cache-Control. Simplify Cache-Control to a single no-store directive,
which on its own already prevents storing per RFC 9111; the previous
no-cache, must-revalidate, max-age=0 tail was HTTP/1.0-era padding.
2026-05-04 20:35:23 +08:00
MarkLee131 c3f1b0c00e test: replace gmock matchers in Split test with gtest equivalents
StringTest.cpp does not include gmock, so EXPECT_THAT/ElementsAre/IsEmpty
do not compile and the unittest target fails on every CI configuration.
Use EXPECT_EQ against a VCString and EXPECT_TRUE(empty()) instead, which
keeps the test scope identical without dragging gmock into this file.
2026-05-04 19:31:29 +08:00
Alexey Sokolov f35e565637 Merge pull request #2013 from MarkLee131/fix/base64-decode-ub
ZNCString: avoid left shift of negative value in Base64Decode
2026-05-01 22:23:24 +01:00
Alexey Sokolov 6186f611b9 Merge pull request #2017 from MarkLee131/fix/checkpass-constant-time
User: use constant-time compare for MD5/SHA256/plain password paths
2026-04-30 08:23:07 +01:00
MarkLee131 f71e021e3b HTTPSock: emit standard hardening response headers
Close #2012.

Add X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff and
Referrer-Policy: same-origin to every response so webadmin and module
pages are framed/sniff-protected by default. Add no-store Cache-Control
and Pragma: no-cache on dynamic responses so shared workstations can't
replay authenticated pages from browser history. Skip the cache headers
for 304 and for static asset MIME types (image, font, text/css,
application/javascript) that the existing ETag/Last-Modified path on
PrintFile already handles.

Per review feedback: the emitter is a private WriteHardeningHeaders that
writes each line via the socket directly from PrintHeader, not a public
helper returning a temporary VCString. Callers can override a default
value with AddHeader, or suppress one outright with the new public
OmitHardeningHeader(name).

Tests: drive PrintHeader on a CHTTPSock subclass that captures Write()
calls, then assert with gmock matchers (Contains(StartsWith(...))).
2026-04-29 20:29:47 +08:00
MarkLee131 099895b1f0 test: fix \xff hex escape parsing in Base64 test for stricter compilers
GCC parses "AA\xffA" greedily as \xffA (next character is a hex digit),
which is out of range for char and breaks the Linux CI build. Split the
literal into "AA\xff" "A" so the escape resolves before the next string,
yielding the intended four bytes (A, A, 0xff, A).
2026-04-29 19:33:30 +08:00
MarkLee131 8d92fe7933 Update test/StringTest.cpp
Co-authored-by: Alexey Sokolov <alexey+github@asokolov.org>
2026-04-28 22:11:13 +08:00
MarkLee131 bee6d9443c Update test/StringTest.cpp
Co-authored-by: Alexey Sokolov <alexey+github@asokolov.org>
2026-04-28 22:11:02 +08:00
Alexey Sokolov 866303eef0 Merge pull request #2014 from MarkLee131/fix/parseservertime-clamp-range
Utils: reject out-of-range years in ParseServerTime
2026-04-27 01:43:24 +01:00
MarkLee131 20e8f73b03 HTTPSock: extract IsValidHeaderField helper and add tests (#2010) 2026-04-25 17:38:31 +08:00
MarkLee131 f0c3341e35 User,Utils: move ConstantTimeEquals to CUtils and add tests (#2011) 2026-04-25 17:37:33 +08:00
MarkLee131 7c47afa888 test: cover ParseServerTime out-of-range year rejection (#2008) 2026-04-25 17:34:58 +08:00
MarkLee131 d60f489c27 test: cover Base64Decode round-trip and out-of-alphabet bytes (#2013) 2026-04-25 17:34:11 +08:00
MarkLee131 c94df21130 test: cover empty-needle Replace and empty-delim Split (#2009) 2026-04-25 17:26:04 +08:00
jabberwock 20908fc2d1 test: add GetParamsColon unit tests including out-of-bounds uIdx cases 2026-03-17 09:39:50 -07:00
Falk Rund ad6a397ca4 Welcome to 2026
[skip ci]
2026-01-01 13:44:32 +01:00
Alexey Sokolov d8b8c16783 Merge branch '1.10.x' 2025-12-10 00:55:07 +00:00
Alexey Sokolov 8c983564e8 Add test for modperl SCString functions.
Pass CClient to the OnClientGetSASLMechanisms callback.

See #1970
2025-07-31 23:47:26 +01:00
KindOne d9ee1da873 Fix spacing in StripControls test. 2025-07-15 00:01:31 -04:00
RealKindOne f89ae9d158 stripcontrols: Use new On...Message events.
Added OnTopicMessage and stripping for /list and /topic output.

Fixes #1179
2025-07-08 01:35:52 -04:00
RealKindOne b61e21e079 Fix AwayNotify test. 2025-07-06 23:02:10 -04:00
RealKindOne 106a9fcbb4 Make account, away-notify, and chghost only send to client if attached into a channel. 2025-06-26 10:15:13 -04:00
Alexey Sokolov 4b12c0dc3c Fix nullptr dereference
If client sends TAGMSG while server is not connected
2025-06-23 22:52:34 +01:00
Alexey Sokolov 7b7f691213 Don't store "this" in static variable
Fix #1960

This could also cause use-after-free if the first connected socket disconnects
2025-06-23 22:41:08 +01:00
Alexey Sokolov b32d3dbbc9 Fix test on cygwin
Depending on timing between client and server, the initial JOIN can come in either order - in one case forwarding directly from client, in another joining the channels after client disconnected.
2025-06-09 20:20:50 +01:00
Alexey Sokolov aaeab22ea3 Fix processing of multi-token CAP ACK
I broke it in 5943bc9ed9 while fixing #1950
2025-05-11 18:49:35 +01:00
Alexey Sokolov 4a15e1cf36 Fix unit test after previous change
See #1949
2025-05-10 21:00:22 +01:00
Alexey Sokolov 3d1551b7f2 Don't forward client JOINs during registration
ZNC remembers that it should join these channels, and will join them after registration. But if client automatically joins some channels, we don't want it to be added to send queue before parts of registration itself (CAP, AUTHENTICATE), because server will just disconnect with "Registration timeout". After registration is complete, using /join still joins the channel immediately.

Only limiting this to joins, because server may request some input from user to finish registration, and joins are the ones which are prone to be sent automatically by client to cause issues.

Fix #1949
2025-05-10 20:09:25 +01:00
Alexey Sokolov 5943bc9ed9 Send several caps in the same CAP REQ
If they got NAKed, then retry them one by one

This should speed up the usual case

Fix #1950
2025-05-09 23:46:11 +01:00
Alexey Sokolov c2f299abdf Filter out server-dependent caps in CAP NEW using blacklist too 2025-05-08 23:25:58 +01:00
Alexey Sokolov 1c197a5508 Add a way to disable certain capabilities
This is a way for admins to mitigate some issues caused by caps if such issues ever arise.

E.g. add this to global level in znc.conf:

DisableClientCap = sasl
DisableServerCap = chghost
DisableServerCap = message-tags

Then these caps will be NAKed to client / not requested from server.

Note that this mechanism doesn't fully prevent a cap from being activated, e.g. one could use *send_raw module to request it from server even when disabled.
2025-05-08 21:55:40 +01:00
Alexey Sokolov 1063b7f5d6 CI: handle the case where junit is not outputted
though maybe github actions should also use one
2025-05-04 19:56:35 +01:00
Alexey Sokolov ca6ae51179 CI: try to fix jenkins from counting every test twice 2025-05-04 19:41:11 +01:00
Alexey Sokolov 2f110896e7 CI: restore JUnit output processing in Jenkinsfile
via wrapper which modifies the environment per test

Workaround for https://github.com/google/gtest-parallel/pull/89
2025-05-04 18:38:43 +01:00
Alexey Sokolov 50f085cc2f Disable i18n test when i18n is disabled 2025-05-04 10:36:48 +01:00
Alexey Sokolov 00579d151e Pass %p to LLVM_PROFILE_FILE instead of wrapper 2025-05-01 22:44:39 +01:00
Alexey Sokolov 2f02a9ea00 Merge branch 'master' into unix 2025-05-01 22:41:27 +01:00
Alexey Sokolov 5974d0ff3b Workaround for parallel writing of LLVM profiler data
Skip failing tests on cygwin: we'll just have to mark the unix socket feature as "experimental", but shouldn't block merging it due to cygwin being weird
2025-05-01 22:24:10 +01:00
Alexey Sokolov 5184d662d3 macos test probably should be fixed now 2025-04-28 22:08:13 +01:00
Alexey Sokolov 81e7fd69de WIP debugging failures on mac and cygwin... 2025-04-28 00:55:13 +01:00