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

Add -c argument to target-shell #873

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

cecinestpasunepipe
Copy link
Contributor

(DIS-150)

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 76.40%. Comparing base (d0eba16) to head (3bb3a81).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dissect/target/tools/shell.py 66.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #873      +/-   ##
==========================================
- Coverage   76.41%   76.40%   -0.01%     
==========================================
  Files         314      314              
  Lines       26918    26927       +9     
==========================================
+ Hits        20569    20574       +5     
- Misses       6349     6353       +4     
Flag Coverage Δ
unittests 76.40% <66.66%> (-0.01%) ⬇️

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.

"""Helper method for starting a :class:`TargetCli` or :class:`TargetHubCli` for one or multiple targets."""
if cli := create_cli(targets, cli_cls):
if commands is not None:
# @todo if cli is not RegistryCli: - load targetrc
Copy link
Contributor

@twiggler twiggler Oct 2, 2024

Choose a reason for hiding this comment

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

Be advised: RegistryCli also supports a targetrc file.

JSCU advised to move the loadtargetrc method to ExtendedCmd.

Originally, I wanted to trigger the execution in ExtendedCmd::__init__, but this causes an initialization fiasco because:

  1. the current directory needs to be set before the targetrc file is run
  2. but the directory can only be set after ExtendedCmd has initialized.

So now I trigger targetrc execution in the preloop, but I can see that this is suboptimal with regard to one-shotting.

Might also be related to the fact that we are reusing code through inheritance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addendum: Since bash does not execute the run commands file for non-interactive shells, you can skip loading the targetrc file, until someone complaints. (discussed with @pyrco)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this means, this PR does not have to wait for targetrc and does not have to integrate with targetrc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

@twiggler twiggler left a comment

Choose a reason for hiding this comment

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

QA'OK.

Code looks good.

Waiting on targetrc merge...

dissect/target/tools/shell.py Outdated Show resolved Hide resolved
dissect/target/tools/shell.py Outdated Show resolved Hide resolved
dissect/target/tools/shell.py Outdated Show resolved Hide resolved
cecinestpasunepipe and others added 5 commits October 7, 2024 11:39
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
@cecinestpasunepipe cecinestpasunepipe merged commit 7e856fd into main Oct 7, 2024
16 of 18 checks passed
@cecinestpasunepipe cecinestpasunepipe deleted the DIS-150_One_shot_command_option branch October 7, 2024 16:44
@Schamper Schamper changed the title Add -c argument to target_shell Add -c argument to target-shell Oct 7, 2024
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