-
Notifications
You must be signed in to change notification settings - Fork 0
fix(security): v0.40.0 — path-boundary scope, more secret redaction, ingestion bounds, run-executor truth, provider errors #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,17 @@ def _norm(name: str) -> str: | |
| return name.lower().replace(" ", "").replace("_", "") | ||
|
|
||
|
|
||
| # Cap every key/prefix/storage-class LABEL: a single object key is bounded only by | ||
| # the 2 GiB upload cap, so one pathological value could blow up the model context | ||
| # and the report prose. Mirrors aggregate._LABEL_LEN / access_logs._LABEL_LEN. | ||
| _LABEL_LEN = 300 | ||
|
|
||
|
|
||
| def _clip(v: object) -> str: | ||
| s = str(v) | ||
| return s if len(s) <= _LABEL_LEN else s[:_LABEL_LEN] + "…" | ||
|
|
||
|
|
||
| # Storage-class tokens used to recognize the storage-class column in a HEADERLESS | ||
| # inventory CSV (S3 + common S3-compatible names). | ||
| _KNOWN_STORAGE = { | ||
|
|
@@ -290,6 +301,10 @@ def series_for(field: str) -> pd.Series: | |
| _AGE_CASE = """ | ||
| CASE | ||
| WHEN try_cast(last_modified AS TIMESTAMP) IS NULL THEN 'unknown' | ||
| -- A future last_modified (clock skew, or a garbage 9999 date) yields a NEGATIVE | ||
| -- age; without this guard it satisfies '<= 7' and is mis-bucketed as freshly | ||
| -- modified ('0-7d'). Treat future-dated objects as 'unknown', not recent. | ||
| WHEN datediff('day', try_cast(last_modified AS TIMESTAMP), current_timestamp) < 0 THEN 'unknown' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This branch now classifies future Useful? React with 👍 / 👎. |
||
| WHEN datediff('day', try_cast(last_modified AS TIMESTAMP), current_timestamp) <= 7 THEN '0-7d' | ||
| WHEN datediff('day', try_cast(last_modified AS TIMESTAMP), current_timestamp) <= 30 THEN '8-30d' | ||
| WHEN datediff('day', try_cast(last_modified AS TIMESTAMP), current_timestamp) <= 90 THEN '31-90d' | ||
|
|
@@ -329,20 +344,21 @@ def analyze_inventory(duckdb_path: str | Path) -> dict[str, Any]: | |
| ).fetchall() | ||
| ] | ||
| prefix_dist = [ | ||
| {"value": str(p), "count": int(c), "size": int(s or 0)} | ||
| {"value": _clip(p), "count": int(c), "size": int(s or 0)} | ||
| for p, c, s in con.execute( | ||
| f"SELECT prefix, count(*) c, COALESCE(sum(size), 0) s FROM {TABLE_NAME} " | ||
| f"GROUP BY prefix ORDER BY s DESC LIMIT {SAMPLE_LIMIT}" | ||
| ).fetchall() | ||
| ] | ||
| storage_dist = [ | ||
| {"value": str(sc), "count": int(c)} | ||
| {"value": _clip(sc), "count": int(c)} | ||
| for sc, c in con.execute( | ||
| f"SELECT storage_class, count(*) c FROM {TABLE_NAME} GROUP BY storage_class ORDER BY c DESC" | ||
| ).fetchall() | ||
| ] | ||
| top_large = [ | ||
| {"key": str(k), "size": int(sz or 0), "storage_class": str(sc) if sc is not None else None} | ||
| {"key": _clip(k), "size": int(sz or 0), | ||
| "storage_class": _clip(sc) if sc is not None else None} | ||
| for k, sz, sc in con.execute( | ||
| f"SELECT key, size, storage_class FROM {TABLE_NAME} " | ||
| f"ORDER BY size DESC NULLS LAST LIMIT {SAMPLE_LIMIT}" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
_nonempty_lines()still returns a materializedlist[str], this 3 GiB ceiling allows a max-size access-log upload to be accumulated in RAM before parsing; for example, a 2 GiB single-line file becomes ~2048 one-MiB chunks appended tooutinimport_access_logs, so the sidecar can still OOM despite the new boundedreadline()loop. The cap needs to be a real in-memory budget or the parser needs to stream chunks instead of collecting them all.Useful? React with 👍 / 👎.