feat(dependencies) CTOR-596 - Add paws dependency to AWS plugins (#5040)

This commit is contained in:
sdepassio 2024-09-24 11:07:38 +02:00 committed by GitHub
parent 8af60e86e2
commit c1f030a532
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 310 additions and 56 deletions

View File

@ -48,6 +48,9 @@ overrides:
perl(POSIX),
perl(Encode),
perl(XML::LibXML),
perl(FindBin),
perl(lib),
perl(sort),
@RPM_DEPENDENCIES@
]
conflicts:

View File

@ -102,7 +102,7 @@ def remove_plugin(plugin, archi):
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
exit(1)
# Remove cache files
tmp_files = glob.glob('/tmp/cache/*')
tmp_files = glob.glob('/dev/shm/*')
for file in tmp_files:
try:
os.remove(file)
@ -122,9 +122,6 @@ if __name__ == '__main__':
archi = sys.argv.pop(1) # expected either deb or rpm.
script_name = sys.argv.pop(0)
# Create a directory for cache files
os.mkdir("/tmp/cache")
error_install = 0
error_tests = 0
error_purge = 0

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,6 +1,7 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
],
"replaces": ["centreon-plugin-Cloud-Aws-Api"]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,6 +1,7 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
],
"replaces": ["centreon-plugin-Cloud-Aws-Api"]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"libdatetime-perl"
"libdatetime-perl",
"libpaws-perl"
]
}

View File

@ -1,5 +1,6 @@
{
"dependencies": [
"perl(DateTime)"
"perl(DateTime)",
"perl(Paws)"
]
}

View File

