Commit Graph

791 Commits

Author SHA1 Message Date
Kartik K. Agaram ed5efcd8a0 drop a forward decl 2022-03-16 20:31:43 -07:00
Kartik K. Agaram 709cc25130 start cleaning up function call instrumentation
It's a mess. I calculate call-graph depth one way and calculate caller
names another way. At least one of the ways fails to work with indirect
calls. Hopefully the other way works?
2022-03-16 20:29:50 -07:00
Kartik K. Agaram b9c187d259 stop using tasks in start_reading/start_writing
We just need queues/streams for file I/O. No need to complect
concurrency concerns with them.
2022-03-16 17:03:38 -07:00
Kartik K. Agaram ab89be1ed3 Teliva's been broken 2 days while I mess with docs 2022-03-15 16:00:08 -07:00
Kartik K. Agaram 2662b1afed . 2022-03-14 18:37:56 -07:00
Kartik K. Agaram 5e976554dd drop the lfs library
I can't feel confident about its sandboxing story yet. And if we can't
build a file navigator, what are we even doing with it.
2022-03-14 17:26:13 -07:00
Kartik K. Agaram 6f5f6849dd . 2022-03-14 17:23:38 -07:00
Kartik K. Agaram babaa235b1 update link to manual 2022-03-14 16:46:05 -07:00
Kartik K. Agaram 2b81ded335 typo 2022-03-14 16:35:24 -07:00
Kartik K. Agaram 06a5e841d1 doc: curses 2022-03-14 11:47:15 -07:00
Kartik K. Agaram a8df25c497 doc: flesh out tasks and channels 2022-03-14 09:56:41 -07:00
Kartik K. Agaram b571a342d7 doc: correct and flesh out json 2022-03-14 09:32:38 -07:00
Kartik K. Agaram 1eb37f220d typo 2022-03-14 07:59:41 -07:00
Kartik K. Agaram 4e89474820 document functions that are sandboxed 2022-03-13 17:45:10 -07:00
Kartik K. Agaram 6133cfa524 drop docs for 2 functions removed from Lua 2022-03-13 17:39:57 -07:00
Kartik K. Agaram b68405fe31 delete debug library
There's security issues here, and they're subtle. Dropping for now until
I or someone else finds a need for them.
2022-03-13 17:36:01 -07:00
Kartik K. Agaram 776d9f9032 standard markup 2022-03-13 17:32:53 -07:00
Kartik K. Agaram 7c843c0b8a . 2022-03-13 17:31:28 -07:00
Kartik K. Agaram e67e61a063 one more highlight 2022-03-13 16:49:04 -07:00
Kartik K. Agaram 4e6ea0adad rudimentary docs for libraries added to Teliva 2022-03-13 16:46:46 -07:00
Kartik K. Agaram ee7f893a7e drop string.dump, clean up docs around it 2022-03-13 14:41:41 -07:00
Kartik K. Agaram 35a6794386 rip out most references to C and userdata in docs 2022-03-13 14:19:08 -07:00
Kartik K. Agaram 23e7cf9c52 starting to spend some time improving docs 2022-03-13 14:01:13 -07:00
Kartik K. Agaram 1017e80fe5 less confusing error when apps get past main 2022-03-13 12:12:19 -07:00
Kartik K. Agaram 6ece3bb664 toot-toot.tlv: scrolling 2022-03-12 09:06:12 -08:00
Kartik K. Agaram cebe9abffe more extensive deletions from the Lua manual
I'm trying to represent where Teliva borrows from Lua, but without
making it seem identical.

Please support the Lua project!
2022-03-10 23:36:22 -08:00
Kartik K. Agaram cee42880e5 zet.tlv: thoroughly test rendering single zettel 2022-03-10 15:38:26 -08:00
Kartik K. Agaram 04a65e05f8 leak check 2022-03-10 09:56:37 -08:00
Kartik K. Agaram 0fa83e1d94 support fixing >1 test failure from within Teliva
This bug was caused by me forgetting that lua_setglobal affects the
stack.
2022-03-10 09:47:10 -08:00
Kartik K. Agaram 7030e70ef3 reconcile template in all apps 2022-03-10 04:32:57 -08:00
Kartik K. Agaram e627114751 zet.tlv: first screen tests
In the process I found a couple of bugs in fake screen primitives.
2022-03-10 04:30:58 -08:00
Kartik K. Agaram 70c3ec42bc screen tests: support bold, reverse, color
We can't test combinations of these yet because Lua 5.1 doesn't support
bitwise operators. Reason #1 to upgrade.
2022-03-08 22:42:32 -08:00
Kartik K. Agaram 08c49b5a0a protect framework files from apps
There's a separate open question here of where Teliva should store files
like teliva_editor_state and teliva_editor_buffer. One school of thought
is that apps should never be dropping crud into people's directories. On
the other hand, I'm kinda encouraging people so far to just run apps
from Teliva's directory. Perhaps that makes it ok?
2022-03-08 19:20:53 -08:00
Kartik K. Agaram 2b47f76308 just always temp files to be created
Implication: os.rename now needs to be sandboxed. Hopefully it's
tractable to treat it as conceptually identical to opening two files.
2022-03-07 21:57:11 -08:00
Kartik K. Agaram 2d393bfb80 stop loading libraries after app code
This whole approach of disallowing overriding is suspect.
2022-03-07 21:43:00 -08:00
Kartik K. Agaram dd8730920a purge all support for per-function permissions
We're now back to the problem of how to transparently allow Teliva to
create temporary filenames without every app having to explicitly allow
them.

