Repository navigation
Audit findings: refuse non-finite STLs, bound uploads, localhost-only compose - #9
Merged
Merged
Conversation
- inlayer: reject non-finite vertices in load_mesh, use integer early-exit in _check_grid_size to avoid float rounding bypass - i18n: log warning on missing translation key - app: chmod uploads 0600, limit to 10 files with error - compose: bind port to 127.0.0.1 with auth hint
- load_mesh loads unprocessed, refuses a NaN or infinite coordinate with its own message, then processes. trimesh's processing dropped such a vertex and hung its triangle on vertex 0, so the check never fired and one bad triangle loaded as a different, real-looking one. A finite file still yields exactly the mesh of trimesh's default load. - _check_grid_size: back to the one-line count, plus an isfinite check. NaN was the only gap - whole numbers stay exact in a float far beyond the 1e9 limit - and the early exit reported a partial voxel count. - app: MAX_UPLOAD_FILES in app_helpers instead of a literal 10; its comment says it bounds the work of a run, not upload memory. The chmod is gone: NamedTemporaryFile creates the file with mode 0600 already. - README and compose.yaml describe the localhost-only port and how to open it to the local network; README names the 10-file limit. - Tests for every change on this branch. The Docker test stage copies compose.yaml for the port test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardening from the audit findings: untrusted input and the default deployment. There are two commits. The first is the hardening itself. The second makes each piece do what its commit message claims and adds tests, because a review found that two of the four changes did nothing or made things worse.
Input
load_meshnow loads unprocessed, checks, then callsprocess(). These files get their own message, "contains invalid coordinates (NaN or infinite)", instead of "contains no triangles". That includes files made only of NaN, which used to get the old message._check_grid_sizecloses the NaN gap. A NaN count failedvoxels > MAX_GRID_VOXELSand passed. It is the old one-line count plusmath.isfinite. The first commit's integer early exit is reverted: the float rounding it guarded against cannot happen (whole numbers stay exact in a float up to 2**53, the limit is 1e9), and its error message reported a partial voxel count (1e10 for a grid of 1e15).Web app
app_helpers.MAX_UPLOAD_FILES). This bounds the work of a single click, not memory: Streamlit already holds every upload when the run starts.inlayer.i18n) instead of failing silently.chmod 0600on the temporary upload files is removed:NamedTemporaryFilealready creates them with that mode.Deployment
compose.yamlpublishes the port on127.0.0.1only. The app has no authentication. README and the compose comment explain how to open it to a trusted network ("8501:8501") and that anything public needs a reverse proxy with authentication.Worth a look before merging
load_meshnow defers trimesh's processing. For finite files the result is the same mesh trimesh's default load builds (byte-identical vertices, faces and normals over boxes, spheres, cylinders, two bodies, degenerate and duplicate faces, binary and ASCII). A test pins this.Tests (513 → 524 in the Docker test stage)
compose.yamlfor this test.inlayer.pyandmain's each fail the tests aimed at them. With processing back at load time, exactly the 5 NaN tests fail. Without the laterprocess(), 20 tests fail.Verified
docker build --target test .: 524 passed, 1 skipped. The runtime image builds anddocker compose configis valid.🤖 Generated with Claude Code