Skip to content

Reject invalid upload chunk sizes before opening a channel - #87

Open
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/validate-chunk-size
Open

Reject invalid upload chunk sizes before opening a channel#87
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/validate-chunk-size

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Reject zero, negative and non-Integer upload chunk sizes before opening an SSH channel. Preserve the existing nil/false default behavior.

Reproduction and evidence

Standalone local reproduction:

require 'net/scp'
require 'stringio'
session = Object.new
def session.logger; nil; end
def session.open_channel; raise 'channel was opened'; end
Net::SCP.new(session).upload(StringIO.new('abc'), 'out', chunk_size: 0)
# before: channel was opened; after: ArgumentError

Zero-sized reads repeatedly produce an empty String and never reach EOF. Focused/model checks reject 0, negative integers, floats, strings and arbitrary objects before channel creation, and accept positive integers and the existing defaults.

Compatibility / breaking changes

Intentional validation change: previously coerced non-Integer values (for example 1.5) now raise ArgumentError. Zero/negative invalid values fail earlier instead of hanging/failing after channel setup. Positive Integer behavior is unchanged.

Verification and limits

  • This focused branch passes the existing upstream suite: 36 tests / 70 assertions, Ruby 4.0.6, net-ssh 7.3.3, test-unit 3.7.8 and Mocha 2.1.0; all Ruby commands used rbenv.
  • The combined release-based consumer candidate passes the suite with frozen string literals enabled, 10 focused cases, 2,906 model assertions, 24 URI-component assertions and 19 local scp/URI assertions. Combined evidence includes other separately proposed fixes and existing upstream frozen-string corrections; it is not attributed to this patch alone.
  • No repository tests added/modified under the consuming project's explicit no-new-tests policy. Reproductions/models ran externally. No deployed servers, SSH connections or production data were used.
  • All seven runtime files parse with the Ruby 2.6 parser; actual older-Ruby/Windows/remote-server matrices were not run locally. No upstream lint config exists; targeted lint has the same eight pre-existing warnings, with no new warnings.
  • Existing upstream PRs/issues and contribution guidance were checked. Maintainer CI results are pending; no CI pass is claimed.

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.

1 participant