Claude commited on
Commit
3feaea0
·
unverified ·
1 Parent(s): 44ebedd

fix: IP 익명화 방식 수정 (inet 타입 호환)

Browse files

DB ip_address 컬럼이 PostgreSQL inet 타입이므로 hex 해시 저장 불가.
SHA-256 해시 대신 마지막 옥텟을 0으로 대체하는 방식으로 변경.
(예: 1.2.3.4 → 1.2.3.0) — inet 형식 유지하면서 개인 식별 불가.
IPv6는 저장하지 않음.

https://claude.ai/code/session_01BRbPoMBBfvgN58bGkNhmv7

Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import hashlib
2
  import logging
3
  import time
4
 
@@ -163,8 +162,11 @@ if st.button("의견 제출", use_container_width=True, type="primary"):
163
  "content": safe_input, "sentiment": sentiment, "author_role": author_role_for_submit,
164
  }
165
  if debate_ip_column_available() and client_ip:
166
- hashed_ip = hashlib.sha256(client_ip.encode()).hexdigest()[:16]
167
- insert_payload["ip_address"] = hashed_ip
 
 
 
168
  try:
169
  res = submit_opinion(supabase, insert_payload)
170
  if res is None:
 
 
1
  import logging
2
  import time
3
 
 
162
  "content": safe_input, "sentiment": sentiment, "author_role": author_role_for_submit,
163
  }
164
  if debate_ip_column_available() and client_ip:
165
+ # inet 컬럼이므로 유효한 IP 형식 유지 — 마지막 옥텟만 0으로 익명화
166
+ parts = client_ip.split(".")
167
+ anonymized_ip = f"{parts[0]}.{parts[1]}.{parts[2]}.0" if len(parts) == 4 else None
168
+ if anonymized_ip:
169
+ insert_payload["ip_address"] = anonymized_ip
170
  try:
171
  res = submit_opinion(supabase, insert_payload)
172
  if res is None: