Skip to content

Refactor MonkeyDownload resource #1974

@mssalvatore

Description

@mssalvatore

Refactor

Component(s) to be refactored

  • monkey_island.cc.resources.monkey_download.MonkeyDownload

Explanation

There's too much business logic in the MonkeyDownload resource. Additionally, it's not defined according to our REST guidelines. The resource should simply retrieve the binaries from a repository with a simple interface.

Tasks

  • Rename MonkeyDownload to have a proper collection resource name like AgentBinaries (0d) - @shreyamalviya
  • Change the URL for the AgentBinaries resource to be consistent with our REST guidelines (/api/agent-binaries/<string:os/>) (0d) - @shreyamalviya
    • Modify Island
    • Modify Agent
    • Test
  • Export AgentBinaries from the resources package (0d) @ilija-lazoroski
    • Edit app.py to use the shorter import
  • Create an IAgentBinaryRepository that allows the caller to get the Linux or Windows binary. It should have functions like get_linux_binary() -> typing.BinaryIO. (0d)
  • Construct a concrete AgentBinaryRepository that utilizes an IFileRepository. (0d) @ilija-lazoroski
    • Construct an LocalStorageFileRepository just for the AgentBinaryRepository to use. Do not add the LocalStorageFileRepository to the DI container
    • Construct the AgentBinaryRepository with theLocalStorageFileRepository in the composition root.
    • Add the AgentBinaryRepository to the DI container
  • Log the executible hashes when the AgentBinaryRepository is constructed. This should be done when the system is initialized, not the resource or repository. (0d) @ilija-lazoroski
  • Refactor the AgentBinaries resource to use the concrete AgentBinaryRepository (0d) @ilija-lazoroski

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions