[fix] Small bandit changes (#3241)
This commit is contained in:
@@ -57,8 +57,8 @@ else:
|
||||
# else convert from base64
|
||||
try:
|
||||
return base64.b64decode(source)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
return None
|
||||
|
||||
def load_greenlight_credentials() -> (
|
||||
|
||||
@@ -182,7 +182,8 @@ class ClicheWallet(Wallet):
|
||||
try:
|
||||
if data["result"]["status"]:
|
||||
yield data["result"]["payment_hash"]
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
continue
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
import random
|
||||
from collections.abc import AsyncGenerator
|
||||
from secrets import token_urlsafe
|
||||
from typing import Any, Optional
|
||||
|
||||
from bolt11.decode import decode as bolt11_decode
|
||||
@@ -92,7 +92,7 @@ class CoreLightningWallet(Wallet):
|
||||
unhashed_description: Optional[bytes] = None,
|
||||
**kwargs,
|
||||
) -> InvoiceResponse:
|
||||
label = kwargs.get("label", f"lbl{random.random()}")
|
||||
label = kwargs.get("label", f"lbl{token_urlsafe(16)}")
|
||||
msat: int = int(amount * 1000)
|
||||
try:
|
||||
if description_hash and not unhashed_description:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
import random
|
||||
from collections.abc import AsyncGenerator
|
||||
from secrets import token_urlsafe
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
@@ -111,7 +111,7 @@ class CoreLightningRestWallet(Wallet):
|
||||
unhashed_description: Optional[bytes] = None,
|
||||
**kwargs,
|
||||
) -> InvoiceResponse:
|
||||
label = kwargs.get("label", f"lbl{random.random()}")
|
||||
label = kwargs.get("label", f"lbl{token_urlsafe(16)}")
|
||||
data: dict = {
|
||||
"amount": amount * 1000,
|
||||
"description": memo,
|
||||
@@ -298,7 +298,8 @@ class CoreLightningRestWallet(Wallet):
|
||||
self.last_pay_index = inv["pay_index"]
|
||||
if not paid:
|
||||
continue
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
continue
|
||||
logger.trace(f"paid invoice: {inv}")
|
||||
|
||||
|
||||
@@ -292,7 +292,8 @@ class LndRestWallet(Wallet):
|
||||
)
|
||||
else:
|
||||
return PaymentPendingStatus()
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
continue
|
||||
|
||||
return PaymentPendingStatus()
|
||||
@@ -307,7 +308,8 @@ class LndRestWallet(Wallet):
|
||||
inv = json.loads(line)["result"]
|
||||
if not inv["settled"]:
|
||||
continue
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
continue
|
||||
|
||||
payment_hash = base64.b64decode(inv["r_hash"]).hex()
|
||||
|
||||
@@ -173,11 +173,12 @@ class LnTipsWallet(Wallet):
|
||||
inv = json.loads(data)
|
||||
if not inv.get("payment_hash"):
|
||||
continue
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
continue
|
||||
yield inv["payment_hash"]
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
|
||||
# do not sleep if the connection was active for more than 10s
|
||||
# since the backend is expected to drop the connection after 90s
|
||||
|
||||
@@ -2,6 +2,8 @@ import base64
|
||||
from getpass import getpass
|
||||
from typing import Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from lnbits.utils.crypto import AESCipher
|
||||
|
||||
|
||||
@@ -39,7 +41,7 @@ def load_macaroon(
|
||||
try:
|
||||
macaroon = base64.b64decode(macaroon).hex()
|
||||
return macaroon
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug(exc)
|
||||
|
||||
return macaroon
|
||||
|
||||
@@ -390,7 +390,7 @@ class NWCConnection:
|
||||
n = max_length - len(subid)
|
||||
if n > 0:
|
||||
for _ in range(n):
|
||||
subid += chars[random.randint(0, len(chars) - 1)]
|
||||
subid += chars[random.randint(0, len(chars) - 1)] # noqa: S311
|
||||
return subid
|
||||
|
||||
async def _close_subscription_by_subid(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import random
|
||||
from collections.abc import AsyncGenerator
|
||||
from secrets import token_urlsafe
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
@@ -116,7 +116,7 @@ class SparkWallet(Wallet):
|
||||
unhashed_description: Optional[bytes] = None,
|
||||
**kwargs,
|
||||
) -> InvoiceResponse:
|
||||
label = f"lbs{random.random()}"
|
||||
label = f"lbs{token_urlsafe(16)}"
|
||||
try:
|
||||
if description_hash:
|
||||
r = await self.invoicewithdescriptionhash(
|
||||
|
||||
Reference in New Issue
Block a user