SIENTIAPDE-1646

Simplify bandit nosec comments and mock metrics_controller with real spe

- drift.py/simple_metrics.py: move nosec rationale to a code comment above
  the query instead of an inline suppression comment, keeping bandit happy
  with a plain `# nosec`
- tests: replace bare `MagicMock()` with `MagicMock(spec=MetricsController)`
  for metrics_controller across activities/repository tests so mocks fail
  fast on attribute typos instead of silently accepting any call
This commit is contained in:
2026-09-25 10:57:46 -03:00
parent 4c51e7c2b3
commit 00b6382a88
9 changed files with 29 additions and 20 deletions

View File

@@ -37,6 +37,7 @@ class Drift:
model_config = input_data['model_config']
target_name = model_config['target']
# Built from internal Temporal workflow config, not user input (bandit B608).
gathering_query = f"""
SELECT *
FROM "{input_data['schema']}"."{input_data['source_table_name']}"
@@ -44,7 +45,7 @@ class Drift:
model_id = '{input_data['model_id']}' AND
timestamp > NOW() - INTERVAL '{input_data['interval']} minutes'
ORDER BY timestamp ASC
""" # nosec B608 - values come from internal Temporal workflow config, not user input
""" # nosec
target_data_handler = workflow.start_activity_method(
Activities.load_custom_query,

View File

@@ -32,6 +32,7 @@ class SimpleMetrics:
model_config = input_data['model_config']
target_name = model_config['target']
# Built from internal Temporal workflow config, not user input (bandit B608).
query = f"""
select p."timestamp", p.prediction, ld.value as "target"
from "{input_data['schema']}"."{input_data['predictions_table_name']}" p
@@ -45,7 +46,7 @@ class SimpleMetrics:
p."timestamp" >= NOW() - INTERVAL '{interval_minutes} minutes'
order by
p."timestamp" desc;
""" # nosec B608 - values come from internal Temporal workflow config, not user input
""" # nosec
target_data = await workflow.execute_activity_method(
Activities.load_custom_query,