From 832dc3d55b05e8a37782c68d9547e655e17cb107 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Wed, 17 Jan 2024 23:37:25 +0100 Subject: [PATCH] add line numer and fix a trigger on commented lines --- package_linter.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/package_linter.py b/package_linter.py index 9f73713..8d5ace1 100755 --- a/package_linter.py +++ b/package_linter.py @@ -1543,18 +1543,17 @@ class Configurations(TestSuite): yield Warning("Can't open/read %s: %s" % (filename, e)) return - for line in content.split("\n"): - comment = ["#", "//", ";"] + for number, line in enumerate(content.split("\n"), 1): + comment = ("#", "//", ";") if ( - "0.0.0.0" in line - or "::" in line + ( "0.0.0.0" in line or "::" in line ) and not line.strip().startswith(comment) ): yield Info( - "%s: Binding to '0.0.0.0' or '::' can result in a security issue as " - "the SSO can be bypassed by knowing a public IP (typically an IPv6) " - "and the app port. Please be sure that this behavior is intentional.\n" - "Maybe use '127.0.0.1' or '::1' instead." % filename + f"{filename}:{number}: Binding to '0.0.0.0' or '::' can result in " + "a security issue as the SSO can be bypassed by knowing a public " + "IP (typically an IPv6) and the app port. Please be sure that this " + "behavior is intentional. Maybe use '127.0.0.1' or '::1' instead." ) #############################################