/usr/share/php/Aws/CloudTrail/LogFileReader.php is in php-aws-sdk 2.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <?php
namespace Aws\CloudTrail;
use Aws\S3\S3Client;
/**
* This class provides an easy way to read log files generated by AWS CloudTrail. CloudTrail log files contain data
* about your AWS API calls and are stored in Amazon S3. The log files are gzipped and contain structured data in JSON
* format. This class will automatically ungzip and decode the data, and return the data as a array of log records
*/
class LogFileReader
{
/**
* @var S3Client The Amazon S3 client used to perform GetObject operations
*/
private $s3Client;
/**
* @param S3Client $s3Client
*/
public function __construct(S3Client $s3Client)
{
$this->s3Client = $s3Client;
}
/**
* Downloads, unzips, and reads a CloudTrail log file from Amazon S3
*
* @param string $s3BucketName The bucket name of the log file in Amazon S3
* @param string $logFileKey The key of the log file in Amazon S3
*
* @return array
*/
public function read($s3BucketName, $logFileKey)
{
// Create a command for getting the log file object
$command = $this->s3Client->getCommand('GetObject', array(
'Bucket' => (string) $s3BucketName,
'Key' => (string) $logFileKey,
));
// Make sure gzip encoding header is sent and accepted in order to inflate the response data
$command->set('ResponseContentEncoding', 'x-gzip');
$command->prepare()->addHeader('Accept-Encoding', 'gzip');
// Get the JSON response data and extract the log records
$command->execute();
$logData = $command->getResponse()->json();
if (isset($logData['Records'])) {
return $logData['Records'];
} else {
return array();
}
}
}
|