Skip to content
Myr

show warning if session cookie domain is ip

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #2007

authored by José Oliveira · committed by David Lord · parent 716edfd · Browse files · 2 files+25 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−1 removed

  • other:+25 added−1 removed

2 files+25 added−1 removed

modified:flask/helpers.py+20 added
974 unmodified lines
975 :returns: number of seconds976 :rtype: int977 """978 return td.days * 60 * 60 * 24 + td.seconds979980def is_ip(ip):981 """Returns the if the string received is an IP or not.982983 :param string: the string to check if it an IP or not984 :param var_name: the name of the string that is being checked985986 :returns: True if string is an IP, False if not987 :rtype: boolean988 """989 import socket990991 for family in (socket.AF_INET, socket.AF_INET6):992 try:993 socket.inet_pton(family, ip)994 except socket.error:995 pass996 else:997 return True998 return False
modified:flask/sessions.py+5 added-1 removed
9 unmodified lines
10"""1112import uuid13import hashlib14from warnings import warn15from base64 import b64encode, b64decode16from datetime import datetime17from werkzeug.http import http_date, parse_date18from werkzeug.datastructures import CallbackDict19from . import Markup, json20from ._compat import iteritems, text_type20from .helpers import total_seconds21from .helpers import total_seconds, is_ip2223from itsdangerous import URLSafeTimedSerializer, BadSignature2425
310 unmodified lines
336 return self.session_class()337338 def save_session(self, app, session, response):339 domain = self.get_cookie_domain(app)340 if domain is not None:341 if is_ip(domain):342 warnings.warn("IP introduced in SESSION_COOKIE_DOMAIN", RuntimeWarning)343 path = self.get_cookie_path(app)344345 # Delete case. If there is no session we bail early.346 # If the session was modified to be empty we remove the
24 unmodified lines