/*
   Odin by Brandefense - Monograph 39 / 46 YARA Structural Detection Suite
   Targets staged HTTP Maven POM descriptors or Java process-execution sources, insecure HTTP Maven/Gradle
   repository configs, exposed agent task directory listings, and Go scope-poller or Compose directory listings.
   Classification: TLP:CLEAR
*/

rule ODIN_HTTP_Maven_POM_or_Java_Process_Execution_Source {
    meta:
        author = "Odin by Brandefense"
        monograph = "39 / 46"
        description = "Detects staged Maven POM descriptors with cleartext HTTP repositories or standalone Java source files invoking process execution sinks"
        date = "2026-11-21"
        tlp = "CLEAR"
    strings:
        $pom_proj = "<project" ascii
        $pom_grp = "<groupId>" ascii
        $pom_art = "<artifactId>" ascii
        $pom_http = "<url>http://" ascii
        $java_pkg = "package " ascii
        $java_cls = "public class " ascii
        $exec1 = "Runtime.getRuntime().exec" ascii
        $exec2 = "ProcessBuilder" ascii
    condition:
        filesize < 256KB and (
            ($pom_proj and $pom_grp and $pom_art and $pom_http) or
            (($java_pkg or $java_cls) and 1 of ($exec1, $exec2))
        )
}

rule ODIN_Insecure_Maven_or_Gradle_HTTP_Repo_Config {
    meta:
        author = "Odin by Brandefense"
        monograph = "39 / 46"
        description = "Detects Maven POM/settings or Gradle build files pointing to cleartext HTTP repository endpoints, overriding HTTP repository blockers, or relaxing HTTPS certificate checks"
        date = "2026-11-21"
        tlp = "CLEAR"
    strings:
        $repo_tag = "<repositories>" ascii
        $grad_repo = "maven {" ascii
        $http_url = "http://" ascii
        $bypass1 = "allowInsecureProtocol" ascii
        $bypass2 = "maven-default-http-blocker" ascii
        $bypass3 = "wagon.http.ssl.insecure" ascii
    condition:
        filesize < 512KB and $http_url and 1 of ($repo_tag, $grad_repo) and 1 of ($bypass1, $bypass2, $bypass3)
}

rule ODIN_Exposed_Agent_Overnight_Workspace {
    meta:
        author = "Odin by Brandefense"
        monograph = "39 / 46"
        description = "Detects exposed autonomous agent task directory listings containing symlinked or shell task output entries"
        date = "2026-11-21"
        tlp = "CLEAR"
    strings:
        $listing = "Directory listing for /" ascii
        $tasks = "tasks/" ascii
        $out_sym = ".output@" ascii
        $out_reg = ".output" ascii
    condition:
        filesize < 512KB and $listing and $tasks and 1 of ($out_sym, $out_reg)
}

rule ODIN_Exposed_Go_Scope_Poller_or_Compose_Listing {
    meta:
        author = "Odin by Brandefense"
        monograph = "39 / 46"
        description = "Detects open HTTP directory listings exposing Go scope-poller source files or Compose manifests"
        date = "2026-11-21"
        tlp = "CLEAR"
    strings:
        $listing = "Directory listing for /" ascii
        $go_ext = ".go" ascii
        $yml_ext1 = ".yml" ascii
        $yml_ext2 = ".yaml" ascii
    condition:
        filesize < 512KB and $listing and $go_ext and 1 of ($yml_ext1, $yml_ext2)
}
