Skip to content

Commit 76fb1f7

Browse files
authored
Merge pull request #125 from SpinnySpiwal/patch-2
2 parents 4def65a + 8328a82 commit 76fb1f7

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/prometheus/steps/AntiTamper.lua

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,28 @@ function AntiTamper:apply(ast, pipeline)
3838
local string = RandomStrings.randomString();
3939
code = code .. [[
4040
-- Anti Beautify
41-
local sethook = debug and debug.sethook or function() end;
42-
local allowedLine = nil;
43-
local called = 0;
44-
sethook(function(s, line)
45-
called = called + 1;
46-
if allowedLine then
47-
if allowedLine ~= line then
48-
sethook(error, "l");
49-
end
50-
else
51-
allowedLine = line;
52-
end
53-
end, "l");
54-
(function() end)();
55-
(function() end)();
56-
sethook();
41+
local sethook = debug and debug.sethook or function() end;
42+
local allowedLine = nil;
43+
local called = 0;
44+
sethook(function(s, line)
45+
if not line then
46+
return
47+
end
48+
called = called + 1;
49+
if allowedLine then
50+
if allowedLine ~= line then
51+
sethook(error, "l", 5);
52+
end
53+
else
54+
allowedLine = line;
55+
end
56+
end, "l", 5);
57+
(function() end)();
58+
(function() end)();
59+
sethook();
60+
if called < 2 then
61+
valid = false;
62+
end
5763
if called < 2 then
5864
valid = false;
5965
end
@@ -173,4 +179,4 @@ end
173179
return ast;
174180
end
175181

176-
return AntiTamper;
182+
return AntiTamper;

0 commit comments

Comments
 (0)