Skip to content

Commit

Permalink
Restructure files
Browse files Browse the repository at this point in the history
  • Loading branch information
MEhrn00 committed Aug 12, 2024
1 parent cb341ce commit 6c65277
Show file tree
Hide file tree
Showing 48 changed files with 833 additions and 75 deletions.
87 changes: 22 additions & 65 deletions Payload_Type/thanatos/Makefile
Original file line number Diff line number Diff line change
@@ -1,78 +1,35 @@
### Variable definitions ###
GO = go
GOFMT = gofmt
GOLINT = golangci-lint
PROTOC = protoc
GOMOD := github.com/MythicAgents/thanatos
GOFLAGS ?=

proto_outdir := proto
proto_srcdir := protobuf

### Protobuf sources ###
proto_srcs := \
config/config.proto \
msg/mythic.proto \
msg/checkin/checkin.proto \
msg/tasking/tasking.proto \
commands/exit.proto \
commands/sleep.proto \

proto_out := $(proto_srcs:%.proto=$(proto_outdir)/%.pb.go)
proto_mods := $(patsubst $(proto_srcdir)/%/,$(GOMOD)/$(proto_outdir)/%,$(dir $(proto_srcs:%=$(proto_srcdir)/%)))
proto_opts := $(join $(patsubst %,--go_opt=M%=,$(proto_srcs)),$(proto_mods))

### Invoked targets ###
.PHONY: all
all: server genconfig ## Build the 'server' and 'genconfig' targets

.PHONY: checkformat
checkformat: ## Check workspace code formatting
$(GOFMT) -l -d . | diff -u /dev/null -
all: mythic agent ## Build both the agent and mythic targets

.PHONY: ci
ci: checkformat lint test ## Run CI workflow
.PHONY: agent
agent: ## Build the Agent portion of the project
@$(MAKE) -C agent

.PHONY: coverage
coverage: ## Generate a code coverage report for tests
@mkdir -p coverage/html
$(GO) test -coverprofile coverage/tests.gocov
$(GO) tool cover -html coverage/tests.gocov -o coverage/html/index.html
.PHONY: mythic
mythic: ## Build the Mythic portion of the project
@$(MAKE) -C mythic

.PHONY: format
format: ## Format the workspace code
$(GOFMT) -w .
.PHONY: ci agent/ci mythic/ci
ci: mythic/ci agent/ci ## Run the CI targets for the Agent and Mythic code.

.PHONY: genconfig
genconfig: cmd/genconfig/main.go $(proto_out) ## Build the standalone configuration generator
$(GO) build $(GOFLAGS) -o $@ ./cmd/genconfig
mythic/ci:
@$(MAKE) -C mythic ci

.PHONY: lint
lint: $(proto_out) ## Lint the workspace code
$(GOLINT) run
agent/ci:
@$(MAKE) -C agent ci

.PHONY: protobuf
protobuf: $(proto_out) ## Build the protobuf files

.PHONY: server
server: $(proto_out) ## Build the Mythic server binary
$(GO) build $(GOFLAGS) -o $@ ./cmd/server

.PHONY: test
test: $(proto_out) ## Run tests
$(GO) test -v ./...
### Housekeeping targets ###
.PHONY: clean agent/clean mythic/clean
clean: agent/clean mythic/clean ## Clean built artifacts

### Helper targets ###
# Pattern rule protobuf files
$(proto_outdir)/%.pb.go: $(proto_srcdir)/%.proto
@mkdir -p $(dir $@)
$(PROTOC) -I$(proto_srcdir) --go_out=$(proto_outdir) --go_opt=paths=source_relative $(proto_opts) $<
mythic/clean:
@$(MAKE) -C mythic clean

### Housekeeping targets ###
.PHONY: clean
clean: ## Clean built artifacts
$(RM) -rv $(proto_outdir) server genconfig
agent/clean:
@$(MAKE) -C agent clean

.PHONY: help
help: ## Print this help output
help: ## Display this help menu
@echo -e "Top level Makefile for general housekeeping. All targets support parallelization with \`make -j\`.\n"
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-15s\033[0m- %s\n", $$1, $$2}'
1 change: 1 addition & 0 deletions Payload_Type/thanatos/mythic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
71 changes: 71 additions & 0 deletions Payload_Type/thanatos/mythic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
### Variable definitions ###
GO = go
GOFMT = gofmt
GOLINT = golangci-lint
GOFLAGS ?=

PROTOC = protoc
PROTO_OUT = pb
PROTO_SRC = ../protobuf

proto_pkgs := pkg/builder
proto_targets := $(addsuffix /pb,$(proto_pkgs))

### Invoked targets ###
.PHONY: all
all: server genconfig ## Build the 'server' and 'genconfig' targets. Supports parallelization

.PHONY: checkformat
checkformat: ## Check workspace code formatting
$(GOFMT) -l -d . | diff -u /dev/null -

.PHONY: ci
ci: checkformat lint test ## Run CI workflow. Supports parallelization

.PHONY: coverage
coverage: ## Generate a code coverage report for tests
@mkdir -p coverage/html
$(GO) test -coverprofile coverage/tests.gocov
$(GO) tool cover -html coverage/tests.gocov -o coverage/html/index.html

.PHONY: format
format: ## Format the workspace code
$(GOFMT) -w .

.PHONY: genconfig
genconfig: cmd/genconfig/main.go pkg/builder/pb ## Build the configuration generator cli
$(GO) build $(GOFLAGS) -o $@ ./cmd/genconfig

.PHONY: lint
lint: $(protobuf) ## Lint the workspace code
$(GOLINT) run

.PHONY: protobuf
protobuf: $(proto_targets) ## Build all protobuf files. Supports parallelization

.PHONY: server
server: cmd/server/main.go pkg/builder/pb ## Build the Mythic server binary
$(GO) build $(GOFLAGS) -o $@ ./cmd/server

.PHONY: test
test: $(protobuf) ## Run tests
$(GO) test -v ./...

### Helper targets ###
VPATH = $(PROTO_SRC)

# Pattern rule for building Golang protobuf files
$(PROTO_OUT)/%.pb.go: %.proto
@mkdir -p $(dir $@)
$(PROTOC) -I$(PROTO_SRC) --go_out=$(PROTO_OUT) --go_opt=paths=source_relative $<

### Housekeeping targets ###
.PHONY: clean
clean: ## Clean built artifacts
$(RM) -rv $(PROTO_OUT) server genconfig libgenconfig.a

.PHONY: help
help: ## Display this help menu
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-15s\033[0m- %s\n", $$1, $$2}'

include $(addsuffix /protobuf.mk,$(proto_pkgs))
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added Payload_Type/thanatos/mythic/genconfig
Binary file not shown.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6c65277

Please sign in to comment.