We recommend that you do not hardcode IP addresses because they might change. A hardcoded IP address can make your code vulnerable to denial of service attacks and IP address spoofing to bypass security checks.
1def hardcoded_ip_address_noncompliant(): 2 sock = socket(AF_INET, SOCK_STREAM) 3 # Noncompliant: IP address is hardcoded. 4 sock.bind(('22.214.171.124', 80))
1def hardcoded_ip_address_compliant(ip_add=None): 2 sock = socket(AF_INET, SOCK_STREAM) 3 # Compliant: IP address is not hardcoded. 4 sock.bind((ip_add, 5080))