Skip to content

Commit

Permalink
feat: preparing for 0.2.0 release of hcltm - now threatcl
Browse files Browse the repository at this point in the history
  • Loading branch information
xntrik committed Mar 4, 2024
1 parent 7837796 commit 338beb3
Show file tree
Hide file tree
Showing 98 changed files with 153 additions and 5,154 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/docker-build-test.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/snyk-container-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build a Docker image
run: docker build -t xntrik/hcltm-snyk .
run: docker build -t xntrik/threatcl-snyk .
- name: Run Snyk to check Docker image for vulnerabilities
# Snyk can be used to break the build when it detects vulnerabilities.
# In this case we want to upload the issues to GitHub Code Scanning
Expand All @@ -41,7 +41,7 @@ jobs:
# or you can signup for free at https://snyk.io/login
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: xntrik/hcltm-snyk
image: xntrik/threatcl-snyk
args: --file=Dockerfile
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: hcltm pre-release
name: threatcl pre-release

on:
push:
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Test
Expand All @@ -31,7 +31,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: linux-pkg
path: out/hcltm-linux-amd64.tar.gz
path: out/threatcl-linux-amd64.tar.gz

pre-release-osx:
runs-on: macos-latest
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Package
Expand All @@ -50,7 +50,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: osx-pkg
path: out/hcltm-darwin-amd64.tar.gz
path: out/threatcl-darwin-amd64.tar.gz

pre-release:
runs-on: ubuntu-latest
Expand All @@ -72,8 +72,8 @@ jobs:
prerelease: true
title: "Development Build"
files: |
hcltm-linux-amd64.tar.gz
hcltm-darwin-amd64.tar.gz
threatcl-linux-amd64.tar.gz
threatcl-darwin-amd64.tar.gz
- name: Remove artifacts
uses: geekyeggo/delete-artifact@v1
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: hcltm release
name: threatcl release

on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Test
Expand All @@ -29,7 +29,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: linux-pkg
path: out/hcltm-linux-amd64.tar.gz
path: out/threatcl-linux-amd64.tar.gz

pre-release-osx:
runs-on: macos-latest
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Package
Expand All @@ -48,7 +48,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: osx-pkg
path: out/hcltm-darwin-amd64.tar.gz
path: out/threatcl-darwin-amd64.tar.gz

release:
runs-on: ubuntu-latest
Expand All @@ -69,8 +69,8 @@ jobs:
prerelease: false
title: "Release"
files: |
hcltm-linux-amd64.tar.gz
hcltm-darwin-amd64.tar.gz
threatcl-linux-amd64.tar.gz
threatcl-darwin-amd64.tar.gz
- name: Remove artifacts
uses: geekyeggo/delete-artifact@v1
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: hcltm testvet
name: threatcl testvet

on: [push, pull_request]

Expand All @@ -11,7 +11,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Vet
run: make vet
- name: Test
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.2-alpine3.17 AS builder
FROM golang:1.22.0-alpine3.19 AS builder
MAINTAINER Christian Frichot <xntrik@gmail.com>

RUN apk update
Expand All @@ -7,9 +7,9 @@ RUN apk add --update git gcc libc-dev libgcc make
WORKDIR /src
COPY . .
ENV CGO_ENABLED=1
RUN go build -o hcltm ./cmd/hcltm
RUN go build -o threatcl ./cmd/threatcl

FROM alpine:3.17 AS hcltm
FROM alpine:3.19 AS threatcl
WORKDIR /app
COPY --from=builder /src/hcltm /bin/hcltm
ENTRYPOINT ["/bin/hcltm"]
COPY --from=builder /src/threatcl /bin/threatcl
ENTRYPOINT ["/bin/threatcl"]
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GO_CMD?=go
BINNAME=hcltm
DOCKERNAME=xntrik/hcltm
BINNAME=threatcl
DOCKERNAME=xntrik/threatcl
DOCKERPLATFORM="linux/amd64,linux/arm64"
GOPATH?=$$($(GO_CMD) env GOPATH)
EXTERNAL_TOOLS=\
Expand Down Expand Up @@ -28,36 +28,36 @@ ifndef TAG
$(error TAG is undefined)
endif

dev: ## Build hcltm and copy to your GOPATH/bin
$(GO_CMD) build -o ${BINNAME} ./cmd/hcltm
build: ## Build threatcl and copy to your GOPATH/bin
$(GO_CMD) build -o ${BINNAME} ./cmd/threatcl

pkg-linux: ## Build packages with gox on linux
gox \
-osarch=${LINUX_PKG_TARGETS} \
-output="out/{{.OS}}_{{.Arch}}/${BINNAME}" \
-gocmd=${GO_CMD} \
-cgo \
./cmd/hcltm
cd out/linux_amd64 && tar -zcvf ../hcltm-linux-amd64.tar.gz hcltm
./cmd/threatcl
cd out/linux_amd64 && tar -zcvf ../threatcl-linux-amd64.tar.gz threatcl

