Skip to content

Commit 6438991

Browse files
committed
fix(spp_api_v2): remove url fallback from display_name to prevent security leak
The _compute_display_name method was falling back to record.url when endpoint was not set. Since url has groups="spp_api_v2.group_api_v2_auditor" but display_name is store=True with no groups restriction, the URL value was being persisted into an unrestricted field, bypassing field-level security. Also adds url to @api.depends implicitly by removing the reference entirely. Replace the url fallback with a generic "API Call" string.
1 parent e36e14f commit 6438991

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

spp_api_v2/models/api_outgoing_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ApiOutgoingLog(models.Model):
142142
def _compute_display_name(self):
143143
for record in self:
144144
timestamp_str = record.timestamp.strftime("%Y-%m-%d %H:%M") if record.timestamp else ""
145-
record.display_name = f"{record.http_method} {record.endpoint or record.url} @ {timestamp_str}"
145+
record.display_name = f"{record.http_method} {record.endpoint or 'API Call'} @ {timestamp_str}"
146146

147147
# ==========================================
148148
# API Methods

spp_api_v2/services/outgoing_api_log_service.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,22 @@ def log_call(
107107
# sudo() is intentional: log records must be created regardless of
108108
# the calling user's permissions on spp.api.outgoing.log. The
109109
# service is an internal component, not a user-facing API.
110-
return (
111-
self.env["spp.api.outgoing.log"]
112-
.sudo()
113-
.log_call(
114-
url=safe_url,
115-
endpoint=endpoint,
116-
http_method=http_method,
117-
request_summary=truncated_request,
118-
response_summary=truncated_response,
119-
response_status_code=response_status_code,
120-
user_id=self.user_id,
121-
origin_model=origin_model,
122-
origin_record_id=origin_record_id,
123-
duration_ms=duration_ms,
124-
service_name=self.service_name,
125-
service_code=self.service_code,
126-
status=status,
127-
error_detail=error_detail,
128-
)
110+
log_model = self.env["spp.api.outgoing.log"].sudo() # nosemgrep: odoo-sudo-without-context
111+
return log_model.log_call(
112+
url=safe_url,
113+
endpoint=endpoint,
114+
http_method=http_method,
115+
request_summary=truncated_request,
116+
response_summary=truncated_response,
117+
response_status_code=response_status_code,
118+
user_id=self.user_id,
119+
origin_model=origin_model,
120+
origin_record_id=origin_record_id,
121+
duration_ms=duration_ms,
122+
service_name=self.service_name,
123+
service_code=self.service_code,
124+
status=status,
125+
error_detail=error_detail,
129126
)
130127
except (KeyError, AttributeError, TypeError) as e:
131128
_logger.warning("Failed to log outgoing API call due to data error: %s", type(e).__name__)

0 commit comments

Comments
 (0)