transformers-0001/ray-project-0001/dask-project-0001/dask-project-0002: 4 CWE-407 defects across 3 ML/data targets
transformers-0001: tokenization_python convert_ids_to_tokens O(T×S) property-rebuild-per-token MEDIUM 3.1x ray-project-0001: dag_node _get_toplevel_child_nodes O(A²) list dedup MEDIUM 1.5x dask-project-0001: parquet filter_partitions disjunction O(P×O) list dedup MEDIUM-HIGH 65x dask-project-0002: methods describe_aggregate O(C²) column name dedup LOW-MEDIUM 12.7x
This commit is contained in:
parent
4560936024
commit
13a4de8613
11 changed files with 486 additions and 0 deletions
30
defects/dask-project/patch/dask-project-0001.patch
Normal file
30
defects/dask-project/patch/dask-project-0001.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# dask-project-0001: parquet/core.py filter_partitions disjunction O(P×O) dedup
|
||||
# CWE-407 — Algorithmic Complexity
|
||||
#
|
||||
# In _filter_partitions(), when combining disjunctions (OR filters), each
|
||||
# partition from a disjunction branch is checked with `if part not in out_parts`
|
||||
# where out_parts is a growing list. This is O(P × O) where P = partitions from
|
||||
# each disjunction and O = accumulated output size.
|
||||
#
|
||||
# For large parquet datasets with many row groups (P=10000+) and multiple
|
||||
# OR filter clauses, this becomes a significant bottleneck.
|
||||
#
|
||||
# Fix: maintain a parallel set of part identities for O(1) membership.
|
||||
# Severity: MEDIUM-HIGH (data I/O path, P can be 10000+ for large datasets)
|
||||
# Speedup: ~50x at P=5000
|
||||
#
|
||||
# File: dask/dataframe/io/parquet/core.py
|
||||
# Function: _filter_partitions
|
||||
--- a/dask/dataframe/io/parquet/core.py
|
||||
+++ b/dask/dataframe/io/parquet/core.py
|
||||
@@ -558,9 +558,11 @@
|
||||
|
||||
out_parts, out_statistics = apply_conjunction(parts, statistics, conjunction)
|
||||
+ out_parts_set = set(id(p) for p in out_parts)
|
||||
for conjunction in disjunction:
|
||||
for part, stats in zip(*apply_conjunction(parts, statistics, conjunction)):
|
||||
- if part not in out_parts:
|
||||
+ if id(part) not in out_parts_set:
|
||||
out_parts.append(part)
|
||||
+ out_parts_set.add(id(part))
|
||||
out_statistics.append(stats)
|
||||
26
defects/dask-project/patch/dask-project-0002.patch
Normal file
26
defects/dask-project/patch/dask-project-0002.patch
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# dask-project-0002: methods.py describe_aggregate column name dedup O(C²)
|
||||
# CWE-407 — Algorithmic Complexity
|
||||
#
|
||||
# In describe_aggregate(), column names are deduplicated using
|
||||
# `if name not in names` where names is a list, making it O(C²) where
|
||||
# C = total number of column names across all describe results.
|
||||
#
|
||||
# Fix: maintain a parallel set for O(1) membership.
|
||||
# Severity: LOW-MEDIUM (describe path, C typically <100 but can grow with wide DataFrames)
|
||||
# Speedup: ~10x at C=500
|
||||
#
|
||||
# File: dask/dataframe/methods.py
|
||||
# Function: describe_aggregate
|
||||
--- a/dask/dataframe/methods.py
|
||||
+++ b/dask/dataframe/methods.py
|
||||
@@ -180,9 +180,11 @@
|
||||
# arrange categorical and numeric stats
|
||||
names = []
|
||||
+ names_set = set()
|
||||
values_indexes = sorted((x.index for x in values), key=len)
|
||||
for idxnames in values_indexes:
|
||||
for name in idxnames:
|
||||
- if name not in names:
|
||||
+ if name not in names_set:
|
||||
names.append(name)
|
||||
+ names_set.add(name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue