An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/domonda/go-rcom

Package rcom provides remote command execution over HTTP with file transfer support. The rcom package allows executing CLI commands on remote servers via HTTP, with support for transferring input files, receiving output files, and capturing command output. Commands run in isolated temporary directories for security and cleanliness. Start a server that allows specific commands: Create a client and execute commands: Commands are represented by the Command struct which includes: - Name: The command to execute - Args: Command arguments - Files: Input files (name -> content) - Stdin: Standard input data - ResultFilePatterns: Glob patterns for result files - NonErrorExitCodes: Exit codes to not treat as errors Both local and remote execution are supported: Input files are sent with the command and written to a temporary directory. Result files matching specified patterns are collected and returned: The server implements several security measures: - Command whitelisting: Only explicitly allowed commands can be executed - Path validation: Filenames cannot contain path separators - Isolated execution: Each command runs in a unique temporary directory - Subprocess cleanup: Child processes are killed on context cancellation The Executor interface provides a common abstraction for both local and remote execution: This allows swapping between local and remote execution transparently: The Result struct contains: - CallID: Unique identifier for the execution - ExitCode: Command exit code - Output: Combined stdout and stderr - Stdout: Standard output - Stderr: Standard error - Files: Result files (name -> content) Access result files: Or write directly to a file: The server supports graceful shutdown when configured: On receiving SIGTERM, SIGINT, or SIGHUP, the server will: 1. Stop accepting new requests 2. Wait for in-flight requests to complete 3. Shutdown after timeout if requests are still running The package uses github.com/domonda/golog for logging. Set a custom logger: Pass nil to disable logging: All execution functions support context.Context for cancellation and timeouts: Commands respect context cancellation and will terminate running processes. Errors are returned with context. Common scenarios: - Non-zero exit codes are treated as errors unless in NonErrorExitCodes - Command not allowed on server - Invalid filenames - Context cancellation - Timeout expiration 1. Always whitelist only necessary commands on the server 2. Use timeouts on clients to prevent hanging 3. Validate result files before processing 4. Use result patterns to avoid transferring unnecessary files 5. Handle non-zero exit codes explicitly 6. Use context for cancellation support 7. Log call IDs for debugging

Registry - Source - Documentation - JSON - codemeta.json
purl: pkg:golang/github.com/domonda/go-rcom
License: MIT
Latest release: about 3 years ago
First release: about 3 years ago
Namespace: github.com/domonda
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 4 days ago

    Loading...
    Readme
    Loading...