diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-07-18 16:03:05 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-07-29 12:18:46 +0200 |
commit | bcba49da00a3f2255125e8a04cd1f0a562b8abb7 (patch) | |
tree | 1d27a91cb02ffb054b7835f915ddc42327024c1c /src | |
parent | db68289fcf9a8db240a98a970696b2779d442f9e (diff) |
fix leak, expand logging
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange/taler-exchange-httpd_purses_create.c | 12 | ||||
-rw-r--r-- | src/kyclogic/kyclogic_api.c | 57 | ||||
-rw-r--r-- | src/testing/test_exchange_api.conf | 5 |
3 files changed, 74 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c index 2de9468fe..f6db221ec 100644 --- a/src/exchange/taler-exchange-httpd_purses_create.c +++ b/src/exchange/taler-exchange-httpd_purses_create.c @@ -482,6 +482,7 @@ TEH_handler_purses_create ( pcc.exchange_timestamp)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_BEFORE_NOW, @@ -490,6 +491,7 @@ TEH_handler_purses_create ( if (GNUNET_TIME_absolute_is_never (pcc.pd.purse_expiration.abs_time)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_IS_NEVER, @@ -500,6 +502,7 @@ TEH_handler_purses_create ( (pcc.num_coins > TALER_MAX_FRESH_COINS) ) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -512,6 +515,7 @@ TEH_handler_purses_create ( if (NULL == keys) { GNUNET_break (0); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, @@ -524,6 +528,7 @@ TEH_handler_purses_create ( { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot create purse: global fees not configured!\n"); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_GENERIC_GLOBAL_FEES_MISSING, @@ -546,6 +551,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<idx; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } } @@ -555,6 +561,7 @@ TEH_handler_purses_create ( { GNUNET_break_op (0); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_CREATE_PURSE_NEGATIVE_VALUE_AFTER_FEE, @@ -576,6 +583,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, TALER_EC_EXCHANGE_PURSE_CREATE_SIGNATURE_INVALID, @@ -593,6 +601,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, TALER_EC_EXCHANGE_PURSE_ECONTRACT_SIGNATURE_INVALID, @@ -607,6 +616,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_START_FAILED, @@ -628,6 +638,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return mhd_ret; } } @@ -643,6 +654,7 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); + GNUNET_JSON_parse_free (spec); return res; } } diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c index 71075c237..07beb556f 100644 --- a/src/kyclogic/kyclogic_api.c +++ b/src/kyclogic/kyclogic_api.c @@ -1021,6 +1021,9 @@ add_provider (const struct GNUNET_CONFIGURATION_Handle *cfg, struct TALER_KYCLOGIC_Plugin *lp; struct TALER_KYCLOGIC_ProviderDetails *pd; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Parsing KYC provider %s\n", + section); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, @@ -1184,6 +1187,9 @@ add_check (const struct GNUNET_CONFIGURATION_Handle *cfg, char *outputs = NULL; char *fallback = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Parsing KYC check %s\n", + section); voluntary = (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, section, @@ -1376,6 +1382,9 @@ add_rule (const struct GNUNET_CONFIGURATION_Handle *cfg, bool exposed; bool is_and; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Processing KYC rule from %s\n", + section); if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (cfg, section, @@ -1474,6 +1483,9 @@ add_rule (const struct GNUNET_CONFIGURATION_Handle *cfg, return GNUNET_SYSERR; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Adding KYC rule %s\n", + section); { struct TALER_KYCLOGIC_KycRule kt; @@ -1540,6 +1552,9 @@ add_program (const struct GNUNET_CONFIGURATION_Handle *cfg, char *required_contexts = NULL; char *required_attributes = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Parsing KYC program %s\n", + section); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, @@ -2021,6 +2036,11 @@ check_amount ( struct KycTestContext *ktc = cls; struct GNUNET_TIME_Relative dur; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC checking transaction amount %s from %s against %u rules\n", + TALER_amount2s (amount), + GNUNET_TIME_absolute2s (date), + ktc->lrs->num_kyc_rules); dur = GNUNET_TIME_absolute_get_duration (date); if (GNUNET_OK != TALER_amount_is_valid (&ktc->sum)) @@ -2036,18 +2056,41 @@ check_amount ( = &ktc->lrs->kyc_rules[i]; if (ktc->event != rule->trigger) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Wrong event type for rule %u\n", + i); continue; /* wrong trigger event type */ + } if (GNUNET_TIME_relative_cmp (dur, >, rule->timeframe)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Out of time range for rule %u\n", + i); continue; /* out of time range for rule */ + } if (-1 == TALER_amount_cmp (&ktc->sum, &rule->threshold)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Below threshold of %s for rule %u\n", + TALER_amount2s (&rule->threshold), + i); continue; /* sum < threshold */ + } if ( (NULL != ktc->triggered_rule) && (1 == TALER_amount_cmp (&ktc->triggered_rule->threshold, &rule->threshold)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Higher than threshold of already triggered rule\n"); continue; /* threshold of triggered_rule > rule */ + } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Remembering rule %s as triggered\n", + rule->rule_name); ktc->triggered_rule = rule; } return GNUNET_OK; @@ -2068,6 +2111,10 @@ TALER_KYCLOGIC_kyc_test_required ( if (NULL == lrs) lrs = &default_rules; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Testing %u KYC rules for trigger %d\n", + lrs->num_kyc_rules, + event); for (unsigned int i=0; i<lrs->num_kyc_rules; i++) { const struct TALER_KYCLOGIC_KycRule *rule @@ -2075,6 +2122,11 @@ TALER_KYCLOGIC_kyc_test_required ( if (event != rule->trigger) continue; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Matched rule %u with timeframe %s\n", + i, + GNUNET_TIME_relative2s (rule->timeframe, + true)); range = GNUNET_TIME_relative_max (range, rule->timeframe); } @@ -2092,6 +2144,11 @@ TALER_KYCLOGIC_kyc_test_required ( range), &check_amount, &ktc); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Triggered rule is %s\n", + (NULL == ktc.triggered_rule) + ? "NONE" + : ktc.triggered_rule->rule_name); *triggered_rule = ktc.triggered_rule; } return qs; diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf index 618427f70..d4ce4457b 100644 --- a/src/testing/test_exchange_api.conf +++ b/src/testing/test_exchange_api.conf @@ -47,6 +47,8 @@ DB = postgres BASE_URL = "http://localhost:8081/" EXPIRE_SHARD_SIZE ="300 ms" EXPIRE_IDLE_SLEEP_INTERVAL ="1 s" +STEFAN_ABS = EUR:0 +STEFAN_LOG = EUR:0.005 [exchangedb-postgres] CONFIG = "postgres:///talercheck" @@ -109,10 +111,13 @@ KYC_OAUTH2_CONVERTER_HELPER = taler-exchange-kyc-oauth2-test-converter.sh CONVERTER = cat [kyc-legitimization-close] +ENABLED = YES +IS_AND_COMBINATOR = YES OPERATION_TYPE = CLOSE REQUIRED_CHECKS = DUMMY THRESHOLD = EUR:0 TIMEFRAME = 1d +NEXT_MEASURES = pass [exchange-extension-age_restriction] ENABLED = YES |