Skip to content

test : added unit tests for classify_memory_violation and resolve_sandbox_config#1229

Open
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#1224
Open

test : added unit tests for classify_memory_violation and resolve_sandbox_config#1229
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#1224

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #1224.

Summary of What Has Been Done:
Created testing/backend/unit/test_sandbox_executor.py covering the classify_memory_violation and resolve_sandbox_config pure helpers from backend.secuscan.sandbox_executor. These are not covered by testing/backend/test_sandbox_executor.py which tests sandbox_execute end-to-end.

Changes Made:

  • classify_memory_violation: 10 tests covering exit-code detection (-11 SIGSEGV, 139 Linux SIGSEGV, exit 0, non-zero), stderr text detection (MemoryError, Cannot allocate memory), and RSS threshold detection (95%%, 96%%, below 95%%, ignored on exit 0)
  • resolve_sandbox_config: 3 tests covering no-override (returns global defaults), partial override (only overridden fields change), and full override (all fields match plugin config)
  • Settings patching uses config_module.settings attribute swap with try/finally for isolation
  • 14 tests total, all passing

Impact it Made:
classify_memory_violation is a post-mortem heuristic for OOM kills. Incorrect classification could misattribute memory-limit exits. resolve_sandbox_config is the gate between global and per-plugin sandboxing. Both are now unit-tested for regression safety.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

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.

test : add unit tests for classify_memory_violation pure function

1 participant