You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@burr.apache.org by "elijahbenizzy (via GitHub)" <gi...@apache.org> on 2026/10/04 20:30:23 UTC
[PR] fix(tracking): validate app ids in the local tracking client [burr]
elijahbenizzy opened a new pull request, #946:
URL: https://github.com/apache/burr/pull/946
`LocalTrackingClient` validated project names but not `app_id`, even though both become directory names under `storage_dir`. This change applies one rule to both (letters, digits, `_`, `-`, `.`, `:`; non-empty; not `.`/`..`; at most 255 chars) and adds a containment check on every path the client builds, so a malformed id fails at `ApplicationBuilder.build()` rather than producing files in unexpected places.
Side effects: project names may now contain `.`; the project-name error message is shorter. The validation helper lives in `burr/tracking/common/identifiers.py` so the tracking server can share it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(tracking): validate app ids in the local tracking client [burr]
Posted by "sangkyoonnam (via GitHub)" <gi...@apache.org>.
sangkyoonnam commented on code in PR #946:
URL: https://github.com/apache/burr/pull/946#discussion_r4206431195
##########
burr/tracking/common/identifiers.py:
##########
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Validation for the identifiers (project names, application ids) that the tracking
+layer turns into filesystem paths, plus a helper that keeps the resulting paths inside
+the storage directory."""
+
+import os
+import re
+from typing import Optional
+
+from burr import system
+
+# Letters, digits, underscore, hyphen, colon and dot. This covers uuid4 (hex and
+# hyphens) as well as the session/conversation style ids applications tend to pass
+# through as app ids.
+_ALLOWED_CHARACTERS = r"A-Za-z0-9_\-:."
+IDENTIFIER_PATTERN = re.compile(f"^[{_ALLOWED_CHARACTERS}]+$")
+MAX_IDENTIFIER_LENGTH = 255
+
+
+def validate_identifier(value: str, what: str, *, on_windows: Optional[bool] = None) -> str:
+ """Checks that ``value`` can be used as a single path component under the storage directory.
+
+ The rule: a non-empty string of at most 255 characters drawn from letters, digits, ``_``,
+ ``-``, ``:`` and ``.``, and not the special directory names ``.`` or ``..``. On Windows
+ ``:`` is also refused, as it is a drive/stream separator there.
+
+ :param value: the identifier to check
+ :param what: short label for the error message, e.g. ``"app_id"`` or ``"project"``
+ :param on_windows: platform override, defaults to the current platform; exposed for tests
+ :return: ``value`` unchanged, so the call can be used inline
+ :raises ValueError: if the identifier does not meet the rule
+ """
+ if on_windows is None:
+ on_windows = system.IS_WINDOWS
+ if not isinstance(value, str):
+ raise ValueError(f"{what} must be a string, got {type(value).__name__}: {value!r}")
+ if not value:
+ raise ValueError(f"{what} must not be empty")
+ if len(value) > MAX_IDENTIFIER_LENGTH:
+ raise ValueError(
+ f"{what} must be at most {MAX_IDENTIFIER_LENGTH} characters, got {len(value)}"
+ )
+ if value in (".", ".."):
+ raise ValueError(f"{what} must not be '.' or '..', got {value!r}")
+ if not IDENTIFIER_PATTERN.match(value) or (on_windows and ":" in value):
Review Comment:
`IDENTIFIER_PATTERN.match(value)` with a pattern ending in `$` accepts `"x\n"` and `"..\n"`; `$` matches before a final newline. `IDENTIFIER_PATTERN.fullmatch(value)` (or `\Z` in the pattern) rejects them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(tracking): validate app ids in the local tracking client [burr]
Posted by "skrawcz (via GitHub)" <gi...@apache.org>.
skrawcz commented on PR #946:
URL: https://github.com/apache/burr/pull/946#issuecomment-6052539286
One remaining integration gap: the bundled demo routers pass URL `app_id` values into `LocalTrackingClient`. This PR correctly rejects invalid IDs at the filesystem sink, but the resulting `ValueError` currently escapes the demo endpoint as HTTP 500.
Before merging, please:
1. Add route-level validation or exception translation so invalid demo `project_id`/`app_id` values return HTTP 400.
2. Add an integration test covering an encoded `..` app ID against at least the counter create endpoint and asserting both HTTP 400 and no writes outside the project application directory.
3. Fix the regex to use `fullmatch()` (or `\Z`) so trailing newlines cannot pass validation.
Keeping validation in `LocalTrackingClient` is correct—the filesystem sink must remain protected even outside HTTP usage. The route layer should additionally translate that validation failure into the appropriate response.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(tracking): validate app ids in the local tracking client [burr]
Posted by "github-actions[bot] (via GitHub) via notifications" <no...@burr.apache.org>.
github-actions[bot] commented on PR #946:
URL: https://github.com/apache/burr/pull/946#issuecomment-6915130088
This PR has been inactive for 15 days after receiving review feedback.
Converting to draft.
Please mark it as ready for review when you have addressed the comments.
If no activity occurs within 90 days, it will be closed automatically.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(tracking): validate app ids in the local tracking client [burr]
Posted by "elijahbenizzy (via GitHub)" <gi...@apache.org>.
elijahbenizzy commented on PR #946:
URL: https://github.com/apache/burr/pull/946#issuecomment-6235631690
@skrawcz addressed all three: (1) `InvalidIdentifier` is translated to HTTP 400 at the app level, so the demo routes no longer 500; (2) integration test posts an encoded `..` to the counter create route and checks nothing lands on disk; (3) rule now rejects control characters outright, so the trailing-newline case is closed. On the upgrade question from @sangkyoonnam: the rule is widened to any single path segment, so previously valid ids like `user@example.com` still work; see the description for the exact list. Sangkyoon, your fixtures are welcome again if you have time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(tracking): validate app ids in the local tracking client [burr]
Posted by "xihaian251 (via GitHub) via notifications" <no...@burr.apache.org>.
xihaian251 commented on PR #946:
URL: https://github.com/apache/burr/pull/946#issuecomment-6543176214
I found one additional issue in `join_within` while testing the #319 integration on Windows.
Under concurrent directory creation, I ran 8 threads creating 3 applications each across 4 partitions. In 2 of 6 rounds, `join_within` intermittently raised `InvalidIdentifier` for a target that was still inside the project directory.
Instrumentation showed that an immediate retry succeeded with the same resolved path strings. This appears to be a transient inconsistency in `os.path.realpath`'s path representation during concurrent directory creation, rather than an actual containment violation.
In my #319 integration candidate, a single re-check in the caller avoids this false rejection while still rejecting genuine path escapes.
I believe the more appropriate long-term fix would be in the shared `join_within` helper itself. One possible approach is to normalize both resolved paths with `os.path.normcase` and retry the containment comparison once. Another possibility worth considering is `os.path.samestat`.
I haven't modified your branch or opened a separate PR for this. I wanted to share the reproducible behavior first and get your thoughts on the appropriate fix.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@burr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org