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

Agent: Change the Agent to use the modified exploiter config #2807

Merged

Conversation

VakarisZ
Copy link
Contributor

What does this PR do?

Addresses #2785 (changes agent to be compatible with configuration changes)

Improved naming a bit

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by exploiting hadoop, looking at the logs

  • If applicable, add screenshots or log transcripts of the feature working

@VakarisZ VakarisZ marked this pull request as draft January 10, 2023 09:49
@VakarisZ VakarisZ force-pushed the 2785-change-exploiter-config-agent branch from 2278b83 to 94e1f51 Compare January 10, 2023 09:56
@@ -121,16 +117,15 @@ def _exploit_hosts_on_queue(

def _run_all_exploiters(
self,
exploiters_to_run: Sequence[PluginConfiguration],
exploiter_configs: Mapping[ExploiterName, Mapping],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure about changing the sequence to Dict, but I think dict is more flexible and it's the responsibility of this method to determine the order based on configuration

Copy link
Collaborator

Choose a reason for hiding this comment

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

A Dict will preserve order. In this case, I think we should type hint with Dict instead of Mapping, as Mappings may not preserve order. Better yet, we should, perhaps, used OrderedDict to signal that order matters.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the exploiters are plugins but don't use PluginConfiguration?

Copy link
Collaborator

Choose a reason for hiding this comment

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

PluginConfiguration will likely go away at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with Dict, because I ran into issues trying to used OrderedDict type hint. We can make it "ordered" later, we don't need the extra method it provides

@VakarisZ VakarisZ force-pushed the 2785-change-exploiter-config-agent branch from 94e1f51 to 730ce6b Compare January 10, 2023 10:51
@VakarisZ VakarisZ marked this pull request as ready for review January 10, 2023 10:51
for exploiter in exploitation_config.exploiters:
) -> Dict[ExploiterName, Dict]:
extended_configs = {}
for exploiter, plugin_options in exploitation_config.exploiters.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's try to avoid the word "plugin" in the master. There's really no reason this component needs to be aware of plugins. It receives a config from C&C and orders the puppet to take action. "exploiter_options" would be better.

target_host: TargetHost,
current_depth: int,
servers: Sequence[str],
results_callback: Callback,
stop: Event,
):

for exploiter in interruptible_iter(exploiters_to_run, stop):
exploiter_name = exploiter.name
for exploiter_name in interruptible_iter(exploiter_configs, stop):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could maybe do

Suggested change
for exploiter_name in interruptible_iter(exploiter_configs, stop):
for exploiter_name, exploiter_config in interruptible_iter(exploiter_configs.items(), stop):

Then you wouldn't need the lookup on line 143. But this is a minor nit.

@VakarisZ VakarisZ force-pushed the 2785-change-exploiter-config-agent branch from 730ce6b to 8cfdcb6 Compare January 10, 2023 13:51
Copy link
Collaborator

@mssalvatore mssalvatore left a comment

Choose a reason for hiding this comment

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

Approved, but let's add a comment stating that order is important and a dict preserves order.

@mssalvatore mssalvatore merged commit b26db38 into 2785-plugins-in-schema Jan 10, 2023
@mssalvatore mssalvatore deleted the 2785-change-exploiter-config-agent branch January 10, 2023 14:02
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