Fix vulnerability

pull/5136/head
nikitosing 3 years ago
parent 7bc604ead7
commit 7088dca160
  1. 2
      apps/explorer/config/test.exs
  2. 2
      apps/explorer/lib/explorer/smart_contract/solidity/verifier.ex
  3. 25
      apps/explorer/test/explorer/smart_contract/solidity/publisher_test.exs
  4. 170
      apps/explorer/test/explorer/smart_contract/solidity/verifier_test.exs

@ -9,7 +9,7 @@ config :explorer, Explorer.Repo,
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox,
# Default of `5_000` was too low for `BlockFetcher` test
ownership_timeout: :timer.minutes(1),
ownership_timeout: :timer.minutes(7),
timeout: :timer.seconds(60),
queue_target: 1000

@ -203,7 +203,7 @@ defmodule Explorer.SmartContract.Solidity.Verifier do
init_without_0x
_ ->
bytecode
""
end
%{

@ -13,10 +13,13 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
describe "publish/2" do
test "with valid data creates a smart_contract" do
contract_code_info = Factory.contract_code_info()
contract_code_info = Factory.contract_code_info_modern_compilator()
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode)
insert(:transaction, created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input)
:transaction
|> insert(created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input)
|> with_block(status: :ok)
valid_attrs = %{
"contract_source_code" => contract_code_info.source_code,
@ -57,7 +60,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
created_contract_address_hash: contract_address.hash,
input: input <> expected_constructor_arguments
)
|> with_block()
|> with_block(status: :ok)
params = %{
"contract_source_code" => contract,
@ -73,10 +76,13 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
end
test "corresponding contract_methods are created for the abi" do
contract_code_info = Factory.contract_code_info()
contract_code_info = Factory.contract_code_info_modern_compilator()
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode)
insert(:transaction, created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input)
:transaction
|> insert(created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input)
|> with_block(status: :ok)
valid_attrs = %{
"contract_source_code" => contract_code_info.source_code,
@ -96,7 +102,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
end
test "creates a smart contract with constructor arguments" do
contract_code_info = Factory.contract_code_info()
contract_code_info = Factory.contract_code_info_modern_compilator()
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode)
@ -115,7 +121,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
created_contract_address_hash: contract_address.hash,
input: contract_code_info.tx_input <> constructor_arguments
)
|> with_block()
|> with_block(status: :ok)
response = Publisher.publish(contract_address.hash, params)
assert {:ok, %SmartContract{} = smart_contract} = response
@ -152,7 +158,10 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do
tx_input = contract_data["tx_input"]
contract_address = insert(:contract_address, contract_code: "0x" <> expected_bytecode)
insert(:transaction, created_contract_address_hash: contract_address.hash, input: "0x" <> tx_input)
:transaction
|> insert(created_contract_address_hash: contract_address.hash, input: "0x" <> tx_input)
|> with_block(status: :ok)
params = %{
"contract_source_code" => contract,

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save