From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CC76460E3; Mon, 27 Jan 2025 12:52:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B96C402C9; Mon, 27 Jan 2025 12:52:06 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 21A3A402C9 for ; Mon, 27 Jan 2025 12:52:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737978723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ehT2dcqPf8dw+zjEeJlktXQxUl2oZq1Q0lc7NDtJZ2w=; b=hmojiMXXlSUYrQtWKeC8ZWg3ZjoEe4HkvveiK4Rjd67EyLXvAlaTt3+CB6yB8Af6nxp0Iq JUynaKBFi5c3NnDODqULKsNMTHte5w7PlY7nqLAk3uzlTob5a17mfK5Dk/uTJgX3m9Xey9 AR5ULhPZNlXVQCiMGyzJu5qUwUQIpd0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-9ZB2Kh-sN-ykVu54IOQA3g-1; Mon, 27 Jan 2025 06:52:00 -0500 X-MC-Unique: 9ZB2Kh-sN-ykVu54IOQA3g-1 X-Mimecast-MFC-AGG-ID: 9ZB2Kh-sN-ykVu54IOQA3g Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52C4619560B3; Mon, 27 Jan 2025 11:51:59 +0000 (UTC) Received: from ringo.redhat.com (unknown [10.39.208.19]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FEE41800365; Mon, 27 Jan 2025 11:51:57 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Bruce Richardson Cc: stable@dpdk.org Subject: [PATCH dpdk] telemetry-exporter: listen on loopback by default Date: Mon, 27 Jan 2025 12:51:44 +0100 Message-ID: <20250127115143.585207-2-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PABPQVK67A6Eay-wOZTt_o7v7-cbGpdtZIS62aOiY2w_1737978719 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Fix the following warning reported by Coverity: Defect type: SIGMA.insecure_network_bind: > dpdk-stable-24.11.1/usertools/dpdk-telemetry-exporter.py:278: > Sigma main event: The HTTP server binds to all network interfaces by > setting the IP address to "", `0.0.0.0`, `::`, or `::0`. > This may expose the server to unintended traffic. Avoid listening to all interfaces by default to avoid exposing private information unwillingly. Unrelated: The Python stdlib TCP server listens on IPv4 only by default. Changing this requires creating a subclass that overrides address_family to socket.AF_INET6. Fixes: d94ebd627a86 ("usertools: add telemetry exporter") Cc: stable@dpdk.org Signed-off-by: Robin Jarry --- usertools/dpdk-telemetry-exporter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usertools/dpdk-telemetry-exporter.py b/usertools/dpdk-telemetry-exporter.py index 6eca0db2e80a..6f66d4ecaab1 100755 --- a/usertools/dpdk-telemetry-exporter.py +++ b/usertools/dpdk-telemetry-exporter.py @@ -75,7 +75,7 @@ def cmd(self, uri, arg=None) -> dict | list: "/usr/local/share/dpdk/telemetry-endpoints", "/usr/share/dpdk/telemetry-endpoints", ] -DEFAULT_OUTPUT = "openmetrics://:9876" +DEFAULT_OUTPUT = "openmetrics://127.0.0.1:9876" def main(): @@ -275,11 +275,11 @@ def serve_openmetrics( Start an HTTP server and serve requests in the openmetrics/prometheus format. """ - listen = (args.output.hostname or "", int(args.output.port or 80)) + listen = (args.output.hostname or "127.0.0.1", int(args.output.port or 80)) with server.HTTPServer(listen, OpenmetricsHandler) as httpd: httpd.dpdk_socket_path = args.socket_path httpd.telemetry_endpoints = endpoints - LOG.info("listening on port %s", httpd.server_port) + LOG.info("listening on %s", httpd.socket.getsockname()) try: httpd.serve_forever() except KeyboardInterrupt: -- 2.48.1