mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
a90c3974bd | |||
c9fe11c371 | |||
0639c347df | |||
6c9f6dd477 | |||
b05a44a3c5 | |||
5fbe6c0211 | |||
09d955711d | |||
f191f7d307 | |||
4f2c84fc60 | |||
5ba0987527 | |||
b09a1e908b | |||
a7c69c8849 | |||
7d46c9544c | |||
10d16d7dd1 | |||
48489e0abb | |||
ca51e076b6 | |||
9025edee1e | |||
853708a598 | |||
8d9f1b48da | |||
9d0a92e74e | |||
49a4022f56 | |||
fe6d95ecd6 | |||
d24a580a78 | |||
9a354add6f | |||
3652af6dc3 | |||
5532d3c629 | |||
97ab2f6e95 | |||
f50f5185df | |||
5a70e5c900 | |||
142dccabf1 | |||
8337281f21 | |||
1c402141bf | |||
9c9fd0b676 | |||
97cfdcc8af | |||
c7c169c96d | |||
f733a0ea96 | |||
31a75cc128 | |||
fd7db83fd8 | |||
1b01933946 | |||
6548cf62ce | |||
6468b5aa6f | |||
bbcc8c9094 | |||
6ff99e4eed | |||
0ebb6fa1e2 | |||
6f9781f06f | |||
e4ca84589b | |||
31f5ca9cb1 | |||
c6855e8511 | |||
6d2500d0f5 | |||
c98b888985 | |||
d062435818 | |||
9ddb076621 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -1 +1 @@
|
|||||||
patreon: mariocandela
|
custom: ["https://www.paypal.com/donate/?business=P75FH5LXKQTAC&no_recurring=0¤cy_code=EUR"]
|
||||||
|
37
.github/workflows/ci.yml
vendored
37
.github/workflows/ci.yml
vendored
@ -8,7 +8,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build:
|
CI:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -16,9 +16,9 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.20.0
|
||||||
|
|
||||||
- name: Dependences
|
- name: Dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Vet
|
- name: Vet
|
||||||
@ -30,17 +30,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: |
|
run: |
|
||||||
go test ./... -coverprofile coverage.tmp.out -covermode count
|
go test ./... -v -coverprofile coverage.tmp.out -covermode count
|
||||||
go tool cover -func coverage.tmp.out
|
go tool cover -func coverage.tmp.out
|
||||||
|
|
||||||
- name: Quality Gate - Test coverage shall be above threshold
|
- name: Quality Gate - Test coverage shall be above threshold
|
||||||
env:
|
env:
|
||||||
TESTCOVERAGE_THRESHOLD: 70
|
TESTCOVERAGE_THRESHOLD: 65
|
||||||
run: |
|
run: |
|
||||||
echo "Quality Gate: checking test coverage is above threshold ..."
|
echo "Quality Gate: checking test coverage is above threshold ..."
|
||||||
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
|
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
|
||||||
# Excluded the concrete strategy from the coverage calculation, this will be tested in the integration tests
|
# Excluded the concrete strategy from the unit test coverage, because covered by integration tests
|
||||||
cat coverage.tmp.out | grep -v "secureShellStrategy.go" | grep -v "hypertextTransferProtocolStrategy.go" | grep -v "transmissionControlProtocolStrategy.go" > coverage.out
|
cat coverage.tmp.out | grep -v "ssh.go" | grep -v "http.go" | grep -v "tcp.go" > coverage.out
|
||||||
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
|
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
|
||||||
echo "Current test coverage : $totalCoverage %"
|
echo "Current test coverage : $totalCoverage %"
|
||||||
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
|
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
|
||||||
@ -50,3 +50,26 @@ jobs:
|
|||||||
echo "Failed"
|
echo "Failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Start integration test dependencies
|
||||||
|
run: |
|
||||||
|
make test.dependencies.start
|
||||||
|
|
||||||
|
- name: Wait for RabbitMQ to be ready
|
||||||
|
run: |
|
||||||
|
sleep 2
|
||||||
|
count=0
|
||||||
|
until docker exec rabbitmq rabbitmqctl list_queues > /dev/null 2>&1; do
|
||||||
|
count=$((count+1))
|
||||||
|
if [ $count -gt 10 ]; then
|
||||||
|
echo "RabbitMQ did not start within the specified time"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting for RabbitMQ to start..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Integration tests
|
||||||
|
run: |
|
||||||
|
make test.integration.verbose
|
||||||
|
make test.dependencies.down
|
||||||
|
40
.github/workflows/codeql.yml
vendored
Normal file
40
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
schedule:
|
||||||
|
- cron: '36 10 * * 0'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'go' ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
|
||||||
|
- name: Build beelzebub
|
||||||
|
run: go build ./...
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
||||||
|
with:
|
||||||
|
category: "/language:${{matrix.language}}"
|
37
.github/workflows/docker-image.yml
vendored
37
.github/workflows/docker-image.yml
vendored
@ -6,21 +6,26 @@ on:
|
|||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
CD:
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
-
|
||||||
- name: Docker login
|
name: Checkout
|
||||||
env:
|
uses: actions/checkout@v3
|
||||||
DOCKER_USER: ${{secrets.DOCKER_USER}}
|
-
|
||||||
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
|
name: Login to Docker Hub
|
||||||
run: |
|
uses: docker/login-action@v2
|
||||||
docker login -u $DOCKER_USER -p $DOCKER_ACCESS_TOKEN
|
with:
|
||||||
- name: Build the Docker image
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
run: docker build . --file Dockerfile --tag m4r10/beelzebub:${{ github.ref_name }}
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
-
|
||||||
- name: Docker Push
|
name: Set up Docker Buildx
|
||||||
run: docker push m4r10/beelzebub:${{ github.ref_name }}
|
uses: docker/setup-buildx-action@v2
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: m4r10/beelzebub:${{ github.ref_name }}
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
logs
|
logs
|
||||||
|
.vscode
|
||||||
|
.history
|
@ -29,6 +29,8 @@ RUN cp /build/main .
|
|||||||
# Build a small image
|
# Build a small image
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
|
# copy the ca-certificate.crt from the builder stage
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
COPY --from=builder /dist/main /
|
COPY --from=builder /dist/main /
|
||||||
|
|
||||||
ENTRYPOINT ["/main"]
|
ENTRYPOINT ["/main"]
|
38
Makefile
Normal file
38
Makefile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
DOCKER_COMPOSE := $(shell which docker-compose)
|
||||||
|
|
||||||
|
ifeq (${DOCKER_COMPOSE},)
|
||||||
|
DOCKER_COMPOSE = docker compose
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: beelzebub.start
|
||||||
|
beelzebub.start:
|
||||||
|
${DOCKER_COMPOSE} build;
|
||||||
|
${DOCKER_COMPOSE} up -d;
|
||||||
|
|
||||||
|
.PHONY: beelzebub.stop
|
||||||
|
beelzebub.stop:
|
||||||
|
${DOCKER_COMPOSE} down;
|
||||||
|
|
||||||
|
.PHONY: test.unit
|
||||||
|
test.unit:
|
||||||
|
go test ./...
|
||||||
|
|
||||||
|
.PHONY: test.unit.verbose
|
||||||
|
test.unit.verbose:
|
||||||
|
go test ./... -v
|
||||||
|
|
||||||
|
.PHONY: test.dependencies.start
|
||||||
|
test.dependencies.start:
|
||||||
|
${DOCKER_COMPOSE} -f ./integration_test/docker-compose.yml up -d
|
||||||
|
|
||||||
|
.PHONY: test.dependencies.down
|
||||||
|
test.dependencies.down:
|
||||||
|
${DOCKER_COMPOSE} -f ./integration_test/docker-compose.yml down
|
||||||
|
|
||||||
|
.PHONY: test.integration
|
||||||
|
test.integration:
|
||||||
|
INTEGRATION=1 go test ./...
|
||||||
|
|
||||||
|
.PHONY: test.integration.verbose
|
||||||
|
test.integration.verbose:
|
||||||
|
INTEGRATION=1 go test ./... -v
|
13
SECURITY.md
Normal file
13
SECURITY.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| >= 2.0.0 | :white_check_mark: |
|
||||||
|
| < 2.0.0 | :x: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Please report (suspected) security vulnerabilities to mario.candela.personal@gmail.com.
|
||||||
|
You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
|
@ -3,19 +3,24 @@ package builder
|
|||||||
import (
|
import (
|
||||||
"beelzebub/parser"
|
"beelzebub/parser"
|
||||||
"beelzebub/protocols"
|
"beelzebub/protocols"
|
||||||
|
"beelzebub/protocols/strategies"
|
||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const RabbitmqQueueName = "event"
|
const RabbitmqQueueName = "event"
|
||||||
|
|
||||||
type Builder struct {
|
type Builder struct {
|
||||||
beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration
|
beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration
|
||||||
|
beelzebubCoreConfigurations *parser.BeelzebubCoreConfigurations
|
||||||
traceStrategy tracer.Strategy
|
traceStrategy tracer.Strategy
|
||||||
rabbitMQChannel *amqp.Channel
|
rabbitMQChannel *amqp.Channel
|
||||||
rabbitMQConnection *amqp.Connection
|
rabbitMQConnection *amqp.Connection
|
||||||
@ -44,7 +49,7 @@ func (b *Builder) buildLogger(configurations parser.Logging) error {
|
|||||||
log.SetLevel(log.InfoLevel)
|
log.SetLevel(log.InfoLevel)
|
||||||
}
|
}
|
||||||
b.logsFile = logsFile
|
b.logsFile = logsFile
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Builder) buildRabbitMQ(rabbitMQURI string) error {
|
func (b *Builder) buildRabbitMQ(rabbitMQURI string) error {
|
||||||
@ -68,24 +73,33 @@ func (b *Builder) buildRabbitMQ(rabbitMQURI string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Builder) Close() error {
|
func (b *Builder) Close() error {
|
||||||
|
if b.rabbitMQConnection != nil {
|
||||||
if err := b.rabbitMQChannel.Close(); err != nil {
|
if err := b.rabbitMQChannel.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := b.rabbitMQConnection.Close(); err != nil {
|
if err := b.rabbitMQConnection.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := b.logsFile.Close(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Builder) Run() error {
|
func (b *Builder) Run() error {
|
||||||
|
// Init Prometheus openmetrics
|
||||||
|
go func() {
|
||||||
|
if (b.beelzebubCoreConfigurations.Core.Prometheus != parser.Prometheus{}) {
|
||||||
|
http.Handle(b.beelzebubCoreConfigurations.Core.Prometheus.Path, promhttp.Handler())
|
||||||
|
|
||||||
|
if err := http.ListenAndServe(b.beelzebubCoreConfigurations.Core.Prometheus.Port, nil); err != nil {
|
||||||
|
log.Fatalf("Error init Prometheus: %s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Init Protocol strategies
|
// Init Protocol strategies
|
||||||
secureShellStrategy := &protocols.SecureShellStrategy{}
|
secureShellStrategy := &strategies.SSHStrategy{}
|
||||||
hypertextTransferProtocolStrategy := &protocols.HypertextTransferProtocolStrategy{}
|
hypertextTransferProtocolStrategy := &strategies.HTTPStrategy{}
|
||||||
transmissionControlProtocolStrategy := &protocols.TransmissionControlProtocolStrategy{}
|
transmissionControlProtocolStrategy := &strategies.TCPStrategy{}
|
||||||
|
|
||||||
// Init Tracer strategies, and set the trace strategy default HTTP
|
// Init Tracer strategies, and set the trace strategy default HTTP
|
||||||
protocolManager := protocols.InitProtocolManager(b.traceStrategy, hypertextTransferProtocolStrategy)
|
protocolManager := protocols.InitProtocolManager(b.traceStrategy, hypertextTransferProtocolStrategy)
|
||||||
@ -110,6 +124,7 @@ func (b *Builder) Run() error {
|
|||||||
return errors.New(fmt.Sprintf("Error during init protocol: %s, %s", beelzebubServiceConfiguration.Protocol, err.Error()))
|
return errors.New(fmt.Sprintf("Error during init protocol: %s, %s", beelzebubServiceConfiguration.Protocol, err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +132,7 @@ func (b *Builder) build() *Builder {
|
|||||||
return &Builder{
|
return &Builder{
|
||||||
beelzebubServicesConfiguration: b.beelzebubServicesConfiguration,
|
beelzebubServicesConfiguration: b.beelzebubServicesConfiguration,
|
||||||
traceStrategy: b.traceStrategy,
|
traceStrategy: b.traceStrategy,
|
||||||
|
beelzebubCoreConfigurations: b.beelzebubCoreConfigurations,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
|||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -21,7 +22,7 @@ func NewDirector(builder *Builder) *Director {
|
|||||||
|
|
||||||
func (d *Director) BuildBeelzebub(beelzebubCoreConfigurations *parser.BeelzebubCoreConfigurations, beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration) (*Builder, error) {
|
func (d *Director) BuildBeelzebub(beelzebubCoreConfigurations *parser.BeelzebubCoreConfigurations, beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration) (*Builder, error) {
|
||||||
d.builder.beelzebubServicesConfiguration = beelzebubServicesConfiguration
|
d.builder.beelzebubServicesConfiguration = beelzebubServicesConfiguration
|
||||||
|
d.builder.beelzebubCoreConfigurations = beelzebubCoreConfigurations
|
||||||
if err := d.builder.buildLogger(beelzebubCoreConfigurations.Core.Logging); err != nil {
|
if err := d.builder.buildLogger(beelzebubCoreConfigurations.Core.Logging); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -52,7 +53,6 @@ func (d *Director) rabbitMQTraceStrategy(event tracer.Event) {
|
|||||||
"event": event,
|
"event": event,
|
||||||
}).Info("New Event")
|
}).Info("New Event")
|
||||||
|
|
||||||
log.Debug("Push Event on queue")
|
|
||||||
eventJSON, err := json.Marshal(event)
|
eventJSON, err := json.Marshal(event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
@ -63,5 +63,10 @@ func (d *Director) rabbitMQTraceStrategy(event tracer.Event) {
|
|||||||
|
|
||||||
if err = d.builder.rabbitMQChannel.PublishWithContext(context.TODO(), "", RabbitmqQueueName, false, false, publishing); err != nil {
|
if err = d.builder.rabbitMQChannel.PublishWithContext(context.TODO(), "", RabbitmqQueueName, false, false, publishing); err != nil {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
|
} else {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"status": event.Status,
|
||||||
|
"event": event,
|
||||||
|
}).Debug("Event published")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,3 +7,7 @@ core:
|
|||||||
tracing:
|
tracing:
|
||||||
rabbitMQEnabled: false
|
rabbitMQEnabled: false
|
||||||
rabbitMQURI: ""
|
rabbitMQURI: ""
|
||||||
|
prometheus:
|
||||||
|
path: "/metrics"
|
||||||
|
port: ":2112"
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
13
configurations/services/ssh-2222.yaml
Normal file
13
configurations/services/ssh-2222.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: "v1"
|
||||||
|
protocol: "ssh"
|
||||||
|
address: ":2222"
|
||||||
|
description: "SSH interactive ChatGPT"
|
||||||
|
commands:
|
||||||
|
- regex: "^(.+)$"
|
||||||
|
plugin: "OpenAIGPTLinuxTerminal"
|
||||||
|
serverVersion: "OpenSSH"
|
||||||
|
serverName: "ubuntu"
|
||||||
|
passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$"
|
||||||
|
deadlineTimeoutSeconds: 60
|
||||||
|
plugin:
|
||||||
|
openAPIChatGPTSecretKey: ""
|
@ -8,9 +8,11 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
ports: # Remove me, if you use configuration network_mode: host
|
ports: # Remove me, if you use configuration network_mode: host
|
||||||
- "22:22"
|
- "22:22"
|
||||||
|
- "2222:2222"
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
|
- "2112:2112" # Prometheus openmetrics
|
||||||
environment:
|
environment:
|
||||||
RABBITMQ_URI: ${RABBITMQ_URI}
|
RABBITMQ_URI: ${RABBITMQ_URI}
|
||||||
volumes:
|
volumes:
|
||||||
|
35
go.mod
35
go.mod
@ -1,13 +1,38 @@
|
|||||||
module beelzebub
|
module beelzebub
|
||||||
|
|
||||||
go 1.16
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gliderlabs/ssh v0.3.5
|
github.com/gliderlabs/ssh v0.3.5
|
||||||
|
github.com/go-resty/resty/v2 v2.7.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/rabbitmq/amqp091-go v1.5.0
|
github.com/jarcoal/httpmock v1.3.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/melbahja/goph v1.3.1
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/prometheus/client_golang v1.16.0
|
||||||
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d
|
github.com/rabbitmq/amqp091-go v1.8.1
|
||||||
|
github.com/sirupsen/logrus v1.9.3
|
||||||
|
github.com/stretchr/testify v1.8.4
|
||||||
|
golang.org/x/crypto v0.10.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
|
||||||
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
|
github.com/kr/fs v0.1.0 // indirect
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/pkg/sftp v1.13.5 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/prometheus/client_model v0.3.0 // indirect
|
||||||
|
github.com/prometheus/common v0.42.0 // indirect
|
||||||
|
github.com/prometheus/procfs v0.10.1 // indirect
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0 // indirect
|
||||||
|
golang.org/x/net v0.10.0 // indirect
|
||||||
|
golang.org/x/sys v0.9.0 // indirect
|
||||||
|
golang.org/x/term v0.9.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
|
)
|
||||||
|
116
go.sum
116
go.sum
@ -1,87 +1,125 @@
|
|||||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||||
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
|
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
|
||||||
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
|
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
|
||||||
|
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
|
||||||
|
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
|
||||||
|
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
|
||||||
|
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
||||||
|
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||||
|
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
|
||||||
|
github.com/melbahja/goph v1.3.1 h1:FxFevAwCCpLkM4WBmnVVxcJBcBz6lKQpsN5biV2hA6w=
|
||||||
|
github.com/melbahja/goph v1.3.1/go.mod h1:uG+VfK2Dlhk+O32zFrRlc3kYKTlV6+BtvPWd/kK7U68=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go=
|
||||||
|
github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rabbitmq/amqp091-go v1.5.0 h1:VouyHPBu1CrKyJVfteGknGOGCzmOz0zcv/tONLkb7rg=
|
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
|
||||||
github.com/rabbitmq/amqp091-go v1.5.0/go.mod h1:JsV0ofX5f1nwOGafb8L5rBItt9GyhfQfcJj+oyz0dGg=
|
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
|
||||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
|
||||||
|
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
|
||||||
|
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
|
||||||
|
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
|
||||||
|
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
|
||||||
|
github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA=
|
||||||
|
github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
|
||||||
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
|
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
|
||||||
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d h1:3qF+Z8Hkrw9sOhrFHti9TlB1Hkac1x+DNRkv0XQiFjo=
|
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
|
||||||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
|
|
||||||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||||
|
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
|
|
||||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28=
|
||||||
|
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||||
|
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
12
integration_test/configurations/beelzebub.yaml
Normal file
12
integration_test/configurations/beelzebub.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
core:
|
||||||
|
logging:
|
||||||
|
debug: false
|
||||||
|
debugReportCaller: false
|
||||||
|
logDisableTimestamp: true
|
||||||
|
logsPath: ./logs
|
||||||
|
tracing:
|
||||||
|
rabbitMQEnabled: true
|
||||||
|
rabbitMQURI: "amqp://integration:integration@localhost:5672/"
|
||||||
|
prometheus:
|
||||||
|
path: "/metrics"
|
||||||
|
port: ":2112"
|
19
integration_test/configurations/services/http-8080.yaml
Normal file
19
integration_test/configurations/services/http-8080.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: "v1"
|
||||||
|
protocol: "http"
|
||||||
|
address: ":8080"
|
||||||
|
description: "Wordpress 6.0"
|
||||||
|
commands:
|
||||||
|
- regex: "index.php"
|
||||||
|
handler: "mocked response"
|
||||||
|
headers:
|
||||||
|
- "Content-Type: text/html"
|
||||||
|
- "Server: Apache/2.4.53 (Debian)"
|
||||||
|
- "X-Powered-By: PHP/7.4.29"
|
||||||
|
statusCode: 200
|
||||||
|
- regex: "^(/wp-login.php|/wp-admin)$"
|
||||||
|
handler: "mocked response"
|
||||||
|
headers:
|
||||||
|
- "Content-Type: text/html"
|
||||||
|
- "Server: Apache/2.4.53 (Debian)"
|
||||||
|
- "X-Powered-By: PHP/7.4.29"
|
||||||
|
statusCode: 400
|
25
integration_test/configurations/services/ssh-2222.yaml
Normal file
25
integration_test/configurations/services/ssh-2222.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
apiVersion: "v1"
|
||||||
|
protocol: "ssh"
|
||||||
|
address: ":2222"
|
||||||
|
description: "SSH interactive"
|
||||||
|
commands:
|
||||||
|
- regex: "^ls$"
|
||||||
|
handler: "Documents Images Desktop Downloads .m2 .kube .ssh .docker"
|
||||||
|
- regex: "^pwd$"
|
||||||
|
handler: "/home/"
|
||||||
|
- regex: "^uname -m$"
|
||||||
|
handler: "x86_64"
|
||||||
|
- regex: "^docker ps$"
|
||||||
|
handler: "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES"
|
||||||
|
- regex: "^docker .*$"
|
||||||
|
handler: "Error response from daemon: dial unix docker.raw.sock: connect: connection refused"
|
||||||
|
- regex: "^uname$"
|
||||||
|
handler: "Linux"
|
||||||
|
- regex: "^ps$"
|
||||||
|
handler: " PID TTY TIME CMD\n21642 ttys000 0:00.07 /bin/dockerd"
|
||||||
|
- regex: "^(.+)$"
|
||||||
|
handler: "command not found"
|
||||||
|
serverVersion: "OpenSSH"
|
||||||
|
serverName: "ubuntu"
|
||||||
|
passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$"
|
||||||
|
deadlineTimeoutSeconds: 60
|
6
integration_test/configurations/services/tcp-3306.yaml
Normal file
6
integration_test/configurations/services/tcp-3306.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: "v1"
|
||||||
|
protocol: "tcp"
|
||||||
|
address: ":3306"
|
||||||
|
description: "Mysql 8.0.29"
|
||||||
|
banner: "8.0.29"
|
||||||
|
deadlineTimeoutSeconds: 10
|
10
integration_test/docker-compose.yml
Normal file
10
integration_test/docker-compose.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
version: "3.9"
|
||||||
|
services:
|
||||||
|
rabbitmq:
|
||||||
|
image: rabbitmq:3-alpine
|
||||||
|
container_name: 'rabbitmq'
|
||||||
|
ports:
|
||||||
|
- 5672:5672
|
||||||
|
environment:
|
||||||
|
- RABBITMQ_DEFAULT_USER=integration
|
||||||
|
- RABBITMQ_DEFAULT_PASS=integration
|
163
integration_test/integration_test.go
Normal file
163
integration_test/integration_test.go
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"beelzebub/builder"
|
||||||
|
"beelzebub/parser"
|
||||||
|
"beelzebub/tracer"
|
||||||
|
"encoding/json"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/melbahja/goph"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IntegrationTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
beelzebubBuilder *builder.Builder
|
||||||
|
prometheusHost string
|
||||||
|
httpHoneypotHost string
|
||||||
|
tcpHoneypotHost string
|
||||||
|
sshHoneypotHost string
|
||||||
|
rabbitMQURI string
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(IntegrationTestSuite))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) SetupSuite() {
|
||||||
|
suite.T().Helper()
|
||||||
|
if os.Getenv("INTEGRATION") == "" {
|
||||||
|
suite.T().Skip("skipping integration tests, set environment variable INTEGRATION")
|
||||||
|
}
|
||||||
|
suite.httpHoneypotHost = "http://localhost:8080"
|
||||||
|
suite.tcpHoneypotHost = "localhost:3306"
|
||||||
|
suite.sshHoneypotHost = "localhost"
|
||||||
|
suite.prometheusHost = "http://localhost:2112/metrics"
|
||||||
|
|
||||||
|
beelzebubConfigPath := "./configurations/beelzebub.yaml"
|
||||||
|
servicesConfigDirectory := "./configurations/services/"
|
||||||
|
|
||||||
|
parser := parser.Init(beelzebubConfigPath, servicesConfigDirectory)
|
||||||
|
|
||||||
|
coreConfigurations, err := parser.ReadConfigurationsCore()
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.rabbitMQURI = coreConfigurations.Core.Tracing.RabbitMQURI
|
||||||
|
|
||||||
|
beelzebubServicesConfiguration, err := parser.ReadConfigurationsServices()
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
suite.beelzebubBuilder = builder.NewBuilder()
|
||||||
|
|
||||||
|
director := builder.NewDirector(suite.beelzebubBuilder)
|
||||||
|
|
||||||
|
suite.beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
suite.Require().NoError(suite.beelzebubBuilder.Run())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) TestInvokeHTTPHoneypot() {
|
||||||
|
response, err := resty.New().R().
|
||||||
|
Get(suite.httpHoneypotHost + "/index.php")
|
||||||
|
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Equal(http.StatusOK, response.StatusCode())
|
||||||
|
suite.Equal("mocked response", string(response.Body()))
|
||||||
|
|
||||||
|
response, err = resty.New().R().
|
||||||
|
Get(suite.httpHoneypotHost + "/wp-admin")
|
||||||
|
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Equal(http.StatusBadRequest, response.StatusCode())
|
||||||
|
suite.Equal("mocked response", string(response.Body()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) TestInvokeTCPHoneypot() {
|
||||||
|
tcpAddr, err := net.ResolveTCPAddr("tcp", suite.tcpHoneypotHost)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
_, err = conn.Write([]byte("hello!"))
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
reply := make([]byte, 1024)
|
||||||
|
|
||||||
|
n, err := conn.Read(reply)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
suite.Equal("8.0.29\n", string(reply[:n]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) TestInvokeSSHHoneypot() {
|
||||||
|
client, err := goph.NewConn(
|
||||||
|
&goph.Config{
|
||||||
|
User: "root",
|
||||||
|
Addr: suite.sshHoneypotHost,
|
||||||
|
Port: 2222,
|
||||||
|
Auth: goph.Password("root"),
|
||||||
|
Callback: ssh.InsecureIgnoreHostKey(),
|
||||||
|
})
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
out, err := client.Run("")
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
suite.Equal("root@ubuntu:~$ ", string(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) TestRabbitMQ() {
|
||||||
|
conn, err := amqp.Dial(suite.rabbitMQURI)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
ch, err := conn.Channel()
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
defer ch.Close()
|
||||||
|
|
||||||
|
msgs, err := ch.Consume("event", "", true, false, false, false, nil)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
//Invoke HTTP Honeypot
|
||||||
|
response, err := resty.New().R().Get(suite.httpHoneypotHost + "/index.php")
|
||||||
|
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Equal(http.StatusOK, response.StatusCode())
|
||||||
|
|
||||||
|
for msg := range msgs {
|
||||||
|
var event tracer.Event
|
||||||
|
err := json.Unmarshal(msg.Body, &event)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
suite.Equal("GET", event.HTTPMethod)
|
||||||
|
suite.Equal("/index.php", event.RequestURI)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
func (suite *IntegrationTestSuite) TestPrometheus() {
|
||||||
|
//Invoke HTTP Honeypot
|
||||||
|
response, err := resty.New().R().Get(suite.httpHoneypotHost + "/index.php")
|
||||||
|
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Equal(http.StatusOK, response.StatusCode())
|
||||||
|
|
||||||
|
response, err = resty.New().R().Get(suite.prometheusHost)
|
||||||
|
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Equal(http.StatusOK, response.StatusCode())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) TestShutdownBeelzebub() {
|
||||||
|
suite.Require().NoError(suite.beelzebubBuilder.Close())
|
||||||
|
}
|
22
main.go
22
main.go
@ -3,14 +3,23 @@ package main
|
|||||||
import (
|
import (
|
||||||
"beelzebub/builder"
|
"beelzebub/builder"
|
||||||
"beelzebub/parser"
|
"beelzebub/parser"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var quit = make(chan struct{})
|
var quit = make(chan struct{})
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
parser := parser.Init("./configurations/beelzebub.yaml", "./configurations/services/")
|
var configurationsCorePath string
|
||||||
|
var configurationsServicesDirectory string
|
||||||
|
|
||||||
|
flag.StringVar(&configurationsCorePath, "confCore", "./configurations/beelzebub.yaml", "Provide the path of configurations core")
|
||||||
|
flag.StringVar(&configurationsServicesDirectory, "confServices", "./configurations/services/", "Directory config services")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
parser := parser.Init(configurationsCorePath, configurationsServicesDirectory)
|
||||||
|
|
||||||
coreConfigurations, err := parser.ReadConfigurationsCore()
|
coreConfigurations, err := parser.ReadConfigurationsCore()
|
||||||
failOnError(err, fmt.Sprintf("Error during ReadConfigurationsCore: "))
|
failOnError(err, fmt.Sprintf("Error during ReadConfigurationsCore: "))
|
||||||
@ -23,14 +32,11 @@ func main() {
|
|||||||
director := builder.NewDirector(beelzebubBuilder)
|
director := builder.NewDirector(beelzebubBuilder)
|
||||||
|
|
||||||
beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
|
beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
|
||||||
if err != nil {
|
failOnError(err, fmt.Sprintf("Error during BuildBeelzebub: "))
|
||||||
log.Fatal(err)
|
|
||||||
}
|
err = beelzebubBuilder.Run()
|
||||||
|
failOnError(err, fmt.Sprintf("Error during run beelzebub core: "))
|
||||||
|
|
||||||
if err := beelzebubBuilder.Run(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer beelzebubBuilder.Close()
|
defer beelzebubBuilder.Close()
|
||||||
|
|
||||||
<-quit
|
<-quit
|
||||||
|
@ -2,17 +2,20 @@ package parser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BeelzebubCoreConfigurations struct {
|
type BeelzebubCoreConfigurations struct {
|
||||||
Core struct {
|
Core struct {
|
||||||
Logging Logging `yaml:"logging"`
|
Logging Logging `yaml:"logging"`
|
||||||
Tracing Tracing `yaml:"tracing"`
|
Tracing Tracing `yaml:"tracing"`
|
||||||
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +31,15 @@ type Tracing struct {
|
|||||||
RabbitMQURI string `yaml:"rabbitMQURI"`
|
RabbitMQURI string `yaml:"rabbitMQURI"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Prometheus struct {
|
||||||
|
Path string `yaml:"path"`
|
||||||
|
Port string `yaml:"port"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Plugin struct {
|
||||||
|
OpenAPIChatGPTSecretKey string `yaml:"openAPIChatGPTSecretKey"`
|
||||||
|
}
|
||||||
|
|
||||||
type BeelzebubServiceConfiguration struct {
|
type BeelzebubServiceConfiguration struct {
|
||||||
ApiVersion string `yaml:"apiVersion"`
|
ApiVersion string `yaml:"apiVersion"`
|
||||||
Protocol string `yaml:"protocol"`
|
Protocol string `yaml:"protocol"`
|
||||||
@ -39,6 +51,7 @@ type BeelzebubServiceConfiguration struct {
|
|||||||
PasswordRegex string `yaml:"passwordRegex"`
|
PasswordRegex string `yaml:"passwordRegex"`
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
Banner string `yaml:"banner"`
|
Banner string `yaml:"banner"`
|
||||||
|
Plugin Plugin `yaml:"plugin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
@ -46,6 +59,7 @@ type Command struct {
|
|||||||
Handler string `yaml:"handler"`
|
Handler string `yaml:"handler"`
|
||||||
Headers []string `yaml:"headers"`
|
Headers []string `yaml:"headers"`
|
||||||
StatusCode int `yaml:"statusCode"`
|
StatusCode int `yaml:"statusCode"`
|
||||||
|
Plugin string `yaml:"plugin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type configurationsParser struct {
|
type configurationsParser struct {
|
||||||
@ -110,15 +124,17 @@ func (bp configurationsParser) ReadConfigurationsServices() ([]BeelzebubServiceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
func gelAllFilesNameByDirName(dirName string) ([]string, error) {
|
func gelAllFilesNameByDirName(dirName string) ([]string, error) {
|
||||||
var filesName []string
|
|
||||||
files, err := ioutil.ReadDir(dirName)
|
files, err := ioutil.ReadDir(dirName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filesName []string
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
|
if !file.IsDir() && strings.HasSuffix(file.Name(), ".yaml") {
|
||||||
filesName = append(filesName, file.Name())
|
filesName = append(filesName, file.Name())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return filesName, nil
|
return filesName, nil
|
||||||
}
|
}
|
||||||
|
|
116
plugins/openai-gpt.go
Normal file
116
plugins/openai-gpt.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package plugins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ChatGPTPluginName = "OpenAIGPTLinuxTerminal"
|
||||||
|
const openAIGPTEndpoint = "https://api.openai.com/v1/completions"
|
||||||
|
|
||||||
|
type History struct {
|
||||||
|
Input, Output string
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpenAIGPTVirtualTerminal struct {
|
||||||
|
Histories []History
|
||||||
|
OpenAPIChatGPTSecretKey string
|
||||||
|
client *resty.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (openAIGPTVirtualTerminal *OpenAIGPTVirtualTerminal) InjectDependency() {
|
||||||
|
if openAIGPTVirtualTerminal.client == nil {
|
||||||
|
openAIGPTVirtualTerminal.client = resty.New()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Choice struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Logprobs interface{} `json:"logprobs"`
|
||||||
|
FinishReason string `json:"finish_reason"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type gptResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Object string `json:"object"`
|
||||||
|
Created int `json:"created"`
|
||||||
|
Model string `json:"model"`
|
||||||
|
Choices []Choice `json:"choices"`
|
||||||
|
Usage struct {
|
||||||
|
PromptTokens int `json:"prompt_tokens"`
|
||||||
|
CompletionTokens int `json:"completion_tokens"`
|
||||||
|
TotalTokens int `json:"total_tokens"`
|
||||||
|
} `json:"usage"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type gptRequest struct {
|
||||||
|
Model string `json:"model"`
|
||||||
|
Prompt string `json:"prompt"`
|
||||||
|
Temperature int `json:"temperature"`
|
||||||
|
MaxTokens int `json:"max_tokens"`
|
||||||
|
TopP int `json:"top_p"`
|
||||||
|
FrequencyPenalty int `json:"frequency_penalty"`
|
||||||
|
PresencePenalty int `json:"presence_penalty"`
|
||||||
|
Stop []string `json:"stop"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reference: https://www.engraved.blog/building-a-virtual-machine-inside/
|
||||||
|
const promptVirtualizeLinuxTerminal = "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do no write explanations. Do not type commands unless I instruct you to do so.\n\nA:pwd\n\nQ:/home/user\n\n"
|
||||||
|
|
||||||
|
func buildPrompt(histories []History, command string) string {
|
||||||
|
var sb strings.Builder
|
||||||
|
|
||||||
|
sb.WriteString(promptVirtualizeLinuxTerminal)
|
||||||
|
|
||||||
|
for _, history := range histories {
|
||||||
|
sb.WriteString(fmt.Sprintf("A:%s\n\nQ:%s\n\n", history.Input, history.Output))
|
||||||
|
}
|
||||||
|
// Append command to evaluate
|
||||||
|
sb.WriteString(fmt.Sprintf("A:%s\n\nQ:", command))
|
||||||
|
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (openAIGPTVirtualTerminal *OpenAIGPTVirtualTerminal) GetCompletions(command string) (string, error) {
|
||||||
|
requestJson, err := json.Marshal(gptRequest{
|
||||||
|
Model: "text-davinci-003",
|
||||||
|
Prompt: buildPrompt(openAIGPTVirtualTerminal.Histories, command),
|
||||||
|
Temperature: 0,
|
||||||
|
MaxTokens: 100,
|
||||||
|
TopP: 1,
|
||||||
|
FrequencyPenalty: 0,
|
||||||
|
PresencePenalty: 0,
|
||||||
|
Stop: []string{"\n"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if openAIGPTVirtualTerminal.OpenAPIChatGPTSecretKey == "" {
|
||||||
|
return "", errors.New("OpenAPIChatGPTSecretKey is empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := openAIGPTVirtualTerminal.client.R().
|
||||||
|
SetHeader("Content-Type", "application/json").
|
||||||
|
SetBody(requestJson).
|
||||||
|
SetAuthToken(openAIGPTVirtualTerminal.OpenAPIChatGPTSecretKey).
|
||||||
|
SetResult(&gptResponse{}).
|
||||||
|
Post(openAIGPTEndpoint)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
log.Debug(response)
|
||||||
|
if len(response.Result().(*gptResponse).Choices) == 0 {
|
||||||
|
return "", errors.New("no choices")
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.Result().(*gptResponse).Choices[0].Text, nil
|
||||||
|
}
|
82
plugins/openai-gpt_test.go
Normal file
82
plugins/openai-gpt_test.go
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package plugins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/jarcoal/httpmock"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBuildPromptEmptyHistory(t *testing.T) {
|
||||||
|
//Given
|
||||||
|
var histories []History
|
||||||
|
command := "pwd"
|
||||||
|
|
||||||
|
//When
|
||||||
|
prompt := buildPrompt(histories, command)
|
||||||
|
|
||||||
|
//Then
|
||||||
|
assert.Equal(t,
|
||||||
|
"I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do no write explanations. Do not type commands unless I instruct you to do so.\n\nA:pwd\n\nQ:/home/user\n\nA:pwd\n\nQ:",
|
||||||
|
prompt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildPromptWithHistory(t *testing.T) {
|
||||||
|
//Given
|
||||||
|
var histories = []History{
|
||||||
|
{
|
||||||
|
Input: "cat hello.txt",
|
||||||
|
Output: "world",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: "echo 1234",
|
||||||
|
Output: "1234",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
command := "pwd"
|
||||||
|
|
||||||
|
//When
|
||||||
|
prompt := buildPrompt(histories, command)
|
||||||
|
|
||||||
|
//Then
|
||||||
|
assert.Equal(t,
|
||||||
|
"I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do no write explanations. Do not type commands unless I instruct you to do so.\n\nA:pwd\n\nQ:/home/user\n\nA:cat hello.txt\n\nQ:world\n\nA:echo 1234\n\nQ:1234\n\nA:pwd\n\nQ:",
|
||||||
|
prompt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildGetCompletions(t *testing.T) {
|
||||||
|
client := resty.New()
|
||||||
|
httpmock.ActivateNonDefault(client.GetClient())
|
||||||
|
defer httpmock.DeactivateAndReset()
|
||||||
|
|
||||||
|
// Given
|
||||||
|
httpmock.RegisterResponder("POST", openAIGPTEndpoint,
|
||||||
|
func(req *http.Request) (*http.Response, error) {
|
||||||
|
resp, err := httpmock.NewJsonResponse(200, &gptResponse{
|
||||||
|
Choices: []Choice{
|
||||||
|
{
|
||||||
|
Text: "prova.txt",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return httpmock.NewStringResponse(500, ""), nil
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
openAIGPTVirtualTerminal := OpenAIGPTVirtualTerminal{
|
||||||
|
OpenAPIChatGPTSecretKey: "sdjdnklfjndslkjanfk",
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
|
||||||
|
//When
|
||||||
|
str, err := openAIGPTVirtualTerminal.GetCompletions("ls")
|
||||||
|
|
||||||
|
//Then
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "prova.txt", str)
|
||||||
|
}
|
@ -1,22 +1,23 @@
|
|||||||
package protocols
|
package strategies
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"beelzebub/parser"
|
"beelzebub/parser"
|
||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HypertextTransferProtocolStrategy struct {
|
type HTTPStrategy struct {
|
||||||
beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration
|
beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (httpStrategy HypertextTransferProtocolStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
func (httpStrategy HTTPStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
||||||
httpStrategy.beelzebubServiceConfiguration = beelzebubServiceConfiguration
|
httpStrategy.beelzebubServiceConfiguration = beelzebubServiceConfiguration
|
||||||
serverMux := http.NewServeMux()
|
serverMux := http.NewServeMux()
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ func (httpStrategy HypertextTransferProtocolStrategy) Init(beelzebubServiceConfi
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"port": beelzebubServiceConfiguration.Address,
|
"port": beelzebubServiceConfiguration.Address,
|
||||||
"commands": len(beelzebubServiceConfiguration.Commands),
|
"commands": len(beelzebubServiceConfiguration.Commands),
|
||||||
}).Infof("Init service %s", beelzebubServiceConfiguration.Protocol)
|
}).Infof("Init service: %s", beelzebubServiceConfiguration.Description)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,24 @@
|
|||||||
package protocols
|
package strategies
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"beelzebub/parser"
|
"beelzebub/parser"
|
||||||
|
"beelzebub/plugins"
|
||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gliderlabs/ssh"
|
"github.com/gliderlabs/ssh"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SecureShellStrategy struct {
|
type SSHStrategy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
func (sshStrategy *SSHStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
||||||
go func() {
|
go func() {
|
||||||
server := &ssh.Server{
|
server := &ssh.Server{
|
||||||
Addr: beelzebubServiceConfiguration.Address,
|
Addr: beelzebubServiceConfiguration.Address,
|
||||||
@ -39,20 +41,13 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
|
|||||||
})
|
})
|
||||||
|
|
||||||
term := terminal.NewTerminal(sess, buildPrompt(sess.User(), beelzebubServiceConfiguration.ServerName))
|
term := terminal.NewTerminal(sess, buildPrompt(sess.User(), beelzebubServiceConfiguration.ServerName))
|
||||||
|
var histories []plugins.History
|
||||||
for {
|
for {
|
||||||
commandInput, err := term.ReadLine()
|
commandInput, err := term.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
tr.TraceEvent(tracer.Event{
|
|
||||||
Msg: "New SSH Terminal Session",
|
|
||||||
RemoteAddr: sess.RemoteAddr().String(),
|
|
||||||
Status: tracer.Interaction.String(),
|
|
||||||
Command: commandInput,
|
|
||||||
ID: uuidSession.String(),
|
|
||||||
Protocol: tracer.SSH.String(),
|
|
||||||
Description: beelzebubServiceConfiguration.Description,
|
|
||||||
})
|
|
||||||
if commandInput == "exit" {
|
if commandInput == "exit" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -64,7 +59,32 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
|
|||||||
}
|
}
|
||||||
|
|
||||||
if matched {
|
if matched {
|
||||||
term.Write(append([]byte(command.Handler), '\n'))
|
commandOutput := command.Handler
|
||||||
|
|
||||||
|
if command.Plugin == plugins.ChatGPTPluginName {
|
||||||
|
openAIGPTVirtualTerminal := plugins.OpenAIGPTVirtualTerminal{Histories: histories, OpenAPIChatGPTSecretKey: beelzebubServiceConfiguration.Plugin.OpenAPIChatGPTSecretKey}
|
||||||
|
openAIGPTVirtualTerminal.InjectDependency()
|
||||||
|
|
||||||
|
if commandOutput, err = openAIGPTVirtualTerminal.GetCompletions(commandInput); err != nil {
|
||||||
|
log.Errorf("Error GetCompletions: %s, %s", commandInput, err.Error())
|
||||||
|
commandOutput = "command not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
histories = append(histories, plugins.History{Input: commandInput, Output: commandOutput})
|
||||||
|
|
||||||
|
term.Write(append([]byte(commandOutput), '\n'))
|
||||||
|
|
||||||
|
tr.TraceEvent(tracer.Event{
|
||||||
|
Msg: "New SSH Terminal Session",
|
||||||
|
RemoteAddr: sess.RemoteAddr().String(),
|
||||||
|
Status: tracer.Interaction.String(),
|
||||||
|
Command: commandInput,
|
||||||
|
CommandOutput: commandOutput,
|
||||||
|
ID: uuidSession.String(),
|
||||||
|
Protocol: tracer.SSH.String(),
|
||||||
|
Description: beelzebubServiceConfiguration.Description,
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,20 @@
|
|||||||
package protocols
|
package strategies
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"beelzebub/parser"
|
"beelzebub/parser"
|
||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TransmissionControlProtocolStrategy struct {
|
type TCPStrategy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (TCPStrategy *TransmissionControlProtocolStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
func (tcpStrategy *TCPStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
||||||
listen, err := net.Listen("tcp", beelzebubServiceConfiguration.Address)
|
listen, err := net.Listen("tcp", beelzebubServiceConfiguration.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error during init TCP Protocol: %s", err.Error())
|
log.Errorf("Error during init TCP Protocol: %s", err.Error())
|
17
pull_request_template.md
Normal file
17
pull_request_template.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
All Submissions:
|
||||||
|
|
||||||
|
* [ ] Have you followed the guidelines in our Contributing document?
|
||||||
|
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
|
||||||
|
|
||||||
|
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
|
||||||
|
|
||||||
|
### New Feature Submissions:
|
||||||
|
|
||||||
|
1. [ ] Does your submission pass tests?
|
||||||
|
2. [ ] Have you lint your code locally before submission?
|
||||||
|
|
||||||
|
### Changes to Core Features:
|
||||||
|
|
||||||
|
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
|
||||||
|
* [ ] Have you written new tests for your core changes, as applicable?
|
||||||
|
* [ ] Have you successfully run tests with your changes locally?
|
@ -2,34 +2,17 @@ package tracer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Strategy func(event Event)
|
|
||||||
|
|
||||||
type Tracer interface {
|
|
||||||
TraceEvent(event Event)
|
|
||||||
}
|
|
||||||
|
|
||||||
type tracer struct {
|
|
||||||
strategy Strategy
|
|
||||||
}
|
|
||||||
|
|
||||||
func Init(strategy Strategy) *tracer {
|
|
||||||
return &tracer{
|
|
||||||
strategy: strategy,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tracer *tracer) TraceEvent(event Event) {
|
|
||||||
event.DateTime = time.Now().UTC().Format(time.RFC3339)
|
|
||||||
tracer.strategy(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
DateTime string
|
DateTime string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
Protocol string
|
Protocol string
|
||||||
Command string
|
Command string
|
||||||
|
CommandOutput string
|
||||||
Status string
|
Status string
|
||||||
Msg string
|
Msg string
|
||||||
ID string
|
ID string
|
||||||
@ -71,3 +54,63 @@ const (
|
|||||||
func (status Status) String() string {
|
func (status Status) String() string {
|
||||||
return [...]string{"Start", "End", "Stateless", "Interaction"}[status]
|
return [...]string{"Start", "End", "Stateless", "Interaction"}[status]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Strategy func(event Event)
|
||||||
|
|
||||||
|
type Tracer interface {
|
||||||
|
TraceEvent(event Event)
|
||||||
|
}
|
||||||
|
|
||||||
|
type tracer struct {
|
||||||
|
strategy Strategy
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
eventsTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "beelzebub",
|
||||||
|
Name: "events_total",
|
||||||
|
Help: "The total number of events",
|
||||||
|
})
|
||||||
|
eventsSSHTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "beelzebub",
|
||||||
|
Name: "ssh_events_total",
|
||||||
|
Help: "The total number of SSH events",
|
||||||
|
})
|
||||||
|
eventsTCPTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "beelzebub",
|
||||||
|
Name: "tcp_events_total",
|
||||||
|
Help: "The total number of TCP events",
|
||||||
|
})
|
||||||
|
eventsHTTPTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "beelzebub",
|
||||||
|
Name: "http_events_total",
|
||||||
|
Help: "The total number of HTTP events",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init(strategy Strategy) *tracer {
|
||||||
|
return &tracer{
|
||||||
|
strategy: strategy,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tracer *tracer) TraceEvent(event Event) {
|
||||||
|
event.DateTime = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
|
tracer.strategy(event)
|
||||||
|
|
||||||
|
//Openmetrics
|
||||||
|
eventsTotal.Inc()
|
||||||
|
|
||||||
|
switch event.Protocol {
|
||||||
|
case HTTP.String():
|
||||||
|
eventsHTTPTotal.Inc()
|
||||||
|
break
|
||||||
|
case SSH.String():
|
||||||
|
eventsSSHTotal.Inc()
|
||||||
|
break
|
||||||
|
case TCP.String():
|
||||||
|
eventsTCPTotal.Inc()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user