Skip to content

Commit

Permalink
Merge pull request #5 from RicYaben/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
RicYaben authored Jan 15, 2023
2 parents d3830e7 + 2533690 commit 1221525
Show file tree
Hide file tree
Showing 35 changed files with 254 additions and 812 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: nightly
tag_name: nightly
files: artifacts/riotpot.zip
prerelease: true
19 changes: 3 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Production binary folder
bin/

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

Expand All @@ -22,16 +12,13 @@ bin/
.vscode/
.DS_Store
.dccache
.iac-data
## VSCode workspace file
workspace*.code-*

# Vendor folder
# Transit folders
/vendor/

# Plugins
*.so

# TCPdump
/bin/
/tcpdump/

# whatever the rules are, include all the `.md` files
Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ SHELL := /bin/bash
APPNAME=riotpot
DOCKER=build/docker/
PLUGINS_DIR=pkg/plugin
EXCLUDE_PLUGINS= sshd

##
exclude_plugins_list := $(subst ., ,$(EXCLUDE_PLUGINS))
EXCLUDE_PLUGINS= modbusd coapd mqttd

# docker cmd below
.PHONY: docker-build-doc docker-doc-up up down up-all build build-plugins build-all ui
Expand All @@ -23,9 +20,9 @@ up-all:
riotpot-doc
riotpot-up
build:
go build -gcflags='all=-N -l' -o ./bin/ ./cmd/riotpot/.
@go build -gcflags='all=-N -l' -o ./bin/ ./cmd/riotpot/.
build-plugins: $(PLUGINS_DIR)/*
exclude=${exclude_plugins_list}; \
@IFS=' ' read -r -a exclude <<< "${EXCLUDE_PLUGINS}"; \
for folder in $^ ; do \
result=$${folder%%+(/)}; \
result=$${result##*/}; \
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ It is important to keep the internal folder structure for RIoTPot to work as int
1. First, download the release of your choice from the [releases](https://github.com/aau-network-security/riotpot/releases) page. Choose the one you need for your Operative System (OS).
2. Extact the `riotpot` folder.
3. Run the `riotpot` binary. This will start RIoTPot with the API enabled, all the plugins ready to use, and the UI server.
- The UI is accessible through the address `localhost:3000` or `local.riotpot.ui`
- The API is accessible through the address `localhost:2022/api/swagger` or `local.riotpot.hp/api/swagger`
- The UI is accessible through the address `localhost:3000`
- The API is accessible through the address `localhost:2022/api/swagger`

</details>

Expand Down Expand Up @@ -254,4 +254,7 @@ The container can be setup in three simple steps:
docker-compose -p riotpot -f build/docker/docker-compose.yaml up -d --build
```

> **_Info:_** Using Docker has it's own perks, such as minglin with the DNS without touching your local files.
> You can now reach the API at `http://riotpot.hp:2022/api/swagger` and the ui at `http://riotpot.ui:3000`
</details>
4 changes: 3 additions & 1 deletion build/docker/Dockerfile → build/docker/Dockerfile.riotpot
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ WORKDIR /riotpot

# Copy the dependencies into the image
COPY --from=builder /riotpot/bin/ ./

# API, required for the UI.
EXPOSE 2022

ENTRYPOINT ["./riotpot"]
CMD ["./riotpot"]
33 changes: 0 additions & 33 deletions build/docker/docker-compose.test.yaml

This file was deleted.

14 changes: 7 additions & 7 deletions build/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
container_name: tcpdump
network_mode: "host"
volumes:
- ../tcpdump:/tcpdump
- ../../tcpdump:/tcpdump
# Run tcdump in autorotating mode, with gzip compression
# The files will be rotated every 24h or 500MB and named
# after the timestamp when the file is created.
Expand All @@ -46,23 +46,23 @@ services:
container_name: riotpot
build:
context: ../..
dockerfile: ./build/docker/Dockerfile
dockerfile: ./build/docker/Dockerfile.riotpot
restart: always # restart riotpot when it crashes
ports:
# Ports under 60 might see errors when unquoted
# https://stackoverflow.com/questions/58810789/quotes-on-docker-compose-yml-ports-make-any-difference
- "7:7"
# - "22:22"
- "22:22"
- "23:23"
# - "80:80"
- "80:80"
- "502:502"
- "1883:1883"
- "2022:2022" # API, Required for the UI
- "2022:2022" # Required for the REST API
- "27017:27017"
- "5683:5683"
- "8080:8080"
env_file:
- ../../build/env/.env
environment:
- API_HOST=0.0.0.0
networks:
honeypot:
default:
Expand Down
40 changes: 0 additions & 40 deletions build/env/.env

This file was deleted.

26 changes: 15 additions & 11 deletions cmd/riotpot/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"flag"
"fmt"
"strings"
"time"

"github.com/gin-contrib/cors"
Expand All @@ -17,7 +18,7 @@ import (
"github.com/riotpot/api/service"
"github.com/riotpot/internal/globals"
"github.com/riotpot/internal/logger"
"github.com/riotpot/pkg"
"github.com/riotpot/internal/plugins"
"github.com/rs/zerolog"

_ "github.com/riotpot/statik"
Expand All @@ -36,12 +37,13 @@ var (
)

var (
debug = flag.Bool("debug", true, "Set log level to debug")
runApi = flag.Bool("api", true, "Whether to start the API")
plugins = flag.Bool("plugins", true, "Whether to load the low-interaction honeypot plugins")
debug = flag.Bool("debug", true, "Set log level to debug")
runApi = flag.Bool("api", true, "Whether to start the API")
loadPlugins = flag.Bool("plugins", true, "Whether to load the low-interaction honeypot plugins")
allowedHosts = flag.String("whitelist", "http://127.0.0.1,http://localhost:3000", "List of allowed hosts to contact the API")
)

func setupApi() *gin.Engine {
func setupApi(allowedHosts []string) *gin.Engine {
// Create a router
router := gin.Default()

Expand All @@ -50,7 +52,7 @@ func setupApi() *gin.Engine {
// - Credentials share
// - Preflight requests cached for 12 hours
router.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:3000", "http://127.0.0.1", "http://0.0.0.0"}, // TODO: Change this to wherever the front-end is located!
AllowOrigins: allowedHosts,
AllowMethods: []string{"OPTIONS", "PUT", "PATCH", "GET", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Type"},
ExposeHeaders: []string{"Content-Length"},
Expand All @@ -71,7 +73,6 @@ func setupApi() *gin.Engine {
}

// Serve the Swagger UI files in the root of the api
// TODO: [7/24/2022] Use Pakr or Statik to bundle non-golang files into the binary
root.StaticFS("swagger", statikFS)

return router
Expand All @@ -84,14 +85,17 @@ func ParseFlags() {
}

// Load the plugins
if *plugins {
pkg.LoadPlugins()
if *loadPlugins {
plugins.LoadPlugins()
}

// Starts the API
if *runApi {
// Serve the API
api := setupApi()
api.Run(fmt.Sprintf("%s:%s", globals.ApiHost, globals.ApiPort))
whitelist := strings.Split(*allowedHosts, ",")
api := setupApi(whitelist)

apiAddress := fmt.Sprintf("%s:%s", globals.ApiHost, globals.ApiPort)
api.Run(apiAddress)
}
}
30 changes: 0 additions & 30 deletions configs/configuration.yml

This file was deleted.

File renamed without changes.
33 changes: 12 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,44 @@ require (
github.com/stretchr/testify v1.8.1
github.com/traetox/pty v0.0.0-20141209045113-df6c8cd2e0e6
github.com/xiegeo/modbusone v1.0.1
go.mongodb.org/mongo-driver v1.11.0
golang.org/x/crypto v0.1.0
golang.org/x/crypto v0.5.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/golib/memfile v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pion/dtls/v2 v2.1.5 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/udp v0.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
golang.org/x/text v0.4.0 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
github.com/gin-gonic/gin v1.8.1
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/gin-gonic/gin v1.8.2
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/pion/transport v0.13.1 // indirect
github.com/pion/transport v0.14.1 // indirect
github.com/rakyll/statik v0.1.7
github.com/rs/zerolog v1.28.0
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/exp v0.0.0-20221106115401-f9659909a136
golang.org/x/net v0.1.0 // indirect
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a
golang.org/x/net v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/sys v0.4.0 // indirect
)
Loading

0 comments on commit 1221525

Please sign in to comment.