From 603346776849ad1c9d4c9cc6c6145a7b874181f8 Mon Sep 17 00:00:00 2001 From: Alireza Sheikholmolouki <144152467+alireza-sheikholmolouki@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:49:19 +0200 Subject: [PATCH] Added support for Athena Named Queries (#79) * feat: added support for athena named queries * Create chilled-carrots-hunt.md --- .changeset/chilled-carrots-hunt.md | 5 + package-lock.json | 517 +++++++++++++++++- package.json | 3 +- src/aws-app/process/getProcessedResource.ts | 15 + src/scanners/getAwsScanners.ts | 2 + .../aws/athena-named-queries.ts | 50 ++ src/types.ts | 2 + 7 files changed, 592 insertions(+), 2 deletions(-) create mode 100644 .changeset/chilled-carrots-hunt.md create mode 100644 src/scanners/scan-functions/aws/athena-named-queries.ts diff --git a/.changeset/chilled-carrots-hunt.md b/.changeset/chilled-carrots-hunt.md new file mode 100644 index 0000000..b135a85 --- /dev/null +++ b/.changeset/chilled-carrots-hunt.md @@ -0,0 +1,5 @@ +--- +"@mirohq/cloud-data-import": minor +--- + +Added support for Athena Named Queries diff --git a/package-lock.json b/package-lock.json index 7bd7c9b..968de48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@aws-sdk/client-auto-scaling": "^3.616.0", + "@aws-sdk/client-athena": "^3.616.0", "@aws-sdk/client-cloudfront": "^3.614.0", "@aws-sdk/client-cloudtrail": "^3.556.0", "@aws-sdk/client-cloudwatch": "^3.614.0", @@ -262,6 +263,520 @@ "node": ">=14.0.0" } }, + "node_modules/@aws-sdk/client-athena": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-athena/-/client-athena-3.616.0.tgz", + "integrity": "sha512-B07NKwLBt+0WlHOAysizDcYrcmVU8FiyhhODM9p5Ekpk16Copnp5GZ4E4ssFLj2Fh0qmCXG0C1QbZURLf018Hw==", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/client-sso-oidc": "3.616.0", + "@aws-sdk/client-sts": "3.616.0", + "@aws-sdk/core": "3.616.0", + "@aws-sdk/credential-provider-node": "3.616.0", + "@aws-sdk/middleware-host-header": "3.616.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.616.0", + "@aws-sdk/middleware-user-agent": "3.616.0", + "@aws-sdk/region-config-resolver": "3.614.0", + "@aws-sdk/types": "3.609.0", + "@aws-sdk/util-endpoints": "3.614.0", + "@aws-sdk/util-user-agent-browser": "3.609.0", + "@aws-sdk/util-user-agent-node": "3.614.0", + "@smithy/config-resolver": "^3.0.5", + "@smithy/core": "^2.2.7", + "@smithy/fetch-http-handler": "^3.2.2", + "@smithy/hash-node": "^3.0.3", + "@smithy/invalid-dependency": "^3.0.3", + "@smithy/middleware-content-length": "^3.0.4", + "@smithy/middleware-endpoint": "^3.0.5", + "@smithy/middleware-retry": "^3.0.10", + "@smithy/middleware-serde": "^3.0.3", + "@smithy/middleware-stack": "^3.0.3", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/node-http-handler": "^3.1.3", + "@smithy/protocol-http": "^4.0.4", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.10", + "@smithy/util-defaults-mode-node": "^3.0.10", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2", + "uuid": "^9.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/client-sso": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.616.0.tgz", + "integrity": "sha512-hwW0u1f8U4dSloAe61/eupUiGd5Q13B72BuzGxvRk0cIpYX/2m0KBG8DDl7jW1b2QQ+CflTLpG2XUf2+vRJxGA==", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "3.616.0", + "@aws-sdk/middleware-host-header": "3.616.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.616.0", + "@aws-sdk/middleware-user-agent": "3.616.0", + "@aws-sdk/region-config-resolver": "3.614.0", + "@aws-sdk/types": "3.609.0", + "@aws-sdk/util-endpoints": "3.614.0", + "@aws-sdk/util-user-agent-browser": "3.609.0", + "@aws-sdk/util-user-agent-node": "3.614.0", + "@smithy/config-resolver": "^3.0.5", + "@smithy/core": "^2.2.7", + "@smithy/fetch-http-handler": "^3.2.2", + "@smithy/hash-node": "^3.0.3", + "@smithy/invalid-dependency": "^3.0.3", + "@smithy/middleware-content-length": "^3.0.4", + "@smithy/middleware-endpoint": "^3.0.5", + "@smithy/middleware-retry": "^3.0.10", + "@smithy/middleware-serde": "^3.0.3", + "@smithy/middleware-stack": "^3.0.3", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/node-http-handler": "^3.1.3", + "@smithy/protocol-http": "^4.0.4", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.10", + "@smithy/util-defaults-mode-node": "^3.0.10", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/client-sso-oidc": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.616.0.tgz", + "integrity": "sha512-YY1hpYS/G1uRGjQf88dL8VLHkP/IjGxKeXdhy+JnzMdCkAWl3V9j0fEALw40NZe0x79gr6R2KUOUH/IKYQfUmg==", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "3.616.0", + "@aws-sdk/credential-provider-node": "3.616.0", + "@aws-sdk/middleware-host-header": "3.616.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.616.0", + "@aws-sdk/middleware-user-agent": "3.616.0", + "@aws-sdk/region-config-resolver": "3.614.0", + "@aws-sdk/types": "3.609.0", + "@aws-sdk/util-endpoints": "3.614.0", + "@aws-sdk/util-user-agent-browser": "3.609.0", + "@aws-sdk/util-user-agent-node": "3.614.0", + "@smithy/config-resolver": "^3.0.5", + "@smithy/core": "^2.2.7", + "@smithy/fetch-http-handler": "^3.2.2", + "@smithy/hash-node": "^3.0.3", + "@smithy/invalid-dependency": "^3.0.3", + "@smithy/middleware-content-length": "^3.0.4", + "@smithy/middleware-endpoint": "^3.0.5", + "@smithy/middleware-retry": "^3.0.10", + "@smithy/middleware-serde": "^3.0.3", + "@smithy/middleware-stack": "^3.0.3", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/node-http-handler": "^3.1.3", + "@smithy/protocol-http": "^4.0.4", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.10", + "@smithy/util-defaults-mode-node": "^3.0.10", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@aws-sdk/client-sts": "^3.616.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/client-sts": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.616.0.tgz", + "integrity": "sha512-FP7i7hS5FpReqnysQP1ukQF1OUWy8lkomaOnbu15H415YUrfCp947SIx6+BItjmx+esKxPkEjh/fbCVzw2D6hQ==", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/client-sso-oidc": "3.616.0", + "@aws-sdk/core": "3.616.0", + "@aws-sdk/credential-provider-node": "3.616.0", + "@aws-sdk/middleware-host-header": "3.616.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.616.0", + "@aws-sdk/middleware-user-agent": "3.616.0", + "@aws-sdk/region-config-resolver": "3.614.0", + "@aws-sdk/types": "3.609.0", + "@aws-sdk/util-endpoints": "3.614.0", + "@aws-sdk/util-user-agent-browser": "3.609.0", + "@aws-sdk/util-user-agent-node": "3.614.0", + "@smithy/config-resolver": "^3.0.5", + "@smithy/core": "^2.2.7", + "@smithy/fetch-http-handler": "^3.2.2", + "@smithy/hash-node": "^3.0.3", + "@smithy/invalid-dependency": "^3.0.3", + "@smithy/middleware-content-length": "^3.0.4", + "@smithy/middleware-endpoint": "^3.0.5", + "@smithy/middleware-retry": "^3.0.10", + "@smithy/middleware-serde": "^3.0.3", + "@smithy/middleware-stack": "^3.0.3", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/node-http-handler": "^3.1.3", + "@smithy/protocol-http": "^4.0.4", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.10", + "@smithy/util-defaults-mode-node": "^3.0.10", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/core": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.616.0.tgz", + "integrity": "sha512-O/urkh2kECs/IqZIVZxyeyHZ7OR2ZWhLNK7btsVQBQvJKrEspLrk/Fp20Qfg5JDerQfBN83ZbyRXLJOOucdZpw==", + "dependencies": { + "@smithy/core": "^2.2.7", + "@smithy/protocol-http": "^4.0.4", + "@smithy/signature-v4": "^4.0.0", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "fast-xml-parser": "4.2.5", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-env": { + "version": "3.609.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.609.0.tgz", + "integrity": "sha512-v69ZCWcec2iuV9vLVJMa6fAb5xwkzN4jYIT8yjo2c4Ia/j976Q+TPf35Pnz5My48Xr94EFcaBazrWedF+kwfuQ==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/property-provider": "^3.1.3", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-http": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.616.0.tgz", + "integrity": "sha512-1rgCkr7XvEMBl7qWCo5BKu3yAxJs71dRaZ55Xnjte/0ZHH6Oc93ZrHzyYy6UH6t0nZrH+FAuw7Yko2YtDDwDeg==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/fetch-http-handler": "^3.2.2", + "@smithy/node-http-handler": "^3.1.3", + "@smithy/property-provider": "^3.1.3", + "@smithy/protocol-http": "^4.0.4", + "@smithy/smithy-client": "^3.1.8", + "@smithy/types": "^3.3.0", + "@smithy/util-stream": "^3.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-ini": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.616.0.tgz", + "integrity": "sha512-5gQdMr9cca3xV7FF2SxpxWGH2t6+t4o+XBGiwsHm8muEjf4nUmw7Ij863x25Tjt2viPYV0UStczSb5Sihp7bkA==", + "dependencies": { + "@aws-sdk/credential-provider-env": "3.609.0", + "@aws-sdk/credential-provider-http": "3.616.0", + "@aws-sdk/credential-provider-process": "3.614.0", + "@aws-sdk/credential-provider-sso": "3.616.0", + "@aws-sdk/credential-provider-web-identity": "3.609.0", + "@aws-sdk/types": "3.609.0", + "@smithy/credential-provider-imds": "^3.1.4", + "@smithy/property-provider": "^3.1.3", + "@smithy/shared-ini-file-loader": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@aws-sdk/client-sts": "^3.616.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-node": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.616.0.tgz", + "integrity": "sha512-Se+u6DAxjDPjKE3vX1X2uxjkWgGq69BTo0uTB0vDUiWwBVgh16s9BsBhSAlKEH1CCbbJHvOg4YdTrzjwzqyClg==", + "dependencies": { + "@aws-sdk/credential-provider-env": "3.609.0", + "@aws-sdk/credential-provider-http": "3.616.0", + "@aws-sdk/credential-provider-ini": "3.616.0", + "@aws-sdk/credential-provider-process": "3.614.0", + "@aws-sdk/credential-provider-sso": "3.616.0", + "@aws-sdk/credential-provider-web-identity": "3.609.0", + "@aws-sdk/types": "3.609.0", + "@smithy/credential-provider-imds": "^3.1.4", + "@smithy/property-provider": "^3.1.3", + "@smithy/shared-ini-file-loader": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-process": { + "version": "3.614.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.614.0.tgz", + "integrity": "sha512-Q0SI0sTRwi8iNODLs5+bbv8vgz8Qy2QdxbCHnPk/6Cx6LMf7i3dqmWquFbspqFRd8QiqxStrblwxrUYZi09tkA==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/property-provider": "^3.1.3", + "@smithy/shared-ini-file-loader": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-sso": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.616.0.tgz", + "integrity": "sha512-3rsWs9GBi8Z8Gps5ROwqguxtw+J6OIg1vawZMLRNMqqZoBvbOToe9wEnpid8ylU+27+oG8uibJNlNuRyXApUjw==", + "dependencies": { + "@aws-sdk/client-sso": "3.616.0", + "@aws-sdk/token-providers": "3.614.0", + "@aws-sdk/types": "3.609.0", + "@smithy/property-provider": "^3.1.3", + "@smithy/shared-ini-file-loader": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/credential-provider-web-identity": { + "version": "3.609.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.609.0.tgz", + "integrity": "sha512-U+PG8NhlYYF45zbr1km3ROtBMYqyyj/oK8NRp++UHHeuavgrP+4wJ4wQnlEaKvJBjevfo3+dlIBcaeQ7NYejWg==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/property-provider": "^3.1.3", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@aws-sdk/client-sts": "^3.609.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/middleware-host-header": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.616.0.tgz", + "integrity": "sha512-mhNfHuGhCDZwYCABebaOvTgOM44UCZZRq2cBpgPZLVKP0ydAv5aFHXv01goexxXHqgHoEGx0uXWxlw0s2EpFDg==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/protocol-http": "^4.0.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/middleware-logger": { + "version": "3.609.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.609.0.tgz", + "integrity": "sha512-S62U2dy4jMDhDFDK5gZ4VxFdWzCtLzwbYyFZx2uvPYTECkepLUfzLic2BHg2Qvtu4QjX+oGE3P/7fwaGIsGNuQ==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/middleware-recursion-detection": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.616.0.tgz", + "integrity": "sha512-LQKAcrZRrR9EGez4fdCIVjdn0Ot2HMN12ChnoMGEU6oIxnQ2aSC7iASFFCV39IYfeMh7iSCPj7Wopqw8rAouzg==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/protocol-http": "^4.0.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/middleware-user-agent": { + "version": "3.616.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.616.0.tgz", + "integrity": "sha512-iMcAb4E+Z3vuEcrDsG6T2OBNiqWAquwahP9qepHqfmnmJqHr1mSHtXDYTGBNid31+621sUQmneUQ+fagpGAe4w==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@aws-sdk/util-endpoints": "3.614.0", + "@smithy/protocol-http": "^4.0.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/region-config-resolver": { + "version": "3.614.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.614.0.tgz", + "integrity": "sha512-vDCeMXvic/LU0KFIUjpC3RiSTIkkvESsEfbVHiHH0YINfl8HnEqR5rj+L8+phsCeVg2+LmYwYxd5NRz4PHxt5g==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/types": "^3.3.0", + "@smithy/util-config-provider": "^3.0.0", + "@smithy/util-middleware": "^3.0.3", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/token-providers": { + "version": "3.614.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.614.0.tgz", + "integrity": "sha512-okItqyY6L9IHdxqs+Z116y5/nda7rHxLvROxtAJdLavWTYDydxrZstImNgGWTeVdmc0xX2gJCI77UYUTQWnhRw==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/property-provider": "^3.1.3", + "@smithy/shared-ini-file-loader": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@aws-sdk/client-sso-oidc": "^3.614.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/types": { + "version": "3.609.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.609.0.tgz", + "integrity": "sha512-+Tqnh9w0h2LcrUsdXyT1F8mNhXz+tVYBtP19LpeEGntmvHwa2XzvLUCWpoIAIVsHp5+HdB2X9Sn0KAtmbFXc2Q==", + "dependencies": { + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/util-endpoints": { + "version": "3.614.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.614.0.tgz", + "integrity": "sha512-wK2cdrXHH4oz4IomV/yrGkftU9A+ITB6nFL+rxxyO78is2ifHJpFdV4aqk4LSkXYPi6CXWNru/Dqc7yiKXgJPw==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/types": "^3.3.0", + "@smithy/util-endpoints": "^2.0.5", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/util-user-agent-browser": { + "version": "3.609.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.609.0.tgz", + "integrity": "sha512-fojPU+mNahzQ0YHYBsx0ZIhmMA96H+ZIZ665ObU9tl+SGdbLneVZVikGve+NmHTQwHzwkFsZYYnVKAkreJLAtA==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/types": "^3.3.0", + "bowser": "^2.11.0", + "tslib": "^2.6.2" + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@aws-sdk/util-user-agent-node": { + "version": "3.614.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.614.0.tgz", + "integrity": "sha512-15ElZT88peoHnq5TEoEtZwoXTXRxNrk60TZNdpl/TUBJ5oNJ9Dqb5Z4ryb8ofN6nm9aFf59GVAerFDz8iUoHBA==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/node-config-provider": "^3.1.4", + "@smithy/types": "^3.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "aws-crt": ">=1.0.0" + }, + "peerDependenciesMeta": { + "aws-crt": { + "optional": true + } + } + }, + "node_modules/@aws-sdk/client-athena/node_modules/@smithy/signature-v4": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-4.1.0.tgz", + "integrity": "sha512-aRryp2XNZeRcOtuJoxjydO6QTaVhxx/vjaR+gx7ZjaFgrgPRyZ3HCTbfwqYj6ZWEBHkCSUfcaymKPURaByukag==", + "dependencies": { + "@smithy/is-array-buffer": "^3.0.0", + "@smithy/protocol-http": "^4.1.0", + "@smithy/types": "^3.3.0", + "@smithy/util-hex-encoding": "^3.0.0", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-uri-escape": "^3.0.0", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/@aws-sdk/client-auto-scaling": { "version": "3.616.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-auto-scaling/-/client-auto-scaling-3.616.0.tgz", @@ -19083,4 +19598,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 26a86d8..4b70702 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ }, "dependencies": { "@aws-sdk/client-auto-scaling": "^3.616.0", + "@aws-sdk/client-athena": "^3.616.0", "@aws-sdk/client-cloudfront": "^3.614.0", "@aws-sdk/client-cloudtrail": "^3.556.0", "@aws-sdk/client-cloudwatch": "^3.614.0", @@ -89,4 +90,4 @@ "npm run format" ] } -} +} \ No newline at end of file diff --git a/src/aws-app/process/getProcessedResource.ts b/src/aws-app/process/getProcessedResource.ts index 1e6ea02..107e1b0 100644 --- a/src/aws-app/process/getProcessedResource.ts +++ b/src/aws-app/process/getProcessedResource.ts @@ -5,6 +5,7 @@ import type * as Lambda from '@aws-sdk/client-lambda' import type * as RDS from '@aws-sdk/client-rds' import type * as ELBv2 from '@aws-sdk/client-elastic-load-balancing-v2' import type * as Redshift from '@aws-sdk/client-redshift' +import type * as Athena from '@aws-sdk/client-athena' import {parse} from '@aws-sdk/util-arn-parser' @@ -37,6 +38,20 @@ export const getProcessedResource = (arn: string, resource: ResourceDescription) } switch (baseOutput.type) { + case 'athena:workgroup': { + const isNamedQuery = baseOutput.name.includes('/query/') + + if (isNamedQuery) { + const namedQuery = resource as Athena.NamedQuery + return { + ...baseOutput, + name: namedQuery.Name ?? baseOutput.name, + type: `athena:named-query`, + } + } + + return baseOutput + } case 'lambda:function': { const lambdaResource = resource as Lambda.FunctionConfiguration return { diff --git a/src/scanners/getAwsScanners.ts b/src/scanners/getAwsScanners.ts index a63a8b1..3d70acb 100644 --- a/src/scanners/getAwsScanners.ts +++ b/src/scanners/getAwsScanners.ts @@ -36,6 +36,7 @@ import {getCloudWatchMetricAlarms} from './scan-functions/aws/cloudwatch-metric- import {getCloudWatchMetricStreams} from './scan-functions/aws/cloudwatch-metric-streams' import {getEC2VpnGateways} from './scan-functions/aws/ec2-vpn-gateways' import {getEC2NetworkInterfaces} from './scan-functions/aws/ec2-network-interfaces' +import {getAthenaNamedQueries} from './scan-functions/aws/athena-named-queries' interface GetAwsScannersArguments { credentials: Credentials @@ -66,6 +67,7 @@ export const getAwsScanners = ({ // Regional scanners const scanners: Scanner[] = [ + createRegionalScanner('athena/named-queries', getAthenaNamedQueries, regions, options), createRegionalScanner('autoscaling/groups', getAutoScalingResources, regions, options), createRegionalScanner('cloudtrail/trails', getCloudTrailTrails, regions, options), createRegionalScanner('cloudwatch/metric-alarms', getCloudWatchMetricAlarms, regions, options), diff --git a/src/scanners/scan-functions/aws/athena-named-queries.ts b/src/scanners/scan-functions/aws/athena-named-queries.ts new file mode 100644 index 0000000..cd0bc5b --- /dev/null +++ b/src/scanners/scan-functions/aws/athena-named-queries.ts @@ -0,0 +1,50 @@ +import {AthenaClient, ListNamedQueriesCommand, GetNamedQueryCommand, NamedQuery} from '@aws-sdk/client-athena' +import {Credentials, Resources} from '@/types' +import {RateLimiter} from '@/scanners/common/RateLimiter' +import {buildARN} from './common/buildArn' +import {getAwsAccountId} from './common/getAwsAccountId' + +export async function getAthenaNamedQueries( + credentials: Credentials, + rateLimiter: RateLimiter, + region: string, +): Promise> { + const client = new AthenaClient({credentials, region}) + const accountId = await getAwsAccountId() + + const resources: Resources = {} + let nextToken: string | undefined + + do { + const listNamedQueriesCommand = new ListNamedQueriesCommand({ + NextToken: nextToken, + }) + + const listNamedQueriesResponse = await rateLimiter.throttle(() => client.send(listNamedQueriesCommand)) + + if (listNamedQueriesResponse.NamedQueryIds) { + for (const queryId of listNamedQueriesResponse.NamedQueryIds) { + const getNamedQueryCommand = new GetNamedQueryCommand({ + NamedQueryId: queryId, + }) + + const getNamedQueryResponse = await rateLimiter.throttle(() => client.send(getNamedQueryCommand)) + + if (getNamedQueryResponse.NamedQuery) { + const namedQuery = getNamedQueryResponse.NamedQuery + const arn = buildARN({ + service: 'athena', + region, + accountId, + resource: `workgroup/${namedQuery.WorkGroup}/query/${namedQuery.NamedQueryId}`, + }) + resources[arn] = namedQuery + } + } + } + + nextToken = listNamedQueriesResponse.NextToken + } while (nextToken) + + return resources +} diff --git a/src/types.ts b/src/types.ts index 9e165fe..33874cc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,6 +17,7 @@ import type * as SQS from '@aws-sdk/client-sqs' import type * as ElastiCache from '@aws-sdk/client-elasticache' import type * as Redshift from '@aws-sdk/client-redshift' import type * as CloudWatch from '@aws-sdk/client-cloudwatch' +import type * as Athena from '@aws-sdk/client-athena' import type {RateLimiter} from './scanners/common/RateLimiter' import type {AwsCredentialIdentity} from '@aws-sdk/types' @@ -24,6 +25,7 @@ import type {AwsCredentialIdentity} from '@aws-sdk/types' export type SQSQueue = NonNullable export type ResourceDescription = + | Athena.NamedQuery | AutoScaling.AutoScalingGroup | S3.Bucket | CloudFront.DistributionSummary