Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active January 12, 2016 20:10
Show Gist options
  • Save sandromello/89704397989b432ba2df to your computer and use it in GitHub Desktop.
Save sandromello/89704397989b432ba2df to your computer and use it in GitHub Desktop.
Example using themis-core classes
# Considerando que a máquina possua o pacote themis-core instalado é possível acessar os dados
>>> from themis.marshalredis import MarshalRedis
>>> from themis.policy import Policy
>>> p = Policy(MarshalRedis('redis01.domain.tld'))
>>> print json.dumps(pdata.as_dict, indent=2)
{
"enable": true,
"jailaction": "block",
"actionheaders": {},
"policy_name": "xxxxxxxx",
"onlyheaders": false,
"spf": false,
"blockprobation": 0.5,
"jailspec": [
[
"300",
"3600"
]
],
"subjectprobation": 0.5,
"jailby": "Sender+",
"ipprobation": 0.5,
"destination": "any",
"replydata": "Limit reached. Blocking for %s second(s)",
"priority": 5.0,
"source": "xxxxxxxxx",
"countrcpt": true,
"countsentprobation": 1.0,
"type": "regular",
"stophere": false,
"requestsmon": false
}
>>> print json.dumps(p.search_keys('*block*'), indent=2)
[
"fblock@xxxxxxxxxxx",
"block:Sender+:[email protected]",
"block:Sender+:xxxxxxxxxxxxx",
"block:Sender+:xxxxxxxxxx",
"AI:metadata:fblock@xxxxxxxx"
]
>>>> print json.dumps(p.get_all_groups(), indent=2)
[
"group:xxxxxxxxxxx",
"group:yyyyyyyyy",
"group:tttttttt",
"group:blank",
"group:abuse_bypass",
"group:dddddddddd",
"group:aaaaaaaaaaa",
"group:ssssssssss"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment