@infrascan/aws-cloudwatch-logs-scanner 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { AwsCredentialIdentityProvider, RetryStrategy, RetryStrategyV2 } from '@aws-sdk/types';
3
+ import { AwsContext } from '@infrascan/shared-types';
4
+
5
+ declare function getClient(credentials: AwsCredentialIdentityProvider, context: AwsContext, retryStrategy?: RetryStrategy | RetryStrategyV2): CloudWatchLogsClient;
6
+
7
+ export { getClient };
@@ -0,0 +1,7 @@
1
+ import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { AwsCredentialIdentityProvider, RetryStrategy, RetryStrategyV2 } from '@aws-sdk/types';
3
+ import { AwsContext } from '@infrascan/shared-types';
4
+
5
+ declare function getClient(credentials: AwsCredentialIdentityProvider, context: AwsContext, retryStrategy?: RetryStrategy | RetryStrategyV2): CloudWatchLogsClient;
6
+
7
+ export { getClient };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/generated/client.ts
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ getClient: () => getClient
24
+ });
25
+ module.exports = __toCommonJS(client_exports);
26
+ var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
27
+ function getClient(credentials, context, retryStrategy) {
28
+ return new import_client_cloudwatch_logs.CloudWatchLogsClient({
29
+ credentials,
30
+ region: context.region,
31
+ retryStrategy
32
+ });
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ getClient
37
+ });
@@ -0,0 +1,12 @@
1
+ // src/generated/client.ts
2
+ import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
3
+ function getClient(credentials, context, retryStrategy) {
4
+ return new CloudWatchLogsClient({
5
+ credentials,
6
+ region: context.region,
7
+ retryStrategy
8
+ });
9
+ }
10
+ export {
11
+ getClient
12
+ };
@@ -0,0 +1,7 @@
1
+ import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { Connector, AwsContext } from '@infrascan/shared-types';
3
+
4
+ declare function DescribeLogGroups(client: CloudWatchLogsClient, stateConnector: Connector, context: AwsContext): Promise<void>;
5
+ declare function DescribeSubscriptionFilters(client: CloudWatchLogsClient, stateConnector: Connector, context: AwsContext): Promise<void>;
6
+
7
+ export { DescribeLogGroups, DescribeSubscriptionFilters };
@@ -0,0 +1,7 @@
1
+ import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { Connector, AwsContext } from '@infrascan/shared-types';
3
+
4
+ declare function DescribeLogGroups(client: CloudWatchLogsClient, stateConnector: Connector, context: AwsContext): Promise<void>;
5
+ declare function DescribeSubscriptionFilters(client: CloudWatchLogsClient, stateConnector: Connector, context: AwsContext): Promise<void>;
6
+
7
+ export { DescribeLogGroups, DescribeSubscriptionFilters };
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/generated/getters.ts
21
+ var getters_exports = {};
22
+ __export(getters_exports, {
23
+ DescribeLogGroups: () => DescribeLogGroups,
24
+ DescribeSubscriptionFilters: () => DescribeSubscriptionFilters
25
+ });
26
+ module.exports = __toCommonJS(getters_exports);
27
+ var import_core = require("@infrascan/core");
28
+ var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
29
+ async function DescribeLogGroups(client, stateConnector, context) {
30
+ const state = [];
31
+ console.log("cloudwatch-logs DescribeLogGroups");
32
+ let pagingToken;
33
+ do {
34
+ const preparedParams = {};
35
+ preparedParams.nextToken = pagingToken;
36
+ try {
37
+ const cmd = new import_client_cloudwatch_logs.DescribeLogGroupsCommand(preparedParams);
38
+ const result = await client.send(cmd);
39
+ state.push({
40
+ _metadata: { account: context.account, region: context.region },
41
+ _parameters: preparedParams,
42
+ _result: result
43
+ });
44
+ pagingToken = result.nextToken;
45
+ } catch (err) {
46
+ if (err instanceof import_client_cloudwatch_logs.CloudWatchLogsServiceException) {
47
+ if (err?.$retryable) {
48
+ console.log("Encountered retryable error", err);
49
+ } else {
50
+ console.log("Encountered unretryable error", err);
51
+ }
52
+ } else {
53
+ console.log("Encountered unexpected error", err);
54
+ }
55
+ pagingToken = void 0;
56
+ }
57
+ } while (pagingToken != null);
58
+ await stateConnector.onServiceScanCompleteCallback(
59
+ context.account,
60
+ context.region,
61
+ "CloudWatchLogs",
62
+ "DescribeLogGroups",
63
+ state
64
+ );
65
+ }
66
+ async function DescribeSubscriptionFilters(client, stateConnector, context) {
67
+ const state = [];
68
+ console.log("cloudwatch-logs DescribeSubscriptionFilters");
69
+ const resolvers = [
70
+ {
71
+ Key: "logGroupName",
72
+ Selector: "CloudWatchLogs|DescribeLogGroups|[]._result.logGroups[].logGroupName"
73
+ }
74
+ ];
75
+ const parameterQueue = await (0, import_core.resolveFunctionCallParameters)(
76
+ context.account,
77
+ context.region,
78
+ resolvers,
79
+ stateConnector
80
+ );
81
+ for (const parameters of parameterQueue) {
82
+ let pagingToken;
83
+ do {
84
+ const preparedParams = parameters;
85
+ preparedParams.nextToken = pagingToken;
86
+ try {
87
+ const cmd = new import_client_cloudwatch_logs.DescribeSubscriptionFiltersCommand(preparedParams);
88
+ const result = await client.send(cmd);
89
+ state.push({
90
+ _metadata: { account: context.account, region: context.region },
91
+ _parameters: preparedParams,
92
+ _result: result
93
+ });
94
+ pagingToken = result.nextToken;
95
+ } catch (err) {
96
+ if (err instanceof import_client_cloudwatch_logs.CloudWatchLogsServiceException) {
97
+ if (err?.$retryable) {
98
+ console.log("Encountered retryable error", err);
99
+ } else {
100
+ console.log("Encountered unretryable error", err);
101
+ }
102
+ } else {
103
+ console.log("Encountered unexpected error", err);
104
+ }
105
+ pagingToken = void 0;
106
+ }
107
+ } while (pagingToken != null);
108
+ }
109
+ await stateConnector.onServiceScanCompleteCallback(
110
+ context.account,
111
+ context.region,
112
+ "CloudWatchLogs",
113
+ "DescribeSubscriptionFilters",
114
+ state
115
+ );
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ DescribeLogGroups,
120
+ DescribeSubscriptionFilters
121
+ });
@@ -0,0 +1,99 @@
1
+ // src/generated/getters.ts
2
+ import { resolveFunctionCallParameters } from "@infrascan/core";
3
+ import {
4
+ CloudWatchLogsServiceException,
5
+ DescribeLogGroupsCommand,
6
+ DescribeSubscriptionFiltersCommand
7
+ } from "@aws-sdk/client-cloudwatch-logs";
8
+ async function DescribeLogGroups(client, stateConnector, context) {
9
+ const state = [];
10
+ console.log("cloudwatch-logs DescribeLogGroups");
11
+ let pagingToken;
12
+ do {
13
+ const preparedParams = {};
14
+ preparedParams.nextToken = pagingToken;
15
+ try {
16
+ const cmd = new DescribeLogGroupsCommand(preparedParams);
17
+ const result = await client.send(cmd);
18
+ state.push({
19
+ _metadata: { account: context.account, region: context.region },
20
+ _parameters: preparedParams,
21
+ _result: result
22
+ });
23
+ pagingToken = result.nextToken;
24
+ } catch (err) {
25
+ if (err instanceof CloudWatchLogsServiceException) {
26
+ if (err?.$retryable) {
27
+ console.log("Encountered retryable error", err);
28
+ } else {
29
+ console.log("Encountered unretryable error", err);
30
+ }
31
+ } else {
32
+ console.log("Encountered unexpected error", err);
33
+ }
34
+ pagingToken = void 0;
35
+ }
36
+ } while (pagingToken != null);
37
+ await stateConnector.onServiceScanCompleteCallback(
38
+ context.account,
39
+ context.region,
40
+ "CloudWatchLogs",
41
+ "DescribeLogGroups",
42
+ state
43
+ );
44
+ }
45
+ async function DescribeSubscriptionFilters(client, stateConnector, context) {
46
+ const state = [];
47
+ console.log("cloudwatch-logs DescribeSubscriptionFilters");
48
+ const resolvers = [
49
+ {
50
+ Key: "logGroupName",
51
+ Selector: "CloudWatchLogs|DescribeLogGroups|[]._result.logGroups[].logGroupName"
52
+ }
53
+ ];
54
+ const parameterQueue = await resolveFunctionCallParameters(
55
+ context.account,
56
+ context.region,
57
+ resolvers,
58
+ stateConnector
59
+ );
60
+ for (const parameters of parameterQueue) {
61
+ let pagingToken;
62
+ do {
63
+ const preparedParams = parameters;
64
+ preparedParams.nextToken = pagingToken;
65
+ try {
66
+ const cmd = new DescribeSubscriptionFiltersCommand(preparedParams);
67
+ const result = await client.send(cmd);
68
+ state.push({
69
+ _metadata: { account: context.account, region: context.region },
70
+ _parameters: preparedParams,
71
+ _result: result
72
+ });
73
+ pagingToken = result.nextToken;
74
+ } catch (err) {
75
+ if (err instanceof CloudWatchLogsServiceException) {
76
+ if (err?.$retryable) {
77
+ console.log("Encountered retryable error", err);
78
+ } else {
79
+ console.log("Encountered unretryable error", err);
80
+ }
81
+ } else {
82
+ console.log("Encountered unexpected error", err);
83
+ }
84
+ pagingToken = void 0;
85
+ }
86
+ } while (pagingToken != null);
87
+ }
88
+ await stateConnector.onServiceScanCompleteCallback(
89
+ context.account,
90
+ context.region,
91
+ "CloudWatchLogs",
92
+ "DescribeSubscriptionFilters",
93
+ state
94
+ );
95
+ }
96
+ export {
97
+ DescribeLogGroups,
98
+ DescribeSubscriptionFilters
99
+ };
@@ -0,0 +1,6 @@
1
+ import { Connector, AwsContext, GraphNode, GraphEdge } from '@infrascan/shared-types';
2
+
3
+ declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<GraphNode[]>;
4
+ declare function getEdges(stateConnector: Connector): Promise<GraphEdge[]>;
5
+
6
+ export { getEdges, getNodes };
@@ -0,0 +1,6 @@
1
+ import { Connector, AwsContext, GraphNode, GraphEdge } from '@infrascan/shared-types';
2
+
3
+ declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<GraphNode[]>;
4
+ declare function getEdges(stateConnector: Connector): Promise<GraphEdge[]>;
5
+
6
+ export { getEdges, getNodes };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/generated/graph.ts
21
+ var graph_exports = {};
22
+ __export(graph_exports, {
23
+ getEdges: () => getEdges,
24
+ getNodes: () => getNodes
25
+ });
26
+ module.exports = __toCommonJS(graph_exports);
27
+ var import_core = require("@infrascan/core");
28
+ async function getNodes(stateConnector, context) {
29
+ const state = [];
30
+ const DescribeSubscriptionFiltersNodes = await (0, import_core.evaluateSelector)(
31
+ context.account,
32
+ context.region,
33
+ "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
34
+ stateConnector
35
+ );
36
+ state.push(...DescribeSubscriptionFiltersNodes);
37
+ return state.map(
38
+ (node) => (0, import_core.formatNode)(node, "cloudwatch-logs", "CloudWatchLogs", context, true)
39
+ );
40
+ }
41
+ async function getEdges(stateConnector) {
42
+ const edges = [];
43
+ const DescribeSubscriptionFiltersState1 = await (0, import_core.evaluateSelectorGlobally)(
44
+ "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
45
+ stateConnector
46
+ );
47
+ const DescribeSubscriptionFiltersEdges1 = DescribeSubscriptionFiltersState1.flatMap((state) => {
48
+ const source = (0, import_core.filterState)(state, "logGroupName");
49
+ const target = (0, import_core.filterState)(
50
+ state,
51
+ "{target:destinationArn}"
52
+ );
53
+ if (!target || !source) {
54
+ return [];
55
+ }
56
+ if (Array.isArray(target)) {
57
+ return target.map((edgeTarget) => (0, import_core.formatEdge)(source, edgeTarget));
58
+ }
59
+ return (0, import_core.formatEdge)(source, target);
60
+ });
61
+ edges.push(...DescribeSubscriptionFiltersEdges1);
62
+ return edges;
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ getEdges,
67
+ getNodes
68
+ });
@@ -0,0 +1,48 @@
1
+ // src/generated/graph.ts
2
+ import {
3
+ evaluateSelector,
4
+ formatNode,
5
+ evaluateSelectorGlobally,
6
+ filterState,
7
+ formatEdge
8
+ } from "@infrascan/core";
9
+ async function getNodes(stateConnector, context) {
10
+ const state = [];
11
+ const DescribeSubscriptionFiltersNodes = await evaluateSelector(
12
+ context.account,
13
+ context.region,
14
+ "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
15
+ stateConnector
16
+ );
17
+ state.push(...DescribeSubscriptionFiltersNodes);
18
+ return state.map(
19
+ (node) => formatNode(node, "cloudwatch-logs", "CloudWatchLogs", context, true)
20
+ );
21
+ }
22
+ async function getEdges(stateConnector) {
23
+ const edges = [];
24
+ const DescribeSubscriptionFiltersState1 = await evaluateSelectorGlobally(
25
+ "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
26
+ stateConnector
27
+ );
28
+ const DescribeSubscriptionFiltersEdges1 = DescribeSubscriptionFiltersState1.flatMap((state) => {
29
+ const source = filterState(state, "logGroupName");
30
+ const target = filterState(
31
+ state,
32
+ "{target:destinationArn}"
33
+ );
34
+ if (!target || !source) {
35
+ return [];
36
+ }
37
+ if (Array.isArray(target)) {
38
+ return target.map((edgeTarget) => formatEdge(source, edgeTarget));
39
+ }
40
+ return formatEdge(source, target);
41
+ });
42
+ edges.push(...DescribeSubscriptionFiltersEdges1);
43
+ return edges;
44
+ }
45
+ export {
46
+ getEdges,
47
+ getNodes
48
+ };
package/dist/index.js CHANGED
@@ -26,17 +26,21 @@ module.exports = __toCommonJS(src_exports);
26
26
 
27
27
  // src/generated/client.ts
28
28
  var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
29
- function getClient(credentials, context) {
30
- return new import_client_cloudwatch_logs.CloudWatchLogsClient({ credentials, region: context.region });
29
+ function getClient(credentials, context, retryStrategy) {
30
+ return new import_client_cloudwatch_logs.CloudWatchLogsClient({
31
+ credentials,
32
+ region: context.region,
33
+ retryStrategy
34
+ });
31
35
  }
32
36
 
33
37
  // src/generated/getters.ts
34
- var import_client_cloudwatch_logs2 = require("@aws-sdk/client-cloudwatch-logs");
35
38
  var import_core = require("@infrascan/core");
39
+ var import_client_cloudwatch_logs2 = require("@aws-sdk/client-cloudwatch-logs");
36
40
  async function DescribeLogGroups(client, stateConnector, context) {
37
41
  const state = [];
38
42
  console.log("cloudwatch-logs DescribeLogGroups");
39
- let pagingToken = void 0;
43
+ let pagingToken;
40
44
  do {
41
45
  const preparedParams = {};
42
46
  preparedParams.nextToken = pagingToken;
@@ -86,7 +90,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
86
90
  stateConnector
87
91
  );
88
92
  for (const parameters of parameterQueue) {
89
- let pagingToken = void 0;
93
+ let pagingToken;
90
94
  do {
91
95
  const preparedParams = parameters;
92
96
  preparedParams.nextToken = pagingToken;
package/dist/index.mjs CHANGED
@@ -1,20 +1,24 @@
1
1
  // src/generated/client.ts
2
2
  import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
3
- function getClient(credentials, context) {
4
- return new CloudWatchLogsClient({ credentials, region: context.region });
3
+ function getClient(credentials, context, retryStrategy) {
4
+ return new CloudWatchLogsClient({
5
+ credentials,
6
+ region: context.region,
7
+ retryStrategy
8
+ });
5
9
  }
6
10
 
7
11
  // src/generated/getters.ts
12
+ import { resolveFunctionCallParameters } from "@infrascan/core";
8
13
  import {
14
+ CloudWatchLogsServiceException,
9
15
  DescribeLogGroupsCommand,
10
- DescribeSubscriptionFiltersCommand,
11
- CloudWatchLogsServiceException
16
+ DescribeSubscriptionFiltersCommand
12
17
  } from "@aws-sdk/client-cloudwatch-logs";
13
- import { resolveFunctionCallParameters } from "@infrascan/core";
14
18
  async function DescribeLogGroups(client, stateConnector, context) {
15
19
  const state = [];
16
20
  console.log("cloudwatch-logs DescribeLogGroups");
17
- let pagingToken = void 0;
21
+ let pagingToken;
18
22
  do {
19
23
  const preparedParams = {};
20
24
  preparedParams.nextToken = pagingToken;
@@ -64,7 +68,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
64
68
  stateConnector
65
69
  );
66
70
  for (const parameters of parameterQueue) {
67
- let pagingToken = void 0;
71
+ let pagingToken;
68
72
  do {
69
73
  const preparedParams = parameters;
70
74
  preparedParams.nextToken = pagingToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrascan/aws-cloudwatch-logs-scanner",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Infrascan scanner definition for AWS Cloudwatch Logs",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  "splitting": false,
23
23
  "sourcemap": false,
24
24
  "entry": [
25
- "src/index.ts"
25
+ "src/**/*.ts"
26
26
  ],
27
27
  "format": [
28
28
  "cjs",
@@ -60,13 +60,13 @@
60
60
  "@aws-sdk/credential-providers": "^3.428.0",
61
61
  "@infrascan/aws-codegen": "^0.1.0",
62
62
  "@infrascan/fs-connector": "^0.2.2",
63
- "@infrascan/shared-types": "^0.2.2",
63
+ "@infrascan/shared-types": "^0.2.4",
64
64
  "aws-sdk-client-mock": "^3.0.0",
65
65
  "eslint-config-codegen": "^1.0.0",
66
66
  "tsconfig": "^0.0.0"
67
67
  },
68
68
  "dependencies": {
69
69
  "@aws-sdk/client-cloudwatch-logs": "3.428.0",
70
- "@infrascan/core": "0.2.2"
70
+ "@infrascan/core": "0.2.3"
71
71
  }
72
- }
72
+ }