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

false negative when using not #88

Open
LuciaMartinezGavier opened this issue Nov 8, 2023 · 2 comments
Open

false negative when using not #88

LuciaMartinezGavier opened this issue Nov 8, 2023 · 2 comments

Comments

@LuciaMartinezGavier
Copy link

When using not: in this case, the order of the lines are not considered

weggli '{
    function(_($param));
    NOT: $foo = _;
    function();
}' /target/src

for example, with this target, there are no findings:

void fun(){
    foo = 1;
    function(&param);
    function(&param);
}

But it should because there is no assignment to foo between calls to function.

In this other case where i remove the _(...) in the function parameter, then it works as expected

weggli '{
    function($param);
    NOT: $foo = _;
    function();
}' /target/src
@matan7890
Copy link

[I am not a maintainer, just curios]
I believe the second case you wrote is the right way to query what you want. In the first one you query for a call of "function" that gets as a parameter another call for a function that gets &param.

The interesting thing here is actually that this query matches:

weggli '{
    $function(_(&$param));
    $function(&$param);
}' .

/tmp/src/./a.c:1
void fun(){
    int param;
    int foo = 1;
    function(&param); // <----- These two lines actually match
    function(&param);
}

As the first call to "function" has no parameter that is by itself a call for a function

@bluec0re
Copy link
Contributor

A

{
    function();        
    NOT: foo = _;
    function();
}

also works. Same as

{
    function(&$param);        
    NOT: foo = _;
    function(&$param);
}

or

{
    function(_);        
    NOT: foo = _;
    function(_);
}

Looks like the _(...) expressions with not throws it off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants