Commit graph

212 commits

Author SHA1 Message Date
Andreas Baumann
8d44bd8e69 added CHECK_EOF to work around warnings about EOF and -1 being the same 2026-01-23 08:57:19 +01:00
Lorenz Kästle
bbc0c8b29f check_curl: clang-format 2026-01-09 13:10:23 +01:00
Lorenz Kästle
544ea5bf95 Fix error message formatting 2026-01-09 13:09:46 +01:00
Lorenz Kästle
f861729abd
Merge pull request #2210 from sthen/curl_types
Some checks failed
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
Tests Debian:Testing and Fedora:Rawhide / Running unit and integrationt tests (push) Has been cancelled
Tests Debian:Testing and Fedora:Rawhide / Running rpm build test on fedora:rawhide (push) Has been cancelled
fix types for most curl_easy_setopt parameters
2025-12-28 13:07:34 +01:00
Lorenz Kästle
9c26154698
Merge branch 'master' into fix/check-curl-append-query-string-on-redirect 2025-12-28 12:30:23 +01:00
Stuart Henderson
d36bf51baf fix types for most curl_easy_setopt parameters
according to https://curl.se/libcurl/c/curl_easy_setopt.html, parameters
are either a long, a function pointer, an object pointer or a curl_off_t,
depending on what the option expects; curl 8.16 checks and warns about
these.
2025-12-23 15:54:27 +00:00
Alvar
eed2dd00bb
check_curl: --verify-cert / -D in examples (#2204)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
Include the -D flag for certificate verification in the "CHECK
CERTIFICATE" examples. Otherwise, only the certificate dates are
checked, but not if the certificate matches to the hostname or is signed
by a trusted CA.

Fixes #2146.
2025-12-14 12:53:51 +01:00
Ahmet Oeztuerk
e0b30cc6e8 append the query string from parsed uri
Check the UriUriA object, and if query string exists append it to the
new_url. Only appends the query part, fragments are still not appended

Function redir parses the new location header value using the
uriParseUriA function already, which populates the query field. This
field was already being printed, but it was not being appended to the
new_url during its construction.

Redirection chain of check_curl --onredirect=follow now mimics the chain
of check_http --onredirect=follow. Tested on the url:
mail.google.com/chat
2025-12-04 17:03:57 +01:00
Lorenz Kästle
db2983da7e
Fix/check curl sticky redir (#2188)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
* check_curl: avoid freeing memory when we don't know where it came from

* check_curl: when using -f sticky conserve IPv6 addresses properly

When running the check on an ipv6 address with a sticky onredirect
policy like in this example:

  check_curl -6 -H example.com -I ::1 -f sticky

It results in a getaddrinfo error:

  HTTP CRITICAL - Unable to lookup IP address for '[::1]': getaddrinfo returned -3 - Temporary failure in name resolution

This happens because in check_http() if the content of server_addr is an
ipv6 address enclosing brackets are added and on redirection a
subsequent call to check_http() will pass this now bracketed value to
getaddrinfo resulting in the error.

To work around this, strip the brackets from the address prior to the
lookup_host() call.

* add Michael Jeanson to thanks
2025-11-28 12:21:08 +01:00
Lorenz Kästle
6c231f0dd8
Merge pull request #2185 from RincewindsHat/fix/curl_segfault
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
check_curl: abort redir if location is not found
2025-11-27 14:43:32 +01:00
Lorenz Kästle
57043387ea Remove some superfluous newlines 2025-11-27 14:42:05 +01:00
Lorenz Kästle
9fc1e24543 check_curl: try to be more helpful in check_curls help
Trying to be more specific with the check_curl help.
The idea is to clarify how the parameters are supposed to be used.
2025-11-27 14:29:33 +01:00
Lorenz Kästle
2917b8735f check_curl: abort redir if location is not found
This commit changes the behaviour of check_curl slightly.
Previously when the redirection method was set to the old 'check_http'
style redirection and there was no "location" header in the original
answer 'check_curl' segfaulted.
Now, at least it dies properly with a message.
2025-11-27 13:24:30 +01:00
Lorenz Kästle
5a2c1b2c3a Add output formatting option 2025-09-15 02:30:42 +02:00
Lorenz Kästle
43c6332322 Fix typo in error message 2025-09-15 02:08:46 +02:00
Lorenz Kästle
f5f4a021a2 Add new cert check function 2025-09-15 01:57:40 +02:00
Lorenz Kästle
c15d12cbd5 check_curl: fix perfdata label 2025-09-15 01:57:08 +02:00
Lorenz Kästle
0bf5fdf41e check_curl: finish after cert without continue param 2025-09-15 01:56:46 +02:00
Lorenz Kästle
166ce184c6 Fix regex matching 2025-09-15 00:22:35 +02:00
Lorenz Kästle
def42dc686 Improve error message 2025-09-15 00:22:08 +02:00
Lorenz Kästle
6ae8ba9110 check_curl: test adaption and output adaption 2025-09-13 12:49:06 +02:00
Lorenz Kästle
9afb5e2a69 check_curl: remove display-html option 2025-09-13 12:28:49 +02:00
Lorenz Kästle
44b2a25a6b check_curl: implement new output mechanism 2025-09-12 16:37:24 +02:00
Lorenz Kästle
ad4faf1a9a Fix struct access 2025-09-12 01:59:05 +02:00
Lorenz Kästle
ab66b41d23 check_curl: create outsourced helpers in extra files 2025-09-12 01:14:14 +02:00
Lorenz Kästle
684602ddec check_curl: http3 is only available with libcurl 7.66 or later 2025-09-11 14:44:17 +02:00
Lorenz Kästle
99206dab7a check_curl: refactoring to modularize code 2025-09-11 13:44:55 +02:00
Lorenz Kästle
6969f57192 check_curl: improve option handling a bit 2025-09-11 11:24:16 +02:00
Lorenz Kästle
977e0a7f8b check_curl: fix function signature 2025-09-11 11:14:29 +02:00
Lorenz Kästle
b44cbae7fb check_curl: less global state 2025-09-11 11:11:44 +02:00
Lorenz Kästle
4b19852dcc check_curl: remove the other gotos 2025-09-10 12:22:46 +02:00
Lorenz Kästle
2c81d1257b check_curl: remove goto logic 2025-09-10 12:06:48 +02:00
Lorenz Kästle
c06ea4e44c check_curl: pre compile regex for string matching 2025-09-10 11:08:52 +02:00
Lorenz Kästle
01f3532284 check_curl: remove another global variable 2025-09-10 11:07:55 +02:00
Lorenz Kästle
40b062f1bd check_curl: more refactoring 2025-09-09 15:12:03 +02:00
Lorenz Kästle
b54869391f Quick save 2025-08-01 14:29:48 +02:00
Lorenz Kästle
e570ce6363 check_curl: various small improvements 2025-07-14 23:35:52 +02:00
Lorenz Kästle
e855107eeb check_curl: clang-format 2025-07-06 23:46:16 +02:00
Lorenz Kästle
f25a4000b6 Refactor check_curl 2025-03-11 02:02:27 +01:00
Lorenz Kästle
aa137f7d4a check_curl: clang-format 2025-03-10 22:56:34 +01:00
Andre Klärner
e7dbfd4223 check_curl: enable internal cookie handling
This enables us to enable curl cookie engine by specifying an empty
filename as the cookie jar file.

This works, since curl's CURLOPT_COOKIEFILE option allows passing an
empty string as filename, which it interprets as a request to enable the
cookie processing. But since CURLOPT_COOKIEJAR would now attempt to
write to a file named by an empty filename, it would break again (or at
least produce a warning in verbose output).

Overall this is allows to handle checking URLs with cookie based
sessions without persisting the cookies to disk, by using the
curl-internal redirect following.
2024-12-02 20:48:24 +01:00
Lorenz Kästle
8de299308c check_curl: update TLS notification notes 2024-11-27 14:22:02 +01:00
Lorenz Kästle
f1dae44075 Fix false formatting directive in printf 2024-11-09 11:26:09 +01:00
RincewindsHat
fde8e9c77b check_curl: Linter fixes 2024-10-31 03:10:57 +01:00
RincewindsHat
7334812a92 check_curl: do not export local variables and remove unused ones 2024-10-31 03:05:43 +01:00
RincewindsHat
367c4f89c1 check_curl: Update copyright 2024-10-31 02:59:49 +01:00
RincewindsHat
80f07ff92b check_curl: clang-format 2024-10-31 02:58:41 +01:00
Sven Nierlein
3b96044248 fix check_curl: OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
using check_curl on a probably embedded device responding as 'Server: GoAhead-Webs'

    %> check_curl -H ... -S -vvv

    > GET / HTTP/1.1
    Host: ...
    User-Agent: check_curl/v2.4.0 (monitoring-plugins 2.4.0, libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.10.4/openssl/zlib nghttp2/1.43.0)
    Accept: */*
    Connection: close

    * Mark bundle as not supporting multiuse
    * HTTP 1.0, assume close after body
    < HTTP/1.0 302 Redirect
    < Server: GoAhead-Webs
    < Date: Tue Mar 26 17:57:16 2019
    < Cache-Control: no-cache, no-store, must-revalidate,private
    < Pragma: no-cache
    < Expires: 0
    < Content-Type: text/html
    < X-Frame-Options: sameorigin
    < X-XSS-Protection: 1; mode=block
    < X-Content-Type-Options: nosniff
    < Location: https://...
    <
    * OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
    * Closing connection 0

reading the discussion on https://github.com/openssl/openssl/discussions/22690 suggest to set the option SSL_OP_IGNORE_UNEXPECTED_EOF
which makes check_curl behave like check_http at this point.
Since this is a rather new flag, fencing it in ifdefs.
And since there can only be one ssl ctx function, we need to move both tasks into one function.
2024-10-10 15:54:28 +02:00
Lorenz Kästle
bc6dda5286
Merge branch 'master' into check_curl_regex_state 2024-10-06 17:28:08 +02:00
Lorenz Kästle
75d5c51207 Remove experimental state from check_curl 2024-08-29 18:20:35 +02:00