Explorar el Código

chore(bandit): annotate tri-state migration SQL as a B608 false positive

The bed_levelling/flow_cali/nozzle_offset_cali boolean->tristate migration
builds two UPDATE statements with an f-string interpolating the column
name. Bandit flags these as B608 (SQL injection) at medium severity, which
failed the release-gate scan in test_security.sh.

The interpolated _col only ever iterates the hardcoded _tristate_cols tuple,
never user input, and SQL identifiers can't be passed as bound parameters.
Suppress with `# nosec B608` (matching the existing settings.py convention)
plus an inline rationale. No behavior change.
maziggy hace 1 mes
padre
commit
7c875b88ff
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      backend/app/core/database.py

+ 5 - 2
backend/app/core/database.py

@@ -1456,11 +1456,14 @@ async def run_migrations(conn):
     if is_sqlite():
         for _col in _tristate_cols:
             async with conn.begin_nested():
+                # B608 is a false positive here: _col is a hardcoded constant
+                # from _tristate_cols, never user input, and SQL identifiers
+                # can't be bound as parameters. Suppressed inline below.
                 await conn.execute(
-                    text(f"UPDATE print_queue SET {_col} = 'on' WHERE {_col} IN (1, '1', 'true', 'True')")
+                    text(f"UPDATE print_queue SET {_col} = 'on' WHERE {_col} IN (1, '1', 'true', 'True')")  # nosec B608
                 )
                 await conn.execute(
-                    text(f"UPDATE print_queue SET {_col} = 'off' WHERE {_col} IN (0, '0', 'false', 'False')")
+                    text(f"UPDATE print_queue SET {_col} = 'off' WHERE {_col} IN (0, '0', 'false', 'False')")  # nosec B608
                 )
     else:
         for _col in _tristate_cols: