forked from robinhilliard/safeish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
64 lines (53 loc) · 1.83 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
defmodule Safeish.MixProject do
use Mix.Project
def project do
[
app: :safeish,
version: "0.5.0",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
description: description(),
package: package(),
deps: deps(),
aliases: aliases(),
source_url: "https://github.com/robinhilliard/safeish",
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}]
end
defp description() do
"NOT FOR PRODUCTION USE: Safe-ish is an experimental sandbox for BEAM modules that examines and rejects BEAM bytecode containing instructions that could cause side effects. You can provide an optional whitelist of opcodes and functions the module can use."
end
defp package() do
[
name: "safeish",
files: ["lib", "mix.exs", "README.md", "LICENSE"],
exclude_patterns: [".DS_Store"],
licenses: ["MIT"],
links: %{"Github" => "https://github.com/robinhilliard/safeish"},
maintainers: ["Robin Hilliard"]
]
end
defp aliases, do: [fixtures: &make_fixtures/1]
defp make_fixtures(_) do
source_path = "#{File.cwd!()}/test/fixtures.ex"
build_path = "#{File.cwd!()}/test/fixtures_build"
Mix.Shell.IO.info("Compiling modules in #{source_path} and saving to #{build_path}")
File.rm_rf(build_path)
File.mkdir(build_path)
for {module, bytecode} <- Code.compile_file(source_path) do
Mix.Shell.IO.info("...#{build_path}/#{Atom.to_string(module)}.beam")
{:ok, file} = File.open("#{build_path}/#{Atom.to_string(module)}.beam", [:write])
IO.binwrite(file, bytecode)
File.close(file)
end
end
end