Skip to content

Commit bb5aa2d

Browse files
mayankmendixbhavin.shahpriyal.chawda@mendix.comPiyushclaude
authored
Merge pull request (#891) from Mendix/develop
* added the metering code * added logging * added the sap metering sidecar * updated the auth token usage * updated the comments * updated the env vars * fix: update cryptography to 46.0.7 to address CVE-2026-39892 - Updated cryptography from 46.0.5 to 46.0.7 - Fixes buffer overflow vulnerability in non-contiguous buffer handling - Regenerated requirements.txt with Python 3.10 - All unit tests passing (184 passed) - All linting checks passing * Bumped the cryptography module version to latest 47.0.0 * Fix CVE-2026-25645 and CVE-2026-34073 by upgrading requests and cryptography Updated requests from 2.32.5 to 2.33.1 to address CVE-2026-25645. Updated cryptography from 46.0.5 to 47.0.0 to address CVE-2026-34073. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Security/upgrade requests urllib3 CVE fix (#894) * Security: Upgrade requests to 2.34.2 and urllib3 to 2.7.0 Fixes high-severity CVEs: - CVE-2026-25645 (requests): Fixed in 2.33.0+ - GHSA-mf9v-mfxr-j63j (urllib3): Streaming API decompression issue - GHSA-qccp-gfcp-xxvc (urllib3): Cross-origin redirect header leakage Changes: - requests: 2.32.5 → 2.34.2 - urllib3: 2.6.3 → 2.7.0 - charset-normalizer: 2.0.3 → 3.4.7 (transitive) - idna: 3.10 → 3.15 (transitive) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Fixes high-severity CVEs: - CVE-2026-25645 (requests): Fixed in 2.33.0+ - GHSA-mf9v-mfxr-j63j (urllib3): Streaming API decompression issue - GHSA-qccp-gfcp-xxvc (urllib3): Cross-origin redirect header leakage --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: bhavin.shah <bhavin.shah@mendix.com> Co-authored-by: priyal.chawda@mendix.com <priyal.chawda@mendix.com> Co-authored-by: Piyush <piyush.tiwari@mendix.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Bhavin Shah <162097397+bhavinshah-mendix@users.noreply.github.com>
1 parent 8c6299d commit bb5aa2d

3 files changed

Lines changed: 68 additions & 6 deletions

File tree

buildpack/telemetry/metering.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ def _is_usage_metering_enabled():
2727
return True
2828

2929

30+
def _is_sap_metering_configured():
31+
use_license_server = os.environ.get("MXRUNTIME_License.UseLicenseServer", "false").lower()
32+
if use_license_server == "true":
33+
return False
34+
35+
endpoint = _get_sap_metering_endpoint()
36+
37+
if not endpoint:
38+
logging.warning(
39+
"Missing configuration for SAP metering sidecar."
40+
)
41+
return False
42+
43+
return True
44+
45+
46+
def _get_sap_metering_endpoint():
47+
return os.environ.get("METERING_BINARY_PATH", "").strip()
48+
49+
50+
def _get_sap_metering_token():
51+
return os.environ.get("METERING_BINARY_TOKEN", "").strip()
52+
53+
3054
def _get_project_id(file_path):
3155
try:
3256
with open(file_path) as file_handle:
@@ -89,6 +113,32 @@ def _is_sidecar_installed():
89113
return False
90114

91115

116+
def _copy_sap_metering_sidecar(build_path, endpoint, token):
117+
"""Download SAP metering sidecar binary from HTTPS endpoint."""
118+
import requests
119+
120+
sidecar_dir = os.path.join(build_path, NAMESPACE)
121+
destination = os.path.join(sidecar_dir, BINARY)
122+
util.mkdir_p(sidecar_dir)
123+
124+
response = requests.get(
125+
endpoint,
126+
headers={"auth-token": token},
127+
stream=True,
128+
timeout=60,
129+
)
130+
response.raise_for_status()
131+
132+
with open(destination, "wb") as file_handle:
133+
for chunk in response.iter_content(chunk_size=8192):
134+
if chunk:
135+
file_handle.write(chunk)
136+
137+
logging.info("SAP metering sidecar downloaded successfully")
138+
util.set_executable(destination)
139+
return destination
140+
141+
92142
def stage(buildpack_path, build_path, cache_dir):
93143
try:
94144
if _is_usage_metering_enabled():
@@ -105,6 +155,18 @@ def stage(buildpack_path, build_path, cache_dir):
105155
os.path.join(build_path, NAMESPACE, SIDECAR_CONFIG_FILE),
106156
config,
107157
)
158+
elif _is_sap_metering_configured():
159+
endpoint = _get_sap_metering_endpoint()
160+
token = _get_sap_metering_token()
161+
try:
162+
_copy_sap_metering_sidecar(build_path, endpoint, token)
163+
logging.info("SAP metering sidecar staged successfully")
164+
except Exception:
165+
logging.error(
166+
"Encountered an exception while staging the SAP metering sidecar. "
167+
"Continuing buildpack execution."
168+
)
169+
logging.debug("SAP metering sidecar staging exception details:", exc_info=True)
108170
else:
109171
logging.info("Usage metering is NOT enabled")
110172
except Exception:

requirements.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
backoff==2.2.1
22
certifi==2024.8.30
3-
cryptography==46.0.5
3+
cryptography==47.0.0
44
distro==1.9.0
55
httplib2==0.22.0
66
jinja2==3.1.6
77
omegaconf==2.3.0
88
psycopg2-binary==2.9.10
99
pyyaml==6.0.2
10-
requests==2.32.5
11-
urllib3==2.6.3
10+
requests==2.34.2
11+
urllib3==2.7.0

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cffi==2.0.0
1616
# via cryptography
1717
charset-normalizer==2.0.3
1818
# via requests
19-
cryptography==46.0.5
19+
cryptography==47.0.0
2020
# via -r requirements.in
2121
distro==1.9.0
2222
# via -r requirements.in
@@ -40,11 +40,11 @@ pyyaml==6.0.2
4040
# via
4141
# -r requirements.in
4242
# omegaconf
43-
requests==2.32.5
43+
requests==2.34.2
4444
# via -r requirements.in
4545
typing-extensions==4.15.0
4646
# via cryptography
47-
urllib3==2.6.3
47+
urllib3==2.7.0
4848
# via
4949
# -r requirements.in
5050
# requests

0 commit comments

Comments
 (0)