aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2013-06-24 19:46:41 -0300
committerHisham Muhammad <hisham@gobolinux.org>2013-06-24 19:46:41 -0300
commit6dfda90a9a9f503eb38207cf1451ef3557608ddd (patch)
tree4747c113c3f04bf964b42f16d64a3421562a206e /src
parent694fc86a750e6a9b51c09e21ed70ee4326f85f14 (diff)
downloadluarocks-6dfda90a9a9f503eb38207cf1451ef3557608ddd.tar.gz
luarocks-6dfda90a9a9f503eb38207cf1451ef3557608ddd.tar.bz2
luarocks-6dfda90a9a9f503eb38207cf1451ef3557608ddd.zip
Add two new configuration options, 'hooks_enabled' and 'accepted_build_types',
to deal with some security concerns raised in #35.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/build.lua4
-rw-r--r--src/luarocks/cfg.lua1
-rw-r--r--src/luarocks/repos.lua5
-rw-r--r--src/luarocks/util.lua9
4 files changed, 19 insertions, 0 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index 27afe18d..71b3cb89 100644
--- a/src/luarocks/build.lua
+++ b/src/luarocks/build.lua
@@ -197,6 +197,10 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode)
197 build.type = "builtin" 197 build.type = "builtin"
198 end 198 end
199 199
200 if cfg.accepted_build_types and util.array_contains(cfg.accepted_build_types, build.type) then
201 return nil, "This rockspec uses the '"..build.type.."' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration."
202 end
203
200 local build_type 204 local build_type
201 ok, build_type = pcall(require, "luarocks.build." .. build.type) 205 ok, build_type = pcall(require, "luarocks.build." .. build.type)
202 if not ok or not type(build_type) == "table" then 206 if not ok or not type(build_type) == "table" then
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index a4626e10..259293c3 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -182,6 +182,7 @@ local defaults = {
182 use_extensions = false, 182 use_extensions = false,
183 accept_unknown_fields = false, 183 accept_unknown_fields = false,
184 fs_use_modules = true, 184 fs_use_modules = true,
185 hooks_enabled = true,
185 deps_mode = "one", 186 deps_mode = "one",
186 187
187 lua_modules_path = "/share/lua/"..lua_version, 188 lua_modules_path = "/share/lua/"..lua_version,
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index dc1b63c8..5e87afe3 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -131,6 +131,11 @@ function run_hook(rockspec, hook_name)
131 if not hooks then 131 if not hooks then
132 return true 132 return true
133 end 133 end
134
135 if cfg.hooks_enabled == false then
136 return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration."
137 end
138
134 if not hooks.substituted_variables then 139 if not hooks.substituted_variables then
135 util.variable_substitutions(hooks, rockspec.variables) 140 util.variable_substitutions(hooks, rockspec.variables)
136 hooks.substituted_variables = true 141 hooks.substituted_variables = true
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index c5095675..b2428f62 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -461,3 +461,12 @@ function show_table(t, name, indent)
461 addtocart(t, name, indent) 461 addtocart(t, name, indent)
462 return cart .. autoref 462 return cart .. autoref
463end 463end
464
465function array_contains(tbl, value)
466 for _, v in ipairs(tbl) do
467 if v == value then
468 return true
469 end
470 end
471 return false
472end