Skip to content

Module Metadata Fields Arch and Platform Should be Automatic #20603

@smcintyre-r7

Description

@smcintyre-r7

Summary

We see a lot of code that follows the following pattern where one or more targets are defined:

        'Platform' => ['unix', 'linux'],
        'Arch' => [ARCH_CMD],
        'Targets' => [
          [
            'Unix Command',
            {
              'Platform' => ['unix', 'linux'],
              'Arch' => ARCH_CMD,
              'Type' => :unix_cmd,
              'DefaultOptions' => {
                # In the Docker container from the official repository, only curl is available
                'FETCH_COMMAND' => 'CURL'
              }
              # Tested with cmd/unix/reverse_bash
              # Tested with cmd/linux/http/x64/meterpreter/reverse_tcp
            }
          ]
        ],

In the case where one or more targets are defined, the high-level Platform and Arch keys should be a unique set of the sum of all of the targets. This would make it unnecessary for the module author to need to define it themselves and ensure that it is sync'ed automatically in the event that additional targets are added.

If no targets are defined, then the Platform and Arch keys should be left as-is.

Basic example

Motivation

We're doing this because we consistently leave feedback to module contributors to reduce the redundant code within their modules. Completing this task will make it easier for new authors to contribute module content that accurately reflects the Platform and Arch metadata.

To Do

We should also consider an implementation where additional keys at the top level are merged down and allowed to be overridden in the target definition. Additionally, we should check if additional top level keys (other than Platform and `Arch) should be calculated automatically when omitted.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions