Potential fix for code scanning alert no. 7: Unvalidated dynamic method call#23
Merged
ialejandro merged 1 commit intomainfrom Feb 15, 2026
Merged
Potential fix for code scanning alert no. 7: Unvalidated dynamic method call#23ialejandro merged 1 commit intomainfrom
ialejandro merged 1 commit intomainfrom
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Iván Alejandro Marugán <hello@ialejandro.rocks>
github-actions bot
pushed a commit
that referenced
this pull request
Feb 15, 2026
## [1.1.3](v1.1.2...v1.1.3) (2026-02-15) ### Bug Fixes * Unvalidated dynamic method call ([#23](#23)) ([d2e5cbc](d2e5cbc))
|
🎉 This PR is included in version 1.1.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Potential fix for https://github.com/devops-ia/self-learning-platform/security/code-scanning/7
In general, to fix unvalidated dynamic method calls you ensure that: (1) the method name is restricted to a safe set (or at least checked as an own property), (2) the resolved value is verified to be a function, and (3) the invocation is wrapped so that any unexpected exception is handled gracefully instead of crashing the request. In this code, steps (1) and (2) are already implemented when selecting
handlerToExecute, but the final call on line 52 is unprotected.The best minimal fix that preserves existing behavior is to (a) re‑check that
handlerToExecuteis still a function right before invocation, and (b) wrap the call in atry/catchso that any exception from the handler returns a structuredTerminalResponseinstead of propagating. This does not require changing how commands are matched or how handlers are defined, and it avoids any new dependencies. Concretely, insrc/lib/terminal/simulator.ts, replace the block:with a block that ensures
typeof handlerToExecute === "function"and catches errors, mapping them to a non‑crashing terminal output (for example, an error message and non‑zero exit code). No changes are needed insrc/app/api/terminal/route.ts.Suggested fixes powered by Copilot Autofix. Review carefully before merging.