Lua and JSON

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Post Reply
Chris_Clark
Posts: 5
Joined: April 21st, 2012, 7:57 am

Lua and JSON

Post by Chris_Clark » April 23rd, 2012, 5:32 pm

For the custom campaign I'm designing, I want to personalize it using JSON data from a server. This would be quite easy to do in Lua if I had access to the Lua socket library from within LuaML, but I realize there are security considerations. I was thinking of modifying Scripting/lua.cpp so as to make the socket library usable to my campaign WML files, but I'm concerned about the security implications of this, and wondering if what I propose could be possible without modifying Lua's source code, so I wouldn't have to create a separate Wesnoth distribution in order for users to play my campaign.

User avatar
Elvish_Hunter
Forum Moderator
Posts: 1395
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Lua and JSON

Post by Elvish_Hunter » April 23rd, 2012, 6:53 pm

Chris_Clark wrote:I'm concerned about the security implications of this, and wondering if what I propose could be possible without modifying Lua's source code, so I wouldn't have to create a separate Wesnoth distribution in order for users to play my campaign.
Given that we don't want that add-ons may be able to execute arbitrary code, your only option is a fork. By the way, what kind of data do you want to pass via JSON, exactly?
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons

Chris_Clark
Posts: 5
Joined: April 21st, 2012, 7:57 am

Re: Lua and JSON

Post by Chris_Clark » April 23rd, 2012, 7:21 pm

That makes sense, Elvish_Hunter. So I assume I should edit lua.cpp, add the sockets library and disable anything in the sockets library that I don't need? (as was done with the lua os library)

I don't mean to be mysterious, but I'd prefer to keep the exact nature of the JSON data under a Shroud until my campaign is ready for beta testing. If you'd like more details, I can PM you though.

Anonymissimus
Inactive Developer
Posts: 2459
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Lua and JSON

Post by Anonymissimus » April 23rd, 2012, 7:36 pm

There is an :unsafe_lua command (or so) for the wesnoth command line (maybe only in debug mode). Perhaps that allows you somehow to do what you need.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign

Post Reply