Skip to content

Add the #129 fragment-length check for #20 - #135

Merged
QuiteYellow merged 7 commits into
scratch/test-scriptsfrom
scripts/pr129-check
Nov 14, 2026
Merged

QuiteYellow merged 7 commits into
scratch/test-scriptsfrom
scripts/pr129-check

Conversation

@QuiteYellow

@QuiteYellow QuiteYellow commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

A script for @maxromanovsky to run on #20, following his offer to test #129 (comment).

pr-129-fragment-length/pr129_check.py installs the library at #129's head, b40b720, and drives FragmentingCertificateAuth through DtlsCoapSession. Per appliance:

  • Arm 1: a session at a fragment length of 1024 that reads /oic/d.
  • Arm 2: a session at 512 that reads /oic/d, then /device/0. It runs only if the handshake in arm 1 completed. The small read goes first because a session can stop answering after a large read times out.

After each arm, a plaintext directory read shows whether the appliance stayed on the network. The run makes at most four handshakes from one fixed local port, with at least 60 s of quiet before each one after the first. The quiet time starts again when the appliance answers after a drop-off: on #20 the units took 22.8 and 26.2 s to come back (comment), so a fixed gap from the handshake end could leave only a few seconds.

Choices a reviewer may want to question:

  • SessionError is redacted, so the alert name comes from the line the session logs on a failed handshake. One test runs the library's real connect() over a fake connection that fails with an alert, so a change to how that line is logged fails it. A second test reads the engine's alert wording from its source.
  • Any failure in arm 1 skips arm 2. After a timeout, the same port can stay locked out for more than ten minutes, and after an alert, arm 2 would meet the same refusal.
  • The credential is loaded before anything is sent, through the provider's private _load_client_credential(), because the provider reads its files only at the first connect.
  • At b40b720, the first request of a read carries no Block2 option, so the appliance chooses the block size, and nothing in the client lowers it to the negotiated length. Arm 2 tests what Add a certificate-capable DTLS client that can offer max_fragment_length #129 ships. On my dryer and oven, /device/0 at 512 ended in FragmentLimitTimeoutError, so that is the expected result on arm 2.
  • The handshake deadline is 3 s, where the library default is 12 s. The engine repeats a flight after 1 s, 2 s and 4 s, and on Can't connect to BespokeAI Washer/Dryer #20 each repeat of the cookie ClientHello asks the unit for the flight that takes it off the network. 3 s allows one repeat, so one lost datagram is recovered and a second times out arm 1.

This branch has no CI. test_pr129_check.py (25 tests, offline) passes on Python 3.11 to 3.14 and on 3.11 at the dependency floor, with the library installed from b40b720. On 2026-11-14 I ran the script at 6a49596 against my dryer and oven, from a fresh python:3.11 container on the host network, with the library installed by the pip line in its header. All four handshakes completed, /oic/d read at 1024 on both, and both answered plaintext 0.1 s after each arm. The output carried no address, UUID or path.

pr129_check.py drives PR #129's FragmentingCertificateAuth through DtlsCoapSession against one or two appliances. Arm 1 offers a fragment length of 1024 and reads /oic/d. Arm 2 offers 512 and reads /device/0. It runs only if the handshake in arm 1 completed. After each arm, a plaintext directory read shows whether the appliance stayed on the network.

The run is capped at four handshakes, holds one local port, and waits at least 30 s between handshakes. The script reads the reason for a handshake failure from the library log and names a peer alert. The output prints no address, UUID, serial or certificate detail.

test_pr129_check.py covers the arm decisions, the ceiling, the redaction, and the two library strings that the script depends on. It runs offline. 11 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T14:00:00+00:00

@QuiteYellow-reviewer QuiteYellow-reviewer 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.

Automated review at a2b3c31.

Not run: the script and the tests. The branch has no CI. The review read the diff and the library at b40b720.

Two findings, one risk, two nits. Each one is inline.

Questions:

  1. Arm 2 reads /device/0 at 512. Does that read measure what a failed large read costs the appliance? If not, /oic/d at 512 may answer more of #20.
  2. connect(cleanup_hvr_peer=True) accepts only the exact types CertificateAuth and ServerCertificateAuth (dtls_session.py:865-872 at b40b720). Is the missing timeout cleanup for FragmentingCertificateAuth a known gap in #129?
  3. discover_ocf_secure_ports calls an advertised port a candidate until probe_dtls_ports checks it (ocf_discovery.py:870-872). Is the probe left out to save ClientHellos?

Comment thread pr-129-fragment-length/pr129_check.py Resolved
Comment thread pr-129-fragment-length/pr129_check.py Resolved
Comment thread pr-129-fragment-length/pr129_check.py Resolved
Comment thread pr-129-fragment-length/pr129_check.py Resolved
The docstring said a read asks for 1024-byte blocks on its first block. The first request of a read carries no Block2 option, so the appliance chooses the block size, and nothing in the client lowers it to the negotiated length.

