Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes the finite state machine (FSM) logic in the port knocking application to prevent invalid parameter specifications. The changes ensure that the optional delay and host parameters can each be specified at most once (in any order) before port knocking begins, eliminating a previously possible infinite cycle between states 1 and 2.
- Modified state transitions to prevent multiple specifications of
delayandhostparameters - Both parameter orderings (delay→host and host→delay) now converge to state 3 where only port specifications are allowed
Comments suppressed due to low confidence (1)
src/main/java/Main.java:90
- The FSM state transition logic lacks test coverage. The changes to the state transitions are not covered by any automated tests, which makes it difficult to verify that the FSM behaves correctly for various input sequences. Consider adding tests that verify:
- Valid sequences: delay then host, host then delay, delay only, host only, neither
- Invalid sequences that should be rejected: multiple delay specifications, multiple host specifications
- Transitions to and behavior in each state
fsm.put(
0,
Map.of(
Symbol.DELAY, 1,
Symbol.HOST, 2,
Symbol.UDP, 3,
Symbol.TCP, 3));
fsm.put(
1,
Map.of(
Symbol.HOST, 3,
Symbol.UDP, 3,
Symbol.TCP, 3));
fsm.put(
2,
Map.of(
Symbol.DELAY, 3,
Symbol.UDP, 3,
Symbol.TCP, 3));
fsm.put(
3,
Map.of(
Symbol.UDP, 3,
Symbol.TCP, 3));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the state transitions in the finite state machine (FSM) logic within
Main.java. The changes adjust how the FSM responds to certain symbols, likely to fix or refine its behavior.FSM transition updates:
Symbol.HOSTin state 1 to go to state 3 instead of state 2.Symbol.DELAYin state 2 to go to state 3 instead of state 1.