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

Lua globals protection #11

Closed
trentgill opened this issue Sep 24, 2018 · 6 comments
Closed

Lua globals protection #11

trentgill opened this issue Sep 24, 2018 · 6 comments
Assignees
Labels
design Issue needs design consideration enhancement New feature or request

Comments

@trentgill
Copy link
Collaborator

Need a solution to make sure the user can't create a script (saved in flash as the default) that makes the lua environment unresponsive, thus being unable to change the script.

Ideas:

  • make certain functions in a protected table
  • make a copy of said functions and test for equality to the runtime versions.

These would include a small number of functions that would break script-updating (dostring(), usb2repl() etc).

@trentgill trentgill added the enhancement New feature or request label Sep 24, 2018
@trentgill trentgill added this to the 1 milestone Sep 24, 2018
@trentgill trentgill modified the milestone: 1 Dec 24, 2018
@pq
Copy link
Contributor

pq commented Mar 1, 2019

fwiw, there's a bunch of conversation on the norns repo that might be relevant here.

the globals meta-issue is a good place to start (if you haven't perused it already):
monome/norns#557.

i'd be curious if the "readonly table" hack in monome/norns#667 might be useful?

@trentgill trentgill added the design Issue needs design consideration label Mar 1, 2019
@tehn
Copy link
Member

tehn commented Mar 1, 2019

the readonly function is a good solution for this. it'd be trivial to add.

i'll get it into the core lib.

@trentgill
Copy link
Collaborator Author

trentgill commented Mar 16, 2019

readonly approach seems good to me.

What are we thinking to protect? My first thoughts:

  • Everything in bootstrap.lua. Can readonly be applied to a global function (ie print)?
  • _c
  • Input, Output, Asl, Asllib, Cal
  • All the C-functions (do these need to be put into a table of their own?)

Metro/metro & II are different though as they have a lot of internal functionality that shouldn't changed, but they can be modified to setup event callbacks, so can't be totally protected. I'm guessing Midi will be in this same category but we'll cross that bridge at the appropriate time.

@trentgill trentgill modified the milestones: 1.0, 1.1 May 2, 2019
@trentgill
Copy link
Collaborator Author

Demoting to 1.1 as this feels like a problem we can solve when it arises?

@pq
Copy link
Contributor

pq commented May 2, 2019

sorry for the slow reply; i haven't dug deeply into the APIs yet but my gut says your candidates look right. the C-functions should get guarded somehow for sure. i think we can follow the lead of whatever we end up doing for norns...

anyway, agreed we can tackle all of this opportunistically!

@trentgill trentgill modified the milestones: 1.1, 1.2 Oct 6, 2019
@trentgill trentgill modified the milestones: 1.0.3, 1.0.4, Minor (1.1) Nov 25, 2019
@trentgill trentgill removed this from the Minor (1.1) milestone Jun 10, 2020
@trentgill
Copy link
Collaborator Author

A non issue in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Issue needs design consideration enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants