Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version of frontend #22

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
data
volumes
/front/node_modules
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg/proto/** linguist-vendored
front/src/proto/** linguist-vendored
19 changes: 9 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand All @@ -30,21 +30,21 @@ jobs:
make setup-release

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -57,7 +57,7 @@ jobs:

- name: Build and push full client image
id: docker_build_full
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
file: client_env/Dockerfile
Expand All @@ -72,7 +72,7 @@ jobs:

- name: Build and push light client image
id: docker_build_light
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
file: client_env/Dockerfile
Expand All @@ -87,7 +87,7 @@ jobs:

- name: Build and push sage client image
id: docker_build_sage
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
file: client_env/Dockerfile
Expand All @@ -99,4 +99,3 @@ jobs:
tags: |
ghcr.io/${{ steps.repo_name.outputs.lowercase }}/neo_env_sage:latest
ghcr.io/${{ steps.repo_name.outputs.lowercase }}/neo_env_sage:${{ steps.get_version.outputs.VERSION }}

42 changes: 32 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,69 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --config .golangci.yml

- name: Run tests
run: make test-cov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4

proto:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
with:
input: proto
config: proto/buf.yaml

front:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: 'front/package.json'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'front/.nvmrc'
cache: 'pnpm'
cache-dependency-path: 'front/pnpm-lock.yaml'

- name: Install deps
run: cd front && pnpm i --frozen-lockfile

- name: run linter
run: make lint-front

image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v2
uses: crazy-max/ghaction-github-runtime@v3

- name: Build && test client image
run: |
Expand Down
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
run:
timeout: 5m
tests: true
skip-dirs:
- pkg/apps/.*

linters:
enable:
Expand All @@ -13,7 +11,6 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- gocritic
- gofmt
- goimports
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ archives:
- cmd
- internal
- pkg
- proto/go
- monitoring
- front

- id: "client_env"
format: zip
Expand Down
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM golang:1.21-alpine as build
FROM golang:1.23-alpine as build

ENV CGO_ENABLED=0

WORKDIR /app
COPY go.* ./
COPY cmd cmd
COPY internal internal
COPY proto/go proto/go
COPY pkg pkg
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
Expand All @@ -15,8 +14,22 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o neo_server \
cmd/server/main.go

FROM node:20-slim AS front-base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

COPY front /app
WORKDIR /app

FROM front-base AS front-build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM alpine

COPY --from=build /app/neo_server /neo_server
WORKDIR /app
COPY --from=build /app/neo_server neo_server
COPY --from=front-build /app/dist front/dist

CMD ["/neo_server", "--config", "/config.yml"]
CMD ["./neo_server", "--config", "/config.yml"]
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ lint-go:
lint-proto:
cd proto && buf lint

.PHONY: lint-front
lint-front:
cd front && pnpm lint

.PHONY: lint
lint: lint-go lint-proto
lint: lint-go lint-proto lint-front

.PHONY: goimports
goimports:
gofancyimports fix --local github.com/c4t-but-s4d/neo -w $(shell find . -type f -name '*.go' -not -path "./proto/*")
gofancyimports fix --local github.com/c4t-but-s4d/neo/v2 -w $(shell find . -type f -name '*.go' -not -path "./pkg/proto/*")

.PHONY: test
test:
Expand All @@ -32,6 +36,7 @@ validate: lint test
.PHONY: proto
proto:
cd proto && buf generate
cd front && ./add_ts_ignore.sh

.PHONY: test-cov
test-cov:
Expand Down
24 changes: 14 additions & 10 deletions client_env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
FROM golang:1.21 as build
FROM golang:1.23-alpine AS build

ENV CGO_ENABLED=0

RUN apk add upx

WORKDIR /app
COPY go.* ./
COPY cmd cmd
COPY internal internal
COPY proto/go proto/go
COPY pkg pkg
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build \
-trimpath \
-ldflags="-s -w" \
-o client \
cmd/client/main.go

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
cmd/client/main.go && \
go build \
-trimpath \
-ldflags="-s -w" \
-o reaper \
cmd/reaper/main.go
cmd/reaper/main.go && \
upx --lzma -9 client && \
upx --lzma -9 reaper

FROM ubuntu:24.04 AS image-full

FROM ubuntu:jammy as image-full
ENV PIP_BREAK_SYSTEM_PACKAGES=1

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down Expand Up @@ -67,15 +71,15 @@ RUN chmod +x /entrypoint.sh
WORKDIR /work
ENTRYPOINT ["/entrypoint.sh"]

FROM image-full as image-full-sage
FROM image-full AS image-full-sage

RUN --mount=type=cache,sharing=private,target=/var/cache/apt \
apt-get update && \
apt-get install -y \
sagemath && \
rm -rf /var/lib/apt/lists/*

FROM alpine:3.16 as image-light
FROM alpine:3.20 AS image-light

RUN apk add bash dbus

Expand Down
2 changes: 1 addition & 1 deletion cmd/client/cli/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/c4t-but-s4d/neo/v2/internal/client"
"github.com/c4t-but-s4d/neo/v2/pkg/archive"
epb "github.com/c4t-but-s4d/neo/v2/proto/go/exploits"
epb "github.com/c4t-but-s4d/neo/v2/pkg/proto/exploits"
)

type addCLI struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/client/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const JobsPerCPU = 5
type runCLI struct {
*baseCLI
run *exploit.Runner
sender *joblogger.RemoteSender
sender joblogger.Sender
}

func parseJobsFlag(cmd *cobra.Command, name string) int {
Expand Down
2 changes: 1 addition & 1 deletion cmd/client/cli/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra"

"github.com/c4t-but-s4d/neo/v2/internal/client"
logspb "github.com/c4t-but-s4d/neo/v2/proto/go/logs"
logspb "github.com/c4t-but-s4d/neo/v2/pkg/proto/logs"
)

type tailCLI struct {
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/cli/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"google.golang.org/protobuf/types/known/durationpb"

"github.com/c4t-but-s4d/neo/v2/internal/client"

epb "github.com/c4t-but-s4d/neo/v2/proto/go/exploits"
epb "github.com/c4t-but-s4d/neo/v2/pkg/proto/exploits"
)

type updateCLI struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/samber/lo"

"github.com/c4t-but-s4d/neo/v2/proto/go/exploits"
"github.com/c4t-but-s4d/neo/v2/pkg/proto/exploits"
)

func isBinary(data []byte) bool {
Expand Down
2 changes: 0 additions & 2 deletions cmd/client/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ func init() {
rootCmd.PersistentFlags().StringP("config", "c", "client_config.yml", "config file")
rootCmd.PersistentFlags().BoolP("verbose", "v", true, "enable debug logging")
rootCmd.PersistentFlags().String("host", "127.0.0.1:5005", "server host")
rootCmd.PersistentFlags().String("metrics_host", "127.0.0.1:9091", "pushgateway host")

mustBindPersistent(rootCmd, "config")
mustBindPersistent(rootCmd, "host")
mustBindPersistent(rootCmd, "verbose")
mustBindPersistent(rootCmd, "metrics_host")
}

func mustBindPersistent(c *cobra.Command, flag string) {
Expand Down
Loading
Loading