pkg-osx: ## Build packages with gox
gox \
-osarch=${MACOS_PKG_TARGETS} \
-output="out/{{.OS}}_{{.Arch}}/${BINNAME}" \
-gocmd=${GO_CMD} \
./cmd/hcltm
cd out/darwin_amd64 && tar -zcvf ../hcltm-darwin-amd64.tar.gz hcltm
./cmd/threatcl
cd out/darwin_amd64 && tar -zcvf ../threatcl-darwin-amd64.tar.gz threatcl

fmt: ## Checks go formatting
goimports -w $(GOFMT_FILES)

install: ## Pretty similar to dev
$(GO_CMD) install ./cmd/hcltm
$(GO_CMD) install ./cmd/threatcl

bootstrap: ## Install build dependencies
@for tool in $(EXTERNAL_TOOLS) ; do \
echo "Installing/Updating $$tool" ; \
GO111MODULE=off $(GO_CMD) get -u $$tool; \
$(GO_CMD) get -u $$tool; \
done

vet: ## Run go vet
Expand All @@ -74,4 +74,4 @@ testcover: ## Run go test and go tool cover
help: ## Output make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: dev help image imagepush pkg-linux pkg-osx fmg install bootstrap vet test testvet testcover check-tag-env check-ver-env
.PHONY: build help image imagepush pkg-linux pkg-osx fmg install bootstrap vet test testvet testcover check-tag-env check-ver-env
12 changes: 6 additions & 6 deletions cmd/hcltm/dashboard.go → cmd/threatcl/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/xntrik/hcltm/pkg/spec"
"github.com/threatcl/spec"
)

type tmListEntryType struct {
Expand All @@ -25,7 +25,7 @@ type tmListEntryType struct {
HasDfd string
}

// DashboardCommand struct defines the "hcltm dashboard" commands
// DashboardCommand struct defines the "threatcl dashboard" commands
type DashboardCommand struct {
*GlobalCmdOptions
specCfg *spec.ThreatmodelSpecConfig
Expand All @@ -39,10 +39,10 @@ type DashboardCommand struct {
flagDashboardHTML bool
}

// Help is the help output for "hcltm dashboard"
// Help is the help output for "threatcl dashboard"
func (c *DashboardCommand) Help() string {
helpText := `
Usage: hcltm dashboard [options] -outdir=<directory> <files>
Usage: threatcl dashboard [options] -outdir=<directory> <files>
Generate markdown files from existing Threat model HCL files (as specified
by <files>)
Expand Down Expand Up @@ -75,7 +75,7 @@ Options:
return strings.TrimSpace(helpText)
}

// Run executes "hcltm dashboard" logic
// Run executes "threatcl dashboard" logic
func (c *DashboardCommand) Run(args []string) int {

flagSet := c.GetFlagset("dashboard")
Expand Down Expand Up @@ -375,7 +375,7 @@ func unixToTime(unixtime int64) string {
return utime.Format("2006-01-02")
}

// Synopsis returns the synopsis for the "hcltm dashboard" command
// Synopsis returns the synopsis for the "threatcl dashboard" command
func (c *DashboardCommand) Synopsis() string {
return "Generate markdown files from existing HCL threatmodel file(s)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"
"testing"

"github.com/xntrik/hcltm/pkg/spec"
"github.com/threatcl/spec"

"github.com/kami-zh/go-capturer"
"github.com/zenizh/go-capturer"
)

func testDashboardCommand(tb testing.TB) *DashboardCommand {
Expand Down Expand Up @@ -75,8 +75,8 @@ func TestDashboardMissingfiles(t *testing.T) {
t.Errorf("Code did not equal 1: %d", code)
}

if !strings.Contains(out, "Usage: hcltm dashboard") {
t.Errorf("Expected %s to contain %s", out, "Usage: hcltm dashboard")
if !strings.Contains(out, "Usage: threatcl dashboard") {
t.Errorf("Expected %s to contain %s", out, "Usage: threatcl dashboard")
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/hcltm/dfd.go → cmd/threatcl/dfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"strings"

"github.com/xntrik/hcltm/pkg/spec"
"github.com/threatcl/spec"
)

type DfdCommand struct {
Expand All @@ -21,7 +21,7 @@ type DfdCommand struct {

func (c *DfdCommand) Help() string {
helpText := `
Usage: hcltm dfd [options] -outdir=<directory> <files>
Usage: threatcl dfd [options] -outdir=<directory> <files>
Generate Data Flow Diagram PNG or DOT files from existing Threat model HCL files
(as specified by <files>)
Expand Down
4 changes: 2 additions & 2 deletions cmd/hcltm/dfd_test.go → cmd/threatcl/dfd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"
"testing"

"github.com/xntrik/hcltm/pkg/spec"
"github.com/threatcl/spec"

"github.com/kami-zh/go-capturer"
"github.com/zenizh/go-capturer"
)

func testDfdCommand(tb testing.TB) *DfdCommand {
Expand Down

0 comments on commit 338beb3

Please sign in to comment.