Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bad websocket parser states unrepresentable. #547

Merged

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Aug 2, 2018

Motivation:

Apparently when I wrote the WebSocket parser I forgot that enums are
great, and so I added a bunch of optional properties. That was silly.
This patch changes the WSParser structure to use an enum with
associated data to ensure that we only store state when we are supposed
to, and to guarantee that the state is good.

Modifications:

Move all state to enum case associated data.

Result:

Easier to validate the correctness of the WSParser code.

Motivation:

Apparently when I wrote the WebSocket parser I forgot that enums are
great, and so I added a bunch of optional properties. That was silly.
This patch changes the WSParser structure to use an enum with
associated data to ensure that we only store state when we are supposed
to, and to guarantee that the state is good.

Modifications:

Move all state to enum case associated data.

Result:

Easier to validate the correctness of the WSParser code.
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Aug 2, 2018
@Lukasa Lukasa added this to the 1.10.0 milestone Aug 2, 2018
@Lukasa Lukasa requested a review from weissi August 2, 2018 10:25
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one, really like it!

@Lukasa Lukasa merged commit 2d38904 into apple:master Aug 2, 2018
@Lukasa Lukasa deleted the cb-impossible-states-should-be-impossible branch August 2, 2018 10:53
@weissi weissi modified the milestones: 1.10.0, 1.9.3 Aug 28, 2018
weissi pushed a commit that referenced this pull request Aug 29, 2018
Motivation:

Apparently when I wrote the WebSocket parser I forgot that enums are
great, and so I added a bunch of optional properties. That was silly.
This patch changes the WSParser structure to use an enum with
associated data to ensure that we only store state when we are supposed
to, and to guarantee that the state is good.

Modifications:

Move all state to enum case associated data.

Result:

Easier to validate the correctness of the WSParser code.
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants