Skip to content

fix(salting): mount router, add CLI harness, fix script reference - #1012

Merged
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
Rudra-clrscr:fix/1001-salting-router-mount
Jul 29, 2026
Merged

fix(salting): mount router, add CLI harness, fix script reference#1012
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
Rudra-clrscr:fix/1001-salting-router-mount

Conversation

@Rudra-clrscr

Copy link
Copy Markdown
Contributor

Closes #1001

Problem

/api/salting/* was completely unreachable: the router was never required
or app.use()'d in server.js, and even mounted it pointed at a
nonexistent text_salting_detector.js instead of the real
text_salting_detector.py.

Fix

  • Required and mounted saltingRoutes at /api/salting, matching the
    existing convention (sibling to /api/poisoning).
  • Fixed SALTING_SCRIPT's path to the .py file that actually exists.
  • text_salting_detector.py had no --command/--params CLI handling at
    all
    — only a hardcoded demo in __main__. Even a correct path reference
    wouldn't have produced usable JSON. Added a run_cli() harness matching
    the contract already established by multi_level_defense.py, exposing
    detect and status; the no-args demo behavior is preserved.
  • Two render/OCR failure-path print() calls wrote warnings to stdout,
    which would corrupt the JSON response whenever rendering or OCR fails (a
    likely real-world path, not just a sandbox quirk) — redirected both to
    stderr.
  • Fixed a genuine ZeroDivisionError in detect()'s "hidden text exceeds
    visible text" branch, triggered whenever OCR extracts zero visible text
    and hidden content is under the 100-char fast-path threshold.

Verification

Verified end-to-end via the exact spawn() call saltingRoutes.js uses:
--command status and --command detect both return clean, single-JSON-object
stdout — confirmed by installing the real opencv-python/pytesseract/
html2image deps from requirements.txt and running actual HTML with
hidden content through it, with render/OCR warnings correctly routed to
stderr instead of polluting stdout.

/api/salting/* was completely unreachable: the router was never
required or app.use()'d in server.js, and even after mounting it
pointed at a nonexistent text_salting_detector.js instead of the
real text_salting_detector.py.

- Require and mount saltingRoutes at /api/poisoning's sibling path,
  /api/salting, matching the existing mounting convention.
- Fix SALTING_SCRIPT's path to point at the .py file that actually
  exists.
- text_salting_detector.py had no --command/--params CLI handling at
  all (only a hardcoded demo in __main__), so even a correct path
  reference wouldn't have produced usable JSON for the Node side to
  parse. Added a run_cli() harness matching the --command/--params
  contract already established by multi_level_defense.py, exposing
  'detect' and 'status'; the no-args demo behavior is preserved.
- Two of the render/OCR failure-path print() calls wrote warnings to
  stdout, which would have corrupted the JSON response whenever
  rendering or OCR failed (a very likely path in real deployments,
  not just this sandbox) - redirected both to stderr.
- Fixed a genuine ZeroDivisionError in detect()'s "hidden text
  exceeds visible text" branch, triggered whenever OCR extracts zero
  visible text and hidden content is below the 100-char fast-path
  threshold - reuses the already-safe hidden/(visible+1) ratio
  instead of a second, unguarded hidden/visible division.

Verified end-to-end via the exact spawn() call routes/saltingRoutes.js
uses: --command status and --command detect both return clean,
single-JSON-object stdout (confirmed by installing the real
opencv-python/pytesseract/html2image deps from requirements.txt and
exercising real HTML with hidden content), with render/OCR warnings
correctly routed to stderr instead of polluting stdout.

Closes Userunknown84#1001
Copilot AI review requested due to automatic review settings July 28, 2026 17:17
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added SSoC26 bug Something isn't working labels Jul 28, 2026
@Userunknown84
Userunknown84 merged commit 95262f5 into Userunknown84:main Jul 29, 2026
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Medium SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Text-salting detection API is unreachable — router never mounted, and targets a non-existent .js script instead of text_salting_detector.py

3 participants