Erikcruzk / TRT

The Transformative Repair Tool
Other
2 stars 0 forks source link

Issue with Running TRT with "preanalyzed: True" Option #75

Open mojtaba-eshghie opened 9 months ago

mojtaba-eshghie commented 9 months ago

I ran TRT on preanalyzed results (successful patch generation without validation). If we assume each pass of TRT has the following three phases, the third one fails.

  1. Analysis (vulnerability detection)
  2. Repair (patch generation)
  3. Analysis (patch validation)

To Reproduce
Use the following configuration:

# Configuration file for automatic program repair experiments

# Folder name for results
experiment_settings:
  experiment_name: "preanalyzed-exp-1" # Folder name for results
  delete_old_experiment_name: false
  llm_model_name: "gpt-3.5-turbo"
  vulnerable_contracts_directory: "sc_datasets/DAppSCAN_processed" #"smartbugs_reentrancy_short_no_comments_test" # Folder name for buggy smart contracts
  target_vulnerabilities: [reentrancy-eth] #[reentrancy-benign, reentrancy-events, reentrancy-no-eth, reentrancy-unlimited-gas, reentrancy-eth, compound-borrowfresh-reentrancy, erc721-reentrancy, curve-readonly-reentrancy, erc777-reentrancy, erc677-reentrancy, arbitrary-low-level-call, SOLIDITY_CALL_WITHOUT_DATA, arbitrary-send-erc20, arbitrary-send-eth, suicidal, arbitrary-send-erc20-permit, compound-sweeptoken-not-restricted, erc20-public-burn, accessible-selfdestruct, oracle-price-update-not-restricted, uniswap-callback-not-protected, SOLIDITY_TX_ORIGIN, controlled-delegatecall, delegatecall-loop, delegatecall-to-arbitrary-address, divide-before-multiply, basic-arithmetic-underflow, SOLIDITY_DIV_MUL, keeper-network-oracle-manipulation, missing-zero-check, shadowing-local, shadowing-state, shadowing-abstract, erc20-interface, SOLIDITY_ERC20_TRANSFER_SHOULD_THROW,  timestamp, weak-prng, uninitialized-local, uninitialized-state, incorrect-equality, boolean-cst, incorrect-use-of-blockhash, SOLIDITY_EXACT_TIME, SOLIDITY_BALANCE_EQUALITY, locked-ether, calls-loop, msg-value-loop, SOLIDITY_LOCKED_MONEY, SOLIDITY_TRANSFER_IN_LOOP, controlled-array-length, SOLIDITY_ARRAY_LENGTH_MANIPULATION, incorrect-modifier, unchecked-transfer,
  #unchecked-lowlevel, SOLIDITY_ERC20_APPROVE]
  n_smartbugs_threads: 60
  n_repair_threads: 20 # n_repair_threads: 10
  # smartbugs_tools: [oyente, slither, confuzzius, conkas, honeybadger, maian, mythril, osiris, securify, sFuzz, solhint]
  smartbugs_tools: [slither, semgrep, smartcheck]
  smartbugs_timeout: 3600
  smartbugs_processes: 11
  patch_examples_directory: "sc_repair_examples"
  prompt_style: "flattened-src---function"
  shave: [comments, NatSpec, file_directives] # sahving configurations
  threshold: 200 # number of tokens that trigger the shaving
  preanalized: True # if the smart contracts have been already analyzed by the sartbugs
  analysis_results_directory: "sc_datasets/vulnerabilities_test" # directory with the analysis results if preanalized is True

# LLM model and settings
llm_settings:
  gpt-4-0125-preview:
    model_name: "gpt-4-0125-preview"
    secret_api_key: "..."
    temperature: 0.9
    top_p: 0.3
    num_candidate_patches: 10 # num_candidate_patches: 10
    max_time: 3600
    stop: ["///"]
  gpt-3.5-turbo:
    model_name: "gpt-3.5-turbo"
    secret_api_key: "..."
    temperature: 0.9
    top_p: 0.3
    num_candidate_patches: 1 # num_candidate_patches: 10
    max_time: 3600
    stop: ["///"]

Expected behavior
In the following directory (under experiment_results) there should be a smartbugs results log that does NOT contain any errors.

image

Currently, it has the following error:

image

Environment (please complete the following information):

sofiabobadilla commented 8 months ago

I've been looking at this and have some implementation questions. If preanalyzed is True, then we run minimal_analysis () but still, on the function (minimal_analysis), Step 2 indicates that is consuming smartbugs_queue, but in this scenario we only want to do it at the end to analyze patches (Link to the line). Therefore, why is consuming smartbugs-queue before repairing?