Analysis AWS WAF logs and generate a report
Project description
Introduction
Accomapnist - It's an accompanist on AWS WAF log analysis.
You can analysis AWS WAF log and generate analysis report automatically with only 3 steps.
- The feature & Report Item
- Histgram of requests
- Top 5 of below items
- Blocked or counted rule group
- URI path
- IP address
- Country code
- The number of requests on specific URI
- Comment (written by you if you have any comments))
Note
-
Target WAF
- AWS WAFv2
- Logging: CloudWatch Logs
- Action: BLOCK or COUNT
- Third Party WAF
- Logging: CloudWatch Logs
- Action: BLOCK or COUNT
- AWS WAFv2
-
Requirement of Client Environment
- IAM Role/User: including permissions to execute as follows
- (1)
start_query
of Logs Insights - (2)
get_query_result
of Logs Insights - The example policy is noted the last
- (1)
- IAM Role/User: including permissions to execute as follows
Install
$ pip install accompanist
Usage
- Configure settings with a following command, then config.json file is generated.
$ accompanist init
- The log group name must be set with this command or you can edit the config.json directly.
- Get query result
(e.g.) To get BLOCK log for 3 days
$ accompanist listen --action BLOCK --days 3
- Generate report (PDF format)
$ accompanist play
Uninstall
$ pip uninstall accompanist
Index
Here is a sample of IAM policy with minimum permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "logs:StartQuery",
"Resource": [
"arn:aws:logs:<region>:<aws-acount>:log-group:<log-group-name>:*"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "logs:GetQueryResults",
"Resource": "*"
}
]
}
Note: The region, aws-acount and log-group-name are should be replaced in this sample policy.
License
The MIT License
Copyright 2023 Itsuki Yutaka
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for accompanist-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a353693ea3619d64ca1b9bdf8436865a974ab2a21c887698b16e55ee38108f |
|
MD5 | 08dc92154c82d352172aaf206a8cfbf6 |
|
BLAKE2b-256 | f27552583f4417a45d2f48bb961ef54c77afec4b99281cde7ffa006d323ac956 |