<commit_before>ruleset io.picolabs.use_honeypot {
  meta {
    use module io.picolabs.subscription alias subs
    shares __testing
  }
  global {
    __testing = { "queries":
      [ { "name": "__testing" }
      //, { "name": "entry", "args": [ "key" ] }
      ] , "events":
      [ //{ "domain": "d1", "type": "t1" }
      //, { "domain": "d2", "type": "t2", "attrs": [ "a1", "a2" ] }
      ]
    }
    getHoneypotEci = function(){
      subs:established("Tx_role","honeypot").head(){"Tx"} || "No user found"
    }
    check_roles = function(){
      event:attr("Rx_role")=="root" && event:attr("Tx_role")=="honeypot"
    }
  }
  rule eci_from_owner_name{
    select when owner login_attempt_failed
    pre {
      eci = getHoneypotEci();
      pico_id = eci != "No user found"
        => engine:getPicoIDByECI(eci.klog("eci"))
         | null;
      channel_name = "authenticate_"+time:now();
    }
    if pico_id then every{
      engine:newChannel(pico_id,channel_name,"temporary")
        setting(new_channel);
      send_directive("Returning eci from owner name", {"eci": new_channel{"id"}});
    }
    fired{
      schedule owner event "authenticate_channel_expired"
        at time:add(time:now(), {"minutes": 5})
        attributes {"eci": new_channel{"id"}};
    }
  }

  rule intialization {
    select when wrangler ruleset_added where event:attr("rids") >< meta:rid
    pre {
      rids = ["io.picolabs.subscription","io.picolabs.null_owner"];
      name = "io.picolabs.null_owner";
    }
    fired {
      raise wrangler event "new_child_request"
        attributes event:attrs.put({"rids":rids,"name":name});
    }
  }

  rule auto_accept {
    select when wrangler inbound_pending_subscription_added
    pre {
      acceptable = check_roles();
    }
    if acceptable then noop();
    fired {
      raise wrangler event "pending_subscription_approval"
        attributes event:attrs
    } else {
      raise wrangler event "inbound_rejection"
        attributes { "Rx": event:attr("Rx") }
    }
  }
}<commit_msg>tweak<commit_after>ruleset io.picolabs.use_honeypot {
  meta {
    use module io.picolabs.subscription alias subs
    shares __testing
  }
  global {
    __testing = { "queries":
      [ { "name": "__testing" }
      //, { "name": "entry", "args": [ "key" ] }
      ] , "events":
      [ //{ "domain": "d1", "type": "t1" }
      //, { "domain": "d2", "type": "t2", "attrs": [ "a1", "a2" ] }
      ]
    }
    getHoneypotEci = function(){
      subs:established("Tx_role","honeypot").head(){"Tx"} || "No user found"
    }
    check_roles = function(){
      event:attr("Rx_role")=="root" && event:attr("Tx_role")=="honeypot"
    }
  }
  rule eci_from_owner_name{
    select when owner login_attempt_failed
    pre {
      eci = getHoneypotEci();
      pico_id = eci != "No user found"
        => engine:getPicoIDByECI(eci.klog("eci"))
         | null;
      channel_name = "authenticate_"+time:now();
    }
    if pico_id then every{
      engine:newChannel(pico_id,channel_name,"temporary")
        setting(new_channel);
      send_directive("Returning eci from owner name", {"eci": new_channel{"id"}});
    }
    fired{
      schedule owner event "authenticate_channel_expired"
        at time:add(time:now(), {"minutes": 5})
        attributes {"eci": new_channel{"id"}};
    }
  }

  rule intialization {
    select when wrangler ruleset_added where event:attr("rids") >< meta:rid
    pre {
      rids = [ //"io.picolabs.logging",
        "io.picolabs.subscription","io.picolabs.null_owner"];
      name = "io.picolabs.null_owner";
    }
    fired {
      raise wrangler event "new_child_request"
        attributes {"rids":rids,"name":name,"color":"#CCCCCC"};
    }
  }

  rule auto_accept {
    select when wrangler inbound_pending_subscription_added
    pre {
      acceptable = check_roles();
    }
    if acceptable then noop();
    fired {
      raise wrangler event "pending_subscription_approval"
        attributes event:attrs
    } else {
      raise wrangler event "inbound_rejection"
        attributes { "Rx": event:attr("Rx") }
    }
  }
}
{'fraction_non_alphanumeric': 0.1532435740514076, 'fraction_numerical': 0.003427172582619339, 'mean_word_length': 2.7973977695167287, 'pattern_counts': {'":': 33, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4735581', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1411, 'n_words': 267}