Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bitonio committed May 27, 2021
2 parents 36cfb91 + c76a443 commit 9c84f5d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ You can also pipe the command to another process like your favorite JSON parser
$ akamai etp event aup --start 1576877365 --end 1576878265|jq .
```

Other event available are DNS activity (use `dns`) and Proxy Traffic (use `proxy`)

### Manage security lists

Get the lists available on the account
Expand Down
20 changes: 17 additions & 3 deletions bin/akamai-etp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from requests.compat import urljoin
from akamai.edgegrid import EdgeGridAuth, EdgeRc
from config import EdgeGridConfig

__version__ = "0.3.2"
__version__ = "0.3.3"

#: Data collection delay, default is 30 minutes
collection_delay_min = 30
Expand Down Expand Up @@ -155,6 +155,20 @@ def build_params(params=None):
return final_params


def input2feed(event_type):
api_eventtype = None
if event_type == "threat":
api_eventtype = "threat-events"
elif event_type == "aup":
api_eventtype = "aup-events"
elif event_type == "dns":
api_eventtype = "dns-activities"
elif event_type == "proxy":
api_eventtype = "proxy-traffic/transactions"
if api_eventtype is None:
raise ValueError(f'event_type provided is support supported: {event_type}')
return api_eventtype

def fetch_events(config, output):
"""
Fetch all events
Expand Down Expand Up @@ -193,11 +207,11 @@ def fetch_events(config, output):
}

timing_s = time.time() # The fetch operation can take a while
event_url = '%(baseurl)s/etp-report/v3/configs/%(config_id)s/%(event_type)s-events/details' % \
event_url = '%(baseurl)s/etp-report/v3/configs/%(config_id)s/%(event_type)s/details' % \
{
'baseurl': baseurl,
'config_id': config.etp_config_id,
'event_type': config.event_type
'event_type': input2feed(config.event_type)
}
LOG.info("{OPEN} API URL: %s" % event_url)
LOG.info("{OPEN} API POST param %s" % post_data)
Expand Down
2 changes: 1 addition & 1 deletion bin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, config_values, configuration, flags=None):
event_parser = subparsers.add_parser("event", help="Fetch last events (from 1h15 ago to 1 hour ago)",
epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
event_parser.add_argument('event_type', nargs='?', default="threat",
choices=['threat', 'aup'], help="Event type, threat or Acceptable User Policy (AUP)")
choices=['threat', 'aup', 'dns', 'proxy'], help="Event type, Threat, Acceptable User Policy (AUP), DNS or Proxy")
event_parser.add_argument('--start', '-s', type=int, help="Start datetime (EPOCH),\nDefault is 1h15 ago")
event_parser.add_argument('--end', '-e', type=int, help="End datetime (EPOCH),\nDefault is start + 15 minutes")
event_parser.add_argument('--output', '-o', help="Output file, default is stdout. Encoding is utf-8.")
Expand Down
2 changes: 1 addition & 1 deletion cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commands": [
{
"name": "etp",
"version": "0.3.2",
"version": "0.3.3",
"description": "Akamai CLI for Enterprise Threat Protector"
}
]
Expand Down

0 comments on commit 9c84f5d

Please sign in to comment.