Skip to content

Commit 193e216

Browse files
kmrozioj
authored andcommitted
ci: begin transition from circleci to gh actions and goreleaser
Build + test + vet all push/PR events. Pushing tags starting with 'v' will perform a draft release driven by GoReleaser. Fixes to allow vet to pass.
1 parent c551390 commit 193e216

File tree

5 files changed

+119
-92
lines changed

5 files changed

+119
-92
lines changed

.circleci/config.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/go.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: builder-releaser
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-test-vet-release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
-
15+
name: Checkout
16+
uses: actions/checkout@v2
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.16
22+
-
23+
name: Build
24+
run: go build -v ./...
25+
-
26+
name: Test
27+
run: go test -v ./...
28+
-
29+
name: Vet
30+
run: go vet -v ./...
31+
-
32+
if: startsWith(github.ref, 'refs/tags/v') == true
33+
name: Import GPG key
34+
id: import_gpg
35+
uses: crazy-max/ghaction-import-gpg@v3
36+
with:
37+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
39+
-
40+
if: startsWith(github.ref, 'refs/tags/v') == true
41+
name: GoReleaser
42+
uses: goreleaser/goreleaser-action@v2
43+
with:
44+
# either 'goreleaser' (default) or 'goreleaser-pro'
45+
distribution: goreleaser
46+
version: latest
47+
args: release --rm-dist
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
51+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.goreleaser.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
builds:
2+
# You can have multiple builds defined as a yaml list.
3+
-
4+
goos:
5+
- linux
6+
- freebsd
7+
- darwin
8+
- windows
9+
# GOARCH to build for.
10+
# For more info refer to: https://golang.org/doc/install/source#environment
11+
# Defaults are 386, amd64 and arm64.
12+
goarch:
13+
- amd64
14+
15+
nfpms:
16+
# note that this is an array of nfpm configs
17+
-
18+
# Replacements for GOOS and GOARCH in the package name.
19+
# Keys should be valid GOOSs or GOARCHs.
20+
# Values are the respective replacements.
21+
# Default is empty.
22+
replacements:
23+
amd64: 64-bit
24+
darwin: macOS
25+
vendor: alphasoc
26+
homepage: https://alphasoc.com/
27+
maintainer: AlphaSOC <[email protected]>
28+
description: A lightweight utility used to generate malicious network traffic and help
29+
security teams to evaluate security controls and network visibility.
30+
license: CCPL
31+
# Formats to be generated.
32+
formats:
33+
- deb
34+
- rpm
35+
- apk
36+
37+
release:
38+
# If set to auto, will mark the release as not ready for production
39+
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
40+
# If set to true, will mark the release as not ready for production.
41+
# Default is false.
42+
prerelease: auto
43+
# If set to true, will not auto-publish the release.
44+
# Default is false.
45+
draft: true
46+
# Header template for the release body.
47+
header: |
48+
## Flightsim Release - {{ time "2006-02-01" }}
49+
50+
Welcome to this new release!
51+
52+
# Footer template for the release body.
53+
footer: |
54+
## Enjoy!
55+
56+
Those were the changes on {{ .Tag }}!
57+
58+
# You can change the name of the release.
59+
# Default is `{{.Tag}}` on OSS and `{{.PrefixedTag}}` on Pro.
60+
name_template: "{{.ProjectName}}-v{{.Version}}"
61+
62+
# Sign all artifacts.
63+
signs:
64+
- artifacts: all

simulator/scan.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ func (s *PortScan) Simulate(ctx context.Context, dst string) error {
109109
// TODO: allow for multiple connection in parallel and hence a longer deadline
110110

111111
for _, port := range scanPorts {
112-
ctx, _ := context.WithTimeout(ctx, callTimeout)
112+
ctx, cancelFn := context.WithTimeout(ctx, callTimeout)
113+
defer cancelFn()
113114
err := s.tcp.Simulate(ctx, fmt.Sprintf("%s:%d", dst, port))
114115
if err != nil {
115116
return err

simulator/tunnel-dns.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (s *Tunnel) Simulate(ctx context.Context, host string) error {
5050

5151
label := strings.ToLower(utils.RandString(30))
5252

53-
ctx, _ := context.WithTimeout(ctx, 200*time.Millisecond)
53+
ctx, cancelFn := context.WithTimeout(ctx, 200*time.Millisecond)
54+
defer cancelFn()
5455
_, err := r.LookupTXT(ctx, fmt.Sprintf("%s.%s", label, host))
5556

5657
// ignore timeout and "no such host"
@@ -61,8 +62,6 @@ func (s *Tunnel) Simulate(ctx context.Context, host string) error {
6162
// wait until context expires so we don't flood
6263
<-ctx.Done()
6364
}
64-
65-
return nil
6665
}
6766

6867
// Hosts returns random generated hosts to alphasoc sandbox.

0 commit comments

Comments
 (0)