Skip to content

Fix two bugs in RPCIndividual - #1683

Open
LautaroPetaccio wants to merge 1 commit into
WebFuzzing:masterfrom
LautaroPetaccio:fix/rpc-indexed-calls
Open

Fix two bugs in RPCIndividual#1683
LautaroPetaccio wants to merge 1 commit into
WebFuzzing:masterfrom
LautaroPetaccio:fix/rpc-indexed-calls

Conversation

@LautaroPetaccio

Copy link
Copy Markdown
Collaborator

Two bugs in RPCIndividual, both found while writing an equivalent individual for another problem type and copying this one's shape. Independent of that work, so sent on its own.

seeIndexedRPCCalls always returns an empty map

funseeIndexedRPCCalls(): Map<Int, RPCCallAction> = getIndexedChildren(RPCCallAction::class.java)

getIndexedChildren filters the individual's direct children by type, but the calls are not direct children: the constructor wraps each in an EnterpriseActionGroup, alongside the external-service actions belonging to it. So nothing ever matches the filter and the result is always empty.

Compare RestIndividual.getIndexedResourceCalls, which works because RestResourceCalls really is the child type there.

The method has no callers today, which is presumably why it went unnoticed. The fix unwraps the group.

The convenience constructor throws whenever it is used without external services

addAll(actions.mapIndexed { index, rpcCallAction ->if (externalServicesActions.isNotEmpty()){
Lazy.assert { actions.size == externalServicesActions.size }
}
EnterpriseActionGroup(...).apply {
addChildrenToGroup(externalServicesActions[index], ...) // <- not guarded
}})

externalServicesActions defaults to an empty list. The isNotEmpty() check guards only the assert; the indexing right after it is unguarded, so externalServicesActions[index] throws IndexOutOfBoundsException on the very first call.

In practice only callers passing a list of matching size work — which is what EvaluatedIndividualBuilder.buildEvaluatedRPCIndividual does, so the existing tests never hit it. Constructing an RPCIndividual the way the default parameters invite you to fails immediately.

The fix adds the missing bound check, leaving behaviour unchanged when a list is supplied.

Testing

Adds RPCIndividualTest, which the class had none of — four tests covering the indexed lookup, the indices actually addressing the children that hold the calls, calls found past initializing actions, and the empty case. The first of them fails on both bugs before the fix.

RPCActionNamingStrategyTest, TestSuiteWriterRPCTest and TestSuiteOrganizerTest still pass.

Both were found while writing an equivalent individual for another problem
type and copying this one's shape.
seeIndexedRPCCalls always returned an empty map. It asks for children of type
RPCCallAction, but the calls are not children of the individual directly:
each is wrapped in an EnterpriseActionGroup alongside the external-service
actions belonging to it, so nothing ever matches. The group is now unwrapped.
The method has no callers today, which is presumably why this went unnoticed.
The convenience constructor threw IndexOutOfBoundsException whenever it was
used without external-service actions. externalServicesActions defaults to an
empty list, and while the assert on its size is guarded by isNotEmpty, the
indexing that follows is not, so externalServicesActions[index] fails for the
very first call. Only callers that pass a list of matching size worked, which
is what the existing test helper does.
Adds RPCIndividualTest, which the class had none of.
@arcuri82

Copy link
Copy Markdown
Collaborator

hi @LautaroPetaccio thx!
as this is about RPC support, @man-zhang can you look at this PR once you are back from vacation? txh!

Sign up for freeto 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

@LautaroPetaccio@arcuri82