stipsan / ioredis-mock

Emulates ioredis by performing all operations in-memory.
MIT License
336 stars 124 forks source link

Creation of global variables in Lua should not be allowed #1047

Open ChrisKitching opened 3 years ago

ChrisKitching commented 3 years ago

Standalone testcase to reproduce the problem (tested with version 5.2.2 of ioredis-mock):

describe("Creation of global variables with lua", () => {
    test("works with ioredis-mock (shouldn't)", async() => {
        const IORedis = require('ioredis-mock');
        const redis = new IORedis('localhost');
        await redis.eval('foo = 3', 0);
    });
    test("Fails with real redis", async() => {
        const IORedis = require('ioredis');
        const redis = new IORedis('localhost');

        // ReplyError: ERR Error running script (call to f_4501040002bbe2b1855b07f138595e980f445a6f): @enable_strict_lua:8: user_script:1: Script attempted to create global variable 'foo'
        await redis.eval('foo = 3', 0);
    });
});

ioredis-mock allows the creation of global variables in lua scripts, but real redis does not.

stipsan commented 3 years ago

PRs welcome <3