From 997640d5e1d14663344329c41d0a51742c739095 Mon Sep 17 00:00:00 2001 From: lmchilton Date: Fri, 31 Jul 2026 13:50:01 -0400 Subject: [PATCH] pcp2openmetrics & pcp2opentelemetry revisions openscanhub revisions for pcp2openmetrics & pcp2opentelemetry Updated error in format for unit assignment in pcp2opentelemetry Updated http authentication --- src/pcp2openmetrics/pcp2openmetrics.py | 4 ++++ src/pcp2opentelemetry/pcp2opentelemetry.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pcp2openmetrics/pcp2openmetrics.py b/src/pcp2openmetrics/pcp2openmetrics.py index da4a7f96b11..c0dfab2af3a 100755 --- a/src/pcp2openmetrics/pcp2openmetrics.py +++ b/src/pcp2openmetrics/pcp2openmetrics.py @@ -512,6 +512,10 @@ def openmetrics_labels(inst, name, desc, labels): if self.url: auth = None if self.http_user and self.http_pass: + if not self.url.lower().startswith("https://"): + raise ValueError( + "HTTP Basic Authentication requires an HTTPS connection to prevent leaking credentials." + ) auth = requests.auth.HTTPBasicAuth(self.http_user, self.http_pass) try: timeout = self.http_timeout diff --git a/src/pcp2opentelemetry/pcp2opentelemetry.py b/src/pcp2opentelemetry/pcp2opentelemetry.py index a22723d09e7..9706c892ff5 100644 --- a/src/pcp2opentelemetry/pcp2opentelemetry.py +++ b/src/pcp2opentelemetry/pcp2opentelemetry.py @@ -531,14 +531,16 @@ def UCUM_count_prefix(scale): if units.dimSpace != 1: ucum_string += "%d" % units.dimSpace first_unit = 0 - elif units.dimTime: + + if units.dimTime: if not first_unit: ucum_string += "." first_unit = 0 ucum_string += "%s" % UCUM_time_prefix(units.scaleTime) if units.dimTime != 1: ucum_string += "%d" % units.dimTime - elif units.dimCount: + + if units.dimCount: if not first_unit: ucum_string += "." first_unit = 0 @@ -549,7 +551,8 @@ def UCUM_count_prefix(scale): ucum_string += "%s{count}" % prefix if units.dimCount != 1: ucum_string += "%d" % units.scaleCount - else: + + if first_unit: ucum_string = "1" # dimensionless return ucum_string @@ -678,6 +681,10 @@ def scope_metric_function(results): if self.url: auth = None if self.http_user and self.http_pass: + if not self.url.lower().startswith("https://"): + raise ValueError( + "HTTP Basic Authentication requires an HTTPS connection to prevent leaking credentials." + ) auth = requests.auth.HTTPBasicAuth(self.http_user, self.http_pass) try: timeout = self.http_timeout