-
Notifications
You must be signed in to change notification settings - Fork 13
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 table format #41
base: master
Are you sure you want to change the base?
Lua table format #41
Conversation
It would be good to point out that the only thing |
I think that the removal of the unnecessary emphasis on "entire" and "parseable", along with changing "parseable" to "able to be parsed" would be sufficient for an initial standard acceptance. Does anyone see any other changes that would be necessary to clearly convey the requirements for the file format? |
I am not sure @lyqyd. As I pointed out earlier, |
It might be worth saying that function calls or definitions are invalid, or alternatively the only valid expressions are tables, strings, numbers, boolean values and |
@SquidDev in what sense? -- Is this allowed?
{
[ 1 ] = function( x ) return x + 1 end;
[ 2 ] = function( x ) return x + 2 end;
} -- What about
{ true, false, true, true } -- Or simply
true |
I'd say only the middle is legal: the first is more of an API rather than data and the last isn't a table. |
Disagreed @SquidDev. This needs proper, well defined rules. Just because you can't -- Linters don't like a Lua file starting with {, so this is what I do to make my serialised tables lintable
(function() return
{
normal = "table follows"
}
end)() {
-- Maths! Sometimes you want to keep fractions easy to read
width = 2/5;
-- But what about
height = 0/0;
} -- The global environment may be empty, but strings still have their metatables
{
("asd"):byte();
} |
The standard proposal as it is now is broad, incomplete, doesn't discuss edge cases and defines a format that can still be exploited while still differing from valid Lua syntax (therefore Lua source code tools can not be used on it (efficiently)). |
I would say that any file that results in textutils.unserialize returning a table when it is fed the file contents would be valid, regardless of how it achieves that result. So, out of your six examples, only the third one would fall outside of this format. This does leave us open to arbitrary code execution when attempting to load the file contents. I think we need to decide whether or not that's actually something that this standard should attempt to mitigate. I don't personally see a need to disallow it, but I'm interested in hearing other thoughts on the matter. |
The point of the file format is to essentially have an easy way of storing data in a file using As, I would imagine, most people would read the file like this, as long as it can be understood by local h = fs.open("file/path", "r")
if h then
local data = textutils.unserialise(h.readAll())
if data then
...
end
end |
My oppinion is that the lua format should just be spread into executeable and data. |
As Lyqyd said, this is vulnerable to arbitrary code execution. Let me give one such example. Imagine a Computercraft server on which an in-game public server can be reconfigured by sending it a new There are three solutions to this.
|
Incorrect, @CrazyPyroEagle. |
As discussed in #26 and #18, the Lua format is being split in to separate types.
This format is exclusively for files that are loadable via
textutils.unserialise
.Also see: #39 and #40.