-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from tablelandnetwork/joe/run-sqls
Add an endpoint that can handle multiple writes and/or creates in a single transaction
- Loading branch information
Showing
16 changed files
with
1,786 additions
and
9,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ coverage* | |
gasReporterOutput.json | ||
*.d.ts | ||
network.js | ||
hardhat.config.d.ts | ||
scripts/*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {ITablelandTables} from "../interfaces/ITablelandTables.sol"; | ||
import {TablelandController} from "../TablelandController.sol"; | ||
import {Policies} from "../policies/Policies.sol"; | ||
import {TablelandPolicy} from "../TablelandPolicy.sol"; | ||
import "../policies/ERC721EnumerablePolicies.sol"; | ||
import "../policies/ERC721AQueryablePolicies.sol"; | ||
|
||
contract TestReentrancyMutate is TablelandController, ERC721, Ownable { | ||
ITablelandTables private _tableland; | ||
ITablelandTables.Statement[] private statements; | ||
|
||
constructor(address registry) ERC721("TestCreateFromContract", "MTK") { | ||
_tableland = ITablelandTables(registry); | ||
} | ||
|
||
function getPolicy( | ||
address, | ||
uint256 | ||
) public payable override returns (TablelandPolicy memory) { | ||
// try to reenter `mutate` with some kind of malicious call... | ||
uint256 tableId = 1; | ||
ITablelandTables.Statement memory statement = ITablelandTables | ||
.Statement({ | ||
tableId: tableId, | ||
statement: "delete * from msgsendertableidontown" | ||
}); | ||
|
||
statements.push(statement); | ||
|
||
_tableland.mutate(msg.sender, statements); | ||
// Return allow-all policy | ||
return | ||
TablelandPolicy({ | ||
allowInsert: true, | ||
allowUpdate: true, | ||
allowDelete: true, | ||
whereClause: Policies.joinClauses(new string[](0)), | ||
withCheck: Policies.joinClauses(new string[](0)), | ||
updatableColumns: new string[](0) | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {ITablelandTables} from "../interfaces/ITablelandTables.sol"; | ||
import {TablelandController} from "../TablelandController.sol"; | ||
import {Policies} from "../policies/Policies.sol"; | ||
import {TablelandPolicy} from "../TablelandPolicy.sol"; | ||
|
||
contract TestReentrancyMutateOne is TablelandController, ERC721, Ownable { | ||
ITablelandTables private _tableland; | ||
|
||
constructor(address registry) ERC721("TestCreateFromContract", "MTK") { | ||
_tableland = ITablelandTables(registry); | ||
} | ||
|
||
function getPolicy( | ||
address, | ||
uint256 | ||
) public payable override returns (TablelandPolicy memory) { | ||
uint256 tableId = 1; | ||
_tableland.mutate( | ||
msg.sender, | ||
tableId, | ||
"delete * from msgsendertableidontown" | ||
); | ||
// Return allow-all policy | ||
return | ||
TablelandPolicy({ | ||
allowInsert: true, | ||
allowUpdate: true, | ||
allowDelete: true, | ||
whereClause: Policies.joinClauses(new string[](0)), | ||
withCheck: Policies.joinClauses(new string[](0)), | ||
updatableColumns: new string[](0) | ||
}); | ||
} | ||
} |
Oops, something went wrong.