-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
833 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 not shown.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.