@ -0,0 +1,31 @@
*** Settings ***
Documentation AWS CloudTrail plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}cloud-aws-cloudtrail.json
${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtrail::plugin --custommode=paws --region=eu-west --aws-secret-key=secret --aws-access-key=key
*** Test Cases ***
AWS CloudTrail check trail status
[Documentation] Check AWS CloudTrail trail status
[Tags] cloud aws cloudtrail
${command} Catenate
... ${CMD}
... --mode=checktrailstatus
... --endpoint=http://${HOSTNAME}:${APIPORT}/cloudtrail/gettrailstatus/${trailstatus}
... --trail-name=trailname
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc trailstatus expected_result --
... 1 true OK: Trail is logging: 1 | 'trail_is_logging'=1;;;0;
... 2 false CRITICAL: Trail is logging: 0 | 'trail_is_logging'=0;;;0;

View File

@ -0,0 +1,133 @@
{
"uuid": "e59ad81e-2050-480d-bbae-0e71c607c927",
"lastMigration": 32,
"name": "Aws cloudtrail",
"endpointPrefix": "",
"latency": 0,
"port": 3000,
"hostname": "",
"folders": [],
"routes": [
{
"uuid": "b5e25f3a-a8e3-4128-9e45-f2654c5a599d",
"type": "http",
"documentation": "",
"method": "post",
"endpoint": "cloudtrail/gettrailstatus/:islogging",
"responses": [
{
"uuid": "76483999-2022-4610-8e8c-9c0bd535e4c5",
"body": "{\r\n \"IsLogging\": {{ urlParam 'islogging' 'true' }},\r\n \"LatestCloudWatchLogsDeliveryError\": \"error\",\r\n \"LatestCloudWatchLogsDeliveryTime\": 1683298944.125,\r\n \"LatestDeliveryAttemptSucceeded\": \"2023-05-05T15:02:24Z\",\r\n \"LatestDeliveryAttemptTime\": \"2023-05-05T15:02:24Z\",\r\n \"LatestDeliveryError\": \"error\",\r\n \"LatestDeliveryTime\": 1683298944.125,\r\n \"LatestDigestDeliveryError\": \"error\",\r\n \"LatestDigestDeliveryTime\": 1683298944.125,\r\n \"LatestNotificationAttemptSucceeded\": \"2023-05-05T15:02:24Z\",\r\n \"LatestNotificationAttemptTime\": \"2023-05-05T15:02:24Z\",\r\n \"LatestNotificationError\": \"error\",\r\n \"LatestNotificationTime\": 1683298944.125,\r\n \"StartLoggingTime\": 1683298944.125,\r\n \"StopLoggingTime\": 1683298477.918,\r\n \"TimeLoggingStarted\": \"2023-05-05T15:02:24Z\",\r\n \"TimeLoggingStopped\": \"2023-05-05T14:54:37Z\"\r\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
},
{
"uuid": "77f82f1c-b06e-478a-8366-ab325830f00e",
"type": "http",
"documentation": "",
"method": "post",
"endpoint": "cloudtrail/events/AwsApiCall/:AwsApiCall/AwsServiceEvent/:AwsServiceEvent/AwsConsoleAction/:AwsConsoleAction/AwsConsoleSignIn/:AwsConsoleSignIn/NextToken/:NextToken",
"responses": [
{
"uuid": "7dd41177-8d63-458a-abcc-b3af3ea8c9cd",
"body": "{\r\n\t\"Events\": [\r\n\t\t{{#each (dataRaw 'EventsData')}}\r\n\t\t {{#if (gt @index 0)}}\r\n\t\t ,\r\n\t\t {{/if}}\r\n \t\t{\r\n \t\t\t\"AccessKeyId\": \"{{AccessKeyId}}\",\r\n \t\t\t\"CloudTrailEvent\": \"{\\\"awsRegion\\\": \\\"eu-west-1\\\", {{#if Error}}\\\"errorCode\\\": \\\"{{ErrorCode}}\\\", \\\"errorMessage\\\": \\\"{{ErrorMessage}}\\\",{{/if}} \\\"eventCategory\\\": \\\"Management\\\", \\\"eventID\\\": \\\"{{EventId}}\\\", \\\"eventName\\\": \\\"{{EventName}}\\\", \\\"eventSource\\\": \\\"{{EventSource}}\\\", \\\"eventTime\\\": \\\"{{EventTime}}\\\", \\\"eventType\\\": \\\"{{EventType}}\\\", \\\"eventVersion\\\": \\\"1.08\\\", \\\"managementEvent\\\": true, \\\"readOnly\\\": true, \\\"recipientAccountId\\\": \\\"{{AccountId}}\\\", \\\"requestID\\\": \\\"{{ faker 'string.uuid' }}\\\", \\\"requestParameters\\\": null, \\\"responseElements\\\": null, \\\"sourceIPAddress\\\": \\\"{{ faker 'internet.ip' }}\\\", \\\"tlsDetails\\\": {\\\"cipherSuite\\\": \\\"ECDHE-RSA-AES128-GCM-SHA256\\\", \\\"clientProvidedHostHeader\\\": \\\"cloudtrail.eu-west-1.amazonaws.com\\\", \\\"tlsVersion\\\": \\\"TLSv1.2\\\"}, \\\"userAgent\\\": \\\"aws-cli/2.11.0 Python/3.11.2 Darwin/22.2.0 source/x86_64 prompt/off command/cloudtrail.lookup-events\\\", \\\"userIdentity\\\": {\\\"accessKeyId\\\": \\\"{{AccessKeyId}}\\\", \\\"accountId\\\": \\\"{{AccountId}}\\\", \\\"arn\\\": \\\"arn:aws:sts::{{AccountId}}:assumed-role/{{UserRole}}/{{UserName}}\\\", \\\"principalId\\\": \\\"{{PrincipalId}}:{{UserName}}\\\", \\\"sessionContext\\\": {\\\"attributes\\\": {\\\"creationDate\\\": \\\"{{ faker 'date.past' EventTime }}\\\", \\\"mfaAuthenticated\\\": \\\"false\\\"}, \\\"sessionIssuer\\\": {\\\"accountId\\\": \\\"{{AccountId}}\\\", \\\"arn\\\": \\\"arn:aws:iam::{{AccountId}}:role/{{UserRole}}\\\", \\\"principalId\\\": \\\"{{PrincipalId}}\\\", \\\"type\\\": \\\"Role\\\", \\\"userName\\\": \\\"{{UserRole}}\\\"}, \\\"webIdFederationData\\\": {}}, \\\"type\\\": \\\"{{ faker 'person.jobArea' }}\\\"}}\",\r\n \t\t\t\"EventId\": \"{{EventId}}\",\r\n \t\t\t\"EventName\": \"{{EventName}}\",\r\n \t\t\t\"EventSource\": \"{{EventSource}}\",\r\n \t\t\t\"EventTime\": \"{{EventTime}}\",\r\n \t\t\t\"ReadOnly\": \"true\",\r\n \t\t\t\"Resources\": [\r\n \t\t\t],\r\n \t\t\t\"Username\": \"{{UserName}}\"\r\n \t\t}\r\n\t\t{{/each}}\r\n\t]\r\n\t{{#if (gte (indexOf (urlParam 'NextToken') 'true' 0) 0)}}\r\n\t {{#unless (includes (stringify (body)) 'NextToken')}}\r\n\t\t ,\"NextToken\": \"{{ faker 'string.alphanumeric' 64 casing='upper' }}\"\r\n\t\t{{/unless}}\r\n\t{{/if}}\r\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "c5kh",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
}
],
"rootChildren": [
{
"type": "route",
"uuid": "b5e25f3a-a8e3-4128-9e45-f2654c5a599d"
},
{
"type": "route",
"uuid": "77f82f1c-b06e-478a-8366-ab325830f00e"
}
],
"proxyMode": false,
"proxyHost": "",
"proxyRemovePrefix": false,
"tlsOptions": {
"enabled": false,
"type": "CERT",
"pfxPath": "",
"certPath": "",
"keyPath": "",
"caPath": "",
"passphrase": ""
},
"cors": true,
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"proxyReqHeaders": [
{
"key": "",
"value": ""
}
],
"proxyResHeaders": [
{
"key": "",
"value": ""
}
],
"data": [
{
"uuid": "5dce6340-bade-4336-8041-50fd22570055",
"id": "nu28",
"name": "EventsTypeData",
"documentation": "",
"value": "[\n {\n \"name\": \"AwsApiCall\",\n \"error\": false\n },\n {\n \"name\": \"AwsServiceEvent\",\n \"error\": false\n },\n {\n \"name\": \"AwsConsoleAction\",\n \"error\": true,\n \t\"errorCode\": \"ThrottlingException\",\n \t\"errorMessage\": \"Rate exceeded error\"\n },\n {\n \"name\": \"AwsConsoleSignIn\",\n \"error\": true,\n \"errorCode\": \"LoginErrorException\",\n \"errorMessage\": \"Login error\"\n }\n]"
},
{
"uuid": "76dec2a5-ff63-4e81-9611-94b900ab16e1",
"id": "c5kh",
"name": "EventsData",
"documentation": "",
"value": "[\n {{#each (dataRaw 'EventsTypeData')}}\n {{#if (gte @isEvent 1)}}\n ,\n {{/if}}\n {{setVar 'isEvent' (add (urlParam name) @isEvent)}}\n {{#repeat (urlParam name comma=true)}}\n {\n \"AccessKeyId\": \"{{ faker 'string.alphanumeric' 20 casing='upper' }}\",\n \"AccountId\": \"{{ faker 'string.numeric' 12 }}\",\n \"Error\": {{error}},\n {{#if error}}\n \"ErrorCode\": \"{{errorCode}}\",\n\t \"ErrorMessage\": \"{{errorMessage}}\",\n {{/if}}\n \"EventId\": \"{{ faker 'string.uuid' }}\",\n \"EventName\": \"{{oneOf (array 'LookupEvents' 'ListInstanceAssociations' 'AssumeRoleWithWebIdentity')}}\",\n \"EventSource\": \"{{oneOf (array 'cloudtrail.amazonaws.com' 'ssm.amazonaws.com' 'sts.amazonaws.com')}}\",\n \"EventTime\": \"{{ faker 'date.recent' }}\",\n \"EventType\": \"{{name}}\",\n \"PrincipalId\": \"{{ faker 'string.alphanumeric' 20 casing='upper' }}\",\n \"UserName\": \"{{ faker 'internet.userName' }}\",\n \"UserRole\": \"{{ faker 'person.jobType' }}\"\n }\n {{/repeat}}\n {{/each}}\n]"
}
],
"callbacks": []
}

View File

@ -0,0 +1,38 @@
*** Settings ***
Documentation AWS CloudTrail plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}cloud-aws-cloudtrail.json
${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtrail::plugin --custommode=paws --region=eu-west --aws-secret-key=secret --aws-access-key=key
*** Test Cases ***
AWS CloudTrail count events
[Documentation] Check AWS CloudTrail count events
[Tags] cloud aws cloudtrail
${command} Catenate
... ${CMD}
... --mode=countevents
... --endpoint=http://localhost:3000/cloudtrail/events/AwsApiCall/${AwsApiCall}/AwsServiceEvent/${AwsServiceEvent}/AwsConsoleAction/${AwsConsoleAction}/AwsConsoleSignIn/${AwsConsoleSignIn}/NextToken/${NextToken}
... ${extraoptions}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc AwsApiCall AwsServiceEvent AwsConsoleAction AwsConsoleSignIn NextToken extraoptions expected_result --
... 1 4 2 1 3 false ${EMPTY} OK: Number of events: 10.00 | 'events_count'=10.00;;;0;
... 2 4 2 1 3 true ${EMPTY} OK: Number of events: 20.00 | 'events_count'=20.00;;;0;
... 3 4 2 1 3 false --event-type=AwsApiCall OK: Number of events: 4.00 | 'events_count'=4.00;;;0;
... 4 4 2 1 3 false --event-type=AwsServiceEvent OK: Number of events: 2.00 | 'events_count'=2.00;;;0;
... 5 4 2 1 3 false --delta=10 OK: Number of events: 10.00 | 'events_count'=10.00;;;0;
... 6 4 2 1 3 false --error-message='Login error' OK: Number of events: 3.00 | 'events_count'=3.00;;;0;
... 7 4 2 1 3 false --error-message='.*error' OK: Number of events: 4.00 | 'events_count'=4.00;;;0;
... 8 4 2 1 3 false --warning-count=3 WARNING: Number of events: 10.00 | 'events_count'=10.00;;;0;
... 9 4 2 1 3 false --critical-count=5 CRITICAL: Number of events: 10.00 | 'events_count'=10.00;;;0;