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

[cmd] Add support for flags specifying filters type in vmmap, and allow multiple filters #1120

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

ValekoZ
Copy link
Collaborator

@ValekoZ ValekoZ commented Jun 5, 2024

Parse args:

  • -a / --addr:
    • filter by address -> parses the next arg as an int or asks gdb the value
  • -n / --name:
    • filter based on section name
  • If nothing is specified, print a warning and guess the type (previous behavior)

@ValekoZ
Copy link
Collaborator Author

ValekoZ commented Jun 5, 2024

I will write docs and tests later :P

Copy link

github-actions bot commented Jun 5, 2024

🤖 Coverage update for 6fd7ef5 🟢

Old New
Commit 1b6f46a 6fd7ef5
Score 71.6907% 71.7283% (0.0376)

@hugsy
Copy link
Owner

hugsy commented Jun 5, 2024

I will write docs and tests later :P

No problem, I'll make this a draft then to see the diff with that's ready to review. Change the status when ready

@hugsy hugsy marked this pull request as draft June 5, 2024 15:57
Copy link

github-actions bot commented Jun 8, 2024

🤖 Coverage update for 36da9f9 🔴

Old New
Commit 1b6f46a 36da9f9
Score 71.6798% 71.6503% (-0.0295)

Copy link

github-actions bot commented Jun 8, 2024

🤖 Coverage update for 36da9f9 🟢

Old New
Commit 1b6f46a 36da9f9
Score 71.6798% 71.6798% (0)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 4136826 🟢

Old New
Commit 1b6f46a 4136826
Score 71.6798% 71.7175% (0.0377)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 4136826 🔴

Old New
Commit 1b6f46a 4136826
Score 71.6798% 71.6503% (-0.0295)

Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting addition but I think you should rewrite the parsing loop using the parse_arguments decorator here. It would gain in simplicity and clarity.

gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 2bf489b 🔴

Old New
Commit 1b6f46a 2bf489b
Score 71.6798% 71.669% (-0.0108)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 2bf489b 🟢

Old New
Commit 1b6f46a 2bf489b
Score 71.6798% 71.6798% (0)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 0027c79 🟢

Old New
Commit 1b6f46a 0027c79
Score 71.6798% 71.6798% (0)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 0027c79 🟢

Old New
Commit 1b6f46a 0027c79
Score 71.6798% 71.6877% (0.0079)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for eb97eb0 🟢

Old New
Commit 1b6f46a eb97eb0
Score 71.6798% 71.6798% (0)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for eb97eb0 🔴

Old New
Commit 1b6f46a eb97eb0
Score 71.6798% 71.669% (-0.0108)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 48ada57 🟢

Old New
Commit 1b6f46a 48ada57
Score 71.6798% 71.6877% (0.0079)

Copy link

github-actions bot commented Jun 9, 2024

🤖 Coverage update for 48ada57 🟢

Old New
Commit 1b6f46a 48ada57
Score 71.6798% 71.6798% (0)

hugsy added a commit that referenced this pull request Jun 24, 2024
…_arguments` decorator (#1122)

Add support for the `append` action for ArgumentParser in the `parse_arguments` decorator on optional arguments.

This makes us able to support this:

```
command --arg 1 --arg 2 --arg 3
```

And get `[1, 2, 3]` as the `arg` value.

This CL is required to make changes to
#1120 before merging.

---------

Co-authored-by: crazy hugsy <hugsy@users.noreply.github.com>
Copy link

🤖 Coverage update for ec99843 🟢

Old New
Commit 6ddd780 ec99843
Score 71.6649% 71.8088% (0.1439)

@ValekoZ ValekoZ requested a review from hugsy June 25, 2024 12:39
Copy link

🤖 Coverage update for ec99843 🟢

Old New
Commit 6ddd780 ec99843
Score 71.6649% 71.6649% (0)

Copy link

🤖 Coverage update for c8d73cd 🟢

Old New
Commit 6ddd780 c8d73cd
Score 71.6649% 71.6649% (0)

Copy link

🤖 Coverage update for c8d73cd 🟢

Old New
Commit 6ddd780 c8d73cd
Score 71.6649% 71.8088% (0.1439)

Copy link

🤖 Coverage update for e9b45bc 🟢

Old New
Commit f298b7f e9b45bc
Score 71.6267% 71.6267% (0)

Copy link

🤖 Coverage update for e9b45bc 🟢

Old New
Commit f298b7f e9b45bc
Score 71.6267% 71.7702% (0.1435)

Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly ok, just needs tests

gef.py Outdated Show resolved Hide resolved
docs/commands/vmmap.md Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
tests/commands/vmmap.py Show resolved Hide resolved
Copy link

🤖 Coverage update for d00aa17 🟢

Old New
Commit f298b7f d00aa17
Score 71.6267% 71.7702% (0.1435)

Copy link

🤖 Coverage update for 93f588e 🟢

Old New
Commit f298b7f 93f588e
Score 71.6267% 71.6267% (0)

Copy link

🤖 Coverage update for d00aa17 🟢

Old New
Commit f298b7f d00aa17
Score 71.6267% 71.6267% (0)

Copy link

🤖 Coverage update for 93f588e 🟢

Old New
Commit f298b7f 93f588e
Score 71.6267% 71.7702% (0.1435)

Copy link

🤖 Coverage update for 3da17fe 🟢

Old New
Commit f298b7f 3da17fe
Score 71.6267% 71.6267% (0)

Copy link

🤖 Coverage update for cb9c3fb 🟢

Old New
Commit f298b7f cb9c3fb
Score 71.6267% 71.6267% (0)

gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
filters = names_filter + addrs_filter
filter_content = f"[{' & '.join(filters)}]"

if len(names) + len(addrs) == 0:
self.print_entry(entry)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could continue after this, and then remove the elif below, & un-indent the rest. Also, couldn't the if above just be if not filter_content?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove the elif because we want to check if there are matched filters (which is not already checked)
And we can't replace the first if with if not filter_content since we want to check if there are existing filters, but this would check if there are matched filters

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then I think if not names and not addrs is probably clearer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you though. Approved.

Co-authored-by: Grazfather <grazfather@gmail.com>
Copy link

🤖 Coverage update for c55c505 🟢

Old New
Commit f298b7f c55c505
Score 71.6319% 71.6319% (0)

Copy link

🤖 Coverage update for 55a1649 🟢

Old New
Commit f298b7f 55a1649
Score 71.6319% 71.6319% (0)

Copy link

🤖 Coverage update for 60215b4 🟢

Old New
Commit f298b7f 60215b4
Score 71.6319% 71.6319% (0)

Copy link

🤖 Coverage update for 76f40f1 🟢

Old New
Commit f298b7f 76f40f1
Score 71.6319% 71.7819% (0.15)

Copy link

🤖 Coverage update for 76f40f1 🟢

Old New
Commit f298b7f 76f40f1
Score 71.6319% 71.6319% (0)

filters = names_filter + addrs_filter
filter_content = f"[{' & '.join(filters)}]"

if len(names) + len(addrs) == 0:
self.print_entry(entry)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then I think if not names and not addrs is probably clearer

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

Successfully merging this pull request may close these issues.

3 participants