Giter VIP home page Giter VIP logo

necessist's People

Contributors

0xphaze avatar dependabot[bot] avatar disconnect3d avatar smoelius avatar tarunbhm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

necessist's Issues

Better highlights for mutated code

Here is an example output on a Rust code base.

engine/src/multisig/client/keygen/tests.rs:72:2-72:28: `ceremony.complete().await;` passed
engine/src/multisig/client/keygen/tests.rs:105:2-105:28: `ceremony.complete().await;` passed

If statements become more complex and contain larger chains, it can become unclear which part has actually been removed. This could be shown in another color in the terminal output for example.

Don't remove method calls in ignored statements

This happens a lot with Go programs.

Example:

			t.Errorf("WriteT.%v: have err == nil, want non-nil", tv.Field(i).Type())
                        //                                                              ^^^^^^^

t.Errorf is ignored, but Necessist still tries to remove .Type().

This change probably should not be made until after the backends have been consolidated in the spirit of #247.

removal of closures and functions that contain `assert` macros cause false positives

Necessist will warn that a test is passing with code remove for the following examples:

  • A closure that contains an assertion
fn test1() {
std::thread::.spawn(move || {
                       ...
                        assert!(
                          ...
                        );
}

  • A function call that contains an assertion
fn test2() {
   let x = ...
   let y = ...
    my_assertion_helper(x, y);
}
fn my_assertion_helper(x, y) { assert!(...); }

Both of these mutations do not indicate that a test statement is unnecessary, and I think they should be ignored since assert is ignored.

Check if package.json exists while installing node modules

The install_node_modules function does not check if the package.json file exists in the project directory. This function is used for foundry projects as well to support foundry projects with hardhat dependencies. But dry run fails for the pure foundry projects because they don't have a package.json file.

pub fn install_node_modules(context: &LightContext) -> Result<()> {
if context.root.join("node_modules").try_exists()? {
return Ok(());
}
// smoelius: If a `yarn.lock` file exists, use `yarn`. Otherwise, default to `npm install`.
let mut command = if context.root.join("yarn.lock").try_exists()? {
Command::new("yarn")
} else {
let mut command = Command::new("npm");
command.arg("install");
command
};
command.current_dir(context.root.as_path());
debug!("{:?}", command);
let output = command.output()?;
ensure!(output.status.success(), "{:#?}", output);
Ok(())
}

Adding a check if the package.json file exists will resolve this issue.

Add a test to check whether third-party revisions are current

Reduce removal of nonbuildable statements

I see a few examples of where the exception list could be refined, however some might require some static analysis.
We could include exceptions for .function in vm.function and abi.function. With further analysis .Struct for Interface.Struct shouldn't be removed as well as .function in contract.function.

test/Test.t.sol:4457:11-4457:45: `.assume(_relayer > address(0x09));` nonbuildable
test/Test.t.sol:4458:9-4458:40: `vm.assume(_oracle != _relayer);` passed
test/Test.t.sol:4458:11-4458:40: `.assume(_oracle != _relayer);` nonbuildable
test/Test.t.sol:4461:9-4461:32: `vm.roll(startingBlock);` failed
test/Test.t.sol:4461:11-4461:32: `.roll(startingBlock);` nonbuildable
test/Test.t.sol:4466:35-4466:105: `.ProtocolFeeSettings(false, payable(address(0)), true, address(0), 0);` nonbuildable
test/Test.t.sol:4467:13-4467:91: `endpoint.updateProtocolFeeSettings("TestLibrary", 1, abi.encode(feeSettings));` passed
test/Test.t.sol:4467:21-4467:91: `.updateProtocolFeeSettings("TestLibrary", 1, abi.encode(feeSettings));` nonbuildable
test/Test.t.sol:4467:69-4467:89: `.encode(feeSettings)` nonbuildable
test/Test.t.sol:4470:46-4470:98: `.encode(false, address(_oracle), address(_relayer));` nonbuildable
test/Test.t.sol:4472:20-4472:121: `.encode(10, 10, 10, 10, _oracle, _relayer, address(this), address(0), address(0), true, true, false);` nonbuildable
test/Test.t.sol:4482:38-4482:49: `.encode(i);` nonbuildable
test/Test.t.sol:4483:45-4483:56: `.encode(i);` nonbuildable
test/Test.t.sol:4484:54-4484:71: `.encode(_relayer)` nonbuildable

Improvements in foundry support

In this issue we list the improvements that can be made to the foundry support:

  1. Do not remove .expectCall lines in mutations
  2. Do not remove .log lines in mutations

Contribution guidelines

Add contribution guidelines with the following:

  1. Describe different test suits and how to run them
  2. General and CI tests that are required to be run to ensure correct formatting, linting, and other things
  3. Documentation requirements if any

Dry run all the test files together before initiating mutations

Currently Necessist dry runs each test file and then starts mutating it line by line to find surviving mutations. The dry run of the next file required an additional build after reverting the last mutation of the earlier file. We can try to improve performance by dry running all the files together at the start, which will allow us to skip the build of the original code again and again with a dry run of every test file.

However, there is a challenge with this approach. The Necessist is built with two goals:

  1. Provide useful information when something fails.
  2. Be able to keep going when something fails.

Therefore to be able to find which test file had a failing test case will require parsing logic for test output for all supported frameworks. We are keeping this issue for future if we can find a better approach to handle this case.

Get rid of `REQUIRE_NODE_MODULES`

However, for the long term, I am wondering if we can remove the REQUIRE_NODE_MODULES and simply rely on the presence of the package.json to decide if we should install node packages or not. There should be only rare cases in which the package.json exists and is not required to build or test the project.

Originally posted by @tarunbhm in #580 (comment)

Should error when `--dump` is passed and no necessist.db is found

What I imagine is that somehow, the arguments to this function are reworked, and a check is added involving the dump flag:

pub(crate) fn init(
root: &Path,
must_not_exist: bool,
reset: bool,
) -> Result<(Sqlite, Vec<crate::Removal>)> {

Here is where sqlite::init is called (you can see the dump flag is already incorporated into the must_not_exist argument):

necessist/core/src/core.rs

Lines 175 to 179 in 7cdeac5

let (sqlite, mut past_removals) = sqlite::init(
context.root,
!context.opts.dump && !context.opts.reset && !context.opts.resume,
context.opts.reset,
)?;

Ideally, the fix would also include a trycmd test to verify the new behavior. That would involve adding a test to this directory: https://github.com/trailofbits/necessist/tree/master/core/tests/necessist_db_absent

`--framework` should be more than just a suggestion

Currently, --framework can be used to resolve ambiguities when multiple frameworks apply.

But Necessist will still error if it believes the specified framework does not apply.

Necessist should consider --framework a command, and should error only if it cannot be honored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.