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

Simulator Sandbox prevents loading test data from .csv file - would be beneficial to be togglable feature #101

Open
BKN46 opened this issue Jul 21, 2022 · 3 comments
Labels
Awaiting More Info Awaiting More Information from the reporter feature New feature or request

Comments

@BKN46
Copy link

BKN46 commented Jul 21, 2022

I'm trying to read some record data to do the data replay like this:

-- start at the simulator config:
rec_file = "data/400m.csv"
data = {}
for line in io.lines(rec_file) do
    table.insert(data, split(line, ","))
end

-- in onLBSimulatorTick function:
simulator:setInputNumber(11, data[ticks % #data + 1][1])
simulator:setInputNumber(12, data[ticks % #data + 1][2])
simulator:setInputNumber(13, data[ticks % #data + 1][3])

It worked fine on earlier version. But on latest version, it pops up a exception:

Exception has occurred: MyMicrocontroller.lua:22: attempt to index a nil value (global 'io')
stack traceback:
	MyMicrocontroller.lua:22: in field '?'
	.../Common/LifeBoatAPI/Tools/Simulator/SimulatorSandbox.lua:67: in field 'require'
	_build/_simulator.lua:29: in main chunk
	[C]: in ?

I tried to manually require io or iolib, but it turned to Could not find require: io.

How can I fix this? Or is it possible to provide a data read interface?

@BKN46 BKN46 added the bug Something isn't working label Jul 21, 2022
@nameouschangey
Copy link
Owner

Hey, the simulator is currently heavily sandboxed, to prevent people transmitting malicious code via libraries (and to replicate the in-game experience more closely)

I can see the benefit of what you're doing; perhaps just making the sandbox optional would be the way to go? I think for 99% of people there'll be no reason to change it, but it looks like you're reading test data out of a csv, which is pretty awesome - and I want you to be able to do that.

Does that sound like a solution you'd be comfortable with?

@nameouschangey nameouschangey added feature New feature or request and removed bug Something isn't working labels Jul 21, 2022
@nameouschangey nameouschangey changed the title io.open exception Simulator Sandbox prevents loading test data from .csv file - would be beneficial to be togglable feature Jul 21, 2022
@nameouschangey nameouschangey added the Awaiting More Info Awaiting More Information from the reporter label Jul 21, 2022
@BKN46
Copy link
Author

BKN46 commented Jul 21, 2022

That's sounds cool to me. I never thought about security aspect. Really appreciate your work, looking forward to coming version :)

@nameouschangey
Copy link
Owner

Awesome, I'll get that in when I get a chance.

There wasn't a security issue before - until adding the "auto-updating git libraries" feature; at which point, realised it would take 10 seconds for somebody to maliciously distribute a library with os.execute("rmdir C:/Users") or worse 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Info Awaiting More Information from the reporter feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants