Skip to content

Improve parsing of plugin arguments in target-query#1619

Open
yunzheng wants to merge 3 commits intomainfrom
bugfix/target-query-argparse-handling
Open

Improve parsing of plugin arguments in target-query#1619
yunzheng wants to merge 3 commits intomainfrom
bugfix/target-query-argparse-handling

Conversation

@yunzheng
Copy link
Member

@yunzheng yunzheng commented Mar 13, 2026

This PR implements the suggested solution described in #1508, the described edgecase is left open.

It mainly gets the supported argparse arguments from the requested plugins to target-query, and then reparses the arguments again so it properly parses known plugin flags. This essentially fixes the problem described in the issue.

Unknown arguments/flags now also throw an error, which before would go unnoticed.

resolves #1508, #1362

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.13%. Comparing base (f66d3dc) to head (9b53c3c).

Files with missing lines Patch % Lines
dissect/target/tools/query.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1619      +/-   ##
==========================================
+ Coverage   81.10%   81.13%   +0.02%     
==========================================
  Files         401      401              
  Lines       35175    35185      +10     
==========================================
+ Hits        28529    28546      +17     
+ Misses       6646     6639       -7     
Flag Coverage Δ
unittests 81.13% <91.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing bugfix/target-query-argparse-handling (9b53c3c) with main (f66d3dc)

Open in CodSpeed

@yunzheng yunzheng force-pushed the bugfix/target-query-argparse-handling branch from 750b9ea to 3c8b561 Compare March 13, 2026 09:50
@JSCU-CNI
Copy link
Contributor

Perhaps this makes implementing #1493 easier.

return 0

# Dynamically add plugin arguments for the specified function(s)
for func_desc in find_and_filter_plugins(
Copy link
Contributor

@JSCU-CNI JSCU-CNI Mar 13, 2026

Choose a reason for hiding this comment

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

Can we cache the results of this find_and_filter_plugins call so it doesn't have to be called again later on? Never mind, we do not have Target context here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't spend much time on figuring out what find_and_filter_plugins all does, so i'm also not sure if target=None will have any effect of some plugins being returned or not.

@yunzheng
Copy link
Member Author

Windows tests are failing due to windows_path vs posix_path. will look into it later.

@yunzheng yunzheng force-pushed the bugfix/target-query-argparse-handling branch from 788599e to 9b53c3c Compare March 13, 2026 14:11
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.

Target-query runtime arguments interpreted as TARGET

2 participants