I think I may need to define start_writing in C, so that it can use a
non-sandboxed version of io.open.
2022-03-07 20:50:41 -08:00
Kartik K. Agaram b9fea70b0a yup, this whole caller-based approach is busted
How can we scope anything to a subset of an app that is user-visible in
such a dynamic language as Lua?! X(
2022-03-07 19:23:26 -08:00
Kartik K. Agaram a0674f7b85 hokey primitive to create temporary file
The trouble with os.tmpname() is that it always creates in /tmp.
If /tmp is in a different volume from our real filename, os.rename()
will fail.

This new primitive doesn't support primitive paths yet.

I'm also again nervous about the security implications of my whole
approach. What if we create an inner function called start_writing?
Would we be able to do anything inside it? I'm starting to suspect this
whole approach of going by caller name is broken. An app could also
create inner functions called 'main'..
2022-03-07 19:14:02 -08:00
Kartik K. Agaram 88827db20d slightly firm up phases in pmain 2022-03-07 16:01:19 -08:00
Kartik K. Agaram b1ad679f3b hide test app a bit 2022-03-07 15:53:12 -08:00
Kartik K. Agaram f268015ac0 fix the security vulnerability
We now have a notion of libraries that we load after app code, to
prevent them from getting overridden.

Should I just load all libraries after the app? There might be value in
allowing apps to override library functions. Disallowing that too much
may be going against Lua's dynamic nature.
2022-03-07 15:40:28 -08:00
Kartik K. Agaram cfb7cff4c1 call app's main() from within Lua pmain 2022-03-07 15:34:20 -08:00
Kartik K. Agaram e07fa910bb pin down a security vulnerability
We aren't actually secure as the previous commit said. The hole here is
that you can't override start_writing by typing in 'start_writing' into
the big picture. However you _can_ override it by typing in _anything
else_.
2022-03-07 11:44:47 -08:00
Kartik K. Agaram 38063812b6 zet.tlv: switch file writes to new API
The interface for apps looks much nicer now, see 'main' in zet.tlv.
However there are some open issues:

- It can still be confusing to the computer owner that an app tries to
  write to some temporary file that isn't mentioned anywhere.

- File renames can fail if /tmp is on a different volume.

- What happens if an app overrides start_writing()? The computer owner
  may think they've audited the caller of start_writing and give it
  blanket file permissions. Teliva tunnels through start_writing when
  computing the caller. If the app can control what start_writing does,
  the app could be performing arbitrary malicious file operations.

  Right now things actually seem perfectly secure. Overriding
  start_writing has no effect. Our approach for loading .tlv files (in
  reverse chronological order, preventing older versions from overriding
  newer ones) has the accidentally _great_ property that Teliva apps can
  never override system definitions.

  So we have a new reason to put standard libraries in a .lua file: if
  we need to prevent apps from overriding it.

  This feels like something that needs an automated test, both to make
  sure I'm running the right experiment and to ensure I don't
  accidentally cause a regression in the future. I can totally imagine a
  future rewrite that tried a different approach than
  reverse-chronological.
2022-03-07 10:55:18 -08:00
Kartik K. Agaram 7a315e3d9f extract a common function call 2022-03-07 08:52:41 -08:00
Kartik K. Agaram 503ad706fb zet.tlv: switch file reads to new API
In the process I found a couple of bugs in parsing JSON string escapes.
2022-03-07 08:22:37 -08:00
Kartik K. Agaram d388cc1f22 decode json from channels 2022-03-06 23:50:58 -08:00
Kartik K. Agaram 6a3098d0e9 use method syntax where possible
Perhaps this is a bad idea. It feels arbitrary, what methods Lua happens
to include in string and table objects without having to go through the
respective modules.
2022-03-06 16:38:49 -08:00
Kartik K. Agaram 5758f6c082 reading from file a character at a time 2022-03-06 09:52:37 -08:00
Kartik K. Agaram f07eb03492 local functions broke start_reading/start_writing
Looks like Lua's local functions lose access to outer scopes (upvalues)
or something like that..
2022-03-06 09:49:33 -08:00