diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..d7c27af --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + title: OPL + name: opl + namespace: perfscale + description: MBU products perf&scale library +spec: + type: library + lifecycle: production + domain: domain:perfscale/perf-dept + owner: group:redhat/hce-perfscale + system: system:perfscale/consoledot-testing + dependencyOf: + - component:perfscale/iperf + tags: + - consoledot diff --git a/core/opl/cluster_read.py b/core/opl/cluster_read.py index 9078367..203df7f 100755 --- a/core/opl/cluster_read.py +++ b/core/opl/cluster_read.py @@ -36,14 +36,27 @@ def execute(command): return result +def redact_sensitive_headers(data: dict): + # Lower-case list of sensitive data in header + sensitive_headers = ["authorization", "set-cookie", "x-api-key", "cookie"] + + redacted_headers = {} + for header, value in data.items(): + if header.lower() in sensitive_headers: + redacted_headers[header] = "" + else: + redacted_headers[header] = value + return redacted_headers + + def _debug_response(r): """ Print various info about the requests response. Should be called when request failed """ logging.error("URL = %s" % r.url) - logging.error("Request headers = %s" % r.request.headers) - logging.error("Response headers = %s" % r.headers) + logging.error("Request headers = %s" % redact_sensitive_headers(r.request.headers)) + logging.error("Response headers = %s" % redact_sensitive_headers(r.headers)) logging.error("Response status code = %s" % r.status_code) logging.error("Response content = %s" % r.content[:500]) raise Exception("Request failed") diff --git a/opl/args.py b/opl/args.py index cfc520d..a8e35e8 100644 --- a/opl/args.py +++ b/opl/args.py @@ -86,6 +86,10 @@ def add_ros_db_opts(parser): _add_generic_db_opts(parser, "ros") +def add_export_db_opts(parser): + _add_generic_db_opts(parser, "export") + + def add_kafka_opts(parser): parser.add_argument( "--kafka-host", diff --git a/opl/cluster_read.py b/opl/cluster_read.py index 9078367..203df7f 100755 --- a/opl/cluster_read.py +++ b/opl/cluster_read.py @@ -36,14 +36,27 @@ def execute(command): return result +def redact_sensitive_headers(data: dict): + # Lower-case list of sensitive data in header + sensitive_headers = ["authorization", "set-cookie", "x-api-key", "cookie"] + + redacted_headers = {} + for header, value in data.items(): + if header.lower() in sensitive_headers: + redacted_headers[header] = "" + else: + redacted_headers[header] = value + return redacted_headers + + def _debug_response(r): """ Print various info about the requests response. Should be called when request failed """ logging.error("URL = %s" % r.url) - logging.error("Request headers = %s" % r.request.headers) - logging.error("Response headers = %s" % r.headers) + logging.error("Request headers = %s" % redact_sensitive_headers(r.request.headers)) + logging.error("Response headers = %s" % redact_sensitive_headers(r.headers)) logging.error("Response status code = %s" % r.status_code) logging.error("Response content = %s" % r.content[:500]) raise Exception("Request failed")