[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 97/124: fix leak, expand logging
From: |
gnunet |
Subject: |
[taler-exchange] 97/124: fix leak, expand logging |
Date: |
Tue, 17 Sep 2024 21:28:29 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to tag cg-aml-branch-compiles
in repository exchange.
commit 9efce9a8474b9a464fc6018629d2a47eef5eeee6
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Jul 18 16:03:05 2024 +0200
fix leak, expand logging
---
src/exchange/taler-exchange-httpd_purses_create.c | 12 +++++
src/kyclogic/kyclogic_api.c | 57 +++++++++++++++++++++++
src/testing/test_exchange_api.conf | 5 ++
3 files changed, 74 insertions(+)
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
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 40/124: work on kyc API, (continued)
- [taler-exchange] 40/124: work on kyc API, gnunet, 2024/09/17
- [taler-exchange] 75/124: implement kyc-info client endpoint, gnunet, 2024/09/17
- [taler-exchange] 70/124: more work on KYC upload, gnunet, 2024/09/17
- [taler-exchange] 42/124: implement more basic KYCLOGIC functions, gnunet, 2024/09/17
- [taler-exchange] 79/124: -bump gana, gnunet, 2024/09/17
- [taler-exchange] 54/124: move ID computation into libtalerutil, gnunet, 2024/09/17
- [taler-exchange] 123/124: -fix age withdraw test, gnunet, 2024/09/17
- [taler-exchange] 84/124: add account_sig for authorization, gnunet, 2024/09/17
- [taler-exchange] 112/124: more bugfixes, gnunet, 2024/09/17
- [taler-exchange] 48/124: add spa logic, gnunet, 2024/09/17
- [taler-exchange] 97/124: fix leak, expand logging,
gnunet <=
- [taler-exchange] 96/124: -SQL fixes, gnunet, 2024/09/17
- [taler-exchange] 88/124: implement wad_in_insert, gnunet, 2024/09/17
- [taler-exchange] 104/124: new test command for KYC wire transfers, gnunet, 2024/09/17
- [taler-exchange] 90/124: pass h_payto, gnunet, 2024/09/17
- [taler-exchange] 93/124: return KYCAUTH transfers from fakebank account history API, gnunet, 2024/09/17
- [taler-exchange] 117/124: WiP, gnunet, 2024/09/17
- [taler-exchange] 115/124: -fix SQL, gnunet, 2024/09/17
- [taler-exchange] 120/124: -misc bugfixes, gnunet, 2024/09/17
- [taler-exchange] 64/124: get AML measures skeleton", gnunet, 2024/09/17
- [taler-exchange] 69/124: -towards form uploads (incomplete), gnunet, 2024/09/17