semgrep: Replace pattern-where-python with metavariable-regex.

pattern-where-python is deprecated and doesn’t work in 0.62.0.  This
should be faster, too.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-08-23 16:58:26 -07:00 committed by Tim Abbott
parent 3e78de4ce8
commit e3a3519913
1 changed files with 18 additions and 5 deletions

View File

@ -45,11 +45,24 @@ rules:
languages: [python]
patterns:
- pattern-either:
- pattern: logging.$Y(... .format(...))
- pattern: logging.$Y(f"...")
- pattern: logger.$Y(... .format(...))
- pattern: logger.$Y(f"...")
- pattern-where-python: "vars['$Y'] in ['debug', 'info', 'warning', 'error', 'critical', 'exception']"
- pattern: $LOGGER.debug($FORMATTED)
- pattern: $LOGGER.info($FORMATTED)
- pattern: $LOGGER.warning($FORMATTED)
- pattern: $LOGGER.error($FORMATTED)
- pattern: $LOGGER.critical($FORMATTED)
- pattern: $LOGGER.exception($FORMATTED)
- metavariable-pattern:
metavariable: $LOGGER
patterns:
- pattern-either:
- pattern: logging
- pattern: logger
- metavariable-pattern:
metavariable: $FORMATTED
patterns:
- pattern-either:
- pattern: ... .format(...)
- pattern: f"..."
severity: ERROR
message: "Pass format arguments to logging (https://docs.python.org/3/howto/logging.html#optimization)"