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

python function call subtleties #144

Closed
ievans opened this issue Feb 10, 2020 · 3 comments
Closed

python function call subtleties #144

ievans opened this issue Feb 10, 2020 · 3 comments
Assignees
Labels
bug Something isn't working priority:medium

Comments

@ievans
Copy link
Member

ievans commented Feb 10, 2020

https://github.com/returntocorp/sgrep-rules/blob/663a95579bb825f578068794ffc63c41cb9e3417/python/socket/bind.py#L24

    - pattern-either:
        - pattern: |
            $S = socket.socket(...)
            ...
            $S.bind(("0.0.0.0", ...))
        - pattern: |
            $S = socket.socket(...)
            ...
            $S.bind(("", ...))

is triggering on:

easy_s = socket.socket(doesnt, matter)
easy_s.bind()

But I expect it not to, given it has no arguments.

@ievans ievans added bug Something isn't working priority:medium labels Feb 10, 2020
@aryx
Copy link
Collaborator

aryx commented Feb 10, 2020

Is it normal there is extra parenthesis inside $S.bind? (("", ...))

@ievans
Copy link
Member Author

ievans commented Feb 12, 2020

Yes, not a typo -- you call .bind with a tuple

@aryx
Copy link
Collaborator

aryx commented Feb 19, 2020

I can't reproduce on your test example.
If I do this pattern:
$S = socket.socket(...)
...
$S.bind()

$ /home/pad/github/sgrep/_build/default/bin/main_sgrep.exe -f tests/python/misc_tuple.sgrep tests/python/
/home/pad/github/sgrep/tests/python/misc_tuple.py:1
easy_s = socket.socket(doesnt, matter)
easy_s.bind()

it finds it. But I put back your pattern:
$S = socket.socket(...)
...
$S.bind(("", ...))

$ /home/pad/github/sgrep/_build/default/bin/main_sgrep.exe -f tests/python/misc_tuple.sgrep tests/python/
then no match (as expected).

@aryx aryx closed this as completed Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:medium
Development

No branches or pull requests

2 participants