mirror of https://github.com/cowrie/cowrie.git
Use botocore's credential auto-discovery if AWS creds are not explicitly defined in config (#707)
This commit is contained in:
parent
19d5a76a29
commit
6e27f54545
|
@ -531,7 +531,9 @@ logfile = log/cowrie.json
|
||||||
#
|
#
|
||||||
#[output_s3]
|
#[output_s3]
|
||||||
#
|
#
|
||||||
# The AWS credentials to use
|
# The AWS credentials to use.
|
||||||
|
# Leave these blank to use botocore's credential discovery e.g .aws/config or ENV variables.
|
||||||
|
# As per https://github.com/boto/botocore/blob/develop/botocore/credentials.py#L50-L65
|
||||||
#access_key_id = AKIDEXAMPLE
|
#access_key_id = AKIDEXAMPLE
|
||||||
#secret_access_key = wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY
|
#secret_access_key = wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY
|
||||||
#
|
#
|
||||||
|
|
|
@ -7,6 +7,8 @@ from __future__ import division, absolute_import
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from twisted.internet import defer, threads
|
from twisted.internet import defer, threads
|
||||||
|
from twisted.python import log
|
||||||
|
|
||||||
|
|
||||||
from botocore.session import get_session
|
from botocore.session import get_session
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
@ -14,6 +16,7 @@ from botocore.exceptions import ClientError
|
||||||
import cowrie.core.output
|
import cowrie.core.output
|
||||||
|
|
||||||
from cowrie.core.config import CONFIG
|
from cowrie.core.config import CONFIG
|
||||||
|
from configparser import NoOptionError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,10 +26,16 @@ class Output(cowrie.core.output.Output):
|
||||||
self.seen = set()
|
self.seen = set()
|
||||||
|
|
||||||
self.session = get_session()
|
self.session = get_session()
|
||||||
|
|
||||||
|
try:
|
||||||
|
if CONFIG.get("output_s3", "access_key_id") and CONFIG.get("output_s3", "secret_access_key"):
|
||||||
self.session.set_credentials(
|
self.session.set_credentials(
|
||||||
CONFIG.get("output_s3", "access_key_id"),
|
CONFIG.get("output_s3", "access_key_id"),
|
||||||
CONFIG.get("output_s3", "secret_access_key"),
|
CONFIG.get("output_s3", "secret_access_key"),
|
||||||
)
|
)
|
||||||
|
except NoOptionError:
|
||||||
|
log.msg("No AWS credentials found in config - using botocore global settings.")
|
||||||
|
|
||||||
self.client = self.session.create_client(
|
self.client = self.session.create_client(
|
||||||
's3',
|
's3',
|
||||||
region_name=CONFIG.get("output_s3", "region"),
|
region_name=CONFIG.get("output_s3", "region"),
|
||||||
|
|
Loading…
Reference in New Issue