NUKE
Some checks failed
Docker image builds / build (push) Failing after 4m22s

This commit is contained in:
Soph :3 2026-02-07 14:27:38 +02:00
parent d2205b11a7
commit 02b9aebbe5
341 changed files with 1571 additions and 32574 deletions

View file

@ -136,16 +136,16 @@ func TestDataFileConversion(t *testing.T) {
*userAgentDeny = oldDeniedAction
}()
// Convert to Anubis rules
anubisRules := convertToAnubisRules(rules)
// Convert to Nuke rules
nukeRules := convertToNukeRules(rules)
// Generate output
var actualOutput []byte
switch strings.ToLower(*outputFormat) {
case "yaml":
actualOutput, err = yaml.Marshal(anubisRules)
actualOutput, err = yaml.Marshal(nukeRules)
case "json":
actualOutput, err = json.MarshalIndent(anubisRules, "", " ")
actualOutput, err = json.MarshalIndent(nukeRules, "", " ")
}
if err != nil {
t.Fatalf("Failed to marshal output: %v", err)
@ -249,10 +249,10 @@ Disallow: /admin`
*policyName = "test-policy"
defer func() { *policyName = oldPolicyName }()
anubisRules := convertToAnubisRules(rules)
nukeRules := convertToNukeRules(rules)
// Test YAML output
yamlOutput, err := yaml.Marshal(anubisRules)
yamlOutput, err := yaml.Marshal(nukeRules)
if err != nil {
t.Fatalf("Failed to marshal YAML: %v", err)
}
@ -262,7 +262,7 @@ Disallow: /admin`
}
// Test JSON output
jsonOutput, err := json.MarshalIndent(anubisRules, "", " ")
jsonOutput, err := json.MarshalIndent(nukeRules, "", " ")
if err != nil {
t.Fatalf("Failed to marshal JSON: %v", err)
}
@ -290,14 +290,14 @@ Disallow: /admin`
*baseAction = action
defer func() { *baseAction = oldAction }()
anubisRules := convertToAnubisRules(rules)
nukeRules := convertToNukeRules(rules)
if len(anubisRules) != 1 {
t.Fatalf("Expected 1 rule, got %d", len(anubisRules))
if len(nukeRules) != 1 {
t.Fatalf("Expected 1 rule, got %d", len(nukeRules))
}
if anubisRules[0].Action != action {
t.Errorf("Expected action %s, got %s", action, anubisRules[0].Action)
if nukeRules[0].Action != action {
t.Errorf("Expected action %s, got %s", action, nukeRules[0].Action)
}
})
}
@ -325,10 +325,10 @@ Disallow: /`
*policyName = name
defer func() { *policyName = oldName }()
anubisRules := convertToAnubisRules(rules)
nukeRules := convertToNukeRules(rules)
// Check that all rule names use the custom prefix
for _, rule := range anubisRules {
for _, rule := range nukeRules {
if !strings.HasPrefix(rule.Name, name+"-") {
t.Errorf("Rule name %s doesn't start with expected prefix %s-", rule.Name, name)
}
@ -360,11 +360,11 @@ Crawl-delay: 60`
*crawlDelay = weight
defer func() { *crawlDelay = oldWeight }()
anubisRules := convertToAnubisRules(rules)
nukeRules := convertToNukeRules(rules)
// Count weight rules and verify they have correct weight
weightRules := 0
for _, rule := range anubisRules {
for _, rule := range nukeRules {
if rule.Action == "WEIGH" && rule.Weight != nil {
weightRules++
if rule.Weight.Adjust != weight {
@ -402,10 +402,10 @@ Disallow: /`
*userAgentDeny = action
defer func() { *userAgentDeny = oldAction }()
anubisRules := convertToAnubisRules(rules)
nukeRules := convertToNukeRules(rules)
// All rules should be blacklist rules with the specified action
for _, rule := range anubisRules {
for _, rule := range nukeRules {
if !strings.Contains(rule.Name, "blacklist") {
t.Errorf("Expected blacklist rule, got %s", rule.Name)
}