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 a build_permission_change_command method to ILinuxAgentCommandBuilder #10

Merged
merged 6 commits into from
Jun 11, 2024

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented Jun 11, 2024

@@ -47,6 +47,12 @@ def build_download_command(self, download_options: LinuxDownloadOptions):
:param download_options: Options needed for the command to be built
"""

@abc.abstractmethod
def build_chmod_command(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Should this be build_set_permissions_command()? I know chmod is normally how that's done, but there are conceivably other ways of getting the job done.
  2. Should this accept a parameter for what the permissions should be? If so, should it be a single parameter or should we build an Options model like we do for the other two commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If command builder is a utility to build command/bash statements then we should be specific. If there's another way to change permissions we'll have to add it to the interface, because it will be a different bash statement.

@@ -20,6 +20,11 @@ class LinuxDownloadOptions(InfectionMonkeyBaseModel):
download_url: str


class LinuxPermissionChangeOptions(InfectionMonkeyBaseModel):
file_path: PurePosixPath
permissions: int = Field(ge=0, le=777)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
permissions: int = Field(ge=0, le=777)
permissions: int = Field(ge=0, le=0o777)

Copy link
Collaborator

@mssalvatore mssalvatore Jun 11, 2024

Choose a reason for hiding this comment

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

NIT: I recommend "LinuxChangePermissionsOptions"

Comment on lines 56 to 57
def build_permission_change_command(self,
permission_change_options: LinuxPermissionChangeOptions):
Copy link
Collaborator

Choose a reason for hiding this comment

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

formatting

Copy link
Collaborator

@mssalvatore mssalvatore Jun 11, 2024

Choose a reason for hiding this comment

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

NIT: I recommend "build_change_permissions_command"

@@ -20,6 +20,11 @@ class LinuxDownloadOptions(InfectionMonkeyBaseModel):
download_url: str


class LinuxPermissionChangeOptions(InfectionMonkeyBaseModel):
file_path: PurePosixPath
permissions: int = Field(ge=0, le=777, default=700)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
permissions: int = Field(ge=0, le=777, default=700)
permissions: int = Field(ge=0, le=0o777, default=0o700)

Comment on lines 140 to 141
ILinuxAgentCommandBuilder.build_permission_change_command
ILinuxAgentCommandBuilder.permission_change_options
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should remove vulture from this repository

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably. The right way to go about it is to make it an option in the cookiecutter template and then use cruft to update this repo and not include it.

@VakarisZ
Copy link
Contributor Author

Feel free to rename, but it's annoying since it has to be done manually, because it's a separate repository, so I prefer not to spend time on it

@VakarisZ VakarisZ changed the title Add a build_chmod_command method to ILinuxAgentCommandBuilder Add a build_permission_change_command method to ILinuxAgentCommandBuilder Jun 11, 2024
@mssalvatore mssalvatore merged commit 37c9ba7 into dev Jun 11, 2024
@mssalvatore mssalvatore deleted the add-chmod-command branch June 11, 2024 15:35
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.

2 participants