Honoring server-reported and client-enabled capabilities
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ruby
- Lĩnh vực
- api, networking
Hướng nghiên cứu
Bắt đầu bằng cách lập bản đồ các bước kiểm tra capability được mô tả cho Net::IMAP#enforce_capabilities=, initialize và các phương thức lệnh như #starttls, #authenticate và #login. Xem xét các dependency đã hoàn tất và các security subtask chưa được giải quyết trước khi quyết định API và hành vi lỗi. Được xem là hoàn tất khi việc xử lý capability của client và server theo đặc tả, các mode cấu hình và các ngoại lệ bảo mật đã được triển khai và kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- Depends on:
- #31
- #33
- Subtasks:
- Security related (authentication, TLS, etc)
- #32
- #48
- #134
- Security related (authentication, TLS, etc)
- Related:
- refuse LOGIN for cleartext connections
- refuse AUTHENTICATE for cleartext connections, configurable per authenticator
Using capabilities information
The client should track whenever it is knowingly violating capabilitied, either server reported or client enabled. At the very least, this should include checking capabilities before sending specific commands or command arguments.
Client-enabled capabilties
There will be no API to work around client.enable(capability). Users who are determined to evade this limitation can figure out how cheat with client.instance_variable_set(...).
Server reported capabilities
The server capabilties cache will always be kept up-to-date when capabilities are checked. If the server hasn't sent its capabilities unsolicited, the client will request capabilties whenever capabilities are checked.
If the capabilities check fails:
- For new commands or new arguments to existing commands.
- A
CapabilityErrorwill be raised without issuing any command to the server,
- A
- Where there is a security risk.
- A
CapabilityErrorwill be raised without issuing any command to the server, - This is backwards incompatible!
- A
- For other existing commands with existing command arguments.
- A warning will be printed to
$stderrbut the command will still be sent
- A warning will be printed to
In some future version of Net::IMAP (perhaps the version released with ruby 3.2 or 3.3), the default for existing commands should change to match the behavior for new commands.
Configuration
To opt-out of the new behavior or to opt-in to more strict behavior:
Net::IMAP#enforce_capabilities=nil-- Uses the current default behavior, which can change in future releases.true-- Always raise an exception for any failed capabilities checks. Never knowingly sends unsupported commands or command arguments to the server.:warn-- Prints a warning to$stderrfor non-security-related capabilities, regardless of the command or the currentNet::IMAPdefault. Still raises for security-related capabilities checks.false-- Restores old default behavior: client doesn't care about server capabilities. Still warns for security-related capabilities checks.def []: (CapabilityError, Net::IMAP) -> (nil | true | false | :warn), eg. aProc. May change security-related capabilities handling.. The command, command args, required capabilities, etc will all be available on CapabilityError.
Net::IMAP#initialize(*args, **kwargs, enforce_capabilities: cfg)- Shorthand for
Net::IMAP.new(...).tap {|client| client.enforce_capabilities = cfg }
- Shorthand for
Net::IMAP#cmdname(..., enforce_capabilities: cfg)#cmdnamerepresents any command which might check server capability.- This kwarg also changes security-related capabilities handling for
#starttls,#authenticate,#login.
opting out of security errors
enforce_capabilities: false will still raise a warning for security related violations. These warnings can only be disabled with a proc.
client.authenticate("PLAIN", username, password, enforce_capabilities: false)
# $stderr << "warning: Ignoring server capability \"AUTH=PLAIN\"" unless capability?("AUTH=PLAIN")
# The server might respond with a tagged `NO` => `NoResponseError`
client.login(username, password, enforce_capabilities: false)
# $stderr << "warning: Ignoring server capability \"LOGINDISABLED\"" if capability?("LOGINDISABLED")
# The server might respond with a tagged `NO` => `NoResponseError`
# Always ignore server capabilities. Please don't do this!
client = Net::IMAP.new(..., enforce_capabilities: -> _ { false })
client.enforce_capabilities = -> _ { false }
Allow fine-grained configuration with a Proc
The arguments will be a CapabilityError exception (which can be raised) and the Net::IMAP client object (in case the proc is shared between multiple clients). CapabilityError should have at least one sub-class, SecurityCapabilityError, to represent LOGINDISABLED, AUTH=, STARTTLS capabilities, etc. CapabilityError and its subclasses should allow pattern matching via #deconstruct and/or #deconstruct_keys
This could be used to:
- add support for capabilities which haven't been added to
net-imapyet - log unexpectedly missing security related capabilities errors.
- log all capabilities errors.
client.enforce_capabilities = proc do |error|
case error
in AuthCapabilityError{sasl_mechanism: "FOOBAR"}
raise "Server doesn't support our pretend SASL mechanism"
in SecurityCapabilityError{command: "AUTHENTICATE" | "STARTTLS"}
raise SecureAuthUnsupportedError
in SecurityCapabilityError
raise error
in command: "SELECT" | "EXAMINE", capability: "QRESYNC"
error.run_alternate_commands do
# a theoretical API for gracefully degrading
end
in capability: "X_PLEASE_WARN"
logger.warn { "X_WARNING: error.warning" }
in capability: "X_PLEASE_WARN_2"
# let Net::IMAP handle warning via $stderr
# just like client.enforce_capabilities = :warn
:warn
in capability: "BINARY"
# let Net::IMAP raise the error
# just like client.enforce_capabilities = true
true
in capability: "X_THIS_CLIENT_ALLOWS_IT"
# ignore the missing capability
# just like client.enforce_capabilities = false
false
else
# use the default behavior for this version of Net::IMAP, i.e. warn now, raise later
# just like client.enforce_capabilities = nil
nil
end
end
- Ngôn ngữ chính
- Ruby
- Star
- 121
- Fork
- 47
- Merge trung bình
- 19 giờ 25 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby/net-imap
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Cannot use FakeServerĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của ruby/net-imap
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Websockify heartbeat for vnc_containerCó thể đã có người làm @robinkar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs verification
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 7 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
akitaonrails/ai-book-2026#13 ·
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày