Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
semgrep: handle trailing arguments
Mikail Kocakf2b84c6f0401
diff --git a/.semgrep/security/logging/exception-object-in-logger-extra.py b/.semgrep/security/logging/exception-object-in-logger-extra.pyindex cf41fe3d7e..85ae4953bb 100644--- a/.semgrep/security/logging/exception-object-in-logger-extra.py+++ b/.semgrep/security/logging/exception-object-in-logger-extra.py@@ -14,6 +14,25 @@ def test_log_multiple_extra():# ruleid: exception-object-in-logger-extralogger.info("Failed", extra={"other1": 1, "error": exc, "other2": 1})+# Should match when extra is before other arguments (case #1).+def test_log_exception_trailing_arguments_case1():+ try:+ do_something()+ except Exception as exc:+ # w/ exc_info trailing & extra={} in the middle+ # ruleid: exception-object-in-logger-extra+ logger.info("Failed", extra={"error": exc}, exc_info=True)+++# Should match when extra is before other arguments (case #2).+def test_log_exception_trailing_arguments_case2():+ try:+ do_something()+ except Exception as exc:+ # Test: extra={} is first parameter+ # ruleid: exception-object-in-logger-extra+ logger.info(extra={"error": exc}, msg="Failed", exc_info=True)+# Should not match when converting an exception object to string.def test_not_logging_exception():try:diff --git a/.semgrep/security/logging/exception-object-in-logger-extra.yaml b/.semgrep/security/logging/exception-object-in-logger-extra.yamlindex 142c8e147f..045e621cf2 100644--- a/.semgrep/security/logging/exception-object-in-logger-extra.yaml+++ b/.semgrep/security/logging/exception-object-in-logger-extra.yaml@@ -7,7 +7,7 @@ rules:except ... as $EXC:...- pattern: |- $LOGGER.$LOG_FUNC(..., extra={..., ...: $EXC, ...})+ $LOGGER.$LOG_FUNC(..., extra={..., ...: $EXC, ...}, ...)- metavariable-regex:metavariable: $LOGGERregex: (?i)(logger|logging)@@ -18,6 +18,6 @@ rules:message: >-Exception objects should not be put inside a logger's `extra` field, it can lead to high memory usage. Instead, use str(exc) to log the message.languages: [python]- severity: ERROR+ severity: ERRORfocus-metavariable: $EXC