@infrascan/aws-cloudwatch-logs-scanner 0.3.2 → 0.4.1

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.
@@ -49,7 +49,11 @@ async function DescribeLogGroups(client, stateConnector, context) {
49
49
  const cmd = new import_client_cloudwatch_logs.DescribeLogGroupsCommand(preparedParams);
50
50
  const result = await client.send(cmd);
51
51
  state.push({
52
- _metadata: { account: context.account, region: context.region },
52
+ _metadata: {
53
+ account: context.account,
54
+ region: context.region,
55
+ timestamp: Date.now()
56
+ },
53
57
  _parameters: preparedParams,
54
58
  _result: result
55
59
  });
@@ -106,7 +110,11 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
106
110
  const cmd = new import_client_cloudwatch_logs.DescribeSubscriptionFiltersCommand(preparedParams);
107
111
  const result = await client.send(cmd);
108
112
  state.push({
109
- _metadata: { account: context.account, region: context.region },
113
+ _metadata: {
114
+ account: context.account,
115
+ region: context.region,
116
+ timestamp: Date.now()
117
+ },
110
118
  _parameters: preparedParams,
111
119
  _result: result
112
120
  });
@@ -18,7 +18,11 @@ async function DescribeLogGroups(client, stateConnector, context) {
18
18
  const cmd = new DescribeLogGroupsCommand(preparedParams);
19
19
  const result = await client.send(cmd);
20
20
  state.push({
21
- _metadata: { account: context.account, region: context.region },
21
+ _metadata: {
22
+ account: context.account,
23
+ region: context.region,
24
+ timestamp: Date.now()
25
+ },
22
26
  _parameters: preparedParams,
23
27
  _result: result
24
28
  });
@@ -75,7 +79,11 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
75
79
  const cmd = new DescribeSubscriptionFiltersCommand(preparedParams);
76
80
  const result = await client.send(cmd);
77
81
  state.push({
78
- _metadata: { account: context.account, region: context.region },
82
+ _metadata: {
83
+ account: context.account,
84
+ region: context.region,
85
+ timestamp: Date.now()
86
+ },
79
87
  _parameters: preparedParams,
80
88
  _result: result
81
89
  });
@@ -1,6 +1,5 @@
1
- import { Connector, AwsContext, SelectedNode, SelectedEdge } from '@infrascan/shared-types';
1
+ import { Connector, SelectedEdge } from '@infrascan/shared-types';
2
2
 
3
- declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<SelectedNode[]>;
4
3
  declare function getEdges(stateConnector: Connector): Promise<SelectedEdge[]>;
5
4
 
6
- export { getEdges, getNodes };
5
+ export { getEdges };
@@ -1,6 +1,5 @@
1
- import { Connector, AwsContext, SelectedNode, SelectedEdge } from '@infrascan/shared-types';
1
+ import { Connector, SelectedEdge } from '@infrascan/shared-types';
2
2
 
3
- declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<SelectedNode[]>;
4
3
  declare function getEdges(stateConnector: Connector): Promise<SelectedEdge[]>;
5
4
 
6
- export { getEdges, getNodes };
5
+ export { getEdges };
@@ -30,31 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/generated/graph.ts
31
31
  var graph_exports = {};
32
32
  __export(graph_exports, {
33
- getEdges: () => getEdges,
34
- getNodes: () => getNodes
33
+ getEdges: () => getEdges
35
34
  });
36
35
  module.exports = __toCommonJS(graph_exports);
37
36
  var import_core = require("@infrascan/core");
38
37
  var import_debug = __toESM(require("debug"));
39
- var nodesDebug = (0, import_debug.default)("cloudwatch-logs:nodes");
40
- async function getNodes(stateConnector, context) {
41
- nodesDebug("Fetching nodes");
42
- const state = [];
43
- nodesDebug(
44
- "Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}"
45
- );
46
- const DescribeSubscriptionFiltersNodes = await (0, import_core.evaluateSelector)(
47
- context.account,
48
- context.region,
49
- "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
50
- stateConnector
51
- );
52
- nodesDebug(
53
- `Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}: ${DescribeSubscriptionFiltersNodes.length} Nodes found`
54
- );
55
- state.push(...DescribeSubscriptionFiltersNodes);
56
- return state.map((node) => (0, import_core.formatNode)(node, "CloudWatchLogs", context, true));
57
- }
58
38
  var edgesDebug = (0, import_debug.default)("cloudwatch-logs:edges");
59
39
  async function getEdges(stateConnector) {
60
40
  edgesDebug("Fetching edges");
@@ -85,6 +65,5 @@ async function getEdges(stateConnector) {
85
65
  }
86
66
  // Annotate the CommonJS export names for ESM import in node:
87
67
  0 && (module.exports = {
88
- getEdges,
89
- getNodes
68
+ getEdges
90
69
  });
@@ -1,31 +1,10 @@
1
1
  // src/generated/graph.ts
2
2
  import {
3
- evaluateSelector,
4
- formatNode,
5
3
  evaluateSelectorGlobally,
6
4
  filterState,
7
5
  formatEdge
8
6
  } from "@infrascan/core";
9
7
  import debug from "debug";
10
- var nodesDebug = debug("cloudwatch-logs:nodes");
11
- async function getNodes(stateConnector, context) {
12
- nodesDebug("Fetching nodes");
13
- const state = [];
14
- nodesDebug(
15
- "Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}"
16
- );
17
- const DescribeSubscriptionFiltersNodes = await evaluateSelector(
18
- context.account,
19
- context.region,
20
- "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
21
- stateConnector
22
- );
23
- nodesDebug(
24
- `Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}: ${DescribeSubscriptionFiltersNodes.length} Nodes found`
25
- );
26
- state.push(...DescribeSubscriptionFiltersNodes);
27
- return state.map((node) => formatNode(node, "CloudWatchLogs", context, true));
28
- }
29
8
  var edgesDebug = debug("cloudwatch-logs:edges");
30
9
  async function getEdges(stateConnector) {
31
10
  edgesDebug("Fetching edges");
@@ -55,6 +34,5 @@ async function getEdges(stateConnector) {
55
34
  return edges;
56
35
  }
57
36
  export {
58
- getEdges,
59
- getNodes
37
+ getEdges
60
38
  };
@@ -0,0 +1,15 @@
1
+ import { DescribeLogGroupsCommandInput, DescribeLogGroupsCommandOutput, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { BaseState, QualifiedMeasure, TimeUnit, SizeUnit, TranslatedEntity, State, WithCallContext } from '@infrascan/shared-types';
3
+
4
+ type CloudwatchLogGroup = BaseState<DescribeLogGroupsCommandInput> & {
5
+ logGroup: {
6
+ dataProtectionStatus?: string;
7
+ accessClass?: string;
8
+ metricFilterCount?: number;
9
+ retentionPeriod?: QualifiedMeasure<TimeUnit>;
10
+ size?: QualifiedMeasure<SizeUnit>;
11
+ };
12
+ };
13
+ declare const CloudwatchLogGroupEntity: TranslatedEntity<CloudwatchLogGroup, State<DescribeLogGroupsCommandOutput, DescribeLogGroupsCommandInput>, WithCallContext<LogGroup, DescribeLogGroupsCommandInput>>;
14
+
15
+ export { type CloudwatchLogGroup, CloudwatchLogGroupEntity };
@@ -0,0 +1,15 @@
1
+ import { DescribeLogGroupsCommandInput, DescribeLogGroupsCommandOutput, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
2
+ import { BaseState, QualifiedMeasure, TimeUnit, SizeUnit, TranslatedEntity, State, WithCallContext } from '@infrascan/shared-types';
3
+
4
+ type CloudwatchLogGroup = BaseState<DescribeLogGroupsCommandInput> & {
5
+ logGroup: {
6
+ dataProtectionStatus?: string;
7
+ accessClass?: string;
8
+ metricFilterCount?: number;
9
+ retentionPeriod?: QualifiedMeasure<TimeUnit>;
10
+ size?: QualifiedMeasure<SizeUnit>;
11
+ };
12
+ };
13
+ declare const CloudwatchLogGroupEntity: TranslatedEntity<CloudwatchLogGroup, State<DescribeLogGroupsCommandOutput, DescribeLogGroupsCommandInput>, WithCallContext<LogGroup, DescribeLogGroupsCommandInput>>;
14
+
15
+ export { type CloudwatchLogGroup, CloudwatchLogGroupEntity };
package/dist/graph.js ADDED
@@ -0,0 +1,123 @@
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/graph.ts
21
+ var graph_exports = {};
22
+ __export(graph_exports, {
23
+ CloudwatchLogGroupEntity: () => CloudwatchLogGroupEntity
24
+ });
25
+ module.exports = __toCommonJS(graph_exports);
26
+ var import_core = require("@infrascan/core");
27
+ var CloudwatchLogGroupEntity = {
28
+ version: "0.1.0",
29
+ debugLabel: "cloudwatch-logs",
30
+ provider: "aws",
31
+ command: "DescribeLogGroups",
32
+ category: "cloudwatch",
33
+ subcategory: "logs",
34
+ nodeType: "cloudwatch-logs",
35
+ selector: "CloudWatchLogs|DescribeLogGroups|[]",
36
+ getState(state, context) {
37
+ return (0, import_core.evaluateSelector)(
38
+ context.account,
39
+ context.region,
40
+ CloudwatchLogGroupEntity.selector,
41
+ state
42
+ );
43
+ },
44
+ translate(val) {
45
+ return (val._result.logGroups ?? []).map(
46
+ (group) => Object.assign(group, {
47
+ $metadata: val._metadata,
48
+ $parameters: val._parameters
49
+ })
50
+ );
51
+ },
52
+ components: {
53
+ $metadata(val) {
54
+ return {
55
+ version: CloudwatchLogGroupEntity.version,
56
+ timestamp: val.$metadata.timestamp
57
+ };
58
+ },
59
+ $graph(val) {
60
+ return {
61
+ id: val.logGroupArn ?? val.arn,
62
+ label: val.logGroupName,
63
+ nodeType: CloudwatchLogGroupEntity.nodeType,
64
+ parent: `${val.$metadata.account}-${val.$metadata.region}`
65
+ };
66
+ },
67
+ $source(val) {
68
+ return {
69
+ command: CloudwatchLogGroupEntity.command,
70
+ parameters: val.$parameters
71
+ };
72
+ },
73
+ tenant(val) {
74
+ return {
75
+ tenantId: val.$metadata.account,
76
+ provider: CloudwatchLogGroupEntity.provider,
77
+ partition: val.$metadata.partition
78
+ };
79
+ },
80
+ location(val) {
81
+ return {
82
+ code: val.$metadata.region
83
+ };
84
+ },
85
+ resource(val) {
86
+ return {
87
+ id: val.logGroupArn,
88
+ name: val.logGroupName,
89
+ category: CloudwatchLogGroupEntity.category,
90
+ subcategory: CloudwatchLogGroupEntity.subcategory
91
+ };
92
+ },
93
+ audit(val) {
94
+ return {
95
+ createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
96
+ };
97
+ },
98
+ encryption(val) {
99
+ return {
100
+ keyId: val.kmsKeyId
101
+ };
102
+ },
103
+ logGroup(val) {
104
+ return {
105
+ accessClass: val.logGroupClass != null ? (0, import_core.toLowerCase)(val.logGroupClass) : void 0,
106
+ dataProtectionStatus: val.dataProtectionStatus != null ? (0, import_core.toLowerCase)(val.dataProtectionStatus) : void 0,
107
+ retentionPeriod: val.retentionInDays != null ? {
108
+ unit: import_core.Time.Days,
109
+ value: val.retentionInDays
110
+ } : void 0,
111
+ size: val.storedBytes != null ? {
112
+ unit: import_core.Size.Bytes,
113
+ value: val.storedBytes
114
+ } : void 0,
115
+ metricFilterCount: val.metricFilterCount
116
+ };
117
+ }
118
+ }
119
+ };
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ CloudwatchLogGroupEntity
123
+ });
package/dist/graph.mjs ADDED
@@ -0,0 +1,98 @@
1
+ // src/graph.ts
2
+ import { evaluateSelector, toLowerCase, Time, Size } from "@infrascan/core";
3
+ var CloudwatchLogGroupEntity = {
4
+ version: "0.1.0",
5
+ debugLabel: "cloudwatch-logs",
6
+ provider: "aws",
7
+ command: "DescribeLogGroups",
8
+ category: "cloudwatch",
9
+ subcategory: "logs",
10
+ nodeType: "cloudwatch-logs",
11
+ selector: "CloudWatchLogs|DescribeLogGroups|[]",
12
+ getState(state, context) {
13
+ return evaluateSelector(
14
+ context.account,
15
+ context.region,
16
+ CloudwatchLogGroupEntity.selector,
17
+ state
18
+ );
19
+ },
20
+ translate(val) {
21
+ return (val._result.logGroups ?? []).map(
22
+ (group) => Object.assign(group, {
23
+ $metadata: val._metadata,
24
+ $parameters: val._parameters
25
+ })
26
+ );
27
+ },
28
+ components: {
29
+ $metadata(val) {
30
+ return {
31
+ version: CloudwatchLogGroupEntity.version,
32
+ timestamp: val.$metadata.timestamp
33
+ };
34
+ },
35
+ $graph(val) {
36
+ return {
37
+ id: val.logGroupArn ?? val.arn,
38
+ label: val.logGroupName,
39
+ nodeType: CloudwatchLogGroupEntity.nodeType,
40
+ parent: `${val.$metadata.account}-${val.$metadata.region}`
41
+ };
42
+ },
43
+ $source(val) {
44
+ return {
45
+ command: CloudwatchLogGroupEntity.command,
46
+ parameters: val.$parameters
47
+ };
48
+ },
49
+ tenant(val) {
50
+ return {
51
+ tenantId: val.$metadata.account,
52
+ provider: CloudwatchLogGroupEntity.provider,
53
+ partition: val.$metadata.partition
54
+ };
55
+ },
56
+ location(val) {
57
+ return {
58
+ code: val.$metadata.region
59
+ };
60
+ },
61
+ resource(val) {
62
+ return {
63
+ id: val.logGroupArn,
64
+ name: val.logGroupName,
65
+ category: CloudwatchLogGroupEntity.category,
66
+ subcategory: CloudwatchLogGroupEntity.subcategory
67
+ };
68
+ },
69
+ audit(val) {
70
+ return {
71
+ createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
72
+ };
73
+ },
74
+ encryption(val) {
75
+ return {
76
+ keyId: val.kmsKeyId
77
+ };
78
+ },
79
+ logGroup(val) {
80
+ return {
81
+ accessClass: val.logGroupClass != null ? toLowerCase(val.logGroupClass) : void 0,
82
+ dataProtectionStatus: val.dataProtectionStatus != null ? toLowerCase(val.dataProtectionStatus) : void 0,
83
+ retentionPeriod: val.retentionInDays != null ? {
84
+ unit: Time.Days,
85
+ value: val.retentionInDays
86
+ } : void 0,
87
+ size: val.storedBytes != null ? {
88
+ unit: Size.Bytes,
89
+ value: val.storedBytes
90
+ } : void 0,
91
+ metricFilterCount: val.metricFilterCount
92
+ };
93
+ }
94
+ }
95
+ };
96
+ export {
97
+ CloudwatchLogGroupEntity
98
+ };
package/dist/index.js CHANGED
@@ -28,11 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- default: () => src_default
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ default: () => index_default
34
34
  });
35
- module.exports = __toCommonJS(src_exports);
35
+ module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/generated/client.ts
38
38
  var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
@@ -63,7 +63,11 @@ async function DescribeLogGroups(client, stateConnector, context) {
63
63
  const cmd = new import_client_cloudwatch_logs2.DescribeLogGroupsCommand(preparedParams);
64
64
  const result = await client.send(cmd);
65
65
  state.push({
66
- _metadata: { account: context.account, region: context.region },
66
+ _metadata: {
67
+ account: context.account,
68
+ region: context.region,
69
+ timestamp: Date.now()
70
+ },
67
71
  _parameters: preparedParams,
68
72
  _result: result
69
73
  });
@@ -120,7 +124,11 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
120
124
  const cmd = new import_client_cloudwatch_logs2.DescribeSubscriptionFiltersCommand(preparedParams);
121
125
  const result = await client.send(cmd);
122
126
  state.push({
123
- _metadata: { account: context.account, region: context.region },
127
+ _metadata: {
128
+ account: context.account,
129
+ region: context.region,
130
+ timestamp: Date.now()
131
+ },
124
132
  _parameters: preparedParams,
125
133
  _result: result
126
134
  });
@@ -157,25 +165,6 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
157
165
  // src/generated/graph.ts
158
166
  var import_core2 = require("@infrascan/core");
159
167
  var import_debug3 = __toESM(require("debug"));
160
- var nodesDebug = (0, import_debug3.default)("cloudwatch-logs:nodes");
161
- async function getNodes(stateConnector, context) {
162
- nodesDebug("Fetching nodes");
163
- const state = [];
164
- nodesDebug(
165
- "Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}"
166
- );
167
- const DescribeSubscriptionFiltersNodes = await (0, import_core2.evaluateSelector)(
168
- context.account,
169
- context.region,
170
- "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
171
- stateConnector
172
- );
173
- nodesDebug(
174
- `Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}: ${DescribeSubscriptionFiltersNodes.length} Nodes found`
175
- );
176
- state.push(...DescribeSubscriptionFiltersNodes);
177
- return state.map((node) => (0, import_core2.formatNode)(node, "CloudWatchLogs", context, true));
178
- }
179
168
  var edgesDebug = (0, import_debug3.default)("cloudwatch-logs:edges");
180
169
  async function getEdges(stateConnector) {
181
170
  edgesDebug("Fetching edges");
@@ -205,6 +194,102 @@ async function getEdges(stateConnector) {
205
194
  return edges;
206
195
  }
207
196
 
197
+ // src/graph.ts
198
+ var import_core3 = require("@infrascan/core");
199
+ var CloudwatchLogGroupEntity = {
200
+ version: "0.1.0",
201
+ debugLabel: "cloudwatch-logs",
202
+ provider: "aws",
203
+ command: "DescribeLogGroups",
204
+ category: "cloudwatch",
205
+ subcategory: "logs",
206
+ nodeType: "cloudwatch-logs",
207
+ selector: "CloudWatchLogs|DescribeLogGroups|[]",
208
+ getState(state, context) {
209
+ return (0, import_core3.evaluateSelector)(
210
+ context.account,
211
+ context.region,
212
+ CloudwatchLogGroupEntity.selector,
213
+ state
214
+ );
215
+ },
216
+ translate(val) {
217
+ return (val._result.logGroups ?? []).map(
218
+ (group) => Object.assign(group, {
219
+ $metadata: val._metadata,
220
+ $parameters: val._parameters
221
+ })
222
+ );
223
+ },
224
+ components: {
225
+ $metadata(val) {
226
+ return {
227
+ version: CloudwatchLogGroupEntity.version,
228
+ timestamp: val.$metadata.timestamp
229
+ };
230
+ },
231
+ $graph(val) {
232
+ return {
233
+ id: val.logGroupArn ?? val.arn,
234
+ label: val.logGroupName,
235
+ nodeType: CloudwatchLogGroupEntity.nodeType,
236
+ parent: `${val.$metadata.account}-${val.$metadata.region}`
237
+ };
238
+ },
239
+ $source(val) {
240
+ return {
241
+ command: CloudwatchLogGroupEntity.command,
242
+ parameters: val.$parameters
243
+ };
244
+ },
245
+ tenant(val) {
246
+ return {
247
+ tenantId: val.$metadata.account,
248
+ provider: CloudwatchLogGroupEntity.provider,
249
+ partition: val.$metadata.partition
250
+ };
251
+ },
252
+ location(val) {
253
+ return {
254
+ code: val.$metadata.region
255
+ };
256
+ },
257
+ resource(val) {
258
+ return {
259
+ id: val.logGroupArn,
260
+ name: val.logGroupName,
261
+ category: CloudwatchLogGroupEntity.category,
262
+ subcategory: CloudwatchLogGroupEntity.subcategory
263
+ };
264
+ },
265
+ audit(val) {
266
+ return {
267
+ createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
268
+ };
269
+ },
270
+ encryption(val) {
271
+ return {
272
+ keyId: val.kmsKeyId
273
+ };
274
+ },
275
+ logGroup(val) {
276
+ return {
277
+ accessClass: val.logGroupClass != null ? (0, import_core3.toLowerCase)(val.logGroupClass) : void 0,
278
+ dataProtectionStatus: val.dataProtectionStatus != null ? (0, import_core3.toLowerCase)(val.dataProtectionStatus) : void 0,
279
+ retentionPeriod: val.retentionInDays != null ? {
280
+ unit: import_core3.Time.Days,
281
+ value: val.retentionInDays
282
+ } : void 0,
283
+ size: val.storedBytes != null ? {
284
+ unit: import_core3.Size.Bytes,
285
+ value: val.storedBytes
286
+ } : void 0,
287
+ metricFilterCount: val.metricFilterCount
288
+ };
289
+ }
290
+ }
291
+ };
292
+
208
293
  // src/index.ts
209
294
  var CloudWatchLogsScanner = {
210
295
  provider: "aws",
@@ -214,7 +299,7 @@ var CloudWatchLogsScanner = {
214
299
  getClient,
215
300
  callPerRegion: true,
216
301
  getters: [DescribeLogGroups, DescribeSubscriptionFilters],
217
- getNodes,
218
- getEdges
302
+ getEdges,
303
+ entities: [CloudwatchLogGroupEntity]
219
304
  };
220
- var src_default = CloudWatchLogsScanner;
305
+ var index_default = CloudWatchLogsScanner;
package/dist/index.mjs CHANGED
@@ -31,7 +31,11 @@ async function DescribeLogGroups(client, stateConnector, context) {
31
31
  const cmd = new DescribeLogGroupsCommand(preparedParams);
32
32
  const result = await client.send(cmd);
33
33
  state.push({
34
- _metadata: { account: context.account, region: context.region },
34
+ _metadata: {
35
+ account: context.account,
36
+ region: context.region,
37
+ timestamp: Date.now()
38
+ },
35
39
  _parameters: preparedParams,
36
40
  _result: result
37
41
  });
@@ -88,7 +92,11 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
88
92
  const cmd = new DescribeSubscriptionFiltersCommand(preparedParams);
89
93
  const result = await client.send(cmd);
90
94
  state.push({
91
- _metadata: { account: context.account, region: context.region },
95
+ _metadata: {
96
+ account: context.account,
97
+ region: context.region,
98
+ timestamp: Date.now()
99
+ },
92
100
  _parameters: preparedParams,
93
101
  _result: result
94
102
  });
@@ -124,32 +132,11 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
124
132
 
125
133
  // src/generated/graph.ts
126
134
  import {
127
- evaluateSelector,
128
- formatNode,
129
135
  evaluateSelectorGlobally,
130
136
  filterState,
131
137
  formatEdge
132
138
  } from "@infrascan/core";
133
139
  import debug3 from "debug";
134
- var nodesDebug = debug3("cloudwatch-logs:nodes");
135
- async function getNodes(stateConnector, context) {
136
- nodesDebug("Fetching nodes");
137
- const state = [];
138
- nodesDebug(
139
- "Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}"
140
- );
141
- const DescribeSubscriptionFiltersNodes = await evaluateSelector(
142
- context.account,
143
- context.region,
144
- "CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
145
- stateConnector
146
- );
147
- nodesDebug(
148
- `Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}: ${DescribeSubscriptionFiltersNodes.length} Nodes found`
149
- );
150
- state.push(...DescribeSubscriptionFiltersNodes);
151
- return state.map((node) => formatNode(node, "CloudWatchLogs", context, true));
152
- }
153
140
  var edgesDebug = debug3("cloudwatch-logs:edges");
154
141
  async function getEdges(stateConnector) {
155
142
  edgesDebug("Fetching edges");
@@ -179,6 +166,102 @@ async function getEdges(stateConnector) {
179
166
  return edges;
180
167
  }
181
168
 
169
+ // src/graph.ts
170
+ import { evaluateSelector, toLowerCase, Time, Size } from "@infrascan/core";
171
+ var CloudwatchLogGroupEntity = {
172
+ version: "0.1.0",
173
+ debugLabel: "cloudwatch-logs",
174
+ provider: "aws",
175
+ command: "DescribeLogGroups",
176
+ category: "cloudwatch",
177
+ subcategory: "logs",
178
+ nodeType: "cloudwatch-logs",
179
+ selector: "CloudWatchLogs|DescribeLogGroups|[]",
180
+ getState(state, context) {
181
+ return evaluateSelector(
182
+ context.account,
183
+ context.region,
184
+ CloudwatchLogGroupEntity.selector,
185
+ state
186
+ );
187
+ },
188
+ translate(val) {
189
+ return (val._result.logGroups ?? []).map(
190
+ (group) => Object.assign(group, {
191
+ $metadata: val._metadata,
192
+ $parameters: val._parameters
193
+ })
194
+ );
195
+ },
196
+ components: {
197
+ $metadata(val) {
198
+ return {
199
+ version: CloudwatchLogGroupEntity.version,
200
+ timestamp: val.$metadata.timestamp
201
+ };
202
+ },
203
+ $graph(val) {
204
+ return {
205
+ id: val.logGroupArn ?? val.arn,
206
+ label: val.logGroupName,
207
+ nodeType: CloudwatchLogGroupEntity.nodeType,
208
+ parent: `${val.$metadata.account}-${val.$metadata.region}`
209
+ };
210
+ },
211
+ $source(val) {
212
+ return {
213
+ command: CloudwatchLogGroupEntity.command,
214
+ parameters: val.$parameters
215
+ };
216
+ },
217
+ tenant(val) {
218
+ return {
219
+ tenantId: val.$metadata.account,
220
+ provider: CloudwatchLogGroupEntity.provider,
221
+ partition: val.$metadata.partition
222
+ };
223
+ },
224
+ location(val) {
225
+ return {
226
+ code: val.$metadata.region
227
+ };
228
+ },
229
+ resource(val) {
230
+ return {
231
+ id: val.logGroupArn,
232
+ name: val.logGroupName,
233
+ category: CloudwatchLogGroupEntity.category,
234
+ subcategory: CloudwatchLogGroupEntity.subcategory
235
+ };
236
+ },
237
+ audit(val) {
238
+ return {
239
+ createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
240
+ };
241
+ },
242
+ encryption(val) {
243
+ return {
244
+ keyId: val.kmsKeyId
245
+ };
246
+ },
247
+ logGroup(val) {
248
+ return {
249
+ accessClass: val.logGroupClass != null ? toLowerCase(val.logGroupClass) : void 0,
250
+ dataProtectionStatus: val.dataProtectionStatus != null ? toLowerCase(val.dataProtectionStatus) : void 0,
251
+ retentionPeriod: val.retentionInDays != null ? {
252
+ unit: Time.Days,
253
+ value: val.retentionInDays
254
+ } : void 0,
255
+ size: val.storedBytes != null ? {
256
+ unit: Size.Bytes,
257
+ value: val.storedBytes
258
+ } : void 0,
259
+ metricFilterCount: val.metricFilterCount
260
+ };
261
+ }
262
+ }
263
+ };
264
+
182
265
  // src/index.ts
183
266
  var CloudWatchLogsScanner = {
184
267
  provider: "aws",
@@ -188,10 +271,10 @@ var CloudWatchLogsScanner = {
188
271
  getClient,
189
272
  callPerRegion: true,
190
273
  getters: [DescribeLogGroups, DescribeSubscriptionFilters],
191
- getNodes,
192
- getEdges
274
+ getEdges,
275
+ entities: [CloudwatchLogGroupEntity]
193
276
  };
194
- var src_default = CloudWatchLogsScanner;
277
+ var index_default = CloudWatchLogsScanner;
195
278
  export {
196
- src_default as default
279
+ index_default as default
197
280
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrascan/aws-cloudwatch-logs-scanner",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "Infrascan scanner definition for AWS Cloudwatch Logs",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -8,8 +8,7 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "require": "./dist/index.js",
11
- "import": "./dist/index.mjs",
12
- "types": "./dist/index.d.ts"
11
+ "import": "./dist/index.mjs"
13
12
  }
14
13
  },
15
14
  "files": [
@@ -44,8 +43,8 @@
44
43
  "devDependencies": {
45
44
  "@aws-sdk/credential-providers": "3.624.0",
46
45
  "@infrascan/aws-codegen": "^0.1.0",
47
- "@infrascan/fs-connector": "^0.2.2",
48
- "@infrascan/shared-types": "^0.5.1",
46
+ "@infrascan/fs-connector": "^0.3.0",
47
+ "@infrascan/shared-types": "^0.6.0",
49
48
  "@infrascan/tsconfig": "*",
50
49
  "aws-sdk-client-mock": "^3.0.0",
51
50
  "eslint-config-codegen": "^1.0.0",
@@ -54,7 +53,7 @@
54
53
  },
55
54
  "dependencies": {
56
55
  "@aws-sdk/client-cloudwatch-logs": "3.624.0",
57
- "@infrascan/core": "0.4.1",
56
+ "@infrascan/core": "0.5.0",
58
57
  "debug": "^4"
59
58
  }
60
- }
59
+ }