[tmf] validate method as POST centrally in resource handlers (#12661)

This commit updates the central CoAP resource handlers in TMF agents
(`Agent::HandleResource`, `BackboneTmfAgent::HandleResource`, and
`Manager::CoapDtlsSession::HandleResource`) to verify that the
incoming request method is a POST request. If the URI is recognized
but the method is not POST, a `kCodeMethodNotAllowed` response is
now sent.

Since all TMF requests are now guaranteed to be POST requests before
reaching their specific handlers, the `IsPostRequest()` checks in
individual handlers are removed. Additionally, the
`IsConfirmablePostRequest()` and `IsNonConfirmablePostRequest()`
helper methods in `Coap::Message` are removed and their usages are
simplified to `IsConfirmable()` and `IsNonConfirmable()` in the
respective handlers.
This commit is contained in:
Abtin Keshavarzian
2026-03-10 22:07:43 -05:00
committed by GitHub
parent d9fce062c7
commit 3559cbd55a
21 changed files with 44 additions and 63 deletions
+2 -2
View File
@@ -3462,7 +3462,7 @@ Error Mle::AddrSolicitInfo::ParseFrom(const Coap::Msg &aMsg)
Error error;
VerifyOrExit(aMsg.IsConfirmablePostRequest(), error = kErrorParse);
VerifyOrExit(aMsg.IsConfirmable(), error = kErrorParse);
SuccessOrExit(error = Tlv::Find<ThreadExtMacAddressTlv>(aMsg.mMessage, mExtAddress));
SuccessOrExit(error = Tlv::Find<ThreadStatusTlv>(aMsg.mMessage, mReason));
@@ -3634,7 +3634,7 @@ template <> void Mle::HandleTmf<kUriAddressRelease>(Coap::Msg &aMsg)
VerifyOrExit(mRole == kRoleLeader);
VerifyOrExit(aMsg.IsConfirmablePostRequest());
VerifyOrExit(aMsg.IsConfirmable());
Log(kMessageReceive, kTypeAddressRelease, aMsg.mMessageInfo.GetPeerAddr());