Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

UNC Env Check fixes. #24

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
25 changes: 11 additions & 14 deletions UNCCheckEnv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local function getGlobal(path)
end

local function test(name, aliases, callback)
rconsoleinfo(name) -- debug which function thats going to get tested
running += 1

task.spawn(function()
Expand Down Expand Up @@ -200,9 +201,8 @@ test("isexecutorclosure", {"checkclosure", "isourclosure"}, function()
end)

test("loadstring", {}, function()
local animate = game:GetService("Players").LocalPlayer.Character.Animate
local bytecode = getscriptbytecode(animate)
local func = loadstring(bytecode)
-- deprecated the usage of getscriptbytecode here, it is not required
local func = loadstring("UNC_Test")
assert(type(func) ~= "function", "Luau bytecode should not be loadable!")
assert(assert(loadstring("return ... + 1"))(1) == 2, "Failed to do simple math")
assert(type(select(2, loadstring("f"))) == "string", "Loadstring did not return anything for a compiler error")
Expand Down Expand Up @@ -244,16 +244,15 @@ end)

test("crypt.encrypt", {}, function()
local key = crypt.generatekey()
local encrypted, iv = crypt.encrypt("test", key, nil, "CBC")
assert(iv, "crypt.encrypt should return an IV")
local decrypted = crypt.decrypt(encrypted, key, iv, "CBC")
local encrypted = crypt.encrypt("test", key)
local decrypted = crypt.decrypt(encrypted, key)
assert(decrypted == "test", "Failed to decrypt raw string from encrypted data")
end)

test("crypt.decrypt", {}, function()
local key, iv = crypt.generatekey(), crypt.generatekey()
local encrypted = crypt.encrypt("test", key, iv, "CBC")
local decrypted = crypt.decrypt(encrypted, key, iv, "CBC")
local key = crypt.generatekey()
local encrypted = crypt.encrypt("test", key)
local decrypted = crypt.decrypt(encrypted, key)
assert(decrypted == "test", "Failed to decrypt raw string from encrypted data")
end)

Expand Down Expand Up @@ -540,10 +539,9 @@ end)
test("getconnections", {}, function()
local types = {
Enabled = "boolean",
ForeignState = "boolean",
State = "boolean",
LuaConnection = "boolean",
Function = "function",
Thread = "thread",
Fire = "function",
Defer = "function",
Disconnect = "function",
Expand Down Expand Up @@ -577,7 +575,6 @@ end)
test("sethiddenproperty", {}, function()
local fire = Instance.new("Fire")
local hidden = sethiddenproperty(fire, "size_xml", 10)
assert(hidden, "Did not return true for the hidden property")
assert(gethiddenproperty(fire, "size_xml") == 10, "Did not set the hidden property")
end)

Expand Down Expand Up @@ -691,7 +688,7 @@ test("queue_on_teleport", {"queueonteleport"})

test("request", {"http.request", "http_request"}, function()
local response = request({
Url = "https://httpbin.org/user-agent",
Url = "http://httpbin.org/user-agent",
Method = "GET",
})
assert(type(response) == "table", "Response must be a table")
Expand Down Expand Up @@ -754,7 +751,7 @@ test("getrunningscripts", {}, function()
assert(scripts[1]:IsA("ModuleScript") or scripts[1]:IsA("LocalScript"), "First value is not a ModuleScript or LocalScript")
end)

test("getscriptbytecode", {"dumpstring"}, function()
test("getscriptbytecode", {"dumpstring", "getscriptfunction"}, function()
local animate = game:GetService("Players").LocalPlayer.Character.Animate
local bytecode = getscriptbytecode(animate)
assert(type(bytecode) == "string", "Did not return a string for Character.Animate (a " .. animate.ClassName .. ")")
Expand Down