This commit is contained in:
parent
d2205b11a7
commit
02b9aebbe5
341 changed files with 1571 additions and 32574 deletions
|
|
@ -8,7 +8,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/TecharoHQ/anubis/lib/checker"
|
||||
"git.sad.ovh/sophie/nuke/lib/checker"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/TecharoHQ/anubis/data"
|
||||
"git.sad.ovh/sophie/nuke/data"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
)
|
||||
|
||||
|
|
@ -63,10 +63,6 @@ type BotConfig struct {
|
|||
Challenge *ChallengeRules `json:"challenge,omitempty" yaml:"challenge,omitempty"`
|
||||
Weight *Weight `json:"weight,omitempty" yaml:"weight,omitempty"`
|
||||
|
||||
// Thoth features
|
||||
GeoIP *GeoIP `json:"geoip,omitempty"`
|
||||
ASNs *ASNs `json:"asns,omitempty"`
|
||||
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Action Rule `json:"action" yaml:"action"`
|
||||
RemoteAddr []string `json:"remote_addresses,omitempty" yaml:"remote_addresses,omitempty"`
|
||||
|
|
@ -81,8 +77,6 @@ func (b BotConfig) Zero() bool {
|
|||
b.Action != "",
|
||||
len(b.RemoteAddr) != 0,
|
||||
b.Challenge != nil,
|
||||
b.GeoIP != nil,
|
||||
b.ASNs != nil,
|
||||
} {
|
||||
if cond {
|
||||
return false
|
||||
|
|
@ -102,9 +96,7 @@ func (b *BotConfig) Valid() error {
|
|||
allFieldsEmpty := b.UserAgentRegex == nil &&
|
||||
b.PathRegex == nil &&
|
||||
len(b.RemoteAddr) == 0 &&
|
||||
len(b.HeadersRegex) == 0 &&
|
||||
b.ASNs == nil &&
|
||||
b.GeoIP == nil
|
||||
len(b.HeadersRegex) == 0
|
||||
|
||||
if allFieldsEmpty && b.Expression == nil {
|
||||
errs = append(errs, ErrBotMustHaveUserAgentOrPath)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/TecharoHQ/anubis/data"
|
||||
. "github.com/TecharoHQ/anubis/lib/config"
|
||||
"git.sad.ovh/sophie/nuke/data"
|
||||
. "git.sad.ovh/sophie/nuke/lib/config"
|
||||
)
|
||||
|
||||
func p[V any](v V) *V { return &v }
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ func TestImpressumValid(t *testing.T) {
|
|||
{
|
||||
name: "basic happy path",
|
||||
inp: Impressum{
|
||||
Footer: "<p>Website hosted by Techaro.<p>",
|
||||
Footer: "<p>Website hosted by sad.ovh<p>",
|
||||
Page: ImpressumPage{
|
||||
Title: "Techaro Imprint",
|
||||
Title: "sad.ovh Imprint",
|
||||
Body: "<p>This is an imprint page.</p>",
|
||||
},
|
||||
},
|
||||
|
|
@ -28,7 +28,7 @@ func TestImpressumValid(t *testing.T) {
|
|||
inp: Impressum{
|
||||
Footer: "",
|
||||
Page: ImpressumPage{
|
||||
Title: "Techaro Imprint",
|
||||
Title: "sad.ovh Imprint",
|
||||
Body: "<p>This is an imprint page.</p>",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func (lfc LoggingFileConfig) Zero() bool {
|
|||
|
||||
func (LoggingFileConfig) Default() *LoggingFileConfig {
|
||||
return &LoggingFileConfig{
|
||||
Filename: "./var/anubis.log",
|
||||
Filename: "./var/nuke.log",
|
||||
MaxBackups: 3,
|
||||
MaxBytes: 104857600, // 100 Mi
|
||||
MaxAge: 7, // 7 days
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func TestLoggingValid(t *testing.T) {
|
|||
input: &Logging{
|
||||
Sink: LogSinkFile,
|
||||
Parameters: &LoggingFileConfig{
|
||||
Filename: "./var/anubis.log",
|
||||
Filename: "./var/nuke.log",
|
||||
MaxBackups: -3,
|
||||
MaxBytes: 104857600, // 100 Mi
|
||||
MaxAge: 7, // 7 days
|
||||
|
|
@ -79,7 +79,7 @@ func TestLoggingValid(t *testing.T) {
|
|||
input: &Logging{
|
||||
Sink: LogSinkFile,
|
||||
Parameters: &LoggingFileConfig{
|
||||
Filename: "./var/anubis.log",
|
||||
Filename: "./var/nuke.log",
|
||||
MaxBackups: 3,
|
||||
MaxBytes: 104857600, // 100 Mi
|
||||
MaxAge: -7, // 7 days
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/TecharoHQ/anubis/lib/store"
|
||||
_ "github.com/TecharoHQ/anubis/lib/store/all"
|
||||
"git.sad.ovh/sophie/nuke/lib/store"
|
||||
_ "git.sad.ovh/sophie/nuke/lib/store/all"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/TecharoHQ/anubis/lib/config"
|
||||
"github.com/TecharoHQ/anubis/lib/store/bbolt"
|
||||
"github.com/TecharoHQ/anubis/lib/store/valkey"
|
||||
"git.sad.ovh/sophie/nuke/lib/config"
|
||||
"git.sad.ovh/sophie/nuke/lib/store/bbolt"
|
||||
"git.sad.ovh/sophie/nuke/lib/store/valkey"
|
||||
)
|
||||
|
||||
func TestStoreValid(t *testing.T) {
|
||||
|
|
@ -53,7 +53,7 @@ func TestStoreValid(t *testing.T) {
|
|||
name: "valkey backend bad URL",
|
||||
input: config.Store{
|
||||
Backend: "valkey",
|
||||
Parameters: json.RawMessage(`{"url": "http://anubis.techaro.lol"}`),
|
||||
Parameters: json.RawMessage(`{"url": "http://git.sad.ovh"}`),
|
||||
},
|
||||
err: valkey.ErrBadURL,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/TecharoHQ/anubis"
|
||||
"git.sad.ovh/sophie/nuke"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -16,14 +16,14 @@ var (
|
|||
|
||||
DefaultThresholds = []Threshold{
|
||||
{
|
||||
Name: "legacy-anubis-behaviour",
|
||||
Name: "legacy-nuke-behaviour",
|
||||
Expression: &ExpressionOrList{
|
||||
Expression: "weight > 0",
|
||||
},
|
||||
Action: RuleChallenge,
|
||||
Challenge: &ChallengeRules{
|
||||
Algorithm: "fast",
|
||||
Difficulty: anubis.DefaultDifficulty,
|
||||
Difficulty: nuke.DefaultDifficulty,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue