Skip to content

Commit aa224ea

Browse files
Merge pull request #132 from mojtaba-eshghie/feat_issue_131
Feat issue 131
2 parents 9e7fc46 + 3543ba5 commit aa224ea

24 files changed

+1007
-81
lines changed

CI/run.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ let argv = yargs(hideBin(process.argv))
4141
type: 'boolean',
4242
description: 'Run with verbose logging'
4343
})
44+
.option('config', {
45+
alias: 'c',
46+
type: 'string',
47+
description: 'Micro config file full relative path (to the root of the project).',
48+
})
4449
.argv;
4550

4651
if (argv.verbose) {
@@ -49,8 +54,14 @@ if (argv.verbose) {
4954
runLogger.level = 'info';
5055
}
5156

52-
const setupAndRunTests = require(`@CI/setup-${argv.type}-${argv.env}`);
57+
let setupAndRunTests = require(`@CI/setup-${argv.type}-${argv.env}`);
5358

54-
setupAndRunTests().catch(error => {
55-
runLogger.error(chalk.red(`Error during setup or test execution:\n${error.stack ? error.stack : error}`));
56-
})
59+
if (argv.config) {
60+
setupAndRunTests(argv.config).catch(error => {
61+
runLogger.error(chalk.red(`Error during setup or test execution:\n${error.stack ? error.stack : error}`));
62+
})
63+
} else {
64+
setupAndRunTests().catch(error => {
65+
runLogger.error(chalk.red(`Error during setup or test execution:\n${error.stack ? error.stack : error}`));
66+
})
67+
}

CI/setup-synthesized-separate.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ async function appendToJsonFile(filePath, data) {
5656
}
5757
}
5858

