Skip to content

fix: eliminate security vulnerabilities and strengthen test coverage#13

Merged
pmclSF merged 7 commits intomainfrom
security/fix-critical-vulnerabilities
Feb 28, 2026
Merged

fix: eliminate security vulnerabilities and strengthen test coverage#13
pmclSF merged 7 commits intomainfrom
security/fix-critical-vulnerabilities

Conversation

@pmclSF
Copy link
Owner

@pmclSF pmclSF commented Feb 28, 2026

Summary

  • Phase 1: Repository hygiene — removed tracked .pyc/egg-info artifacts, fixed packaging (setup.py deps, Python version), converted to relative imports, fixed parallel_process.py unconditional terminate and mp_report.py compression ratio direction
  • Phase 2: Data pipeline fixes — OFF parser robustness, mesh sampling boundary bugs, PLY I/O safety, octree block processing edge cases
  • Phase 3: Entropy model mathematics — discretized Gaussian likelihood numerical stability, z_bits computation, joint rate-distortion optimization
  • Phase 4: Architecture alignment — GDN layer rewrite (correct divisive normalization formula), synthesis transform output activation, encode/decode consistency
  • Phase 5: Validation test suite — 141 new tests across 6 files covering entropy correctness, mask causality, model roundtrip, numerical stability, data pipeline, and benchmarks

Result: 379 tests passing, 0 failures. Addresses all 66 findings from adversarial code review.

Test plan

  • ruff check src/ tests/ — passes clean
  • pytest tests/ -v -m "not gpu and not slow" — 379 passed, 0 failures
  • New test files: test_entropy_correctness.py, test_causality.py, test_roundtrip.py, test_numerical.py, test_data_pipeline.py, test_benchmarks.py

🤖 Generated with Claude Code

pmclSF and others added 7 commits February 27, 2026 17:03
- Remove numpy.load(allow_pickle=True) in compress_octree.py and
  training_pipeline.py to prevent arbitrary code execution via crafted
  .npy/.npz files. Metadata now saved as JSON sidecar; optimizer
  variables saved as individual .npy files with numeric dtypes.
- Add path validation in training_pipeline.py (traversal guard) and
  evaluation_pipeline.py (existence check) for checkpoint loading.
- Replace model.save() with model.save_weights() in cli_train.py to
  avoid full SavedModel format vulnerable to Keras deserialization RCE.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…age analysis

Bug fixes in source:
- compress_octree: _save_debug_info no longer pickles dicts (only saves ndarrays)
- compress_octree: save_compressed converts NaN/Inf scalars to None for valid JSON
- training_pipeline: path validation uses Path.relative_to() to prevent prefix
  collision bypass (e.g. checkpoints_evil matching checkpoints prefix)

New tests (26 total, 213 → 239):
- test_compress_octree (13): NaN/Inf metadata, empty grid, no-normals roundtrip,
  missing sidecar/grid files, debug pickle prevention, metadata value fidelity,
  numpy scalar types, dtype change documentation, E2E quality check
- test_training_pipeline (9): path traversal/absolute/prefix-collision rejection,
  NaN in optimizer vars, save before training, missing weights, partial optimizer
  files, old pickle format ignored, optimizer state value fidelity
- test_evaluation_pipeline (3): no checkpoint configured, empty string checkpoint,
  missing checkpoint raises FileNotFoundError
- test_integration (1): checkpoint resume preserves eval loss

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ixes

Remove 37 tracked .pyc/egg-info build artifacts from git index.
Convert all intra-package imports in src/ to relative imports and add a
meta-path import hook in conftest.py so test files work unchanged.
Fix setup.py dependencies (add tensorflow, tf-probability, etc; remove
pytest from install_requires), set version 2.0.0, require Python >=3.10.
Update pyproject.toml target-version to py310.
Replace hardcoded CI test file list with pytest discovery.
Fix evaluation_pipeline --checkpoint CLI arg not being applied.
Fix Popen.__exit__ unconditionally terminating finished processes.
Fix mp_report compression_ratio direction (higher is better).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ation

- Add src/file_io.py with read_off(), read_ply(), read_point_cloud() dispatcher
- Fix data_loader.py: use file_io for both .off/.ply, guard divide-by-zero in normalization
- Fix ds_mesh_to_pc.py: triangulate n-gon faces, replace centroid with barycentric sampling
- Fix ds_pc_octree_blocks.py: replace broken TF PLY parser, remove dual file write
- Fix octree_coding.py and compress_octree.py: half-open intervals prevent boundary duplication
- Fix cli_train.py: use read_point_cloud instead of read_off for .ply files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t optimization

Replace continuous log-PDF with discretized CDF-difference probability mass
function for correct entropy coding. Fix quantization to use standard grid
(round(y - mean), not round((y - mean) / scale)). Add missing z_bits
(hyper-latent rate) to total bitrate across all entropy models. Switch
training pipeline to joint rate-distortion optimization with gradient
clipping and configurable lambda_rd.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…de consistency

Phase 4 of adversarial code review fixes:
- Replace CENICGDN with standard GDN (Balle 2016) supporting inverse (IGDN) for synthesis
- Fix SynthesisTransform to always use Conv3DTranspose (was incorrectly downsampling with SpatialSeparableConv)
- Fix DeepCompressModel.call() to pass quantized y_hat to synthesis, apply sigmoid to output
- Fix DeepCompressModelV2 compress/decompress for all 6 entropy model types
- Fix HybridAttentionEntropyModel: proper attention-to-params projection (replaces concat hack)
- Fix ChannelContextEntropyModel inference path for first channel group
- Fix quick_benchmark: proper decode timing, Shannon entropy estimate, V1 unpack
- Fix training_pipeline: empty validation guard, V1 unpack
- Fix evaluation_pipeline: V1 unpack
- 238 tests pass, ruff clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…roundtrip, numerical stability

Add 6 new test files with 141 tests validating mathematical correctness:
- test_entropy_correctness: PMF validity, rate computation, quantization behavior
- test_causality: MaskedConv3D causal masks, raster-scan ordering, AutoregressiveContext
- test_roundtrip: V1/V2 compress/decompress shape/bounds/determinism, gradient flow
- test_numerical: GDN/IGDN stability, entropy model extreme values, constants correctness
- test_data_pipeline: OFF/PLY I/O, mesh sampling, point cloud partitioning
- test_benchmarks: Benchmark utilities, timing methodology, comparison functions

Full suite: 379 passed, 0 failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pmclSF pmclSF merged commit 7765320 into main Feb 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant