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

Use a mock sentinel for MARK instead of a gensym #216

Merged
merged 1 commit into from
May 29, 2023
Merged

Conversation

gilch
Copy link
Owner

@gilch gilch commented May 29, 2023

Gensyms just resolve to strings, and shouldn't be used literally anywhere they might collide with adversarial input, which commonly come in the form of unsanitized strings. User input could theoretically change where a MARK is, altering behavior.

sentinels normally shouldn't be used outside of tests, but the standalone property limits my options. At run time a simple object() would do, but unpickling the same object() created at read time twice wouldn't preserve equality in this case. A sentinel can do that.

I've used getattr to create a sentinel with a non-identifier string, which are almost never used, so this is unlikely to interfere with tests. For good measure, I prepended hissp. to the ] as an ad-hoc namespace.

Gensyms just resolve to strings, and shouldn't be used literally anywhere they might collide with adversarial input, which commonly come in the form of unsanitized strings. User input could theoretically change where a MARK is, altering behavior.

sentinels normally shouldn't be used outside of tests, but the standalone property limits my options. At run time a simple `object()` would do, but unpickling the same object() created at read time twice wouldn't preserve equality in this case. A sentinel can do that.

I've used getattr to create a sentinel with a non-identifier string, which are almost never used, so this is unlikely to interfere with tests. For good measure, I prepended `hissp.` to the `]` as a namespace.
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #216 (3e059e2) into master (4874223) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master      #216   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          710       710           
  Branches       109       109           
=========================================
  Hits           710       710           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gilch gilch merged commit 48053f4 into master May 29, 2023
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.

None yet

1 participant