59-
async function setupAndRunTests() {
60-
let ciConfig = readCIConfig('config-synthesized.yml');
59+
async function setupAndRunTests(configFilePath) {
60+
let ciConfig;
61+
if (configFilePath) {
62+
ciConfig = readCIConfig(configFilePath);
63+
} else {
64+
ciConfig = readCIConfig('config-synthesized.yml');
65+
}
66+
6167
let successfulExploitsCount = 0;
6268
let failedExploitsCount = 0;
6369
let unresolvedExploitsCount = 0;

config-synthesized.yml

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Configuration for Continuous Integration (CI) of smart contract monitoring ecosystem
22

33
contracts:
4-
# - name: "MultiStageAuction"
5-
# numOfVariants: 25
6-
# constructorParamSpecs: []
7-
# models:
8-
# - name: "MultiStageAuction"
9-
# id: "1701049"
10-
# functions: []
11-
# tests:
12-
# - "MultiStageAuctionExploit"
4+
- name: "MultiStageAuction"
5+
numOfVariants: 25
6+
constructorParamSpecs: []
7+
models:
8+
- name: "MultiStageAuction"
9+
id: "1701049"
10+
functions: []
11+
tests:
12+
- "MultiStageAuctionExploit"
1313

14-
# - name: "ProductOrder"
15-
# numOfVariants: 25
16-
# constructorParamSpecs:
17-
# - name: "_price"
18-
# type: "uint256"
19-
# sourceType: "static"
20-
# value: 1
21-
# models:
22-
# - name: "ProductOrder"
23-
# id: "1822680"
24-
# functions: []
25-
# hasResponseRelation: true
26-
# tests:
27-
# - "ProductOrderExploit"
14+
- name: "ProductOrder"
15+
numOfVariants: 25
16+
constructorParamSpecs:
17+
- name: "_price"
18+
type: "uint256"
19+
sourceType: "static"
20+
value: 1
21+
models:
22+
- name: "ProductOrder"
23+
id: "1822680"
24+
functions: []
25+
hasResponseRelation: true
26+
tests:
27+
- "ProductOrderExploit"
2828

2929
- name: "Escrow"
3030
numOfVariants: 4
@@ -50,48 +50,48 @@ contracts:
5050
tests:
5151
- "EscrowExploit"
5252

53-
# - name: "PrizeDistribution"
54-
# numOfVariants: 1
55-
# constructorParamSpecs:
56-
# - name: "_beneficiary"
57-
# type: "address"
58-
# sourceType: "dynamic" # Indicates the value should be fetched dynamically
59-
# source:
60-
# type: "EOA" # EOA or contract
61-
# # details for a contract source:
62-
# # details:
63-
# # contractAddress: "0x0"
64-
# # functionCall: "getSubscriberAddress"
65-
# # returnType: "address"
66-
# # details for an EOA:
67-
# # For an EOA, you can just get the address from the list of accounts in the environment; no need to specify it here;
68-
# # - name: "threshold"
69-
# # type: "uint256"
70-
# # source: "static"
71-
# # value: "1000" # Static value provided directly in the config
72-
# models:
73-
# - name: "PrizeDistribution"
74-
# id: "1822535" # The id of the model in DCRGraphs.net website
75-
# # - name: "Model2"
76-
# # id: "1701159"
77-
# # functions:
78-
# # setGreet:
79-
# # EVMType: "string"
80-
# # DCRType: "integer"
81-
# # DCRNodeID: "setGreet"
82-
# tests: # if there are tests specified for this model, it will run them alongside the monitor automatically. Otherwise, only thing that will run is the monitor
83-
# - "PrizeDistributionExploit"
53+
- name: "PrizeDistribution"
54+
numOfVariants: 1
55+
constructorParamSpecs:
56+
- name: "_beneficiary"
57+
type: "address"
58+
sourceType: "dynamic" # Indicates the value should be fetched dynamically
59+
source:
60+
type: "EOA" # EOA or contract
61+
# details for a contract source:
62+
# details:
63+
# contractAddress: "0x0"
64+
# functionCall: "getSubscriberAddress"
65+
# returnType: "address"
66+
# details for an EOA:
67+
# For an EOA, you can just get the address from the list of accounts in the environment; no need to specify it here;
68+
# - name: "threshold"
69+
# type: "uint256"
70+
# source: "static"
71+
# value: "1000" # Static value provided directly in the config
72+
models:
73+
- name: "PrizeDistribution"
74+
id: "1822535" # The id of the model in DCRGraphs.net website
75+
# - name: "Model2"
76+
# id: "1701159"
77+
# functions:
78+
# setGreet:
79+
# EVMType: "string"
80+
# DCRType: "integer"
81+
# DCRNodeID: "setGreet"
82+
tests: # if there are tests specified for this model, it will run them alongside the monitor automatically. Otherwise, only thing that will run is the monitor
83+
- "PrizeDistributionExploit"
8484

85-
# - name: "Governance"
86-
# numOfVariants: 1
87-
# constructorParamSpecs: []
88-
# models:
89-
# - name: "Governance"
90-
# id: "1822788"
91-
# functions: []
92-
# hasResponseRelation: true
93-
# tests:
94-
# - "GovernanceExploit"
85+
- name: "Governance"
86+
numOfVariants: 1
87+
constructorParamSpecs: []
88+
models:
89+
- name: "Governance"
90+
id: "1822788"
91+
functions: []
92+
hasResponseRelation: true
93+
tests:
94+
- "GovernanceExploit"
9595

9696
tests:
9797
- name: "PrizeDistributionExploit"

lib/config/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ let readCIConfig = (configFileName = 'config.yml') => {
1919

2020

2121

22+
let readCIConfigWithPath = (configFilePath) => {
23+
let ciConfigContent = fs.readFileSync(path.join(__dirname, configFilePath), 'utf8');
24+
return yaml.load(ciConfigContent);
25+
}
26+
27+
28+
29+
2230

2331

2432
/**
@@ -62,5 +70,6 @@ let readModelFunctionsParams = (contractName, modelId, configFile) => {
6270

6371
module.exports = {
6472
readCIConfig,
73+
readCIConfigWithPath,
6574
readModelFunctionsParams
6675
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Configuration for Continuous Integration (CI) of smart contract monitoring ecosystem
2+
3+
contracts:
4+
# - name: "MultiStageAuction"
5+
# numOfVariants: 25
6+
# constructorParamSpecs: []
7+
# models:
8+
# - name: "MultiStageAuction"
9+
# id: "1701049"
10+
# functions: []
11+
# tests:
12+
# - "MultiStageAuctionExploit"
13+
14+
# - name: "ProductOrder"
15+
# numOfVariants: 25
16+
# constructorParamSpecs:
17+
# - name: "_price"
18+
# type: "uint256"
19+
# sourceType: "static"
20+
# value: 1
21+
# models:
22+
# - name: "ProductOrder"
23+
# id: "1822680"
24+
# functions: []
25+
# hasResponseRelation: true
26+
# tests:
27+
# - "ProductOrderExploit"
28+
29+
- name: "Escrow"
30+
numOfVariants: 4
31+
constructorParamSpecs:
32+
- name: "_sender"
33+
type: "address"
34+
sourceType: "dynamic"
35+
source:
36+
type: "EOA"
37+
- name: "_receiver"
38+
type: "address"
39+
sourceType: "dynamic"
40+
source:
41+
type: "EOA"
42+
- name: "_delayUntilRelease"
43+
type: "uint"
44+
sourceType: "static"
45+
value: 0
46+
models:
47+
- name: "Escrow"
48+
id: "1624258"
49+
functions: []
50+
tests:
51+
- "EscrowExploit"
52+
53+
# - name: "PrizeDistribution"
54+
# numOfVariants: 1
55+
# constructorParamSpecs:
56+
# - name: "_beneficiary"
57+
# type: "address"
58+
# sourceType: "dynamic" # Indicates the value should be fetched dynamically
59+
# source:
60+
# type: "EOA" # EOA or contract
61+
# # details for a contract source:
62+
# # details:
63+
# # contractAddress: "0x0"
64+
# # functionCall: "getSubscriberAddress"
65+
# # returnType: "address"
66+
# # details for an EOA:
67+
# # For an EOA, you can just get the address from the list of accounts in the environment; no need to specify it here;
68+
# # - name: "threshold"
69+
# # type: "uint256"
70+
# # source: "static"
71+
# # value: "1000" # Static value provided directly in the config
72+
# models:
73+
# - name: "PrizeDistribution"
74+
# id: "1822535" # The id of the model in DCRGraphs.net website
75+
# # - name: "Model2"
76+
# # id: "1701159"
77+
# # functions:
78+
# # setGreet:
79+
# # EVMType: "string"
80+
# # DCRType: "integer"
81+
# # DCRNodeID: "setGreet"
82+
# tests: # if there are tests specified for this model, it will run them alongside the monitor automatically. Otherwise, only thing that will run is the monitor
83+
# - "PrizeDistributionExploit"
84+
85+
# - name: "Governance"
86+
# numOfVariants: 1
87+
# constructorParamSpecs: []
88+
# models:
89+
# - name: "Governance"
90+
# id: "1822788"
91+
# functions: []
92+
# hasResponseRelation: true
93+
# tests:
94+
# - "GovernanceExploit"
95+
96+
tests:
97+
- name: "PrizeDistributionExploit"
98+
description: "Exploits for time-based vulnerability of PrizeDistribution contract which is enabled by a poor logic in the contract implementation."
99+
directory: "/exploits//synthesized"
100+
environment: "anvil"
101+
102+
- name: "MultiStageAuctionExploit"
103+
description: "Exploits for a temporal property of ..."
104+
directory: "/exploits/synthesized"
105+
environment: "anvil"
106+
107+
- name: "ProductOrderExploit"
108+
description: "No description yet..."
109+
directory: "/exploits/synthesized"
110+
environment: "anvil"
111+
112+
- name: "EscrowExploit"
113+
description: "No description yet..."
114+
directory: "/exploits/synthesized"
115+
environment: "anvil"
116+
117+
- name: "GovernanceExploit"
118+
description: "No description yet..."
119+
directory: "/exploits/synthesized"
120+
environment: "anvil"
121+
122+
environments:
123+
- name: "anvil"
124+
version: "0.2.0"

0 commit comments

Comments
 (0)