The test of the library log line read only its source text, so a change of level or logger kept it passing while the script lost every alert name. A test now runs the real DtlsCoapSession.connect() over a fake connection that fails with an alert, and checks that the script names it. With the library's warning demoted to info, that test fails.

The liveness check now counts any answer from the plaintext directory, not only one that lists a secure port, so an appliance that answers with no port no longer reads as gone from the network.

Alert 22 is named record_overflow. Every exit after the prompt prints the reminder to re-enable the integration, and Ctrl-C exits 130.

16 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor, with the library installed from b40b720.

Publish-Approved: 2026-11-14T17:45:00+00:00

@QuiteYellow-reviewer QuiteYellow-reviewer 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.

Automated re-review at 1086f48, against review 5906113699 at a2b3c31.

Not run: the script and the tests. The branch has no CI.

All five findings are fixed. One new nit is inline. The three questions in the earlier review are still open. None of them blocks a merge.

@QuiteYellow-reviewer QuiteYellow-reviewer 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.

Automated re-review at 9efc5b7, against review 5906228951 at 1086f48.

Not run: the script and the tests. The branch has no CI.

N1 is fixed. The claims in the new comments hold against b40b720. One new nit is inline.

Question: the PR body does not mention the change of the handshake deadline from 15 s to 3 s. 3 s recovers from one lost datagram. A second loss times out arm 1, and arm 2 is then skipped. Add this to the list of choices?

The handshake deadline goes from 15 s to 3 s. The engine retransmits a flight after 1 s, 2 s and 4 s, and each repeat of the cookie ClientHello asks the appliance for its whole flight again. On #20 that flight is what takes the unit off the network, so if a unit ignores the fragment length, 15 s would trigger the drop up to four times. 3 s allows one repeat. Handshakes measured with a fragment length took 0.6 to 1.0 s.

A handshake timeout now says that one attempt is not conclusive, and points to the plaintext check. The header says to run on the host, because Docker bridge NAT drops replies from the port these appliances answer on.

The test module no longer claims "no network": one test binds a local UDP socket and sends nothing. That test uses its own local port, so a real run on the same machine cannot make it fail to bind.

16 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T18:30:00+00:00

@QuiteYellow-reviewer QuiteYellow-reviewer 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.

Automated re-review at 30f3889.

Not run: the tests and the script. This branch has no CI.

R1, R2 and R3 from the review at 6a49596 are fixed. The fix commit adds two nits.

N2, nit.
Problem: A Ctrl-C in two short windows is not handled as the comments say.
Trigger: A Ctrl-C during the smartthings_local import prints a traceback. A Ctrl-C after the prompt, before the try in main(), exits without "Re-enable your integration now".
Fix: Optional. Each window is milliseconds long.

Comment thread pr-129-fragment-length/pr129_check.py Resolved
The docstring said the 60 s quiet time comes before each handshake, but the first handshake does not wait. Each drop-off also adds its recovery time, so a run where the appliances drop off takes 6 minutes or more, not 4. The docstring and the start prompt now say so, because the reader uses them to plan how long the integration stays disabled.

25 tests pass on Python 3.11, 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T18:55:00+00:00
The test used local port 47219, which sits inside the default Linux ephemeral range, 32768-60999. A temporary socket could hold it, and the bind would then fail. It now uses 26961, below that range and next to the default of the script, which avoids the range for the same reason.

16 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T19:00:00+00:00
@QuiteYellow
QuiteYellow merged commit 00c5123 into scratch/test-scripts Nov 14, 2026
The reason filter blocked IPv4 addresses and long hex runs, so an IPv6 address or a hostname passed through. A reason is now printed only if every word is a plain lowercase word, a known protocol name, a short hex code or an exception class name. A test reads every refusal reason from the installed engine and checks that each one still prints, and six identifying shapes are checked to be withheld.

A Python warning printed the path of the file that raised it, which holds the home directory. Warnings now print their class only, set before the library import so import-time warnings are covered. Anything that escapes main() is reported by its class, without a traceback.

24 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T19:30:00+00:00
Arm 2 now reads /oic/d, then /device/0, in one session. A session can stop answering after a large read times out, so the small read goes first. /device/0 timed out at 512 on a dryer and an oven here on 2026-11-14, and the docstring now says that this is the expected result.

The quiet time before a handshake is now 60 s, and it starts again when the appliance answers plaintext after a drop-off. On #20 the units took 22.8 and 26.2 s to come back, so a 30 s gap counted from the handshake end left about 4 s of quiet. The output puts a blank line before each arm, and the cost text states the run time.

The allowlist now passes a signature algorithm pair such as "(4,1)", so the engine's signature-pair reason prints. The test that reads the engine's reasons now joins a reason split across adjacent literals, which is how it missed that one. A Ctrl-C outside main() exits 130 without a traceback. The allowlist comment says that a single-label hostname would pass, and the deadline comment cites the measured handshake times.

25 tests pass on Python 3.11 to 3.14 and on 3.11 at the dependency floor.

Publish-Approved: 2026-11-14T18:50:00+00:00
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.

2 participants