-
Notifications
You must be signed in to change notification settings - Fork 841
Fix wrong checks for some integer config records #12643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
e6e1f06
681ddb3
220a2fe
3fc1bb6
1fcab70
6a2c978
a7b084e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,9 @@ | |||||||||||||||||||||||||||||||
| #include "tscore/Filenames.h" | ||||||||||||||||||||||||||||||||
| #include "records/RecordsConfig.h" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #include <string_view> | ||||||||||||||||||||||||||||||||
| #include <cstddef> | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #if TS_USE_REMOTE_UNWINDING | ||||||||||||||||||||||||||||||||
| #define MGMT_CRASHLOG_HELPER "traffic_crashlog" | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
|
|
@@ -72,11 +75,11 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.dump_mem_info_frequency", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| //# 0 == CLOCK_REALTIME, change carefully | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.system_clock", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-9]+", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.system_clock", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.cache.max_disk_errors", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.cache.persist_bad_disks", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[01]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.cache.persist_bad_disks", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.output.logfile.name", RECD_STRING, "traffic.out", RECU_RESTART_TS, RR_REQUIRED, RECC_NULL, nullptr, | ||||||||||||||||||||||||||||||||
| RECA_NULL} | ||||||||||||||||||||||||||||||||
|
|
@@ -204,7 +207,7 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.diags.debug.tags", RECD_STRING, "http|dns", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.diags.debug.throttling_interval_msec", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.diags.debug.throttling_interval_msec", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.diags.debug.client_ip", RECD_STRING, nullptr, RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
|
|
@@ -409,7 +412,7 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.http.auth_server_session_private", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-2]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.http.max_post_size", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.http.max_post_size", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // ############################## | ||||||||||||||||||||||||||||||||
| // # parent proxy configuration # | ||||||||||||||||||||||||||||||||
|
|
@@ -1075,9 +1078,9 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.log.max_line_size", RECD_INT, "9216", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // How often periodic tasks get executed in the Log.cc infrastructure | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.log.periodic_tasks_interval", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.log.periodic_tasks_interval", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.log.throttling_interval_msec", RECD_INT, "60000", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.log.throttling_interval_msec", RECD_INT, "60000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| //############################################################################## | ||||||||||||||||||||||||||||||||
|
|
@@ -1097,7 +1100,7 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.plugin.dynamic_reload_mode", RECD_INT, "1", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.url_remap.min_rules_required", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-9]+", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.url_remap.min_rules_required", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.url_remap.acl_behavior_policy", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
|
|
@@ -1244,16 +1247,16 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.enabled", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // # Number of seconds before an OCSP response expires in the stapling cache. 3600s (1 hour) by default. | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.cache_timeout", RECD_INT, "3600", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.cache_timeout", RECD_INT, "3600", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // # Request method "mode" for queries to OCSP responders; 0 is POST, 1 is "prefer GET." | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.request_mode", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // # Timeout for queries to OCSP responders. 10s by default. | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.request_timeout", RECD_INT, "10", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.request_timeout", RECD_INT, "10", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // # Update period for stapling caches. 60s (1 min) by default. | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.update_period", RECD_INT, "60", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.update_period", RECD_INT, "60", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| // # Base path for OCSP prefetched responses | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.ssl.ocsp.response.path", RECD_STRING, TS_BUILD_SYSCONFDIR, RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL} | ||||||||||||||||||||||||||||||||
|
|
@@ -1465,13 +1468,13 @@ static constexpr RecordElement RecordsConfig[] = | |||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.disable_active_migration", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_recv_udp_payload_size_in", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_recv_udp_payload_size_in", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_recv_udp_payload_size_out", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_recv_udp_payload_size_out", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_send_udp_payload_size_in", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_send_udp_payload_size_in", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_send_udp_payload_size_out", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_INT, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.max_send_udp_payload_size_out", RECD_INT, "65527", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
| {RECT_CONFIG, "proxy.config.quic.disable_http_0_9", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_STR, "[0-1]", RECA_NULL} | ||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||
|
|
@@ -1565,6 +1568,98 @@ validate_check_type_has_regex() | |||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| //------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| // Compile-time validation helpers for RECC_INT patterns | ||||||||||||||||||||||||||||||||
| //------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| namespace | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| constexpr bool | ||||||||||||||||||||||||||||||||
| is_digit(char c) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| return c >= '0' && c <= '9'; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Parse an integer (possibly negative) at compile time | ||||||||||||||||||||||||||||||||
| // Updates index i to point past the parsed number | ||||||||||||||||||||||||||||||||
| // TODO: C++23 has std::from_chars for constexpr integer parsing | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| // Parse an integer (possibly negative) at compile time | |
| // Updates index i to point past the parsed number | |
| // TODO: C++23 has std::from_chars for constexpr integer parsing | |
| /** | |
| * Parses an integer (possibly negative) from the given string view at compile time. | |
| * Updates the index `i` to point past the parsed number. | |
| * Returns true if a valid integer was parsed, false otherwise. | |
| * | |
| * This function is intended for compile-time validation of integer patterns. | |
| * Note: C++23 introduces std::from_chars for constexpr integer parsing. | |
| * | |
| * @param s The string view to parse. | |
| * @param i The index into `s` where parsing starts; updated to point past the parsed integer. | |
| * @return true if parsing succeeded, false otherwise. | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, but use @param[in] and @param[out]. The AI's don't seem to know about the [in]/[out] qualifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You resolved this, but I don't see the use of @param[in] and @param[out].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message on line 401 says 'does not start with' but the actual check allows '[' to appear at any position (or not at all) via
find('['). Ifstart != 0, it means '[' was found but not at position 0. If '[' is not found at all,findreturnsstd::string_view::npos. The message should distinguish between these cases: 'pattern does not start with' vs 'pattern does not contain'. Consider checking fornposexplicitly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting with a [ is a stronger requirement than containing a [. We should tell the dev the stronger requirement up front to avoid multiple iterations when fixing the range syntax.